[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kdeprint/cups
From: George Staikos <staikos () kde ! org>
Date: 2003-02-27 17:29:40
[Download RAW message or body]
CVS commit by staikos:
forward port the fix for freezes with kdeprint.
M +43 -3 kmcupsmanager.cpp 1.50
M +6 -1 kmcupsmanager.h 1.13
--- kdelibs/kdeprint/cups/kmcupsmanager.cpp #1.49:1.50
@@ -40,4 +40,6 @@
#include <qtimer.h>
#include <qsocket.h>
+#include <qdatetime.h>
+
#include <kdebug.h>
#include <kapplication.h>
@@ -266,7 +269,34 @@ bool KMCupsManager::completePrinterShort
if (!p->uri().isEmpty())
{
+ // THIS IS AN UGLY HACK!! FIXME
+ // This attempts a "pre-connection" to see if the host is
+ // actually reachable. It times out after 2 seconds at most,
+ // preventing application freezes.
+ m_hostSuccess = false;
+ m_lookupDone = false;
+ // Give 2 seconds to connect to the printer, or abort
+ KExtendedSocket *kes = new KExtendedSocket(p->uri().host(),
+ p->uri().port());
+ connect(kes, SIGNAL(connectionSuccess()), this, \
SLOT(hostPingSlot())); + connect(kes, SIGNAL(connectionFailed(int)), \
this, SLOT(hostPingFailedSlot())); + if (kes->startAsyncConnect() != \
0) { + delete kes;
+ m_hostSuccess = false;
+ } else {
+ QDateTime tm = QDateTime::currentDateTime().addSecs(2);
+ while (!m_lookupDone && (QDateTime::currentDateTime() < tm))
+ qApp->processEvents();
+
+ delete kes;
+
+ if (!m_lookupDone)
+ m_hostSuccess = false;
+ }
+
+ if (m_hostSuccess == true) {
req.setHost(p->uri().host());
req.setPort(p->uri().port());
}
+ }
// disable location as it has been transferred to listing (for filtering)
//keys.append("printer-location");
@@ -1054,4 +1084,14 @@ void KMCupsManager::slotConnectionFailed
"Error: %1." ).arg( errcode == \
QSocket::ErrConnectionRefused ? i18n( "connection refused" ) : i18n( "host not found" \
) ) ); setUpdatePossible( false );
+}
+
+void KMCupsManager::hostPingSlot() {
+ m_hostSuccess = true;
+ m_lookupDone = true;
+}
+
+void KMCupsManager::hostPingFailedSlot() {
+ m_hostSuccess = false;
+ m_lookupDone = true;
}
--- kdelibs/kdeprint/cups/kmcupsmanager.h #1.12:1.13
@@ -76,4 +76,7 @@ protected slots:
void slotAsyncConnect();
+ void hostPingSlot();
+ void hostPingFailedSlot();
+
protected:
// the real printer listing job is done here
@@ -96,4 +99,6 @@ private:
KMPrinter *m_currentprinter;
QSocket *m_socket;
+ bool m_hostSuccess;
+ bool m_lookupDone;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic