diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 16:25:22 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 16:25:22 +0000 |
commit | 74dd68ad611d15abf16a65c36a7cfd3f4492930a (patch) | |
tree | 843fed9ba6bb03253a01314afc3b1dfbb2dfd26c /src/gatscon | |
parent | d9b407475ae3ebe434b29d9eabdd7d4416e17881 (diff) | |
download | libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.tar.gz libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.tar.bz2 libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.tar.xz libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.zip |
Made the repo less libbu++-centric.
Diffstat (limited to 'src/gatscon')
29 files changed, 0 insertions, 1838 deletions
diff --git a/src/gatscon/clientthread.cpp b/src/gatscon/clientthread.cpp deleted file mode 100644 index 4c7b72a..0000000 --- a/src/gatscon/clientthread.cpp +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #include "clientthread.h" | ||
2 | |||
3 | #include <bu/tcpsocket.h> | ||
4 | |||
5 | ClientThread::ClientThread( QObject *pParent, const QByteArray &baHost, | ||
6 | int iPort ) : | ||
7 | QThread( pParent ), | ||
8 | baHost( baHost ), | ||
9 | iPort( iPort ), | ||
10 | gsCli( ssCli ) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | ClientThread::~ClientThread() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | void ClientThread::send( Gats::Object *pObj ) | ||
19 | { | ||
20 | gsCli.writeObject( pObj ); | ||
21 | } | ||
22 | |||
23 | void ClientThread::run() | ||
24 | { | ||
25 | ssCli.setStream( | ||
26 | new Bu::TcpSocket( baHost.constData(), iPort ) | ||
27 | ); | ||
28 | |||
29 | while( !ssCli.isEos() ) | ||
30 | { | ||
31 | Gats::Object *pObj = gsCli.readObject(); | ||
32 | if( pObj == NULL ) | ||
33 | continue; | ||
34 | |||
35 | emit recv( pObj ); | ||
36 | } | ||
37 | } | ||
38 | |||
diff --git a/src/gatscon/clientthread.h b/src/gatscon/clientthread.h deleted file mode 100644 index 3182d37..0000000 --- a/src/gatscon/clientthread.h +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | #ifndef CLIENT_THREAD_H | ||
2 | #define CLIENT_THREAD_H | ||
3 | |||
4 | #include <QThread> | ||
5 | #include <QByteArray> | ||
6 | |||
7 | #include <bu/streamstack.h> | ||
8 | #include <gats/gatsstream.h> | ||
9 | |||
10 | namespace Gats | ||
11 | { | ||
12 | class Object; | ||
13 | }; | ||
14 | |||
15 | class ClientThread : public QThread | ||
16 | { | ||
17 | Q_OBJECT; | ||
18 | public: | ||
19 | ClientThread( QObject *pParent, const QByteArray &baHost, int iPort ); | ||
20 | virtual ~ClientThread(); | ||
21 | |||
22 | void send( Gats::Object *pObj ); | ||
23 | |||
24 | signals: | ||
25 | void recv( Gats::Object *pObj ); | ||
26 | |||
27 | protected: | ||
28 | virtual void run(); | ||
29 | |||
30 | private: | ||
31 | QByteArray baHost; | ||
32 | int iPort; | ||
33 | Bu::StreamStack ssCli; | ||
34 | Gats::GatsStream gsCli; | ||
35 | }; | ||
36 | |||
37 | #endif | ||
diff --git a/src/gatscon/clientwidget.cpp b/src/gatscon/clientwidget.cpp deleted file mode 100644 index 941d9fa..0000000 --- a/src/gatscon/clientwidget.cpp +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | #include "clientwidget.h" | ||
2 | #include "clientthread.h" | ||
3 | |||
4 | #include "gatstotree.h" | ||
5 | #include "treetogats.h" | ||
6 | |||
7 | #include <QMessageBox> | ||
8 | |||
9 | #include <gats/gatsstream.h> | ||
10 | #include <bu/tcpsocket.h> | ||
11 | #include <bu/sio.h> | ||
12 | #include <bu/file.h> | ||
13 | |||
14 | using namespace Bu; | ||
15 | |||
16 | ClientWidget::ClientWidget( QWidget *pParent, const QByteArray &baHost, | ||
17 | int iPort ) : | ||
18 | QWidget( pParent ) | ||
19 | { | ||
20 | setupUi( this ); | ||
21 | |||
22 | pCli = new ClientThread( this, baHost, iPort ); | ||
23 | connect( pCli, SIGNAL(recv( Gats::Object *)), | ||
24 | this, SLOT(recv(Gats::Object *)), Qt::QueuedConnection ); | ||
25 | |||
26 | pCli->start(); | ||
27 | } | ||
28 | |||
29 | ClientWidget::~ClientWidget() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void ClientWidget::saveTo( const QString &sFile ) | ||
34 | { | ||
35 | File fOut( sFile.toAscii().constData(), File::WriteNew ); | ||
36 | Gats::GatsStream gsOut( fOut ); | ||
37 | QTreeWidgetItem *pRoot = twHistory->invisibleRootItem(); | ||
38 | for( int j = 0; j < pRoot->childCount(); j++ ) | ||
39 | { | ||
40 | Gats::Object *pObj = treeToGats( pRoot->child( j ) ); | ||
41 | gsOut.writeObject( pObj ); | ||
42 | delete pObj; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | void ClientWidget::send() | ||
47 | { | ||
48 | try | ||
49 | { | ||
50 | Gats::Object *pObj = Gats::Object::strToGats( | ||
51 | leGats->text().toAscii().constData() | ||
52 | ); | ||
53 | sio << "Send: " << *pObj << sio.nl; | ||
54 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | ||
55 | twHistory->invisibleRootItem() | ||
56 | ); | ||
57 | pIt->setText( 0, "send" ); | ||
58 | gatsToTree( pIt, pObj ); | ||
59 | pCli->send( pObj ); | ||
60 | delete pObj; | ||
61 | |||
62 | leGats->setText(""); | ||
63 | leGats->setFocus(); | ||
64 | } | ||
65 | catch( Bu::ExceptionBase &e ) | ||
66 | { | ||
67 | QMessageBox::critical( this, "Gats Console - Error", e.what() ); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void ClientWidget::recv( Gats::Object *pObj ) | ||
72 | { | ||
73 | sio << "Recv: " << *pObj << sio.nl; | ||
74 | |||
75 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | ||
76 | twHistory->invisibleRootItem() | ||
77 | ); | ||
78 | pIt->setText( 0, "recv" ); | ||
79 | gatsToTree( pIt, pObj ); | ||
80 | delete pObj; | ||
81 | } | ||
82 | |||
diff --git a/src/gatscon/clientwidget.h b/src/gatscon/clientwidget.h deleted file mode 100644 index 06c154d..0000000 --- a/src/gatscon/clientwidget.h +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #ifndef CLIENT_WIDGET_H | ||
2 | #define CLIENT_WIDGET_H | ||
3 | |||
4 | #include <QObject> | ||
5 | #include "ui_clientwidget.h" | ||
6 | #include "iobase.h" | ||
7 | |||
8 | namespace Gats | ||
9 | { | ||
10 | class Object; | ||
11 | }; | ||
12 | |||
13 | class ClientWidget : public QWidget, protected Ui::ClientWidget, public IoBase | ||
14 | { | ||
15 | Q_OBJECT; | ||
16 | public: | ||
17 | ClientWidget( QWidget *pParent, const QByteArray &baHost, int iPort ); | ||
18 | virtual ~ClientWidget(); | ||
19 | |||
20 | virtual void saveTo( const QString &sFile ); | ||
21 | |||
22 | public slots: | ||
23 | void send(); | ||
24 | void recv( Gats::Object *pObj ); | ||
25 | |||
26 | private: | ||
27 | class ClientThread *pCli; | ||
28 | }; | ||
29 | |||
30 | #endif | ||
diff --git a/src/gatscon/clientwidget.ui b/src/gatscon/clientwidget.ui deleted file mode 100644 index a0cb997..0000000 --- a/src/gatscon/clientwidget.ui +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>ClientWidget</class> | ||
4 | <widget class="QWidget" name="ClientWidget"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>363</width> | ||
10 | <height>291</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Form</string> | ||
15 | </property> | ||
16 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
17 | <item> | ||
18 | <widget class="QTreeWidget" name="twHistory"> | ||
19 | <column> | ||
20 | <property name="text"> | ||
21 | <string>Name</string> | ||
22 | </property> | ||
23 | </column> | ||
24 | <column> | ||
25 | <property name="text"> | ||
26 | <string>Type</string> | ||
27 | </property> | ||
28 | </column> | ||
29 | <column> | ||
30 | <property name="text"> | ||
31 | <string>Value</string> | ||
32 | </property> | ||
33 | </column> | ||
34 | </widget> | ||
35 | </item> | ||
36 | <item> | ||
37 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
38 | <item> | ||
39 | <widget class="QLabel" name="label"> | ||
40 | <property name="text"> | ||
41 | <string>Gats:</string> | ||
42 | </property> | ||
43 | </widget> | ||
44 | </item> | ||
45 | <item> | ||
46 | <widget class="QLineEdit" name="leGats"/> | ||
47 | </item> | ||
48 | <item> | ||
49 | <widget class="QPushButton" name="pushButton"> | ||
50 | <property name="text"> | ||
51 | <string>Send</string> | ||
52 | </property> | ||
53 | <property name="autoDefault"> | ||
54 | <bool>true</bool> | ||
55 | </property> | ||
56 | <property name="default"> | ||
57 | <bool>true</bool> | ||
58 | </property> | ||
59 | </widget> | ||
60 | </item> | ||
61 | </layout> | ||
62 | </item> | ||
63 | </layout> | ||
64 | </widget> | ||
65 | <resources/> | ||
66 | <connections> | ||
67 | <connection> | ||
68 | <sender>pushButton</sender> | ||
69 | <signal>clicked()</signal> | ||
70 | <receiver>ClientWidget</receiver> | ||
71 | <slot>send()</slot> | ||
72 | <hints> | ||
73 | <hint type="sourcelabel"> | ||
74 | <x>332</x> | ||
75 | <y>276</y> | ||
76 | </hint> | ||
77 | <hint type="destinationlabel"> | ||
78 | <x>322</x> | ||
79 | <y>367</y> | ||
80 | </hint> | ||
81 | </hints> | ||
82 | </connection> | ||
83 | </connections> | ||
84 | <slots> | ||
85 | <slot>send()</slot> | ||
86 | </slots> | ||
87 | </ui> | ||
diff --git a/src/gatscon/connectdlg.cpp b/src/gatscon/connectdlg.cpp deleted file mode 100644 index 589ae97..0000000 --- a/src/gatscon/connectdlg.cpp +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #include "connectdlg.h" | ||
2 | |||
3 | ConnectDlg::ConnectDlg( QWidget *pParent ) : | ||
4 | QDialog( pParent ) | ||
5 | { | ||
6 | setupUi( this ); | ||
7 | } | ||
8 | |||
9 | ConnectDlg::~ConnectDlg() | ||
10 | { | ||
11 | } | ||
12 | |||
13 | QByteArray ConnectDlg::getHostname() const | ||
14 | { | ||
15 | return leHost->text().toAscii(); | ||
16 | } | ||
17 | |||
18 | int ConnectDlg::getPort() const | ||
19 | { | ||
20 | return sbPort->value(); | ||
21 | } | ||
22 | |||
diff --git a/src/gatscon/connectdlg.h b/src/gatscon/connectdlg.h deleted file mode 100644 index 57ea6cd..0000000 --- a/src/gatscon/connectdlg.h +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | #ifndef CONNECT_DLG_H | ||
2 | #define CONNECT_DLG_H | ||
3 | |||
4 | #include "ui_connectdlg.h" | ||
5 | |||
6 | class ConnectDlg : public QDialog, protected Ui::ConnectDlg | ||
7 | { | ||
8 | Q_OBJECT; | ||
9 | public: | ||
10 | ConnectDlg( QWidget *pParent ); | ||
11 | virtual ~ConnectDlg(); | ||
12 | |||
13 | QByteArray getHostname() const; | ||
14 | int getPort() const; | ||
15 | }; | ||
16 | |||
17 | #endif | ||
diff --git a/src/gatscon/connectdlg.ui b/src/gatscon/connectdlg.ui deleted file mode 100644 index 6875e27..0000000 --- a/src/gatscon/connectdlg.ui +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>ConnectDlg</class> | ||
4 | <widget class="QDialog" name="ConnectDlg"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>300</width> | ||
10 | <height>93</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Gats Console - Connect</string> | ||
15 | </property> | ||
16 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
17 | <item> | ||
18 | <layout class="QFormLayout" name="formLayout"> | ||
19 | <item row="0" column="0"> | ||
20 | <widget class="QLabel" name="label"> | ||
21 | <property name="text"> | ||
22 | <string>Hostname:</string> | ||
23 | </property> | ||
24 | </widget> | ||
25 | </item> | ||
26 | <item row="1" column="0"> | ||
27 | <widget class="QLabel" name="label_2"> | ||
28 | <property name="text"> | ||
29 | <string>Port:</string> | ||
30 | </property> | ||
31 | </widget> | ||
32 | </item> | ||
33 | <item row="0" column="1"> | ||
34 | <widget class="QLineEdit" name="leHost"> | ||
35 | <property name="text"> | ||
36 | <string>localhost</string> | ||
37 | </property> | ||
38 | </widget> | ||
39 | </item> | ||
40 | <item row="1" column="1"> | ||
41 | <widget class="QSpinBox" name="sbPort"> | ||
42 | <property name="minimum"> | ||
43 | <number>1</number> | ||
44 | </property> | ||
45 | <property name="maximum"> | ||
46 | <number>32767</number> | ||
47 | </property> | ||
48 | </widget> | ||
49 | </item> | ||
50 | </layout> | ||
51 | </item> | ||
52 | <item> | ||
53 | <widget class="QDialogButtonBox" name="buttonBox"> | ||
54 | <property name="orientation"> | ||
55 | <enum>Qt::Horizontal</enum> | ||
56 | </property> | ||
57 | <property name="standardButtons"> | ||
58 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
59 | </property> | ||
60 | </widget> | ||
61 | </item> | ||
62 | </layout> | ||
63 | </widget> | ||
64 | <resources/> | ||
65 | <connections> | ||
66 | <connection> | ||
67 | <sender>buttonBox</sender> | ||
68 | <signal>accepted()</signal> | ||
69 | <receiver>ConnectDlg</receiver> | ||
70 | <slot>accept()</slot> | ||
71 | <hints> | ||
72 | <hint type="sourcelabel"> | ||
73 | <x>248</x> | ||
74 | <y>254</y> | ||
75 | </hint> | ||
76 | <hint type="destinationlabel"> | ||
77 | <x>157</x> | ||
78 | <y>274</y> | ||
79 | </hint> | ||
80 | </hints> | ||
81 | </connection> | ||
82 | <connection> | ||
83 | <sender>buttonBox</sender> | ||
84 | <signal>rejected()</signal> | ||
85 | <receiver>ConnectDlg</receiver> | ||
86 | <slot>reject()</slot> | ||
87 | <hints> | ||
88 | <hint type="sourcelabel"> | ||
89 | <x>316</x> | ||
90 | <y>260</y> | ||
91 | </hint> | ||
92 | <hint type="destinationlabel"> | ||
93 | <x>286</x> | ||
94 | <y>274</y> | ||
95 | </hint> | ||
96 | </hints> | ||
97 | </connection> | ||
98 | </connections> | ||
99 | </ui> | ||
diff --git a/src/gatscon/filewidget.cpp b/src/gatscon/filewidget.cpp deleted file mode 100644 index dbd70fd..0000000 --- a/src/gatscon/filewidget.cpp +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | #include "filewidget.h" | ||
2 | |||
3 | #include "gatstotree.h" | ||
4 | #include "treetogats.h" | ||
5 | |||
6 | #include <gats/types.h> | ||
7 | #include <gats/gatsstream.h> | ||
8 | #include <bu/file.h> | ||
9 | |||
10 | #include <QInputDialog> | ||
11 | |||
12 | using namespace Bu; | ||
13 | |||
14 | FileWidget::FileWidget( QWidget *pParent ) : | ||
15 | QWidget( pParent ) | ||
16 | { | ||
17 | setupUi( this ); | ||
18 | } | ||
19 | |||
20 | FileWidget::FileWidget( QWidget *pParent, QString sFile ) : | ||
21 | QWidget( pParent ) | ||
22 | { | ||
23 | setupUi( this ); | ||
24 | |||
25 | File fIn( sFile.toAscii().constData(), File::Read ); | ||
26 | Gats::GatsStream gsIn( fIn ); | ||
27 | Gats::Object *pObj; | ||
28 | while( (pObj = gsIn.readObject()) ) | ||
29 | { | ||
30 | QTreeWidgetItem *pNew = new QTreeWidgetItem( | ||
31 | twGats->invisibleRootItem() | ||
32 | ); | ||
33 | pNew->setText( 0, "<root>" ); | ||
34 | gatsToTree( pNew, pObj ); | ||
35 | delete pObj; | ||
36 | } | ||
37 | } | ||
38 | |||
39 | FileWidget::~FileWidget() | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void FileWidget::saveTo( const QString &sFile ) | ||
44 | { | ||
45 | File fOut( sFile.toAscii().constData(), File::WriteNew ); | ||
46 | Gats::GatsStream gsOut( fOut ); | ||
47 | QTreeWidgetItem *pRoot = twGats->invisibleRootItem(); | ||
48 | for( int j = 0; j < pRoot->childCount(); j++ ) | ||
49 | { | ||
50 | Gats::Object *pObj = treeToGats( pRoot->child( j ) ); | ||
51 | gsOut.writeObject( pObj ); | ||
52 | delete pObj; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | void FileWidget::addRootItem() | ||
57 | { | ||
58 | QString sText = QInputDialog::getText( this, "Gats Console - Add Root Item", | ||
59 | "Gats:"); | ||
60 | Gats::Object *pObj = Gats::Object::strToGats( sText.toAscii().constData() ); | ||
61 | QTreeWidgetItem *pNew = new QTreeWidgetItem( | ||
62 | twGats->invisibleRootItem() | ||
63 | ); | ||
64 | pNew->setText( 0, "<root>" ); | ||
65 | gatsToTree( pNew, pObj ); | ||
66 | delete pObj; | ||
67 | } | ||
68 | |||
69 | void FileWidget::delRootItem() | ||
70 | { | ||
71 | } | ||
72 | |||
diff --git a/src/gatscon/filewidget.h b/src/gatscon/filewidget.h deleted file mode 100644 index 9993bfe..0000000 --- a/src/gatscon/filewidget.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #ifndef FILE_WIDGET_H | ||
2 | #define FILE_WIDGET_H | ||
3 | |||
4 | #include "ui_filewidget.h" | ||
5 | #include "iobase.h" | ||
6 | |||
7 | namespace Gats | ||
8 | { | ||
9 | class Object; | ||
10 | }; | ||
11 | |||
12 | class FileWidget : public QWidget, protected Ui::FileWidget, public IoBase | ||
13 | { | ||
14 | Q_OBJECT; | ||
15 | public: | ||
16 | FileWidget( QWidget *pParent=NULL ); | ||
17 | FileWidget( QWidget *pParent, QString sFile ); | ||
18 | virtual ~FileWidget(); | ||
19 | |||
20 | virtual void saveTo( const QString &sFile ); | ||
21 | |||
22 | public slots: | ||
23 | void addRootItem(); | ||
24 | void delRootItem(); | ||
25 | |||
26 | private: | ||
27 | }; | ||
28 | |||
29 | #endif | ||
diff --git a/src/gatscon/filewidget.ui b/src/gatscon/filewidget.ui deleted file mode 100644 index d0e6ec3..0000000 --- a/src/gatscon/filewidget.ui +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>FileWidget</class> | ||
4 | <widget class="QWidget" name="FileWidget"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>316</width> | ||
10 | <height>300</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Form</string> | ||
15 | </property> | ||
16 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
17 | <item> | ||
18 | <widget class="QTreeWidget" name="twGats"> | ||
19 | <column> | ||
20 | <property name="text"> | ||
21 | <string>Name</string> | ||
22 | </property> | ||
23 | </column> | ||
24 | <column> | ||
25 | <property name="text"> | ||
26 | <string>Type</string> | ||
27 | </property> | ||
28 | </column> | ||
29 | <column> | ||
30 | <property name="text"> | ||
31 | <string>Value</string> | ||
32 | </property> | ||
33 | </column> | ||
34 | </widget> | ||
35 | </item> | ||
36 | <item> | ||
37 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
38 | <item> | ||
39 | <widget class="QPushButton" name="pushButton_2"> | ||
40 | <property name="text"> | ||
41 | <string>Add Root Item</string> | ||
42 | </property> | ||
43 | </widget> | ||
44 | </item> | ||
45 | <item> | ||
46 | <widget class="QPushButton" name="pushButton"> | ||
47 | <property name="text"> | ||
48 | <string>Del Root Item</string> | ||
49 | </property> | ||
50 | </widget> | ||
51 | </item> | ||
52 | </layout> | ||
53 | </item> | ||
54 | </layout> | ||
55 | </widget> | ||
56 | <resources/> | ||
57 | <connections> | ||
58 | <connection> | ||
59 | <sender>pushButton_2</sender> | ||
60 | <signal>clicked()</signal> | ||
61 | <receiver>FileWidget</receiver> | ||
62 | <slot>addRootItem()</slot> | ||
63 | <hints> | ||
64 | <hint type="sourcelabel"> | ||
65 | <x>60</x> | ||
66 | <y>283</y> | ||
67 | </hint> | ||
68 | <hint type="destinationlabel"> | ||
69 | <x>10</x> | ||
70 | <y>343</y> | ||
71 | </hint> | ||
72 | </hints> | ||
73 | </connection> | ||
74 | <connection> | ||
75 | <sender>pushButton</sender> | ||
76 | <signal>clicked()</signal> | ||
77 | <receiver>FileWidget</receiver> | ||
78 | <slot>delRootItem()</slot> | ||
79 | <hints> | ||
80 | <hint type="sourcelabel"> | ||
81 | <x>252</x> | ||
82 | <y>283</y> | ||
83 | </hint> | ||
84 | <hint type="destinationlabel"> | ||
85 | <x>258</x> | ||
86 | <y>324</y> | ||
87 | </hint> | ||
88 | </hints> | ||
89 | </connection> | ||
90 | </connections> | ||
91 | <slots> | ||
92 | <slot>addRootItem()</slot> | ||
93 | <slot>delRootItem()</slot> | ||
94 | </slots> | ||
95 | </ui> | ||
diff --git a/src/gatscon/gatstotree.cpp b/src/gatscon/gatstotree.cpp deleted file mode 100644 index e388d5e..0000000 --- a/src/gatscon/gatstotree.cpp +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | #include "gatstotree.h" | ||
2 | |||
3 | #include <gats/types.h> | ||
4 | |||
5 | #include <QTreeWidgetItem> | ||
6 | |||
7 | void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ) | ||
8 | { | ||
9 | switch( pObj->getType() ) | ||
10 | { | ||
11 | case Gats::typeInteger: | ||
12 | gatsToTree( p, dynamic_cast<Gats::Integer *>( pObj ) ); | ||
13 | break; | ||
14 | |||
15 | case Gats::typeString: | ||
16 | gatsToTree( p, dynamic_cast<Gats::String *>( pObj ) ); | ||
17 | break; | ||
18 | |||
19 | case Gats::typeFloat: | ||
20 | gatsToTree( p, dynamic_cast<Gats::Float *>( pObj ) ); | ||
21 | break; | ||
22 | |||
23 | case Gats::typeBoolean: | ||
24 | gatsToTree( p, dynamic_cast<Gats::Boolean *>( pObj ) ); | ||
25 | break; | ||
26 | |||
27 | case Gats::typeList: | ||
28 | gatsToTree( p, dynamic_cast<Gats::List *>( pObj ) ); | ||
29 | break; | ||
30 | |||
31 | case Gats::typeDictionary: | ||
32 | gatsToTree( p, dynamic_cast<Gats::Dictionary *>( pObj ) ); | ||
33 | break; | ||
34 | |||
35 | case Gats::typeNull: | ||
36 | gatsToTree( p, dynamic_cast<Gats::Null *>( pObj ) ); | ||
37 | break; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | void gatsToTree( QTreeWidgetItem *p, Gats::Integer *pObj ) | ||
42 | { | ||
43 | p->setText( 1, "int"); | ||
44 | p->setText( 2, QString("%1").arg( pObj->getValue() ) ); | ||
45 | } | ||
46 | |||
47 | void gatsToTree( QTreeWidgetItem *p, Gats::String *pObj ) | ||
48 | { | ||
49 | p->setText( 1, "str"); | ||
50 | p->setText( 2, QString("%1").arg( pObj->getStr() ) ); | ||
51 | } | ||
52 | |||
53 | void gatsToTree( QTreeWidgetItem *p, Gats::Float *pObj ) | ||
54 | { | ||
55 | p->setText( 1, "float"); | ||
56 | p->setText( 2, QString("%1").arg( pObj->getValue() ) ); | ||
57 | } | ||
58 | |||
59 | void gatsToTree( QTreeWidgetItem *p, Gats::Boolean *pObj ) | ||
60 | { | ||
61 | p->setText( 1, "bool"); | ||
62 | p->setText( 2, pObj->getValue()?"true":"false" ); | ||
63 | } | ||
64 | |||
65 | void gatsToTree( QTreeWidgetItem *p, Gats::List *pObj ) | ||
66 | { | ||
67 | p->setText( 1, "list"); | ||
68 | int j = 0; | ||
69 | for( Gats::List::iterator i = pObj->begin(); i; i++ ) | ||
70 | { | ||
71 | QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); | ||
72 | pIt->setText( 0, QString("%1").arg( j++ ) ); | ||
73 | gatsToTree( pIt, *i ); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | void gatsToTree( QTreeWidgetItem *p, Gats::Dictionary *pObj ) | ||
78 | { | ||
79 | p->setText( 1, "dict"); | ||
80 | for( Gats::Dictionary::iterator i = pObj->begin(); i; i++ ) | ||
81 | { | ||
82 | QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); | ||
83 | pIt->setText( 0, QString( i.getKey().getStr() ) ); | ||
84 | gatsToTree( pIt, *i ); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | void gatsToTree( QTreeWidgetItem *p, Gats::Null *pObj ) | ||
89 | { | ||
90 | p->setText( 1, "null"); | ||
91 | } | ||
diff --git a/src/gatscon/gatstotree.h b/src/gatscon/gatstotree.h deleted file mode 100644 index a803017..0000000 --- a/src/gatscon/gatstotree.h +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #ifndef GATS_TO_TREE_H | ||
2 | #define GATS_TO_TREE_H | ||
3 | |||
4 | class QTreeWidgetItem; | ||
5 | |||
6 | namespace Gats | ||
7 | { | ||
8 | class Integer; | ||
9 | class String; | ||
10 | class Float; | ||
11 | class Boolean; | ||
12 | class List; | ||
13 | class Dictionary; | ||
14 | class Object; | ||
15 | }; | ||
16 | |||
17 | #include <gats/types.h> | ||
18 | |||
19 | void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ); | ||
20 | void gatsToTree( QTreeWidgetItem *p, Gats::Integer *pObj ); | ||
21 | void gatsToTree( QTreeWidgetItem *p, Gats::String *pObj ); | ||
22 | void gatsToTree( QTreeWidgetItem *p, Gats::Float *pObj ); | ||
23 | void gatsToTree( QTreeWidgetItem *p, Gats::Boolean *pObj ); | ||
24 | void gatsToTree( QTreeWidgetItem *p, Gats::List *pObj ); | ||
25 | void gatsToTree( QTreeWidgetItem *p, Gats::Dictionary *pObj ); | ||
26 | void gatsToTree( QTreeWidgetItem *p, Gats::Null *pObj ); | ||
27 | |||
28 | #endif | ||
diff --git a/src/gatscon/iobase.cpp b/src/gatscon/iobase.cpp deleted file mode 100644 index 309444c..0000000 --- a/src/gatscon/iobase.cpp +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | #include "iobase.h" | ||
diff --git a/src/gatscon/iobase.h b/src/gatscon/iobase.h deleted file mode 100644 index 5bd3843..0000000 --- a/src/gatscon/iobase.h +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #ifndef IO_BASE_H | ||
2 | #define IO_BASE_H | ||
3 | |||
4 | class IoBase | ||
5 | { | ||
6 | public: | ||
7 | virtual void saveTo( const class QString &sFile )=0; | ||
8 | }; | ||
9 | |||
10 | #endif | ||
diff --git a/src/gatscon/main.cpp b/src/gatscon/main.cpp deleted file mode 100644 index b9b2327..0000000 --- a/src/gatscon/main.cpp +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | #include "mainwnd.h" | ||
2 | #include <QApplication> | ||
3 | |||
4 | int main( int argc, char *argv[] ) | ||
5 | { | ||
6 | QApplication app( argc, argv ); | ||
7 | |||
8 | MainWnd wnd; | ||
9 | wnd.show(); | ||
10 | |||
11 | return app.exec(); | ||
12 | } | ||
13 | |||
diff --git a/src/gatscon/mainwnd.cpp b/src/gatscon/mainwnd.cpp deleted file mode 100644 index 5d31019..0000000 --- a/src/gatscon/mainwnd.cpp +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
1 | #include "mainwnd.h" | ||
2 | |||
3 | #include "clientwidget.h" | ||
4 | #include "proxywidget.h" | ||
5 | #include "filewidget.h" | ||
6 | |||
7 | #include "connectdlg.h" | ||
8 | #include "setupproxydlg.h" | ||
9 | |||
10 | #include <QLabel> | ||
11 | #include <QFileDialog> | ||
12 | |||
13 | MainWnd::MainWnd() | ||
14 | { | ||
15 | setupUi( this ); | ||
16 | |||
17 | pMode = new QLabel( "Idle", this ); | ||
18 | statusBar()->addPermanentWidget( pMode ); | ||
19 | } | ||
20 | |||
21 | MainWnd::~MainWnd() | ||
22 | { | ||
23 | } | ||
24 | |||
25 | void MainWnd::connect() | ||
26 | { | ||
27 | ConnectDlg dlg( this ); | ||
28 | if( dlg.exec() == QDialog::Accepted ) | ||
29 | { | ||
30 | sCurFile.clear(); | ||
31 | setCentralWidget( | ||
32 | new ClientWidget( | ||
33 | this, dlg.getHostname(), dlg.getPort() | ||
34 | ) | ||
35 | ); | ||
36 | pMode->setText( | ||
37 | QString("Client Mode: %1:%2").arg( QString(dlg.getHostname()) ). | ||
38 | arg( dlg.getPort() ) | ||
39 | ); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | void MainWnd::proxy() | ||
44 | { | ||
45 | SetupProxyDlg dlg( this ); | ||
46 | |||
47 | if( dlg.exec() == QDialog::Accepted ) | ||
48 | { | ||
49 | sCurFile.clear(); | ||
50 | setCentralWidget( | ||
51 | new ProxyWidget( | ||
52 | this, dlg.getPortIn(), dlg.getHostOut(), dlg.getPortOut() | ||
53 | ) | ||
54 | ); | ||
55 | pMode->setText( | ||
56 | QString("Proxy Mode: :%1 -> %2:%3").arg( dlg.getPortIn() ). | ||
57 | arg( QString(dlg.getHostOut()) ). | ||
58 | arg( dlg.getPortOut() ) | ||
59 | ); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | void MainWnd::open() | ||
64 | { | ||
65 | QString sFile = QFileDialog::getOpenFileName( | ||
66 | this, "Gats Console - open gats file" | ||
67 | ); | ||
68 | if( sFile.isEmpty() ) | ||
69 | return; | ||
70 | |||
71 | sCurFile = sFile; | ||
72 | setCentralWidget( | ||
73 | new FileWidget( this, sFile ) | ||
74 | ); | ||
75 | pMode->setText( QString("File mode: %1").arg( sCurFile ) ); | ||
76 | } | ||
77 | |||
78 | void MainWnd::newFile() | ||
79 | { | ||
80 | sCurFile.clear(); | ||
81 | setCentralWidget( | ||
82 | new FileWidget( this ) | ||
83 | ); | ||
84 | pMode->setText( QString("File mode: <untitled>") ); | ||
85 | } | ||
86 | |||
87 | void MainWnd::save() | ||
88 | { | ||
89 | if( sCurFile.isEmpty() ) | ||
90 | { | ||
91 | saveAs(); | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | IoBase *pIo = dynamic_cast<IoBase *>(centralWidget()); | ||
96 | if( !pIo ) | ||
97 | return; | ||
98 | |||
99 | pIo->saveTo( sCurFile ); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | void MainWnd::saveAs() | ||
104 | { | ||
105 | IoBase *pIo = dynamic_cast<IoBase *>(centralWidget()); | ||
106 | if( !pIo ) | ||
107 | return; | ||
108 | |||
109 | QString sFile = QFileDialog::getSaveFileName( | ||
110 | this, "Gats Console - save gats file" | ||
111 | ); | ||
112 | if( sFile.isEmpty() ) | ||
113 | return; | ||
114 | |||
115 | pIo->saveTo( sFile ); | ||
116 | |||
117 | sCurFile = sFile; | ||
118 | } | ||
119 | |||
diff --git a/src/gatscon/mainwnd.h b/src/gatscon/mainwnd.h deleted file mode 100644 index d1ae080..0000000 --- a/src/gatscon/mainwnd.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | #ifndef MAIN_WND_H | ||
2 | #define MAIN_WND_H | ||
3 | |||
4 | #include "ui_mainwnd.h" | ||
5 | |||
6 | class MainWnd : public QMainWindow, protected Ui::MainWnd | ||
7 | { | ||
8 | Q_OBJECT; | ||
9 | public: | ||
10 | MainWnd(); | ||
11 | virtual ~MainWnd(); | ||
12 | |||
13 | public slots: | ||
14 | void connect(); | ||
15 | void proxy(); | ||
16 | void open(); | ||
17 | void newFile(); | ||
18 | void save(); | ||
19 | void saveAs(); | ||
20 | |||
21 | private: | ||
22 | QString sCurFile; | ||
23 | class QLabel *pMode; | ||
24 | }; | ||
25 | |||
26 | #endif | ||
diff --git a/src/gatscon/mainwnd.ui b/src/gatscon/mainwnd.ui deleted file mode 100644 index 01f534a..0000000 --- a/src/gatscon/mainwnd.ui +++ /dev/null | |||
@@ -1,207 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>MainWnd</class> | ||
4 | <widget class="QMainWindow" name="MainWnd"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>431</width> | ||
10 | <height>319</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Gats Console</string> | ||
15 | </property> | ||
16 | <widget class="QWidget" name="centralwidget"/> | ||
17 | <widget class="QMenuBar" name="menubar"> | ||
18 | <property name="geometry"> | ||
19 | <rect> | ||
20 | <x>0</x> | ||
21 | <y>0</y> | ||
22 | <width>431</width> | ||
23 | <height>21</height> | ||
24 | </rect> | ||
25 | </property> | ||
26 | <widget class="QMenu" name="menu_File"> | ||
27 | <property name="title"> | ||
28 | <string>&File</string> | ||
29 | </property> | ||
30 | <addaction name="action_Open_gats_file"/> | ||
31 | <addaction name="action_New_Gats_File"/> | ||
32 | <addaction name="action_Save"/> | ||
33 | <addaction name="action_Save_As"/> | ||
34 | <addaction name="separator"/> | ||
35 | <addaction name="actionE_xit"/> | ||
36 | </widget> | ||
37 | <widget class="QMenu" name="menu_Network"> | ||
38 | <property name="title"> | ||
39 | <string>&Network</string> | ||
40 | </property> | ||
41 | <addaction name="action_Open_connection"/> | ||
42 | <addaction name="action_Open_proxy_connection"/> | ||
43 | </widget> | ||
44 | <addaction name="menu_File"/> | ||
45 | <addaction name="menu_Network"/> | ||
46 | </widget> | ||
47 | <widget class="QStatusBar" name="statusbar"/> | ||
48 | <action name="action_Open_connection"> | ||
49 | <property name="text"> | ||
50 | <string>&Open connection...</string> | ||
51 | </property> | ||
52 | </action> | ||
53 | <action name="action_Open_proxy_connection"> | ||
54 | <property name="text"> | ||
55 | <string>&Start proxy...</string> | ||
56 | </property> | ||
57 | </action> | ||
58 | <action name="action_Open_gats_file"> | ||
59 | <property name="text"> | ||
60 | <string>&Open Gats File...</string> | ||
61 | </property> | ||
62 | </action> | ||
63 | <action name="action_New_Gats_File"> | ||
64 | <property name="text"> | ||
65 | <string>&New Gats File</string> | ||
66 | </property> | ||
67 | </action> | ||
68 | <action name="action_Save"> | ||
69 | <property name="text"> | ||
70 | <string>&Save</string> | ||
71 | </property> | ||
72 | </action> | ||
73 | <action name="action_Save_As"> | ||
74 | <property name="text"> | ||
75 | <string>&Save As...</string> | ||
76 | </property> | ||
77 | </action> | ||
78 | <action name="actionE_xit"> | ||
79 | <property name="text"> | ||
80 | <string>E&xit</string> | ||
81 | </property> | ||
82 | </action> | ||
83 | </widget> | ||
84 | <resources/> | ||
85 | <connections> | ||
86 | <connection> | ||
87 | <sender>action_Open_connection</sender> | ||
88 | <signal>triggered()</signal> | ||
89 | <receiver>MainWnd</receiver> | ||
90 | <slot>connect()</slot> | ||
91 | <hints> | ||
92 | <hint type="sourcelabel"> | ||
93 | <x>-1</x> | ||
94 | <y>-1</y> | ||
95 | </hint> | ||
96 | <hint type="destinationlabel"> | ||
97 | <x>215</x> | ||
98 | <y>159</y> | ||
99 | </hint> | ||
100 | </hints> | ||
101 | </connection> | ||
102 | <connection> | ||
103 | <sender>action_Open_proxy_connection</sender> | ||
104 | <signal>triggered()</signal> | ||
105 | <receiver>MainWnd</receiver> | ||
106 | <slot>proxy()</slot> | ||
107 | <hints> | ||
108 | <hint type="sourcelabel"> | ||
109 | <x>-1</x> | ||
110 | <y>-1</y> | ||
111 | </hint> | ||
112 | <hint type="destinationlabel"> | ||
113 | <x>215</x> | ||
114 | <y>159</y> | ||
115 | </hint> | ||
116 | </hints> | ||
117 | </connection> | ||
118 | <connection> | ||
119 | <sender>action_Open_gats_file</sender> | ||
120 | <signal>triggered()</signal> | ||
121 | <receiver>MainWnd</receiver> | ||
122 | <slot>open()</slot> | ||
123 | <hints> | ||
124 | <hint type="sourcelabel"> | ||
125 | <x>-1</x> | ||
126 | <y>-1</y> | ||
127 | </hint> | ||
128 | <hint type="destinationlabel"> | ||
129 | <x>215</x> | ||
130 | <y>159</y> | ||
131 | </hint> | ||
132 | </hints> | ||
133 | </connection> | ||
134 | <connection> | ||
135 | <sender>actionE_xit</sender> | ||
136 | <signal>triggered()</signal> | ||
137 | <receiver>MainWnd</receiver> | ||
138 | <slot>close()</slot> | ||
139 | <hints> | ||
140 | <hint type="sourcelabel"> | ||
141 | <x>-1</x> | ||
142 | <y>-1</y> | ||
143 | </hint> | ||
144 | <hint type="destinationlabel"> | ||
145 | <x>215</x> | ||
146 | <y>159</y> | ||
147 | </hint> | ||
148 | </hints> | ||
149 | </connection> | ||
150 | <connection> | ||
151 | <sender>action_New_Gats_File</sender> | ||
152 | <signal>triggered()</signal> | ||
153 | <receiver>MainWnd</receiver> | ||
154 | <slot>newFile()</slot> | ||
155 | <hints> | ||
156 | <hint type="sourcelabel"> | ||
157 | <x>-1</x> | ||
158 | <y>-1</y> | ||
159 | </hint> | ||
160 | <hint type="destinationlabel"> | ||
161 | <x>215</x> | ||
162 | <y>159</y> | ||
163 | </hint> | ||
164 | </hints> | ||
165 | </connection> | ||
166 | <connection> | ||
167 | <sender>action_Save</sender> | ||
168 | <signal>triggered()</signal> | ||
169 | <receiver>MainWnd</receiver> | ||
170 | <slot>save()</slot> | ||
171 | <hints> | ||
172 | <hint type="sourcelabel"> | ||
173 | <x>-1</x> | ||
174 | <y>-1</y> | ||
175 | </hint> | ||
176 | <hint type="destinationlabel"> | ||
177 | <x>215</x> | ||
178 | <y>159</y> | ||
179 | </hint> | ||
180 | </hints> | ||
181 | </connection> | ||
182 | <connection> | ||
183 | <sender>action_Save_As</sender> | ||
184 | <signal>triggered()</signal> | ||
185 | <receiver>MainWnd</receiver> | ||
186 | <slot>saveAs()</slot> | ||
187 | <hints> | ||
188 | <hint type="sourcelabel"> | ||
189 | <x>-1</x> | ||
190 | <y>-1</y> | ||
191 | </hint> | ||
192 | <hint type="destinationlabel"> | ||
193 | <x>215</x> | ||
194 | <y>159</y> | ||
195 | </hint> | ||
196 | </hints> | ||
197 | </connection> | ||
198 | </connections> | ||
199 | <slots> | ||
200 | <slot>connect()</slot> | ||
201 | <slot>proxy()</slot> | ||
202 | <slot>open()</slot> | ||
203 | <slot>save()</slot> | ||
204 | <slot>saveAs()</slot> | ||
205 | <slot>newFile()</slot> | ||
206 | </slots> | ||
207 | </ui> | ||
diff --git a/src/gatscon/proxythread.cpp b/src/gatscon/proxythread.cpp deleted file mode 100644 index 574b56b..0000000 --- a/src/gatscon/proxythread.cpp +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | #include "proxythread.h" | ||
2 | |||
3 | #include <gats/types.h> | ||
4 | |||
5 | #include <bu/tcpsocket.h> | ||
6 | #include <bu/tcpserversocket.h> | ||
7 | #include <bu/sio.h> | ||
8 | #include <bu/membuf.h> | ||
9 | |||
10 | using namespace Bu; | ||
11 | |||
12 | ProxyThread::ProxyThread( QObject *pParent, int iPortIn, | ||
13 | const QByteArray &baHostOut, int iPortOut ) : | ||
14 | QThread( pParent ), | ||
15 | pHost( NULL ), | ||
16 | iPortIn( iPortIn ), | ||
17 | baHostOut( baHostOut ), | ||
18 | iPortOut( iPortOut ), | ||
19 | gsCli( ssCli ) | ||
20 | { | ||
21 | pHost = new ProxyHostThread( pParent, this ); | ||
22 | } | ||
23 | |||
24 | ProxyThread::~ProxyThread() | ||
25 | { | ||
26 | } | ||
27 | |||
28 | void ProxyThread::send( Gats::Object *pObj ) | ||
29 | { | ||
30 | MemBuf bg; | ||
31 | Gats::GatsStream gs( bg ); | ||
32 | gs.writeObject( pObj ); | ||
33 | ssCli.write( bg.getString().getStr(), bg.getString().getSize() ); | ||
34 | } | ||
35 | |||
36 | void ProxyThread::run() | ||
37 | { | ||
38 | int iSockIn; | ||
39 | |||
40 | { | ||
41 | TcpServerSocket tsIn( iPortIn ); | ||
42 | do | ||
43 | { | ||
44 | iSockIn = tsIn.accept( 5 ); | ||
45 | } while( iSockIn < 0 ); | ||
46 | } | ||
47 | |||
48 | emit gotConnection(); | ||
49 | |||
50 | ssCli.setStream( new TcpSocket( iSockIn ) ); | ||
51 | ssCli.setBlocking( true ); | ||
52 | |||
53 | pHost->setStream( | ||
54 | new TcpSocket( baHostOut.constData(), iPortOut ) | ||
55 | ); | ||
56 | |||
57 | pHost->start(); | ||
58 | |||
59 | while( !ssCli.isEos() ) | ||
60 | { | ||
61 | Gats::Object *pObj = gsCli.readObject(); | ||
62 | if( pObj == NULL ) | ||
63 | continue; | ||
64 | |||
65 | pHost->send( pObj ); | ||
66 | emit recv( pObj ); | ||
67 | } | ||
68 | |||
69 | } | ||
70 | |||
71 | ProxyHostThread::ProxyHostThread( QObject *pParent, ProxyThread *pClient ) : | ||
72 | QThread( pParent ), | ||
73 | pClient( pClient ), | ||
74 | ssHst(), | ||
75 | gsHst( ssHst ) | ||
76 | { | ||
77 | } | ||
78 | |||
79 | ProxyHostThread::~ProxyHostThread() | ||
80 | { | ||
81 | } | ||
82 | |||
83 | void ProxyHostThread::send( Gats::Object *pObj ) | ||
84 | { | ||
85 | MemBuf bg; | ||
86 | Gats::GatsStream gs( bg ); | ||
87 | gs.writeObject( pObj ); | ||
88 | ssHst.write( bg.getString().getStr(), bg.getString().getSize() ); | ||
89 | } | ||
90 | |||
91 | void ProxyHostThread::setStream( Bu::Stream *pStr ) | ||
92 | { | ||
93 | ssHst.setStream( pStr ); | ||
94 | } | ||
95 | |||
96 | void ProxyHostThread::run() | ||
97 | { | ||
98 | while( !ssHst.isEos() ) | ||
99 | { | ||
100 | Gats::Object *pObj = gsHst.readObject(); | ||
101 | if( pObj == NULL ) | ||
102 | continue; | ||
103 | |||
104 | pClient->send( pObj ); | ||
105 | emit recv( pObj ); | ||
106 | } | ||
107 | } | ||
108 | |||
diff --git a/src/gatscon/proxythread.h b/src/gatscon/proxythread.h deleted file mode 100644 index df75046..0000000 --- a/src/gatscon/proxythread.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | #ifndef PROXY_THREAD_H | ||
2 | #define PROXY_THREAD_H | ||
3 | |||
4 | #include <QThread> | ||
5 | |||
6 | #include <bu/streamstack.h> | ||
7 | #include <gats/gatsstream.h> | ||
8 | |||
9 | class ProxyThread : public QThread | ||
10 | { | ||
11 | Q_OBJECT; | ||
12 | public: | ||
13 | ProxyThread( QObject *pParent, int iPortIn, const QByteArray &baHostOut, | ||
14 | int iPortOut ); | ||
15 | virtual ~ProxyThread(); | ||
16 | |||
17 | class ProxyHostThread *pHost; | ||
18 | |||
19 | void send( Gats::Object *pObj ); | ||
20 | |||
21 | signals: | ||
22 | void recv( Gats::Object *pObj ); | ||
23 | void gotConnection(); | ||
24 | |||
25 | protected: | ||
26 | virtual void run(); | ||
27 | |||
28 | private: | ||
29 | int iPortIn; | ||
30 | QByteArray baHostOut; | ||
31 | int iPortOut; | ||
32 | |||
33 | Bu::StreamStack ssCli; | ||
34 | Gats::GatsStream gsCli; | ||
35 | }; | ||
36 | |||
37 | class ProxyHostThread : public QThread | ||
38 | { | ||
39 | Q_OBJECT; | ||
40 | public: | ||
41 | ProxyHostThread( QObject *pParent, ProxyThread *pClient ); | ||
42 | virtual ~ProxyHostThread(); | ||
43 | |||
44 | void send( Gats::Object *pObj ); | ||
45 | |||
46 | void setStream( Bu::Stream *pStr ); | ||
47 | |||
48 | signals: | ||
49 | void recv( Gats::Object *pObj ); | ||
50 | |||
51 | protected: | ||
52 | virtual void run(); | ||
53 | |||
54 | private: | ||
55 | ProxyThread *pClient; | ||
56 | Bu::StreamStack ssHst; | ||
57 | Gats::GatsStream gsHst; | ||
58 | }; | ||
59 | |||
60 | #endif | ||
diff --git a/src/gatscon/proxywidget.cpp b/src/gatscon/proxywidget.cpp deleted file mode 100644 index 215f95f..0000000 --- a/src/gatscon/proxywidget.cpp +++ /dev/null | |||
@@ -1,131 +0,0 @@ | |||
1 | #include "proxywidget.h" | ||
2 | #include "proxythread.h" | ||
3 | |||
4 | #include "gatstotree.h" | ||
5 | #include "treetogats.h" | ||
6 | |||
7 | #include <QMessageBox> | ||
8 | |||
9 | #include <gats/gatsstream.h> | ||
10 | #include <gats/types.h> | ||
11 | #include <bu/sio.h> | ||
12 | #include <bu/file.h> | ||
13 | |||
14 | using namespace Bu; | ||
15 | |||
16 | ProxyWidget::ProxyWidget( QWidget *pParent, int iPortIn, | ||
17 | const QByteArray baHost, int iPortOut ) : | ||
18 | QWidget( pParent ), | ||
19 | pPrx( NULL ) | ||
20 | { | ||
21 | setupUi( this ); | ||
22 | |||
23 | pPrx = new ProxyThread( this, iPortIn, baHost, iPortOut ); | ||
24 | |||
25 | connect( pPrx, SIGNAL(gotConnection()), | ||
26 | this, SLOT(gotConnection()), Qt::QueuedConnection ); | ||
27 | connect( pPrx, SIGNAL(recv( Gats::Object *)), | ||
28 | this, SLOT(clientRecv(Gats::Object *)), Qt::QueuedConnection ); | ||
29 | connect( pPrx->pHost, SIGNAL(recv( Gats::Object *)), | ||
30 | this, SLOT(hostRecv(Gats::Object *)), Qt::QueuedConnection ); | ||
31 | |||
32 | pPrx->start(); | ||
33 | } | ||
34 | |||
35 | ProxyWidget::~ProxyWidget() | ||
36 | { | ||
37 | } | ||
38 | |||
39 | void ProxyWidget::saveTo( const QString &sFile ) | ||
40 | { | ||
41 | File fOut( sFile.toAscii().constData(), File::WriteNew ); | ||
42 | Gats::GatsStream gsOut( fOut ); | ||
43 | QTreeWidgetItem *pRoot = twHistory->invisibleRootItem(); | ||
44 | for( int j = 0; j < pRoot->childCount(); j++ ) | ||
45 | { | ||
46 | Gats::Object *pObj = treeToGats( pRoot->child( j ) ); | ||
47 | gsOut.writeObject( pObj ); | ||
48 | delete pObj; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | void ProxyWidget::sendToClient() | ||
53 | { | ||
54 | try | ||
55 | { | ||
56 | Gats::Object *pObj = Gats::Object::strToGats( | ||
57 | leGats->text().toAscii().constData() | ||
58 | ); | ||
59 | sio << "Send: " << *pObj << sio.nl; | ||
60 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | ||
61 | twHistory->invisibleRootItem() | ||
62 | ); | ||
63 | pIt->setText( 0, "proxy -> client" ); | ||
64 | gatsToTree( pIt, pObj ); | ||
65 | pPrx->send( pObj ); | ||
66 | delete pObj; | ||
67 | |||
68 | leGats->setText(""); | ||
69 | leGats->setFocus(); | ||
70 | } | ||
71 | catch( Bu::ExceptionBase &e ) | ||
72 | { | ||
73 | QMessageBox::critical( this, "Gats Console - Error", e.what() ); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | void ProxyWidget::sendToServer() | ||
78 | { | ||
79 | try | ||
80 | { | ||
81 | Gats::Object *pObj = Gats::Object::strToGats( | ||
82 | leGats->text().toAscii().constData() | ||
83 | ); | ||
84 | sio << "Send: " << *pObj << sio.nl; | ||
85 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | ||
86 | twHistory->invisibleRootItem() | ||
87 | ); | ||
88 | pIt->setText( 0, "proxy -> host" ); | ||
89 | gatsToTree( pIt, pObj ); | ||
90 | pPrx->pHost->send( pObj ); | ||
91 | delete pObj; | ||
92 | |||
93 | leGats->setText(""); | ||
94 | leGats->setFocus(); | ||
95 | } | ||
96 | catch( Bu::ExceptionBase &e ) | ||
97 | { | ||
98 | QMessageBox::critical( this, "Gats Console - Error", e.what() ); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | void ProxyWidget::clientRecv( Gats::Object *pObj ) | ||
103 | { | ||
104 | sio << "Recv: " << *pObj << sio.nl; | ||
105 | |||
106 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | ||
107 | twHistory->invisibleRootItem() | ||
108 | ); | ||
109 | pIt->setText( 0, "client -> host" ); | ||
110 | gatsToTree( pIt, pObj ); | ||
111 | delete pObj; | ||
112 | } | ||
113 | |||
114 | void ProxyWidget::hostRecv( Gats::Object *pObj ) | ||
115 | { | ||
116 | sio << "Recv: " << *pObj << sio.nl; | ||
117 | |||
118 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | ||
119 | twHistory->invisibleRootItem() | ||
120 | ); | ||
121 | pIt->setText( 0, "host -> client" ); | ||
122 | gatsToTree( pIt, pObj ); | ||
123 | delete pObj; | ||
124 | } | ||
125 | |||
126 | void ProxyWidget::gotConnection() | ||
127 | { | ||
128 | lwConnect->stop(); | ||
129 | swRoot->setCurrentIndex( 1 ); | ||
130 | } | ||
131 | |||
diff --git a/src/gatscon/proxywidget.h b/src/gatscon/proxywidget.h deleted file mode 100644 index d6ebf4d..0000000 --- a/src/gatscon/proxywidget.h +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | #ifndef PROXY_WIDGET_H | ||
2 | #define PROXY_WIDGET_H | ||
3 | |||
4 | #include "ui_proxywidget.h" | ||
5 | #include "iobase.h" | ||
6 | |||
7 | namespace Gats | ||
8 | { | ||
9 | class Object; | ||
10 | }; | ||
11 | |||
12 | class ProxyWidget : public QWidget, protected Ui::ProxyWidget, public IoBase | ||
13 | { | ||
14 | Q_OBJECT; | ||
15 | public: | ||
16 | ProxyWidget( QWidget *pParent, int iPortIn, const QByteArray baHost, | ||
17 | int iPortOut ); | ||
18 | virtual ~ProxyWidget(); | ||
19 | |||
20 | virtual void saveTo( const QString &sFile ); | ||
21 | |||
22 | public slots: | ||
23 | void sendToClient(); | ||
24 | void sendToServer(); | ||
25 | void clientRecv( Gats::Object *pObj ); | ||
26 | void hostRecv( Gats::Object *pObj ); | ||
27 | void gotConnection(); | ||
28 | |||
29 | private: | ||
30 | class ProxyThread *pPrx; | ||
31 | }; | ||
32 | |||
33 | #endif | ||
diff --git a/src/gatscon/proxywidget.ui b/src/gatscon/proxywidget.ui deleted file mode 100644 index 995fc73..0000000 --- a/src/gatscon/proxywidget.ui +++ /dev/null | |||
@@ -1,181 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>ProxyWidget</class> | ||
4 | <widget class="QWidget" name="ProxyWidget"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>338</width> | ||
10 | <height>300</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Form</string> | ||
15 | </property> | ||
16 | <layout class="QVBoxLayout" name="verticalLayout_2"> | ||
17 | <property name="margin"> | ||
18 | <number>0</number> | ||
19 | </property> | ||
20 | <item> | ||
21 | <widget class="QStackedWidget" name="swRoot"> | ||
22 | <property name="currentIndex"> | ||
23 | <number>0</number> | ||
24 | </property> | ||
25 | <widget class="QWidget" name="page"> | ||
26 | <layout class="QVBoxLayout" name="verticalLayout_4"> | ||
27 | <item> | ||
28 | <spacer name="verticalSpacer"> | ||
29 | <property name="orientation"> | ||
30 | <enum>Qt::Vertical</enum> | ||
31 | </property> | ||
32 | <property name="sizeHint" stdset="0"> | ||
33 | <size> | ||
34 | <width>20</width> | ||
35 | <height>40</height> | ||
36 | </size> | ||
37 | </property> | ||
38 | </spacer> | ||
39 | </item> | ||
40 | <item> | ||
41 | <widget class="QLabel" name="label_2"> | ||
42 | <property name="text"> | ||
43 | <string>Listening for connections...</string> | ||
44 | </property> | ||
45 | <property name="alignment"> | ||
46 | <set>Qt::AlignCenter</set> | ||
47 | </property> | ||
48 | </widget> | ||
49 | </item> | ||
50 | <item> | ||
51 | <widget class="LoadingWidget" name="lwConnect" native="true"> | ||
52 | <property name="minimumSize"> | ||
53 | <size> | ||
54 | <width>0</width> | ||
55 | <height>50</height> | ||
56 | </size> | ||
57 | </property> | ||
58 | </widget> | ||
59 | </item> | ||
60 | <item> | ||
61 | <spacer name="verticalSpacer_2"> | ||
62 | <property name="orientation"> | ||
63 | <enum>Qt::Vertical</enum> | ||
64 | </property> | ||
65 | <property name="sizeHint" stdset="0"> | ||
66 | <size> | ||
67 | <width>20</width> | ||
68 | <height>40</height> | ||
69 | </size> | ||
70 | </property> | ||
71 | </spacer> | ||
72 | </item> | ||
73 | </layout> | ||
74 | </widget> | ||
75 | <widget class="QWidget" name="page_2"> | ||
76 | <layout class="QVBoxLayout" name="verticalLayout_3"> | ||
77 | <item> | ||
78 | <widget class="QTreeWidget" name="twHistory"> | ||
79 | <column> | ||
80 | <property name="text"> | ||
81 | <string>Name</string> | ||
82 | </property> | ||
83 | </column> | ||
84 | <column> | ||
85 | <property name="text"> | ||
86 | <string>Type</string> | ||
87 | </property> | ||
88 | </column> | ||
89 | <column> | ||
90 | <property name="text"> | ||
91 | <string>Value</string> | ||
92 | </property> | ||
93 | </column> | ||
94 | </widget> | ||
95 | </item> | ||
96 | <item> | ||
97 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
98 | <item> | ||
99 | <widget class="QLabel" name="label"> | ||
100 | <property name="text"> | ||
101 | <string>Gats:</string> | ||
102 | </property> | ||
103 | </widget> | ||
104 | </item> | ||
105 | <item> | ||
106 | <widget class="QLineEdit" name="leGats"/> | ||
107 | </item> | ||
108 | <item> | ||
109 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
110 | <item> | ||
111 | <widget class="QPushButton" name="pushButton"> | ||
112 | <property name="text"> | ||
113 | <string>Send to Client</string> | ||
114 | </property> | ||
115 | </widget> | ||
116 | </item> | ||
117 | <item> | ||
118 | <widget class="QPushButton" name="pushButton_2"> | ||
119 | <property name="text"> | ||
120 | <string>Send to Server</string> | ||
121 | </property> | ||
122 | </widget> | ||
123 | </item> | ||
124 | </layout> | ||
125 | </item> | ||
126 | </layout> | ||
127 | </item> | ||
128 | </layout> | ||
129 | </widget> | ||
130 | </widget> | ||
131 | </item> | ||
132 | </layout> | ||
133 | </widget> | ||
134 | <customwidgets> | ||
135 | <customwidget> | ||
136 | <class>LoadingWidget</class> | ||
137 | <extends>QWidget</extends> | ||
138 | <header>loadingwidget.h</header> | ||
139 | <container>1</container> | ||
140 | </customwidget> | ||
141 | </customwidgets> | ||
142 | <resources/> | ||
143 | <connections> | ||
144 | <connection> | ||
145 | <sender>pushButton</sender> | ||
146 | <signal>clicked()</signal> | ||
147 | <receiver>ProxyWidget</receiver> | ||
148 | <slot>sendToClient()</slot> | ||
149 | <hints> | ||
150 | <hint type="sourcelabel"> | ||
151 | <x>280</x> | ||
152 | <y>258</y> | ||
153 | </hint> | ||
154 | <hint type="destinationlabel"> | ||
155 | <x>392</x> | ||
156 | <y>223</y> | ||
157 | </hint> | ||
158 | </hints> | ||
159 | </connection> | ||
160 | <connection> | ||
161 | <sender>pushButton_2</sender> | ||
162 | <signal>clicked()</signal> | ||
163 | <receiver>ProxyWidget</receiver> | ||
164 | <slot>sendToServer()</slot> | ||
165 | <hints> | ||
166 | <hint type="sourcelabel"> | ||
167 | <x>306</x> | ||
168 | <y>284</y> | ||
169 | </hint> | ||
170 | <hint type="destinationlabel"> | ||
171 | <x>199</x> | ||
172 | <y>340</y> | ||
173 | </hint> | ||
174 | </hints> | ||
175 | </connection> | ||
176 | </connections> | ||
177 | <slots> | ||
178 | <slot>sendToClient()</slot> | ||
179 | <slot>sendToServer()</slot> | ||
180 | </slots> | ||
181 | </ui> | ||
diff --git a/src/gatscon/setupproxydlg.cpp b/src/gatscon/setupproxydlg.cpp deleted file mode 100644 index 7c7a873..0000000 --- a/src/gatscon/setupproxydlg.cpp +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | #include "setupproxydlg.h" | ||
2 | |||
3 | SetupProxyDlg::SetupProxyDlg( QWidget *pParent ) : | ||
4 | QDialog( pParent ) | ||
5 | { | ||
6 | setupUi( this ); | ||
7 | } | ||
8 | |||
9 | SetupProxyDlg::~SetupProxyDlg() | ||
10 | { | ||
11 | } | ||
12 | |||
13 | int SetupProxyDlg::getPortIn() const | ||
14 | { | ||
15 | return sbPortIn->value(); | ||
16 | } | ||
17 | |||
18 | QByteArray SetupProxyDlg::getHostOut() const | ||
19 | { | ||
20 | return leHostOut->text().toAscii(); | ||
21 | } | ||
22 | |||
23 | int SetupProxyDlg::getPortOut() const | ||
24 | { | ||
25 | return sbPortOut->value(); | ||
26 | } | ||
27 | |||
diff --git a/src/gatscon/setupproxydlg.h b/src/gatscon/setupproxydlg.h deleted file mode 100644 index 6cc31bd..0000000 --- a/src/gatscon/setupproxydlg.h +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | #ifndef SETUP_PROXY_DLG_H | ||
2 | #define SETUP_PROXY_DLG_H | ||
3 | |||
4 | #include "ui_setupproxydlg.h" | ||
5 | |||
6 | class SetupProxyDlg : public QDialog, protected Ui::SetupProxyDlg | ||
7 | { | ||
8 | Q_OBJECT; | ||
9 | public: | ||
10 | SetupProxyDlg( QWidget *pParent=NULL ); | ||
11 | virtual ~SetupProxyDlg(); | ||
12 | |||
13 | int getPortIn() const; | ||
14 | QByteArray getHostOut() const; | ||
15 | int getPortOut() const; | ||
16 | }; | ||
17 | |||
18 | #endif | ||
diff --git a/src/gatscon/setupproxydlg.ui b/src/gatscon/setupproxydlg.ui deleted file mode 100644 index c713baf..0000000 --- a/src/gatscon/setupproxydlg.ui +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>SetupProxyDlg</class> | ||
4 | <widget class="QDialog" name="SetupProxyDlg"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>359</width> | ||
10 | <height>122</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Gats Console - Setup Proxy</string> | ||
15 | </property> | ||
16 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
17 | <item> | ||
18 | <layout class="QFormLayout" name="formLayout"> | ||
19 | <item row="0" column="0"> | ||
20 | <widget class="QLabel" name="label_2"> | ||
21 | <property name="text"> | ||
22 | <string>Listening port:</string> | ||
23 | </property> | ||
24 | </widget> | ||
25 | </item> | ||
26 | <item row="0" column="1"> | ||
27 | <widget class="QSpinBox" name="sbPortIn"> | ||
28 | <property name="minimum"> | ||
29 | <number>1</number> | ||
30 | </property> | ||
31 | <property name="maximum"> | ||
32 | <number>32767</number> | ||
33 | </property> | ||
34 | </widget> | ||
35 | </item> | ||
36 | <item row="1" column="0"> | ||
37 | <widget class="QLabel" name="label_3"> | ||
38 | <property name="text"> | ||
39 | <string>Target host:</string> | ||
40 | </property> | ||
41 | </widget> | ||
42 | </item> | ||
43 | <item row="1" column="1"> | ||
44 | <widget class="QLineEdit" name="leHostOut"/> | ||
45 | </item> | ||
46 | <item row="2" column="0"> | ||
47 | <widget class="QLabel" name="label_4"> | ||
48 | <property name="text"> | ||
49 | <string>Target port:</string> | ||
50 | </property> | ||
51 | </widget> | ||
52 | </item> | ||
53 | <item row="2" column="1"> | ||
54 | <widget class="QSpinBox" name="sbPortOut"> | ||
55 | <property name="minimum"> | ||
56 | <number>1</number> | ||
57 | </property> | ||
58 | <property name="maximum"> | ||
59 | <number>32767</number> | ||
60 | </property> | ||
61 | </widget> | ||
62 | </item> | ||
63 | </layout> | ||
64 | </item> | ||
65 | <item> | ||
66 | <widget class="QDialogButtonBox" name="buttonBox"> | ||
67 | <property name="orientation"> | ||
68 | <enum>Qt::Horizontal</enum> | ||
69 | </property> | ||
70 | <property name="standardButtons"> | ||
71 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
72 | </property> | ||
73 | </widget> | ||
74 | </item> | ||
75 | </layout> | ||
76 | </widget> | ||
77 | <resources/> | ||
78 | <connections> | ||
79 | <connection> | ||
80 | <sender>buttonBox</sender> | ||
81 | <signal>accepted()</signal> | ||
82 | <receiver>SetupProxyDlg</receiver> | ||
83 | <slot>accept()</slot> | ||
84 | <hints> | ||
85 | <hint type="sourcelabel"> | ||
86 | <x>248</x> | ||
87 | <y>254</y> | ||
88 | </hint> | ||
89 | <hint type="destinationlabel"> | ||
90 | <x>157</x> | ||
91 | <y>274</y> | ||
92 | </hint> | ||
93 | </hints> | ||
94 | </connection> | ||
95 | <connection> | ||
96 | <sender>buttonBox</sender> | ||
97 | <signal>rejected()</signal> | ||
98 | <receiver>SetupProxyDlg</receiver> | ||
99 | <slot>reject()</slot> | ||
100 | <hints> | ||
101 | <hint type="sourcelabel"> | ||
102 | <x>316</x> | ||
103 | <y>260</y> | ||
104 | </hint> | ||
105 | <hint type="destinationlabel"> | ||
106 | <x>286</x> | ||
107 | <y>274</y> | ||
108 | </hint> | ||
109 | </hints> | ||
110 | </connection> | ||
111 | </connections> | ||
112 | </ui> | ||
diff --git a/src/gatscon/treetogats.cpp b/src/gatscon/treetogats.cpp deleted file mode 100644 index a1571d1..0000000 --- a/src/gatscon/treetogats.cpp +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | #include "treetogats.h" | ||
2 | |||
3 | #include <QTreeWidgetItem> | ||
4 | |||
5 | #include <gats/types.h> | ||
6 | |||
7 | Gats::Object *treeToGats( QTreeWidgetItem *pRoot ) | ||
8 | { | ||
9 | QString sType = pRoot->text( 1 ); | ||
10 | QByteArray baDat = pRoot->text( 2 ).toAscii(); | ||
11 | if( sType == "int" ) | ||
12 | { | ||
13 | return new Gats::Integer( strtoll( baDat.constData(), NULL, 10 ) ); | ||
14 | } | ||
15 | else if( sType == "str" ) | ||
16 | { | ||
17 | return new Gats::String( baDat.constData(), baDat.size() ); | ||
18 | } | ||
19 | else if( sType == "float" ) | ||
20 | { | ||
21 | return new Gats::Float( strtod( baDat.constData(), NULL ) ); | ||
22 | } | ||
23 | else if( sType == "bool" ) | ||
24 | { | ||
25 | return new Gats::Boolean( baDat == "true" ); | ||
26 | } | ||
27 | else if( sType == "list" ) | ||
28 | { | ||
29 | Gats::List *pRet = new Gats::List(); | ||
30 | for( int j = 0; j < pRoot->childCount(); j++ ) | ||
31 | { | ||
32 | pRet->append( treeToGats( pRoot->child( j ) ) ); | ||
33 | } | ||
34 | return pRet; | ||
35 | } | ||
36 | else if( sType == "dict" ) | ||
37 | { | ||
38 | Gats::Dictionary *pRet = new Gats::Dictionary(); | ||
39 | for( int j = 0; j < pRoot->childCount(); j++ ) | ||
40 | { | ||
41 | QTreeWidgetItem *pChild = pRoot->child( j ); | ||
42 | pRet->insert( | ||
43 | pChild->text( 0 ).toAscii().constData(), | ||
44 | treeToGats( pChild ) | ||
45 | ); | ||
46 | } | ||
47 | return pRet; | ||
48 | } | ||
49 | |||
50 | throw Bu::ExceptionBase("Unhandled type found."); | ||
51 | } | ||
52 | |||
diff --git a/src/gatscon/treetogats.h b/src/gatscon/treetogats.h deleted file mode 100644 index 931623d..0000000 --- a/src/gatscon/treetogats.h +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | #ifndef TREE_TO_GATS_H | ||
2 | #define TREE_TO_GATS_H | ||
3 | |||
4 | class QTreeWidgetItem; | ||
5 | |||
6 | namespace Gats | ||
7 | { | ||
8 | class Object; | ||
9 | }; | ||
10 | |||
11 | Gats::Object *treeToGats( QTreeWidgetItem *pRoot ); | ||
12 | |||
13 | #endif | ||