summaryrefslogtreecommitdiffstats
path: root/libkdegames/kgame/kmessageserver.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:42:31 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:42:31 +0000
commit576eb4299a00bc053db35414406f46372a0f70f2 (patch)
tree4c030922d533821db464af566188e7d40cc8848c /libkdegames/kgame/kmessageserver.cpp
parent0718336b6017d1a4fc1d626544180a5a2a29ddec (diff)
downloadtdegames-576eb4299a00bc053db35414406f46372a0f70f2.tar.gz
tdegames-576eb4299a00bc053db35414406f46372a0f70f2.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1157643 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdegames/kgame/kmessageserver.cpp')
-rw-r--r--libkdegames/kgame/kmessageserver.cpp110
1 files changed, 55 insertions, 55 deletions
diff --git a/libkdegames/kgame/kmessageserver.cpp b/libkdegames/kgame/kmessageserver.cpp
index e857ea31..105f35da 100644
--- a/libkdegames/kgame/kmessageserver.cpp
+++ b/libkdegames/kgame/kmessageserver.cpp
@@ -17,12 +17,12 @@
Boston, MA 02110-1301, USA.
*/
-#include <qiodevice.h>
-#include <qbuffer.h>
-#include <qptrlist.h>
-#include <qptrqueue.h>
-#include <qtimer.h>
-#include <qvaluelist.h>
+#include <tqiodevice.h>
+#include <tqbuffer.h>
+#include <tqptrlist.h>
+#include <tqptrqueue.h>
+#include <tqtimer.h>
+#include <tqvaluelist.h>
#include <kdebug.h>
@@ -31,8 +31,8 @@
// --------------- internal class KMessageServerSocket
-KMessageServerSocket::KMessageServerSocket (Q_UINT16 port, QObject *parent)
- : QServerSocket (port, 0, parent)
+KMessageServerSocket::KMessageServerSocket (Q_UINT16 port, TQObject *parent)
+ : TQServerSocket (port, 0, parent)
{
}
@@ -50,11 +50,11 @@ void KMessageServerSocket::newConnection (int socket)
class MessageBuffer
{
public:
- MessageBuffer (Q_UINT32 clientID, const QByteArray &messageData)
+ MessageBuffer (Q_UINT32 clientID, const TQByteArray &messageData)
: id (clientID), data (messageData) { }
~MessageBuffer () {}
Q_UINT32 id;
- QByteArray data;
+ TQByteArray data;
};
// ---------------- KMessageServer's private class
@@ -77,23 +77,23 @@ public:
KMessageServerSocket* mServerSocket;
- QPtrList <KMessageIO> mClientList;
- QPtrQueue <MessageBuffer> mMessageQueue;
- QTimer mTimer;
+ TQPtrList <KMessageIO> mClientList;
+ TQPtrQueue <MessageBuffer> mMessageQueue;
+ TQTimer mTimer;
bool mIsRecursive;
};
// ------------------ KMessageServer
-KMessageServer::KMessageServer (Q_UINT16 cookie,QObject* parent)
- : QObject(parent, 0)
+KMessageServer::KMessageServer (Q_UINT16 cookie,TQObject* parent)
+ : TQObject(parent, 0)
{
d = new KMessageServerPrivate;
d->mIsRecursive=false;
d->mCookie=cookie;
- connect (&(d->mTimer), SIGNAL (timeout()),
- this, SLOT (processOneMessage()));
+ connect (&(d->mTimer), TQT_SIGNAL (timeout()),
+ this, TQT_SLOT (processOneMessage()));
kdDebug(11001) << "CREATE(KMessageServer="
<< this
<< ") cookie="
@@ -138,8 +138,8 @@ bool KMessageServer::initNetwork (Q_UINT16 port)
kdDebug (11001) << k_funcinfo << ": Now listening to port "
<< d->mServerSocket->port() << endl;
- connect (d->mServerSocket, SIGNAL (newClientConnected (KMessageIO*)),
- this, SLOT (addClient (KMessageIO*)));
+ connect (d->mServerSocket, TQT_SIGNAL (newClientConnected (KMessageIO*)),
+ this, TQT_SLOT (addClient (KMessageIO*)));
return true;
}
@@ -169,7 +169,7 @@ bool KMessageServer::isOfferingConnections() const
void KMessageServer::addClient (KMessageIO* client)
{
- QByteArray msg;
+ TQByteArray msg;
// maximum number of clients reached?
if (d->mMaxClients >= 0 && d->mMaxClients <= clientCount())
@@ -183,25 +183,25 @@ void KMessageServer::addClient (KMessageIO* client)
kdDebug (11001) << k_funcinfo << ": " << client->id() << endl;
// connect its signals
- connect (client, SIGNAL (connectionBroken()),
- this, SLOT (removeBrokenClient()));
- connect (client, SIGNAL (received (const QByteArray &)),
- this, SLOT (getReceivedMessage (const QByteArray &)));
+ connect (client, TQT_SIGNAL (connectionBroken()),
+ this, TQT_SLOT (removeBrokenClient()));
+ connect (client, TQT_SIGNAL (received (const TQByteArray &)),
+ this, TQT_SLOT (getReceivedMessage (const TQByteArray &)));
// Tell everyone about the new guest
// Note: The new client doesn't get this message!
- QDataStream (msg, IO_WriteOnly) << Q_UINT32 (EVNT_CLIENT_CONNECTED) << client->id();
+ TQDataStream (msg, IO_WriteOnly) << Q_UINT32 (EVNT_CLIENT_CONNECTED) << client->id();
broadcastMessage (msg);
// add to our list
d->mClientList.append (client);
// tell it its ID
- QDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_CLIENT_ID) << client->id();
+ TQDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_CLIENT_ID) << client->id();
client->send (msg);
// Give it the complete list of client IDs
- QDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_CLIENT_LIST) << clientIDs();
+ TQDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_CLIENT_LIST) << clientIDs();
client->send (msg);
@@ -213,7 +213,7 @@ void KMessageServer::addClient (KMessageIO* client)
else
{
// otherwise tell it who is the admin
- QDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_ADMIN_ID) << adminID();
+ TQDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_ADMIN_ID) << adminID();
client->send (msg);
}
@@ -230,8 +230,8 @@ void KMessageServer::removeClient (KMessageIO* client, bool broken)
}
// tell everyone about the removed client
- QByteArray msg;
- QDataStream (msg, IO_WriteOnly) << Q_UINT32 (EVNT_CLIENT_DISCONNECTED) << client->id() << (Q_INT8)broken;
+ TQByteArray msg;
+ TQDataStream (msg, IO_WriteOnly) << Q_UINT32 (EVNT_CLIENT_DISCONNECTED) << client->id() << (Q_INT8)broken;
broadcastMessage (msg);
// If it was the admin, select a new admin.
@@ -280,10 +280,10 @@ int KMessageServer::clientCount() const
return d->mClientList.count();
}
-QValueList <Q_UINT32> KMessageServer::clientIDs () const
+TQValueList <Q_UINT32> KMessageServer::clientIDs () const
{
- QValueList <Q_UINT32> list;
- for (QPtrListIterator <KMessageIO> iter (d->mClientList); *iter; ++iter)
+ TQValueList <Q_UINT32> list;
+ for (TQPtrListIterator <KMessageIO> iter (d->mClientList); *iter; ++iter)
list.append ((*iter)->id());
return list;
}
@@ -293,7 +293,7 @@ KMessageIO* KMessageServer::findClient (Q_UINT32 no) const
if (no == 0)
no = d->mAdminID;
- QPtrListIterator <KMessageIO> iter (d->mClientList);
+ TQPtrListIterator <KMessageIO> iter (d->mClientList);
while (*iter)
{
if ((*iter)->id() == no)
@@ -322,8 +322,8 @@ void KMessageServer::setAdmin (Q_UINT32 adminID)
d->mAdminID = adminID;
- QByteArray msg;
- QDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_ADMIN_ID) << adminID;
+ TQByteArray msg;
+ TQDataStream (msg, IO_WriteOnly) << Q_UINT32 (ANS_ADMIN_ID) << adminID;
// Tell everyone about the new master
broadcastMessage (msg);
@@ -339,26 +339,26 @@ Q_UINT32 KMessageServer::uniqueClientNumber() const
// --------------------- Messages ---------------------------
-void KMessageServer::broadcastMessage (const QByteArray &msg)
+void KMessageServer::broadcastMessage (const TQByteArray &msg)
{
- for (QPtrListIterator <KMessageIO> iter (d->mClientList); *iter; ++iter)
+ for (TQPtrListIterator <KMessageIO> iter (d->mClientList); *iter; ++iter)
(*iter)->send (msg);
}
-void KMessageServer::sendMessage (Q_UINT32 id, const QByteArray &msg)
+void KMessageServer::sendMessage (Q_UINT32 id, const TQByteArray &msg)
{
KMessageIO *client = findClient (id);
if (client)
client->send (msg);
}
-void KMessageServer::sendMessage (const QValueList <Q_UINT32> &ids, const QByteArray &msg)
+void KMessageServer::sendMessage (const TQValueList <Q_UINT32> &ids, const TQByteArray &msg)
{
- for (QValueListConstIterator <Q_UINT32> iter = ids.begin(); iter != ids.end(); ++iter)
+ for (TQValueListConstIterator <Q_UINT32> iter = ids.begin(); iter != ids.end(); ++iter)
sendMessage (*iter, msg);
}
-void KMessageServer::getReceivedMessage (const QByteArray &msg)
+void KMessageServer::getReceivedMessage (const TQByteArray &msg)
{
if (!sender() || !sender()->inherits("KMessageIO"))
{
@@ -369,7 +369,7 @@ void KMessageServer::getReceivedMessage (const QByteArray &msg)
KMessageIO *client = (KMessageIO *) sender();
Q_UINT32 clientID = client->id();
- //QByteArray *ta=new QByteArray;
+ //TQByteArray *ta=new QByteArray;
//ta->duplicate(msg);
//d->mMessageQueue.enqueue (new MessageBuffer (clientID, *ta));
@@ -396,18 +396,18 @@ void KMessageServer::processOneMessage ()
MessageBuffer *msg_buf = d->mMessageQueue.head();
Q_UINT32 clientID = msg_buf->id;
- QBuffer in_buffer (msg_buf->data);
+ TQBuffer in_buffer (msg_buf->data);
in_buffer.open (IO_ReadOnly);
- QDataStream in_stream (&in_buffer);
+ TQDataStream in_stream (&in_buffer);
- QByteArray out_msg;
- QBuffer out_buffer (out_msg);
+ TQByteArray out_msg;
+ TQBuffer out_buffer (out_msg);
out_buffer.open (IO_WriteOnly);
- QDataStream out_stream (&out_buffer);
+ TQDataStream out_stream (&out_buffer);
bool unknown = false;
- QByteArray ttt=in_buffer.buffer();
+ TQByteArray ttt=in_buffer.buffer();
Q_UINT32 messageID;
in_stream >> messageID;
//kdDebug(11001) << k_funcinfo << ": got message with messageID=" << messageID << endl;
@@ -416,19 +416,19 @@ void KMessageServer::processOneMessage ()
case REQ_BROADCAST:
out_stream << Q_UINT32 (MSG_BROADCAST) << clientID;
// FIXME, compiler bug?
- // this should be okay, since QBuffer is subclass of QIODevice! :
+ // this should be okay, since TQBuffer is subclass of QIODevice! :
// out_buffer.writeBlock (in_buffer.readAll());
- out_buffer.QIODevice::writeBlock (in_buffer.readAll());
+ out_buffer.TQIODevice::writeBlock (in_buffer.readAll());
broadcastMessage (out_msg);
break;
case REQ_FORWARD:
{
- QValueList <Q_UINT32> clients;
+ TQValueList <Q_UINT32> clients;
in_stream >> clients;
out_stream << Q_UINT32 (MSG_FORWARD) << clientID << clients;
// see above!
- out_buffer.QIODevice::writeBlock (in_buffer.readAll());
+ out_buffer.TQIODevice::writeBlock (in_buffer.readAll());
sendMessage (clients, out_msg);
}
break;
@@ -455,9 +455,9 @@ void KMessageServer::processOneMessage ()
case REQ_REMOVE_CLIENT:
if (clientID == d->mAdminID)
{
- QValueList <Q_UINT32> client_list;
+ TQValueList <Q_UINT32> client_list;
in_stream >> client_list;
- for (QValueListIterator <Q_UINT32> iter = client_list.begin(); iter != client_list.end(); ++iter)
+ for (TQValueListIterator <Q_UINT32> iter = client_list.begin(); iter != client_list.end(); ++iter)
{
KMessageIO *client = findClient (*iter);
if (client)