From atlantik-devel Wed Jul 07 16:23:04 2004 From: kde () office ! kde ! org Date: Wed, 07 Jul 2004 16:23:04 +0000 To: atlantik-devel Subject: [atlantik-cvs] CVS: kdegames/atlantik/client atlantik.cpp, 1.169, Message-Id: <40EC2368.mailDWG15DQ9Q () office ! kde ! org> X-MARC-Message: https://marc.info/?l=atlantik-devel&m=108921739927083 Update of /home/kde/kdegames/atlantik/client In directory office:/tmp/cvs-serv17934/client Modified Files: atlantik.cpp main.cpp main.h monopigator.cpp monopigator.h selectserver_widget.cpp selectserver_widget.h Log Message: Backport: KLatencyTimer is buggy. KExtendedSocket latency checks from atlantik--development are not. Fixes a problem reported on kde-apps.org. Index: atlantik.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v retrieving revision 1.169 retrieving revision 1.170 diff -u -d -r1.169 -r1.170 --- atlantik.cpp 2 Jul 2004 10:40:46 -0000 1.169 +++ atlantik.cpp 7 Jul 2004 16:23:01 -0000 1.170 @@ -306,6 +306,8 @@ connect(m_selectServer, SIGNAL(serverConnect(const QString, int)), m_atlantikNetwork, SLOT(serverConnect(const QString, int))); connect(m_selectServer, SIGNAL(msgStatus(const QString &)), this, SLOT(slotMsgStatus(const QString &))); + + m_selectServer->slotRefresh( m_config.connectOnStart ); } void Atlantik::showSelectGame() Index: main.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/client/main.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- main.cpp 4 Jul 2004 12:03:40 -0000 1.39 +++ main.cpp 7 Jul 2004 16:23:01 -0000 1.40 @@ -49,7 +49,7 @@ aboutData.addAuthor("Rob Kaper", I18N_NOOP("main author"), "cap@capsi.com", "http://capsi.com/"); // Patches and artists - aboutData.addCredit("Thiago Macieira", I18N_NOOP("KExtendedSocket support, KLatencyTimer"), "thiagom@wanadoo.fr"); + aboutData.addCredit("Thiago Macieira", I18N_NOOP("KExtendedSocket support"), "thiagom@wanadoo.fr"); aboutData.addCredit("Albert Astals Cid", I18N_NOOP("various patches"), "tsdgeos@terra.es"); aboutData.addCredit("Bart Szyszka", I18N_NOOP("application icon"), "bart@gigabee.com", "http://www.gigabee.com/"); Index: main.h =================================================================== RCS file: /home/kde/kdegames/atlantik/client/main.h,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- main.h 27 Jun 2004 16:04:43 -0000 1.49 +++ main.h 7 Jul 2004 16:23:01 -0000 1.50 @@ -18,7 +18,7 @@ #define ATLANTIK_MAIN_H #define ATLANTIK_VERSION 070 -#define ATLANTIK_VERSION_STRING "0.7.0 (CVS >= 20040627)" +#define ATLANTIK_VERSION_STRING "0.7.0 (CVS >= 20040707)" #define ATLANTIK_VERSION_MAJOR 0 #define ATLANTIK_VERSION_MINOR 7 Index: monopigator.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/client/monopigator.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- monopigator.cpp 23 May 2004 00:45:18 -0000 1.22 +++ monopigator.cpp 7 Jul 2004 16:23:01 -0000 1.23 @@ -16,9 +16,9 @@ #include #include +#include #include -#include #include "monopigator.moc" #include "main.h" @@ -99,7 +99,7 @@ if(!e.isNull()) { if (e.tagName() == "server") - emit monopigatorAdd(e.attributeNode(QString("host")).value(), e.attributeNode(QString("port")).value(), e.attributeNode(QString("version")).value(), e.attributeNode(QString("users")).value().toInt()); + emit monopigatorAdd(e.attributeNode(QString("ip")).value(), e.attributeNode(QString("host")).value(), e.attributeNode(QString("port")).value(), e.attributeNode(QString("version")).value(), e.attributeNode(QString("users")).value().toInt()); } n = n.nextSibling(); } @@ -108,30 +108,32 @@ } } -MonopigatorEntry::MonopigatorEntry(QListView *parent, QString host, QString latency, QString version, QString users, QString port) : QObject(), QListViewItem(parent, host, latency, version, users, port) +MonopigatorEntry::MonopigatorEntry(QListView *parent, QString host, QString latency, QString version, QString users, QString port, QString ip) : QObject(), QListViewItem(parent, host, latency, version, users, port) { -// setEnabled(false); - parent->sort(); - - QPtrList addresses = KExtendedSocket::lookup(host, port); - addresses.setAutoDelete(true); - m_latencyTimer = new KLatencyTimer(port.toInt(), this, "latencyTimer"); + m_isDev = ( version.find( QRegExp("(CVS|-dev)") ) != -1 ) ? true : false; - if ( addresses.count() ) - { - m_latencyTimer->setHost(addresses.first()->address()); + setEnabled(false); + parent->sort(); - connect(m_latencyTimer, SIGNAL(answer(int)), this, SLOT(updateLatency(int))); - m_latencyTimer->start(); - } + if ( !ip.isEmpty() ) + host = ip; + m_latencySocket = new KExtendedSocket( host, port.toInt(), KExtendedSocket::inputBufferedSocket | KExtendedSocket::noResolve ); + connect(m_latencySocket, SIGNAL(lookupFinished(int)), this, SLOT(resolved())); + connect(m_latencySocket, SIGNAL(connectionSuccess()), this, SLOT(connected())); + m_latencySocket->startAsyncConnect(); } -void MonopigatorEntry::updateLatency(int msec) +void MonopigatorEntry::resolved() { - setText(1, QString::number(msec)); -// setEnabled(true); + time.start(); +} +void MonopigatorEntry::connected() +{ + setText( 1, QString::number(time.elapsed()) ); + setEnabled(true); listView()->sort(); + delete m_latencySocket; } int MonopigatorEntry::compare(QListViewItem *i, int col, bool ascending) const @@ -149,3 +151,14 @@ } return key( col, ascending ).compare( i->key( col, ascending) ); } + +bool MonopigatorEntry::isDev() const +{ + return m_isDev; +} + +void MonopigatorEntry::showDevelopmentServers(bool show) +{ + if ( isVisible() != show ) + setVisible(show); +} Index: monopigator.h =================================================================== RCS file: /home/kde/kdegames/atlantik/client/monopigator.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- monopigator.h 10 Feb 2004 19:46:34 -0000 1.17 +++ monopigator.h 7 Jul 2004 16:23:01 -0000 1.18 @@ -1,4 +1,4 @@ -// Copyright (c) 2002-2003 Rob Kaper +// Copyright (c) 2002-2004 Rob Kaper // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -25,7 +25,8 @@ #include #include -class KLatencyTimer; +class KExtendedSocket; +class QTime; class Monopigator : public QObject { @@ -37,7 +38,7 @@ void loadData(const KURL &); signals: - void monopigatorAdd(QString host, QString port, QString version, int users); + void monopigatorAdd(QString ip, QString host, QString port, QString version, int users); void finished(); void timeout(); @@ -59,15 +60,20 @@ Q_OBJECT public: - MonopigatorEntry(QListView *parent, QString host, QString latency, QString version, QString users, QString port); + MonopigatorEntry(QListView *parent, QString host, QString latency, QString version, QString users, QString port, QString ip); int compare(QListViewItem *i, int col, bool ascending) const; + bool isDev() const; private slots: - void updateLatency(int msec); + void resolved(); + void connected(); + void showDevelopmentServers(bool show); private: - KLatencyTimer *m_latencyTimer; + KExtendedSocket *m_latencySocket; + QTime time; QListView *m_parent; + bool m_isDev; }; #endif Index: selectserver_widget.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/client/selectserver_widget.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- selectserver_widget.cpp 7 Jul 2004 13:01:36 -0000 1.43 +++ selectserver_widget.cpp 7 Jul 2004 16:23:01 -0000 1.44 @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -92,11 +91,9 @@ // Monopigator m_monopigator = new Monopigator(); - connect(m_monopigator, SIGNAL(monopigatorAdd(QString, QString, QString, int)), this, SLOT(slotMonopigatorAdd(QString, QString, QString, int))); + connect(m_monopigator, SIGNAL(monopigatorAdd(QString, QString, QString, QString, int)), this, SLOT(slotMonopigatorAdd(QString, QString, QString, QString, int))); connect(m_monopigator, SIGNAL(finished()), SLOT(monopigatorFinished())); connect(m_monopigator, SIGNAL(timeout()), SLOT(monopigatorTimeout())); - - slotRefresh(useMonopigatorOnStart); } SelectServer::~SelectServer() @@ -106,7 +103,11 @@ void SelectServer::setHideDevelopmentServers(bool hideDevelopmentServers) { - m_hideDevelopmentServers = hideDevelopmentServers; + if ( m_hideDevelopmentServers != hideDevelopmentServers ) + { + m_hideDevelopmentServers = hideDevelopmentServers; + emit showDevelopmentServers( !m_hideDevelopmentServers ); + } } void SelectServer::initMonopigator() @@ -118,13 +119,17 @@ m_monopigator->loadData(KURL( "http://monopd.unixcode.org/")); } -void SelectServer::slotMonopigatorAdd(QString host, QString port, QString version, int users) +void SelectServer::slotMonopigatorAdd(QString ip, QString host, QString port, QString version, int users) { - if (m_hideDevelopmentServers && version.find( QRegExp("(CVS|-dev)") ) != -1 ) - return; - - MonopigatorEntry *item = new MonopigatorEntry(m_serverList, host, QString::number(9999), version, (users == -1) ? i18n("unknown") : QString::number(users), port); + MonopigatorEntry *item = new MonopigatorEntry(m_serverList, host, QString::number(9999), version, (users == -1) ? i18n("unknown") : QString::number(users), port, ip); item->setPixmap(0, BarIcon("atlantik", KIcon::SizeSmall)); + + if ( item->isDev() ) + { + item->setVisible( !m_hideDevelopmentServers ); + connect(this, SIGNAL(showDevelopmentServers(bool)), item, SLOT(showDevelopmentServers(bool))); + } + validateConnectButton(); } Index: selectserver_widget.h =================================================================== RCS file: /home/kde/kdegames/atlantik/client/selectserver_widget.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- selectserver_widget.h 10 Feb 2004 19:46:34 -0000 1.21 +++ selectserver_widget.h 7 Jul 2004 16:23:01 -0000 1.22 @@ -1,4 +1,4 @@ -// Copyright (c) 2002-2003 Rob Kaper +// Copyright (c) 2002-2004 Rob Kaper // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -45,19 +45,19 @@ public slots: void validateConnectButton(); - - void slotMonopigatorAdd(QString host, QString port, QString version, int users); + void slotRefresh(bool useMonopigator = true); + void slotMonopigatorAdd(QString ip, QString host, QString port, QString version, int users); private slots: void slotConnect(); void customConnect(); - void slotRefresh(bool useMonopigator = true); void monopigatorFinished(); void monopigatorTimeout(); signals: void serverConnect(const QString host, int port); void msgStatus(const QString &message); + void showDevelopmentServers(bool show); private: void initMonopigator(); _______________________________________________ atlantik-cvs mailing list atlantik-cvs@kde.org https://mail.kde.org/mailman/listinfo/atlantik-cvs