summaryrefslogtreecommitdiff
path: root/client/netcom.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/netcom.cc')
-rw-r--r--client/netcom.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/client/netcom.cc b/client/netcom.cc
index 755357e..ab2446e 100644
--- a/client/netcom.cc
+++ b/client/netcom.cc
@@ -37,6 +37,7 @@ NetCom::NetCom(QString host, quint16 port, QString user, QString cpr)
this->cpr = cpr;
socket.connectToHost(host, port);
connect(&socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
+ socket.waitForConnected();
transmitting = false;
}
@@ -47,6 +48,9 @@ NetCom::~NetCom()
QDomDocument NetCom::send(QString course, QString macro)
{
+ printf("Socket state: %d\n", socket.state());
+ if(socket.state() != 3) printf("Socket state not connected: %s\n", socket.errorString().toStdString().c_str());
+
if(qApp->activeWindow()) qApp->activeWindow()->setEnabled(false);
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@@ -66,10 +70,10 @@ QDomDocument NetCom::send(QString course, QString macro)
if(macro != "") request_elem.setAttribute("macro", macro);
pracro_elem.appendChild(request_elem);
- printf("\nSending:\n%s", doc.toString().toStdString().c_str());
+ printf("\nSending request:\n%s", doc.toString().toStdString().c_str());
socket.write(doc.toByteArray());
- socket.waitForReadyRead();
+ // socket.waitForReadyRead();
do {
qApp->processEvents();
@@ -79,7 +83,7 @@ QDomDocument NetCom::send(QString course, QString macro)
QDomElement elem = res_doc.documentElement();
- printf("\nRecieved:\n%s", res_doc.toString().toStdString().c_str());
+ printf("\nRecieved request:\n%s", res_doc.toString().toStdString().c_str());
QApplication::restoreOverrideCursor();
if(qApp->activeWindow()) qApp->activeWindow()->setEnabled(true);
@@ -94,6 +98,9 @@ void NetCom::readyRead()
void NetCom::send(QVector< Widget* > widgets, QString macro, QString version)
{
+ printf("Socket state: %d\n", socket.state());
+ if(socket.state() != 3) printf("Socket state not connected: %s\n", socket.errorString().toStdString().c_str());
+
qApp->activeWindow()->setEnabled(false);
if(qApp->activeWindow()) qApp->activeWindow()->setEnabled(false);
@@ -126,10 +133,10 @@ void NetCom::send(QVector< Widget* > widgets, QString macro, QString version)
i++;
}
- printf("\nSending:\n%s", doc.toString().toStdString().c_str());
+ printf("\nSending commit:\n%s", doc.toString().toStdString().c_str());
socket.write(doc.toByteArray());
- socket.waitForReadyRead();
+ // socket.waitForReadyRead();
//
// Wait for the (hopefully) empty answer.
@@ -140,9 +147,9 @@ void NetCom::send(QVector< Widget* > widgets, QString macro, QString version)
buffer = "";
- QDomElement elem = res_doc.documentElement();
+ //QDomElement elem = res_doc.documentElement();
- printf("\nRecieved:\n%s", res_doc.toString().toStdString().c_str());
+ printf("\nRecieved commit:\n%s", res_doc.toString().toStdString().c_str());
QApplication::restoreOverrideCursor();
if(qApp->activeWindow()) qApp->activeWindow()->setEnabled(true);