Update of /home/kde/kdegames/atlantik/libatlantikclient
In directory office:/tmp/cvs-serv22555/libatlantikclient
Modified Files:
atlantik_network.cpp atlantik_network.h
Log Message:
bugfix wrt utf-8 handling (#52644)
Index: atlantik_network.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- atlantik_network.cpp 24 Dec 2002 10:42:18 -0000 1.77
+++ atlantik_network.cpp 6 Jan 2003 01:34:48 -0000 1.78
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -16,6 +16,8 @@
#include <iostream>
+#include <qtextcodec.h>
+#include <qtextstream.h>
#include <qtimer.h>
#include <kdebug.h>
@@ -37,7 +39,8 @@
AtlantikNetwork::AtlantikNetwork(AtlanticCore *atlanticCore, QObject *parent, const char *name) : KExtendedSocket(0, 0, KExtendedSocket::inputBufferedSocket)
{
m_atlanticCore = atlanticCore;
- m_parent = parent;
+ m_textStream = new QTextStream(this);
+ m_textStream->setCodec(QTextCodec::codecForName("utf8"));
m_playerId = -1;
QObject::connect(this, SIGNAL(readyRead()), this, SLOT(slotRead()));
@@ -49,6 +52,11 @@
this, SLOT(slotConnectionFailed(int)));
}
+AtlantikNetwork::~AtlantikNetwork(void)
+{
+ delete m_textStream;
+}
+
void AtlantikNetwork::rollDice()
{ writeData(".r");
}
@@ -219,7 +227,7 @@
kdDebug() << "sending [" << msg << "]" << endl;
msg.append("\n");
if (socketStatus() == KExtendedSocket::connected)
- writeBlock(msg.latin1(), strlen(msg.latin1()));
+ *m_textStream << msg;
else
kdDebug() << "warning: socket not connected!" << endl;
}
@@ -228,11 +236,7 @@
{
if (canReadLine())
{
- char *tmp = new char[1024 * 32];
- readLine(tmp, 1024 * 32);
- processMsg(tmp);
- delete[] tmp;
-
+ processMsg(m_textStream->readLine());
// There might be more data
QTimer::singleShot(0, this, SLOT(slotRead()));
}
Index: atlantik_network.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- atlantik_network.h 24 Dec 2002 10:42:18 -0000 1.41
+++ atlantik_network.h 6 Jan 2003 01:34:48 -0000 1.42
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -30,12 +30,15 @@
class Trade;
class Auction;
+class QTextStream;
+
class AtlantikNetwork : public KExtendedSocket
{
Q_OBJECT
public:
AtlantikNetwork(AtlanticCore *atlanticCore, QObject *parent=0, const char *name=0);
+ virtual ~AtlantikNetwork(void);
void setName(QString name);
void cmdGamesList();
void cmdChat(QString msg);
@@ -160,7 +163,7 @@
void processNode(QDomNode);
AtlanticCore *m_atlanticCore;
- QObject *m_parent;
+ QTextStream *m_textStream;
QDomDocument msg;
int m_playerId;
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.