aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/gatscon/proxywidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--c++-libbu++/src/gatscon/proxywidget.cpp169
1 files changed, 88 insertions, 81 deletions
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