6
#include "gs_globals.h"
8
#include "igsconnection.h"
9
#include <qapplication.h>
10
#include <qmessagebox.h>
11
#include <qlineedit.h>
16
TelnetInterface *telnetIF;
19
TelnetConnection::TelnetConnection(QWidget* parent)
26
// Create IGSConnection instance
27
igsInterface = new IGSConnection();
28
CHECK_PTR(igsInterface);
29
void (*fp)(const char*, uint);
30
fp = TelnetInterface::callback;
31
igsInterface->registerCallback(fp);
33
// Create TelnetInterface instance
34
telnetIF = new TelnetInterface();
37
SIGNAL(textRecieved(const QString&)),
39
SLOT(sendTextToApp(const QString&)));
42
TelnetConnection::~TelnetConnection()
44
// qDebug("bfor deleting igsinterface addres: %x",igsInterface );
45
// CHECK_PTR(igsInterface);
47
// qDebug("after deleting igsinterface");
52
qDebug("TelnetConnection::~TelnetConnection() DONE");
55
void TelnetConnection::slotHostConnect()
57
if (igsInterface->isConnected())
59
qDebug("Already connected!");
62
// igsInterface->openConnection(host, port);
63
if (!igsInterface->openConnection(host.latin1(), port, loginName, password))
65
qDebug("Failed to connect to host!");
71
void TelnetConnection::slotHostDisconnect()
73
if (!igsInterface->closeConnection())
75
qDebug("Failed to disconnect from host!");
79
// send text (from MainWindow) to host
80
void TelnetConnection::sendTextFromApp(const QString &txt)
82
igsInterface->sendTextToHost(txt);
86
void TelnetConnection::setHost(const QString h, const QString lg, const QString pw, unsigned int pt)
88
// set variables for connection
94
qDebug("SELECTED %s %d, %s, %s", host.latin1(), port, loginName.latin1(), (password ? "***" : "NULL"));
97
void TelnetConnection::slotHostQuit()
99
// TODO: Timeout for connection termination, if still data has to be written
100
if (igsInterface->isConnected())
101
slotHostDisconnect();
104
//------------------------------------------------------------
106
TelnetInterface::TelnetInterface()
110
TelnetInterface::~TelnetInterface()
114
void TelnetInterface::callback(const char *s, uint i)
116
// QString qstr = QString::fromLatin1(s, i);
117
// qDebug("GUI: Callback recieved: %s!", qstr.latin1());
119
if (telnetIF != NULL)
120
// emit telnetIF->textRecieved(qstr, i);
121
emit telnetIF->textRecieved(QString::fromLatin1(s, i));