[atlantik-cvs] CVS: kdegames/atlantik/client monopigator.cpp,1.12,1.13 monopigator.h,1.11,1.12 selectserver_widget.cpp,1.25,1.26 selectserver_widget.h,1.13,1.14

[email protected]
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv15972

Modified Files:
	monopigator.cpp monopigator.h selectserver_widget.cpp 
	selectserver_widget.h 
Log Message:
albert's improved fixes for monopigator timeouts

Index: monopigator.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/monopigator.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- monopigator.cpp	27 May 2003 21:03:19 -0000	1.12
+++ monopigator.cpp	2 Jun 2003 18:38:26 -0000	1.13
@@ -22,11 +22,14 @@
 Monopigator::Monopigator()
 {
 	m_downloadData = 0;
+	m_job = 0;
+	m_timer = 0;
 }
 
 Monopigator::~Monopigator()
 {
-	if (m_job != NULL) m_job -> kill();
+	if (m_job)
+		m_job -> kill();
 }
 
 void Monopigator::loadData(const KURL &url)
@@ -40,19 +43,36 @@
 	m_job = KIO::get(url.url(), true, false);
 	m_job->addMetaData(QString::fromLatin1("UserAgent"), QString::fromLatin1("Atlantik/" ATLANTIK_VERSION_STRING));
 
+	if (!m_timer)
+	{
+		m_timer = new QTimer(this);
+		m_timer->start(10000, true);
+	}
+
 	connect(m_job, SIGNAL(data(KIO::Job *, const QByteArray &)), SLOT(slotData(KIO::Job *, const QByteArray &)));
 	connect(m_job, SIGNAL(result(KIO::Job *)), SLOT(slotResult(KIO::Job *)));
+	connect(m_timer, SIGNAL(timeout()), SLOT(slotTimeout()));
 }
 
 void Monopigator::slotData(KIO::Job *, const QByteArray &data)
 {
+	m_timer->stop();
 	m_downloadData->writeBlock(data.data(), data.size());
 }
 
 void Monopigator::slotResult(KIO::Job *job)
 {
 	processData(m_downloadData->buffer(), !job->error());
-	m_job = NULL;
+	m_job = 0;
+}
+
+void Monopigator::slotTimeout()
+{
+	if (m_job)
+		m_job -> kill();
+	m_job = 0;
+
+	emit timeout();
 }
 
 void Monopigator::processData(const QByteArray &data, bool okSoFar)

Index: monopigator.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/monopigator.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- monopigator.h	27 May 2003 21:03:19 -0000	1.11
+++ monopigator.h	2 Jun 2003 18:38:26 -0000	1.12
@@ -19,6 +19,7 @@
 
 #include <qobject.h>
 #include <qbuffer.h>
+#include <qtimer.h>
 
 #include <kio/job.h>
 #include <kurl.h>
@@ -35,15 +36,18 @@
 signals:
 	void monopigatorAdd(QString host, QString port, QString version, int users);
 	void finished();
+	void timeout();
 
 private slots:
 	void slotData(KIO::Job *, const QByteArray &);
 	void slotResult(KIO::Job *);
+	void slotTimeout();
 
 private:
 	void processData(const QByteArray &, bool = true);
 
 	QBuffer *m_downloadData;
+	QTimer *m_timer;
 	KIO::Job *m_job;
 };
 

Index: selectserver_widget.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectserver_widget.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- selectserver_widget.cpp	27 May 2003 21:03:19 -0000	1.25
+++ selectserver_widget.cpp	2 Jun 2003 18:38:26 -0000	1.26
@@ -80,6 +80,7 @@
 
 	connect(m_monopigator, SIGNAL(monopigatorAdd(QString, QString, QString, int)), this, SLOT(slotMonopigatorAdd(QString, QString, QString, int)));
 	connect(m_monopigator, SIGNAL(finished()), SLOT(monopigatorFinished()));
+	connect(m_monopigator, SIGNAL(timeout()), SLOT(monopigatorTimeout()));
 
 	// Until we have a good way to use start a local monopd server, disable this button
 //	m_localGameButton->setEnabled(false);
@@ -140,6 +141,12 @@
 	status_label->setText(i18n("Retrieved server list."));
 }
 
+void SelectServer::monopigatorTimeout()
+{
+	status_label->setText(i18n("Error while retrieving the server list."));
+	m_refreshButton->setEnabled(true);
+}
+
 void SelectServer::validateRadioButtons()
 {
 	return;
@@ -183,7 +190,10 @@
 
 	checkLocalServer();
 	if (useMonopigator)
+	{
+		m_refreshButton->setEnabled(false);
 		initMonopigator();
+	}
 }
 
 void SelectServer::slotAddServer()

Index: selectserver_widget.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectserver_widget.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- selectserver_widget.h	6 Mar 2003 13:42:53 -0000	1.13
+++ selectserver_widget.h	2 Jun 2003 18:38:26 -0000	1.14
@@ -56,6 +56,7 @@
 		void slotLocalConnected();
 		void slotLocalError();
 		void monopigatorFinished();
+		void monopigatorTimeout();
 
 	signals:
 		void serverConnect(const QString host, int port);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.