|
@@ -64,12 +64,12 @@ App::App(int &argc, char **argv) :
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- print("CIMS Bot Service v0.12\n========================================================\n");
|
|
|
+ print("CIMS Bot Service v0.13\n========================================================\n");
|
|
|
|
|
|
setApplicationName("CIMSBOT");
|
|
|
- setOrganizationDomain("http://redmine.b4r.org/projects/cimsqwbot/");
|
|
|
+ setOrganizationDomain("https://gitlab.netdome.biz/community-messaging-project/qwbot");
|
|
|
setOrganizationName("CIMS");
|
|
|
- setApplicationVersion("0.12");
|
|
|
+ setApplicationVersion("0.13");
|
|
|
|
|
|
myClientsFrameTimerID = startTimer(0);
|
|
|
|
|
@@ -150,8 +150,8 @@ void App::saveServerList()
|
|
|
foreach(ac, myClients)
|
|
|
{
|
|
|
Settings::Server sv;
|
|
|
- sv.address = ac->serverAddressString().split(":").at(0);
|
|
|
- sv.port = ac->serverAddressString().split(":").at(1).toUShort();
|
|
|
+ sv.address = ac->serverHostNameString().split(":").at(0);
|
|
|
+ sv.port = ac->serverHostNameString().split(":").at(1).toUShort();
|
|
|
list.push_back(sv);
|
|
|
}
|
|
|
Settings::globalInstance()->setServerList(list);
|
|
@@ -175,11 +175,16 @@ void App::print(const QString &msg)
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
-bool App::addClient(const QString &host, quint16 port, const QString& password)
|
|
|
+bool App::addClient(const QString &hostName, quint16 port, const QString& password)
|
|
|
{
|
|
|
+ QHostInfo hi = QHostInfo::fromName(hostName);
|
|
|
+ if (hi.error() != QHostInfo::NoError) {
|
|
|
+ print("Couldn't add server " + hostName + ": " + hi.errorString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ QHostAddress hostAddress = hi.addresses().first();
|
|
|
+ QString fullAddress = hostAddress.toString() + ":" + QString::number(port);
|
|
|
ActiveClient* ac;
|
|
|
- QHostAddress ha(host);
|
|
|
- QString fullAddress = host + ":" + QString::number(port);
|
|
|
foreach(ac, myClients)
|
|
|
{
|
|
|
if(ac->serverAddressString() == fullAddress)
|
|
@@ -190,7 +195,7 @@ bool App::addClient(const QString &host, quint16 port, const QString& password)
|
|
|
}
|
|
|
|
|
|
ac = new ActiveClient(this, password, this);
|
|
|
- ac->setAddress(ha, port);
|
|
|
+ ac->setAddress(hostName, hostAddress, port);
|
|
|
ac->client()->setQuakeFolder(Settings::globalInstance()->quakeFolder().toLatin1().data());
|
|
|
ac->client()->setName(Settings::globalInstance()->botName().toLatin1().data());
|
|
|
ac->client()->setSpectator(Settings::globalInstance()->botSpectator());
|
|
@@ -206,11 +211,16 @@ bool App::addClient(const QString &host, quint16 port, const QString& password)
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
-bool App::removeClient(const QString &host, quint16 port)
|
|
|
+bool App::removeClient(const QString &hostName, quint16 port)
|
|
|
{
|
|
|
+ QHostInfo hi = QHostInfo::fromName(hostName);
|
|
|
+ if (hi.error() != QHostInfo::NoError) {
|
|
|
+ print("Couldn't add server " + hostName + ": " + hi.errorString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ QHostAddress hostAddress = hi.addresses().first();
|
|
|
+ QString fullAddress = hostAddress.toString() + ":" + QString::number(port);
|
|
|
ActiveClient* ac;
|
|
|
- QHostAddress ha(host);
|
|
|
- QString fullAddress = host + ":" + QString::number(port);
|
|
|
foreach(ac, myClients)
|
|
|
{
|
|
|
if(ac->serverAddressString() == fullAddress)
|
|
@@ -370,6 +380,11 @@ void App::setReplyHashAndWaitForReply(const QString &serverAddress, const QStrin
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+const QList<ActiveClient*> App::clients() const {
|
|
|
+ return myClients;
|
|
|
+}
|
|
|
+
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
void App::incrementReplyCounters(const QString &hash, int userCount, int channelCount, int playerCount, int serverCount)
|
|
|
{
|
|
@@ -390,8 +405,10 @@ void App::requestCachedHostNames()
|
|
|
ActiveClient* ac;
|
|
|
foreach(ac, myClients)
|
|
|
{
|
|
|
- print("Requested HostName for server " + ac->serverAddressString() + "\n");
|
|
|
- mySshClient->write("REQ_DNS " + ac->serverAddressString() + "\n");
|
|
|
+ if (!ac->hasHostName()) {
|
|
|
+ print("Requested HostName for server " + ac->serverAddressString() + "\n");
|
|
|
+ mySshClient->write("REQ_DNS " + ac->serverAddressString() + "\n");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -403,8 +420,10 @@ void App::setServerHostName(const QString &serverAddress, const QString &hostNam
|
|
|
{
|
|
|
if(ac->serverAddressString() == serverAddress)
|
|
|
{
|
|
|
- print("HostName for " + serverAddress + " set to " + hostName + "\n");
|
|
|
- ac->setHostName(hostName);
|
|
|
+ if (!ac->hasHostName() && ac->hostName() != hostName) {
|
|
|
+ print("HostName for " + serverAddress + " set to " + hostName + "\n");
|
|
|
+ ac->setHostName(hostName);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
}
|