[prev in list] [next in list] [prev in thread] [next in thread] 

List:       atlantik-devel
Subject:    [atlantik-cvs] CVS: kdegames/atlantik/libatlantikclient
From:       kde () office ! kde ! org
Date:       2003-11-15 13:31:07
[Download RAW message or body]

Update of /home/kde/kdegames/atlantik/libatlantikclient
In directory office:/tmp/cvs-serv18240/libatlantikclient

Modified Files:
      Tag: atlantik_3_3_branch
	atlantik_network.cpp atlantik_network.h 
Log Message:
eventlog and statusbar support

Index: atlantik_network.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.cpp,v
retrieving revision 1.95
retrieving revision 1.95.2.1
diff -u -d -r1.95 -r1.95.2.1
--- atlantik_network.cpp	5 Nov 2003 23:40:26 -0000	1.95
+++ atlantik_network.cpp	15 Nov 2003 13:31:05 -0000	1.95.2.1
@@ -16,6 +16,7 @@
 
 #include <iostream>
 
+#include <qdom.h>
 #include <qtextcodec.h>
 #include <qtextstream.h>
 #include <qtimer.h>
@@ -120,6 +121,7 @@
 
 void AtlantikNetwork::cmdGamesList()
 {
+	emit msgStatus(i18n("Requesting game list..."));
 	writeData(".gl");
 }
 
@@ -195,7 +197,7 @@
 
 void AtlantikNetwork::writeData(QString msg)
 {
-	kdDebug() << "sending [" << msg << "]" << endl;
+	emit networkEvent(msg, "1rightarrow");
 	msg.append("\n");
 	if (socketStatus() == KExtendedSocket::connected)
 		*m_textStream << msg;
@@ -220,11 +222,13 @@
 	}
 }
 
-void AtlantikNetwork::processMsg(QString str)
+void AtlantikNetwork::processMsg(const QString &msg)
 {
-	kdDebug() << "processing msg: " + str << endl;
-	msg.setContent(str);
-	QDomElement e = msg.documentElement();
+	emit networkEvent(msg, "1leftarrow");
+
+	QDomDocument dom;
+	dom.setContent(msg);
+	QDomElement e = dom.documentElement();
 	if (e.tagName() != "monopd")
 	{
 		// Invalid data, request full update from server
@@ -245,7 +249,9 @@
 		QDomElement e = n.toElement();
 		if(!e.isNull())
 		{
-			if (e.tagName() == "msg")
+			if (e.tagName() == "server")
+				emit receivedHandshake();
+			else if (e.tagName() == "msg")
 			{
 				a = e.attributeNode(QString("type"));
 				if (!a.isNull())
@@ -316,7 +322,6 @@
 				if (!a.isNull())
 				{
 					m_playerId = a.value().toInt();
-					// TODO: move to Atlantik::slotNetworkConnected(), not needed on auto-join
 					cmdGamesList();
 				}
 				a = e.attributeNode(QString("cookie"));
@@ -831,21 +836,21 @@
 {
 	setAddress(host, port);
 	enableRead(true);
-	emit msgInfo(i18n("Connecting to %1...").arg(host));
+	emit msgStatus(i18n("Connecting to %1:%2...").arg(host).arg(QString::number(port)), \
"connect_creating");  startAsyncConnect();
 }
 
 void AtlantikNetwork::slotLookupFinished(int count)
 {
-	emit msgInfo(i18n("Server host name lookup finished..."));
+	emit msgStatus(i18n("Server host name lookup finished..."));
 }
 
 void AtlantikNetwork::slotConnectionSuccess()
 {
-	emit msgInfo(i18n("Connection established!"));
+	emit msgStatus(i18n("Connected to %1:%2.").arg(host()).arg(port()), \
"connect_established");  }
 
 void AtlantikNetwork::slotConnectionFailed(int error)
 {
-	emit msgError(i18n("Connection failed! Error code: %1").arg(error));
+	emit msgStatus(i18n("Connection failed! Error code: %1").arg(error), "connect_no");
 }

Index: atlantik_network.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.h,v
retrieving revision 1.47
retrieving revision 1.47.2.1
diff -u -d -r1.47 -r1.47.2.1
--- atlantik_network.h	29 Jun 2003 03:24:19 -0000	1.47
+++ atlantik_network.h	15 Nov 2003 13:31:05 -0000	1.47.2.1
@@ -17,11 +17,13 @@
 #ifndef LIBATLANTIK_NETWORK_H
 #define LIBATLANTIK_NETWORK_H
 
-#include <qdom.h>
 #include <qmap.h>
 
 #include <kextsock.h>
 
+class QDomNode;
+class QTextStream;
+
 class AtlanticCore;
 
 class Player;
@@ -30,8 +32,6 @@
 class Trade;
 class Auction;
 
-class QTextStream;
-
 class AtlantikNetwork : public KExtendedSocket
 {
 Q_OBJECT
@@ -78,7 +78,6 @@
 	void slotRead();
 		
 signals:
-
 	/**
 	 * A new player was created. This signal might be replaced with one in
 	 * the AtlanticCore class in the future, but it is here now because we
@@ -122,6 +121,8 @@
 	void msgInfo(QString);
 	void msgError(QString);
 	void msgChat(QString, QString);
+	void msgStatus(const QString &data, const QString &icon = QString::null);
+	void networkEvent(const QString &data, const QString &icon);
 
 	void displayDetails(QString text, bool clearText, bool clearButtons, Estate *estate \
= 0);  void addCommandButton(QString command, QString caption, bool enabled);
@@ -160,15 +161,15 @@
 
 	void newAuction(Auction *auction);
 	void auctionCompleted(Auction *auction);
+	void receivedHandshake();
 	void clientCookie(QString cookie);
 
 private:
-	void processMsg(QString);
+	void processMsg(const QString &msg);
 	void processNode(QDomNode);
 
 	AtlanticCore *m_atlanticCore;
 	QTextStream *m_textStream;
-	QDomDocument msg;
 
 	int m_playerId;
 

_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@kde.org
https://mail.kde.org/mailman/listinfo/atlantik-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic