diff options
Diffstat (limited to 'src/gatscon/proxywidget.cpp')
-rw-r--r-- | src/gatscon/proxywidget.cpp | 131 |
1 files changed, 0 insertions, 131 deletions
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 | |||