ソースを参照

Ident spaces now.

Mihawk 12 年 前
コミット
f55cfda05b
7 ファイル変更403 行追加403 行削除
  1. 183 183
      App.cpp
  2. 21 21
      App.h
  3. 83 83
      Client.cpp
  4. 18 18
      Client.h
  5. 95 95
      ServerQuery.cpp
  6. 2 2
      ServerQuery.h
  7. 1 1
      SshClient.cpp

+ 183 - 183
App.cpp

@@ -37,7 +37,7 @@ App::App(int &argc, char **argv) :
   print("CIMS Bot Service v0.101\n========================================================\n");
 
   setApplicationName("CIMSBOT");
-	setOrganizationDomain("qwbr.tk");
+  setOrganizationDomain("qwbr.tk");
   setOrganizationName("CIMS");
   setApplicationVersion("0.101");
 
@@ -94,16 +94,16 @@ bool App::parseCommandLine()
 
 void App::onNewConnection()
 {
-	if(mySocketConnectedFlag)
-	{
-		print("Someone just connected to the bot.\nBye Bye.\n");
-		mySocket->disconnectFromHost();
-		if(mySocket->state() != QTcpSocket::UnconnectedState)
-			mySocket->waitForDisconnected();
-		mySocketConnectedFlag = false;
+  if(mySocketConnectedFlag)
+  {
+    print("Someone just connected to the bot.\nBye Bye.\n");
+    mySocket->disconnectFromHost();
+    if(mySocket->state() != QTcpSocket::UnconnectedState)
+      mySocket->waitForDisconnected();
+    mySocketConnectedFlag = false;
   }
 
-	mySocket = myServer->nextPendingConnection();
+  mySocket = myServer->nextPendingConnection();
   mySocketConnectedFlag = true;
   connect(mySocket, SIGNAL(readyRead()), SLOT(onDataArrival()));
   connect(mySocket, SIGNAL(disconnected()), SLOT(onDisconnection()));
@@ -113,8 +113,8 @@ void App::onNewConnection()
 
 void App::onDisconnection()
 {
-	mySocketConnectedFlag = false;
-	mySocket->deleteLater();
+  mySocketConnectedFlag = false;
+  mySocket->deleteLater();
 }
 
 void App::loadServerList()
@@ -143,148 +143,148 @@ void App::saveServerList()
   ActiveClient* ac;
 
   foreach(ac, myClients)
-    list.push_back(ac->serverAddressString());
+  list.push_back(ac->serverAddressString());
 
   Settings::globalInstance()->setServerList(list);
 }
 
 void App::parseAddClientCommand(const QString &args)
 {
-	if(!args.size())
-	{
-		print("No server specified\n");
-		return;
-	}
-	if(args.contains(" "))
-	{
-		print("Invalid server address\n");
-		return;
-	}
-
-	QStringList clientData = args.split(":");
-	if(clientData.size() == 1)
-	{
-		addClient(clientData.at(0), 27500);
-		return;
-	}
-
-	if(clientData.size() == 2)
-	{
-		addClient(clientData.at(0), clientData.at(1).toUShort());
-		return;
-	}
+  if(!args.size())
+  {
+    print("No server specified\n");
+    return;
+  }
+  if(args.contains(" "))
+  {
+    print("Invalid server address\n");
+    return;
+  }
+
+  QStringList clientData = args.split(":");
+  if(clientData.size() == 1)
+  {
+    addClient(clientData.at(0), 27500);
+    return;
+  }
+
+  if(clientData.size() == 2)
+  {
+    addClient(clientData.at(0), clientData.at(1).toUShort());
+    return;
+  }
 }
 
 void App::parseRemoveClientCommand(const QString &args)
 {
-	if(!args.size())
-	{
-		print("No server specified\n");
-		return;
-	}
-
-	QStringList clientData = args.split(":");
-	if(clientData.size() == 1)
-	{
-		removeClient(clientData.at(0), 27500);
-		return;
-	}
-
-	if(clientData.size() == 2)
-	{
-		removeClient(clientData.at(0), clientData.at(1).toUShort());
-		return;
-	}
+  if(!args.size())
+  {
+    print("No server specified\n");
+    return;
+  }
+
+  QStringList clientData = args.split(":");
+  if(clientData.size() == 1)
+  {
+    removeClient(clientData.at(0), 27500);
+    return;
+  }
+
+  if(clientData.size() == 2)
+  {
+    removeClient(clientData.at(0), clientData.at(1).toUShort());
+    return;
+  }
 }
 
 void App::onDataArrival()
 {
-	while(mySocket->canReadLine())
-	{
-		QByteArray		line;
-
-		line = mySocket->readLine();
-
-		QString data(line);
-		QRegExp regex("([0-9a-zA-Z]+)\\s+([a-z]+)\\s+(.*)");
-		if(regex.indexIn(data) == -1)
-		{
-			print("command format: <password> <command> ?<arguments>\nEg.: pss help\nDisconnected\n");
-			mySocket->disconnectFromHost();
-			return;
-		}
-
-		QString pass = regex.capturedTexts().at(1);
-		if(!checkPassword(pass))
-		{
-			print("Wrong password\nDisconnected\n");
-			mySocket->disconnectFromHost();
-			return;
-		}
-
-		QString cmd  = regex.capturedTexts().at(2);
-		QString args = regex.capturedTexts().at(3).trimmed();
+  while(mySocket->canReadLine())
+  {
+    QByteArray		line;
+
+    line = mySocket->readLine();
+
+    QString data(line);
+    QRegExp regex("([0-9a-zA-Z]+)\\s+([a-z]+)\\s+(.*)");
+    if(regex.indexIn(data) == -1)
+    {
+      print("command format: <password> <command> ?<arguments>\nEg.: pss help\nDisconnected\n");
+      mySocket->disconnectFromHost();
+      return;
+    }
+
+    QString pass = regex.capturedTexts().at(1);
+    if(!checkPassword(pass))
+    {
+      print("Wrong password\nDisconnected\n");
+      mySocket->disconnectFromHost();
+      return;
+    }
+
+    QString cmd  = regex.capturedTexts().at(2);
+    QString args = regex.capturedTexts().at(3).trimmed();
 
     if(cmd == "add")
-		{
+    {
       parseAddClientCommand(args);
-			return;
-		}
+      return;
+    }
 
     if(cmd == "remove")
-		{
+    {
       parseRemoveClientCommand(args);
-			return;
-		}
+      return;
+    }
 
-		if(cmd == "say")
-		{
+    if(cmd == "say")
+    {
       broadcast(args);
-			return;
-		}
-
-		if(cmd == "servers")
-		{
-			listClients();
-			return;
-		}
-
-		if(cmd == "name")
-		{
-			setNick(args);
-			return;
-		}
-
-		if(cmd == "color")
-		{
-			setColor(args);
-			return;
-		}
-
-		if(cmd == "setping")
-		{
-			setPing(args);
-			return;
-		}
-
-		if(cmd == "team")
-		{
-			setTeam(args);
-			return;
-		}
-
-		if(cmd == "quit")
-		{
-			mySocket->disconnectFromHost();
-			return;
-		}
-
-		if(cmd == "help")
-		{
-			help();
-			return;
-		}
-	}
+      return;
+    }
+
+    if(cmd == "servers")
+    {
+      listClients();
+      return;
+    }
+
+    if(cmd == "name")
+    {
+      setNick(args);
+      return;
+    }
+
+    if(cmd == "color")
+    {
+      setColor(args);
+      return;
+    }
+
+    if(cmd == "setping")
+    {
+      setPing(args);
+      return;
+    }
+
+    if(cmd == "team")
+    {
+      setTeam(args);
+      return;
+    }
+
+    if(cmd == "quit")
+    {
+      mySocket->disconnectFromHost();
+      return;
+    }
+
+    if(cmd == "help")
+    {
+      help();
+      return;
+    }
+  }
 }
 
 const QStringList& App::lastMessages() const
@@ -294,76 +294,76 @@ const QStringList& App::lastMessages() const
 
 void App::help()
 {
-	print("connect server:port -> connects the bot on a server\n");
-	print("disconnect server:port -> removes the bot from a server\n");
-	print("say message -> says the message on all servers where the bot is connected\n");
-	print("servers -> lists all servers the bot is connected\n");
-	print("name nick -> changes the bot name to nick\n");
-	print("color x x -> changes the player color\n");
-	print("setping x -> sets the bot ping to x. ofc you can't lower your actual ping with this.\n");
-	print("team teamname -> sets the bot team\n");
-	print("help -> displays this message\n");
+  print("connect server:port -> connects the bot on a server\n");
+  print("disconnect server:port -> removes the bot from a server\n");
+  print("say message -> says the message on all servers where the bot is connected\n");
+  print("servers -> lists all servers the bot is connected\n");
+  print("name nick -> changes the bot name to nick\n");
+  print("color x x -> changes the player color\n");
+  print("setping x -> sets the bot ping to x. ofc you can't lower your actual ping with this.\n");
+  print("team teamname -> sets the bot team\n");
+  print("help -> displays this message\n");
 }
 
 void App::setTeam(const QString &args)
 {
   ActiveClient* ac;
   foreach(ac, myClients)
-	{
+  {
     ac->client()->setTeam(args);
-	}
-	print("Team changed.\n");
+  }
+  print("Team changed.\n");
 }
 
 void App::setColor(const QString &args)
 {
   ActiveClient* ac;
-	quint8 bottom, top;
-	QStringList colors = args.split(" ");
+  quint8 bottom, top;
+  QStringList colors = args.split(" ");
 
-	if(colors.size() < 2)
-		return;
+  if(colors.size() < 2)
+    return;
 
-	bottom = colors.at(0).toUShort();
-	top = colors.at(1).toUShort();
+  bottom = colors.at(0).toUShort();
+  top = colors.at(1).toUShort();
 
   foreach(ac, myClients)
-	{
+  {
     ac->client()->setColor(bottom, top);
-	}
-	print("All clients colors have changed.\n");
+  }
+  print("All clients colors have changed.\n");
 }
 
 void App::setPing(const QString &args)
 {
   ActiveClient* ac;
   foreach(ac, myClients)
-	{
+  {
     ac->client()->setPing(args.toInt());
-	}
-	print("All clients pings have changed.\n");
+  }
+  print("All clients pings have changed.\n");
 }
 
 void App::setNick(const QString &args)
 {
   ActiveClient* ac;
   foreach(ac, myClients)
-	{
+  {
     ac->client()->setName(args.toAscii().data());
-	}
-	print("All clients nicks have changed.\n");
+  }
+  print("All clients nicks have changed.\n");
 }
 
 bool App::checkPassword(const QString &password)
 {
-	if(QCryptographicHash::hash(password.toAscii(), QCryptographicHash::Md4).toHex().toLower() == "bf4df9f74d05c50ea00492224fb02854")
+  if(QCryptographicHash::hash(password.toAscii(), QCryptographicHash::Md4).toHex().toLower() == "bf4df9f74d05c50ea00492224fb02854")
     return false; //telnet adm disabled!!
-	return false;
+  return false;
 }
 
 void App::print(const QString &msg)
 {
-	printf("%s", msg.toAscii().data());
+  printf("%s", msg.toAscii().data());
   if(mySocketConnectedFlag)
   {
     mySocket->write(msg.toAscii());
@@ -374,16 +374,16 @@ void App::print(const QString &msg)
 void App::addClient(const QString &host, quint16 port)
 {
   ActiveClient* ac;
-	QHostAddress ha = QHostInfo::fromName(host).addresses().at(0);
+  QHostAddress ha = QHostInfo::fromName(host).addresses().at(0);
 
   foreach(ac, myClients)
-	{
+  {
     if(QString(ac->client()->host()) == ha.toString() && ac->client()->port() == port)
-		{
-			print("That client is already on the list.\n");
-			return;
-		}
-	}
+    {
+      print("That client is already on the list.\n");
+      return;
+    }
+  }
 
   ac = new ActiveClient(this, this);
   ac->setAddress(ha, port);
@@ -402,12 +402,12 @@ void App::addClient(const QString &host, quint16 port)
 void App::removeClient(const QString &host, quint16 port)
 {
   ActiveClient* ac;
-	QHostAddress ha = QHostInfo::fromName(host).addresses().at(0);
+  QHostAddress ha = QHostInfo::fromName(host).addresses().at(0);
 
   foreach(ac, myClients)
-	{
+  {
     if(ac->serverAddressString() == QString(ha.toString() + ':' + QString::number(port)))
-		{
+    {
       ac->client()->disconnect();
       delete ac;
       myClients.removeAll(ac);
@@ -415,19 +415,19 @@ void App::removeClient(const QString &host, quint16 port)
       saveServerList();
 
       print("Client removed from watch list.\n");
-			return;
-		}
-	}
-	print("Client not found on the list.\n");
+      return;
+    }
+  }
+  print("Client not found on the list.\n");
 }
 
 void App::listClients()
 {
   ActiveClient* ac;
   foreach(ac, myClients)
-	{
+  {
     print(QString(ac->serverAddressString() + '\n'));
-	}
+  }
 }
 
 void App::activeClientsReplyCounters(int *serverCount, int *playerCount, ActiveClient *ignoreClient)
@@ -455,14 +455,14 @@ void App::activeClientsReplyCounters(int *serverCount, int *playerCount, ActiveC
 
 void App::timerEvent(QTimerEvent *e)
 {
-	if(e->timerId() == myClientsFrameTimerID)
-	{
+  if(e->timerId() == myClientsFrameTimerID)
+  {
     ActiveClient *ac;
     foreach(ac, myClients)
-		{
+    {
       ac->run();
     }
-	}
+  }
   Sleeper::msleep(1);
 }
 
@@ -530,10 +530,10 @@ void App::cleanup()
 {
   ActiveClient* ac;
   foreach(ac, myClients)
-	{
+  {
     ac->client()->disconnect();
     delete ac;
-	}
+  }
 }
 
 void App::setReplyHash(const QString &serverAddress, const QString &hash)

+ 21 - 21
App.h

@@ -15,10 +15,10 @@ class ActiveClient;
 
 class App : public QCoreApplication
 {
-	Q_OBJECT
+  Q_OBJECT
 public:
-	explicit							App(int &argc, char **argv);
-												~App();
+  explicit							App(int &argc, char **argv);
+  ~App();
 
   void									print(const QString& msg);
   void									broadcast(const QString& msg, int *serverCount, int *userCount);
@@ -30,44 +30,44 @@ public:
   const QStringList&    lastMessages() const;
 
 protected:
-	void									timerEvent(QTimerEvent *e);
+  void									timerEvent(QTimerEvent *e);
 
 private:
   QTcpSocket*           mySocket;
   QTcpServer*           myServer;
-	bool									mySocketConnectedFlag;
+  bool									mySocketConnectedFlag;
   SshClient*            myQWNETSshClient;
 
   QList<ActiveClient*>  myClients;
-	quint32								myCurrentClient;
-	QSettings							mySettings;
-	int										myClientsFrameTimerID; //timer for mainloop
+  quint32								myCurrentClient;
+  QSettings							mySettings;
+  int										myClientsFrameTimerID; //timer for mainloop
   QStringList           myLastMessages;
 
   void									loadServerList();
   void                  saveServerList();
-	void									cleanup();
+  void									cleanup();
   void                  addMessageToHistory(const QString& msg);
 
   /* TCP Server */
-	bool									checkPassword(const QString& password);
+  bool									checkPassword(const QString& password);
   void									addClient(const QString& host, quint16 port);
-	void									removeClient(const QString& host, quint16 port);
+  void									removeClient(const QString& host, quint16 port);
   void									parseAddClientCommand(const QString& args);
   void									parseRemoveClientCommand(const QString& args);
-	void									setTeam(const QString& team);
-	void									listClients();
-	void									setColor(const QString& args);
-	void									setNick(const QString& args);
-	void									setPing(const QString& args);
-	void									help();
+  void									setTeam(const QString& team);
+  void									listClients();
+  void									setColor(const QString& args);
+  void									setNick(const QString& args);
+  void									setPing(const QString& args);
+  void									help();
   bool                  parseCommandLine();
 
 private slots:
-	/* TCP server */
-	void									onDataArrival();
-	void									onNewConnection();
-	void									onDisconnection();
+  /* TCP server */
+  void									onDataArrival();
+  void									onNewConnection();
+  void									onDisconnection();
 };
 
 #endif // APP_H

+ 83 - 83
Client.cpp

@@ -50,19 +50,19 @@ void Client::connect(const char *host, quint16 port)
 
 void Client::say(const QString &msg)
 {
-	QString cmd = "say " + msg;
-	sendCmd(cmd.toAscii().data());
+  QString cmd = "say " + msg;
+  sendCmd(cmd.toAscii().data());
 }
 
 void Client::sayTeam(const QString &msg)
 {
-	QString cmd = "say_team " + msg;
-	sendCmd(cmd.toAscii().data());
+  QString cmd = "say_team " + msg;
+  sendCmd(cmd.toAscii().data());
 }
 
 void Client::setTeam(const QString &msg)
 {
-	sendCmd(QString("setinfo \"team\" \"" + msg + "\"").toAscii().data());
+  sendCmd(QString("setinfo \"team\" \"" + msg + "\"").toAscii().data());
 }
 
 void Client::disconnect()
@@ -73,12 +73,12 @@ void Client::disconnect()
 
 void Client::print(const QString &msg)
 {
-	QString str;
+  QString str;
 
   str = "[" + QTime::currentTime().toString(Qt::ISODate) + "] " + QString(host()) + ":" + QString::number(port()) + "> " + msg;
-	QByteArray b = str.toAscii();
-	Client::stripColor(b.data());
-	str = QString::fromAscii(b.data());
+  QByteArray b = str.toAscii();
+  Client::stripColor(b.data());
+  str = QString::fromAscii(b.data());
 
   myApp->print(str);
 }
@@ -90,23 +90,23 @@ void Client::setPlayerList(PlayerList &playerList)
 
 void Client::onDisconnect()
 {
-	print("Disconnected..\n");
+  print("Disconnected..\n");
   myOnServerFlag = false;
 }
 
 void Client::retryConnection()
 {
-	if(myConnectionRetries == ConnectionRetries)
-	{
-		print("Giving up!\n");
-		disconnect();
+  if(myConnectionRetries == ConnectionRetries)
+  {
+    print("Giving up!\n");
+    disconnect();
     myOnServerFlag = false;
-		return;
-	}
+    return;
+  }
 
-	print("Reconnecting...\n");
-	reconnect();
-	myConnectionRetries++;
+  print("Reconnecting...\n");
+  reconnect();
+  myConnectionRetries++;
 }
 
 bool Client::isQWMuted() const
@@ -149,7 +149,7 @@ void Client::parsePrintedLine()
     }
   }
   if(!parsed)
-		return;
+    return;
 
   QString nick(myPrintLine.left(lastMatchSize));
   QString message(myPrintLine.right(myPrintLine.size() - lastMatchSize));
@@ -158,18 +158,18 @@ void Client::parsePrintedLine()
   if(regex.indexIn(message) == -1)
     return;
 
-	/* Flood prot */
+  /* Flood prot */
   QTime currentTime = QTime::currentTime();
   int   floodProtTime = Settings::globalInstance()->floodProtTime();
   if(myFloodTimer->isActive())
-	{
-		if(!myFloodMsgPrinted)
-		{
+  {
+    if(!myFloodMsgPrinted)
+    {
       say("> FloodProt: Not so fast, wait " + QString::number(floodProtTime + currentTime.secsTo(myFloodTimerStart)) + " sec(s).");
-			myFloodMsgPrinted = true;
-		}
-		return;
-	}
+      myFloodMsgPrinted = true;
+    }
+    return;
+  }
   myFloodTimerStart = currentTime;
   myFloodTimer->start(floodProtTime*1000);
   myFloodMsgPrinted = false;
@@ -177,19 +177,19 @@ void Client::parsePrintedLine()
   QString command = regex.capturedTexts().at(1);
   QString args = regex.capturedTexts().at(2);
 
-	if(command == "help")
-	{
+  if(command == "help")
+  {
     //say("> Commands:");
     say("> Broadcast a message: .qw <message> and .spam <message>");
     //, beware of the floodprot limits 600s for .qw and 300s for .spam");
     say("> (Un)Mute: .qw_mute .qw_unmute or .spam_mute .spam_unmute");
     say("> Last 5 messages: .lastmsgs");
 
-		return;
-	}
+    return;
+  }
 
   if(command == "qw" || command == "spam")
-	{
+  {
     if(!args.trimmed().size())
     {
       say("> The format is ." + command + " <message>.");
@@ -235,8 +235,8 @@ void Client::parsePrintedLine()
     else
       myApp->requestBroadcast("dev", nick, server, parsedMsg);
 
-		return;
-	}
+    return;
+  }
 
   if(command == "qw_mute")
   {
@@ -313,21 +313,21 @@ int Client::maxClients() const
 
 void Client::onPrint(int, const char *msg)
 {
-	if(!strlen(msg))
-		return;
-
-	QString text(msg);
-	if(text.endsWith('\n'))
-	{
-		myPrintLine.append(text);
-		parsePrintedLine();
+  if(!strlen(msg))
+    return;
+
+  QString text(msg);
+  if(text.endsWith('\n'))
+  {
+    myPrintLine.append(text);
+    parsePrintedLine();
     print(myPrintLine);
-		myPrintLine.clear();
-	}
-	else
-	{
-		myPrintLine.append(text);
-	}
+    myPrintLine.clear();
+  }
+  else
+  {
+    myPrintLine.append(text);
+  }
 }
 
 bool Client::isOnServer() const
@@ -337,44 +337,44 @@ bool Client::isOnServer() const
 
 void Client::onError(const char *description)
 {
-	QString desc(description);
-	if(desc == "Client Timed Out.")
-	{
-		print("Error (" + QString(description) + ")\n");
-	}
-	else
-	{
-		print("Error (" + QString(description) + ")\n");
-	}
+  QString desc(description);
+  if(desc == "Client Timed Out.")
+  {
+    print("Error (" + QString(description) + ")\n");
+  }
+  else
+  {
+    print("Error (" + QString(description) + ")\n");
+  }
   myOnServerFlag = false;
 }
 
 void Client::onLevelChanged(int, const char *levelName, float, float, float, float, float, float, float, float, float, float)
 {
-	print(QString(levelName) + "\n");
-	myDownloadProgressPrintedFlag = false;
+  print(QString(levelName) + "\n");
+  myDownloadProgressPrintedFlag = false;
   mySpamMutedFlag = false;
   myQWMutedFlag = false;
 }
 
 void Client::onChallenge()
 {
-	print("challenge\n");
+  print("challenge\n");
 }
 
 void Client::onConnection()
 {
-	print("connection\n");
+  print("connection\n");
 }
 
 void Client::onConnected()
 {
-	print("connected\n");
+  print("connected\n");
 }
 
 void Client::onDownloadStarted(const char *fileName)
 {
-	print("Download started " + QString(fileName) + "\n");
+  print("Download started " + QString(fileName) + "\n");
 }
 
 void Client::run()
@@ -397,15 +397,15 @@ void Client::run()
 
 void Client::onOOBPrint(const char *msg)
 {
-	print(QString(msg));
+  print(QString(msg));
 }
 
 void Client::onStuffedCmd(const char *cmd)
 {
-	QString strCmd(cmd);
-	if(strCmd == "skins") //connection sequence complete
-	{
-		myConnectionRetries = 0;
+  QString strCmd(cmd);
+  if(strCmd == "skins") //connection sequence complete
+  {
+    myConnectionRetries = 0;
     myOnServerFlag = true;
 
     /* Only say hi if hi is scheduled */
@@ -415,28 +415,28 @@ void Client::onStuffedCmd(const char *cmd)
       myJoinMessagePrinted = false;
       myJoinMessageScheduled = false;
     }
-	}
+  }
 }
 
 void Client::onDownloadProgress(int percent)
 {
-	if(!(percent % 10))
-	{
-		if(!myDownloadProgressPrintedFlag)
-		{
-			print("Download " + QString::number(percent) + "%\n");
-			myDownloadProgressPrintedFlag = true;
-		}
-	}
-	else
-	{
-		myDownloadProgressPrintedFlag = false;
-	}
+  if(!(percent % 10))
+  {
+    if(!myDownloadProgressPrintedFlag)
+    {
+      print("Download " + QString::number(percent) + "%\n");
+      myDownloadProgressPrintedFlag = true;
+    }
+  }
+  else
+  {
+    myDownloadProgressPrintedFlag = false;
+  }
 }
 
 void Client::onDownloadFinished()
 {
-	print("Download 100% finished.\n");
+  print("Download 100% finished.\n");
 }
 
 QString Client::parseNameFun(const QString &string)

+ 18 - 18
Client.h

@@ -22,9 +22,9 @@ public:
   void run();
   void disconnect();
   void say(const QString& msg);
-	void sayTeam(const QString& msg);
+  void sayTeam(const QString& msg);
   void setTeam(const QString& msg);
-	void setSocket(class QTcpSocket* socket);
+  void setSocket(class QTcpSocket* socket);
   void retryConnection(); //unused
   bool isOnServer() const;
   bool isQWMuted() const;
@@ -33,25 +33,25 @@ public:
   void setMaxClients(int maxClients);
 
 protected:
-	void onLevelChanged(int playerNum, const char *levelName, float gravity, float stopSpeed, float maxSpeed, float spectatorMaxSpeed, float accelerate, float airAccelerate, float waterAccelerate, float friction, float waterFriction, float entGravity);
-	void onDisconnect();
-	void onPrint(int level, const char *msg);
-	void onChallenge();
-	void onConnection();
-	void onConnected();
-	void onDownloadStarted(const char *fileName);
-	void onDownloadFinished();
-	void onDownloadProgress(int percent);
-	void onStuffedCmd(const char *cmd);
-	void onError(const char *description);
-	void onOOBPrint(const char *msg);
+  void onLevelChanged(int playerNum, const char *levelName, float gravity, float stopSpeed, float maxSpeed, float spectatorMaxSpeed, float accelerate, float airAccelerate, float waterAccelerate, float friction, float waterFriction, float entGravity);
+  void onDisconnect();
+  void onPrint(int level, const char *msg);
+  void onChallenge();
+  void onConnection();
+  void onConnected();
+  void onDownloadStarted(const char *fileName);
+  void onDownloadFinished();
+  void onDownloadProgress(int percent);
+  void onStuffedCmd(const char *cmd);
+  void onError(const char *description);
+  void onOOBPrint(const char *msg);
 
 private:
   ActiveClient*     myActiveClient;
-	App*							myApp;
+  App*							myApp;
 
-	int								myConnectionRetries;
-	static const int	ConnectionRetries = 10;
+  int								myConnectionRetries;
+  static const int	ConnectionRetries = 10;
 
   QString						myPrintLine;
 
@@ -83,7 +83,7 @@ private:
   int               myMaxClients;
 
   void print(const QString& msg);
-	void parsePrintedLine();
+  void parsePrintedLine();
   int  playerCount() const;
   int  maxClients() const;
 

+ 95 - 95
ServerQuery.cpp

@@ -53,11 +53,11 @@ bool ServerQuery::query(bool pingServer)
   {
     emit error(HostLookupError);
     myActiveFlag = false;
-		return false;
+    return false;
   }
 
-	if(mySocket->isOpen())
-		mySocket->close();
+  if(mySocket->isOpen())
+    mySocket->close();
 
   mySocket->connectToHost(myAddress, myPort);
   if(!mySocket->waitForConnected(100))
@@ -68,11 +68,11 @@ bool ServerQuery::query(bool pingServer)
   }
 
   if(mySocket->write("\xff\xff\xff\xffstatus 23\n", 14) == -1)
-	{
+  {
     emit error(SendError);
     myActiveFlag = false;
-		return false;
-	}
+    return false;
+  }
   if(!mySocket->waitForBytesWritten(300))
   {
     emit error(SendError);
@@ -124,95 +124,95 @@ void ServerQuery::parseServerInfo()
   QByteArray serverData = mySocket->readAll();
 
   if(serverData.isEmpty())
-	{
+  {
     emit error(EmptyResponseError);
     myActiveFlag = false;
     return;
-	}
+  }
 
-	if(!serverData.startsWith("\xff\xff\xff\xffn"))
-	{
+  if(!serverData.startsWith("\xff\xff\xff\xffn"))
+  {
     emit error(InvalidResponseError);
     myActiveFlag = false;
     return;
-	}
+  }
 
   /* Parse server rules */
   myRules.clear();
   QString     infoString(serverData.data()+5);
-	QStringList splitInfoString = infoString.split("\n", QString::SkipEmptyParts);
+  QStringList splitInfoString = infoString.split("\n", QString::SkipEmptyParts);
   int         i;
   QStringList rules = splitInfoString.at(0).split("\\", QString::SkipEmptyParts);
   if((rules.size() % 2) != 0)
-	{
+  {
     emit error(InvalidInfoStringError);
     myActiveFlag = false;
     return;
-	}
+  }
 
-	ServerRule	rule;
+  ServerRule	rule;
   for(i = 0; i < rules.size(); i += 2)
-	{
+  {
     rule.rule = rules.at(i);
     rule.value = rules.at(i+1);
 
     /* Proxy detection */
-		if(rule.rule == "*QTV")
-		{
+    if(rule.rule == "*QTV")
+    {
       myIsProxyFlag = true;
-		}
-		else if(rule.rule == "*version")
-		{
+    }
+    else if(rule.rule == "*version")
+    {
       QString value = rule.value;
-			if(value.startsWith("qwfwd", Qt::CaseInsensitive) || value.startsWith("QTV", Qt::CaseInsensitive) || value.startsWith("2.91"))
+      if(value.startsWith("qwfwd", Qt::CaseInsensitive) || value.startsWith("QTV", Qt::CaseInsensitive) || value.startsWith("2.91"))
         myIsProxyFlag = true;
-		}
+    }
 
     /* Adjust FPS */
     if(rule.rule == "maxfps" && myPing > 0)
       myPing += rule.value.toUInt() * 12 / 77;
 
     myRules.append(rule);
-	}
+  }
 
   /* Parse player info */
   myPlayers.clear();
-	Player	player;
-	QRegExp regex("^([-0-9]+)\\s+([-0-9]+)\\s+([-0-9]+)\\s+([-0-9]+)\\s+\"([^\"]*)\"\\s+\"([^\"]*)\"\\s+([0-9]+)\\s+([0-9]+)(?:\\s+\"([^\"]*)\")?$");
-	QStringList	playerInfo;
-	for(i = 1; i < splitInfoString.size(); i++)
-	{
-		if(regex.indexIn(splitInfoString.at(i)) == -1)
-		{
+  Player	player;
+  QRegExp regex("^([-0-9]+)\\s+([-0-9]+)\\s+([-0-9]+)\\s+([-0-9]+)\\s+\"([^\"]*)\"\\s+\"([^\"]*)\"\\s+([0-9]+)\\s+([0-9]+)(?:\\s+\"([^\"]*)\")?$");
+  QStringList	playerInfo;
+  for(i = 1; i < splitInfoString.size(); i++)
+  {
+    if(regex.indexIn(splitInfoString.at(i)) == -1)
+    {
       emit error(InvalidPlayerInfoError);
-			continue;
-		}
-
-		playerInfo = regex.capturedTexts();
-		player.id = playerInfo.at(1).toInt();
-		player.frags = playerInfo.at(2).toInt();
-		player.time = playerInfo.at(3).toInt();
-		player.ping = playerInfo.at(4).toInt();
+      continue;
+    }
+
+    playerInfo = regex.capturedTexts();
+    player.id = playerInfo.at(1).toInt();
+    player.frags = playerInfo.at(2).toInt();
+    player.time = playerInfo.at(3).toInt();
+    player.ping = playerInfo.at(4).toInt();
     player.name = convertNameFun(playerInfo.at(5));
-		player.skin = playerInfo.at(6);
-		player.topColor = playerInfo.at(7).toInt();
-		player.bottomColor = playerInfo.at(8).toInt();
+    player.skin = playerInfo.at(6);
+    player.topColor = playerInfo.at(7).toInt();
+    player.bottomColor = playerInfo.at(8).toInt();
     player.team = convertNameFun(playerInfo.at(9));
 
-		if(player.name.startsWith("\\s\\"))
-		{
-			player.spectator = true;
-			player.team = "(spec)";
-			player.name = player.name.replace(QRegExp("^\\\\s\\\\"), "");
-			if(player.ping < 0)
-				player.ping = -player.ping;
-		}
-		else
-		{
-			player.spectator = false;
-		}
+    if(player.name.startsWith("\\s\\"))
+    {
+      player.spectator = true;
+      player.team = "(spec)";
+      player.name = player.name.replace(QRegExp("^\\\\s\\\\"), "");
+      if(player.ping < 0)
+        player.ping = -player.ping;
+    }
+    else
+    {
+      player.spectator = false;
+    }
     myPlayers.append(player);
-	}
+  }
 
   myActiveFlag = false;
 
@@ -234,28 +234,28 @@ void ServerQuery::socketError(QAbstractSocket::SocketError)
 
 int ServerQuery::ping(int count, int timeout)
 {
-	int pong = 0;
-	QTime timer;
-
-	timer.start();
-	for(int i = 0; i < count; i++)
-	{
-		mySocket->write("\xff\xff\xff\xffk\n");
-		timer.restart();
-		if(!mySocket->waitForReadyRead(timeout))
-		{
-			pong += 999;
-		}
-		else
-		{
-			if(mySocket->readAll() == "l")
-				pong += timer.elapsed();
-			else
-				pong += 999;
-		}
-	}
-
-	return pong/count;
+  int pong = 0;
+  QTime timer;
+
+  timer.start();
+  for(int i = 0; i < count; i++)
+  {
+    mySocket->write("\xff\xff\xff\xffk\n");
+    timer.restart();
+    if(!mySocket->waitForReadyRead(timeout))
+    {
+      pong += 999;
+    }
+    else
+    {
+      if(mySocket->readAll() == "l")
+        pong += timer.elapsed();
+      else
+        pong += 999;
+    }
+  }
+
+  return pong/count;
 }
 
 PlayerList ServerQuery::playerList() const
@@ -282,36 +282,36 @@ QString ServerQuery::serverRuleValue(const QString &ruleName) const
 //========================================================================
 /* Name fun */
 char ServerQuery::ourReadableCharsTable[256] = {	'.', '_' , '_' , '_' , '_' , '.' , '_' , '_' , '_' , '_' , '\n' , '_' , '\n' , '>' , '.' , '.',
-                                       '[', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', '_', '_'
-                                       };
+    '[', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', '_', '_'
+                                               };
 bool ServerQuery::ourReadableCharsTableInitialized = false;
 
 void ServerQuery::fillReadableCharsTable()
 {
-	int i;
+  int i;
 
-	for(i = 32; i < 127; i++)
-		ourReadableCharsTable[i] = ourReadableCharsTable[128 + i] = i;
-	ourReadableCharsTable[127] = ourReadableCharsTable[128 + 127] = '_';
+  for(i = 32; i < 127; i++)
+    ourReadableCharsTable[i] = ourReadableCharsTable[128 + i] = i;
+  ourReadableCharsTable[127] = ourReadableCharsTable[128 + 127] = '_';
 
-	for(i = 0; i < 32; i++)
-		ourReadableCharsTable[128 + i] = ourReadableCharsTable[i];
-	ourReadableCharsTable[128] = '_';
-	ourReadableCharsTable[10 + 128] = '_';
-	ourReadableCharsTable[12 + 128] = '_';
+  for(i = 0; i < 32; i++)
+    ourReadableCharsTable[128 + i] = ourReadableCharsTable[i];
+  ourReadableCharsTable[128] = '_';
+  ourReadableCharsTable[10 + 128] = '_';
+  ourReadableCharsTable[12 + 128] = '_';
 
-	ourReadableCharsTableInitialized = true;
+  ourReadableCharsTableInitialized = true;
 }
 
 QString ServerQuery::convertNameFun(const QString &name)
 {
-	if(!ourReadableCharsTableInitialized)
-		fillReadableCharsTable();
+  if(!ourReadableCharsTableInitialized)
+    fillReadableCharsTable();
 
-	QString stripped;
+  QString stripped;
 
-	for(int i = 0; i < name.length(); i++)
-		stripped.append(QChar(ourReadableCharsTable[(unsigned char)name.at(i).toAscii()] & 127));
+  for(int i = 0; i < name.length(); i++)
+    stripped.append(QChar(ourReadableCharsTable[(unsigned char)name.at(i).toAscii()] & 127));
 
-	return stripped;
+  return stripped;
 }

+ 2 - 2
ServerQuery.h

@@ -52,12 +52,12 @@ typedef QList<ServerRule> ServerRules;
 
 class ServerQuery : public QObject
 {
-	Q_OBJECT
+  Q_OBJECT
 public:
 
   enum Error { NoError, TimedOutError, EmptyResponseError, InvalidResponseError, InvalidInfoStringError, InvalidPlayerInfoError, SendError, HostLookupError, ConnectionError, UnknownError };
 
-	explicit ServerQuery(QObject *parent = 0);
+  explicit ServerQuery(QObject *parent = 0);
   ~ServerQuery();
 
   bool          setAddress(const QString &address, quint16 port = 27500);

+ 1 - 1
SshClient.cpp

@@ -72,7 +72,7 @@ void SshClient::read()
       parse(time,
             myCommandRegex->cap(3).section(' ', 0, 0),
             myCommandRegex->cap(3).section(' ', 1)
-            );
+           );
     }
   }
 }