diff options
author | deva <deva> | 2008-10-08 11:58:34 +0000 |
---|---|---|
committer | deva <deva> | 2008-10-08 11:58:34 +0000 |
commit | 9b697d2d3e34962385cd85a14d4cb14d5b1763ce (patch) | |
tree | 0bd158b1e747850e293f0dac714b7afaeaf0b895 /client/netcom.cc | |
parent | 8bbcc59fd1488833a4d8dd346b6e8fec2a0021a8 (diff) |
Removed obsolete macro.{cc,h}. Made the passing of the Netcom class, use a pointer.
Diffstat (limited to 'client/netcom.cc')
-rw-r--r-- | client/netcom.cc | 21 |
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); |