|
@@ -64,12 +64,12 @@ App::App(int &argc, char **argv) :
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- print("CIMS Bot Service v0.12\n========================================================\n");
|
|
|
|
|
|
+ print("CIMS Bot Service v0.13\n========================================================\n");
|
|
|
|
|
|
setApplicationName("CIMSBOT");
|
|
setApplicationName("CIMSBOT");
|
|
- setOrganizationDomain("http://redmine.b4r.org/projects/cimsqwbot/");
|
|
|
|
|
|
+ setOrganizationDomain("https://gitlab.netdome.biz/community-messaging-project/qwbot");
|
|
setOrganizationName("CIMS");
|
|
setOrganizationName("CIMS");
|
|
- setApplicationVersion("0.12");
|
|
|
|
|
|
+ setApplicationVersion("0.13");
|
|
|
|
|
|
myClientsFrameTimerID = startTimer(0);
|
|
myClientsFrameTimerID = startTimer(0);
|
|
|
|
|
|
@@ -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;
|
|
ActiveClient* ac;
|
|
- QHostAddress ha(host);
|
|
|
|
- QString fullAddress = host + ":" + QString::number(port);
|
|
|
|
foreach(ac, myClients)
|
|
foreach(ac, myClients)
|
|
{
|
|
{
|
|
if(ac->serverAddressString() == fullAddress)
|
|
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 = new ActiveClient(this, password, this);
|
|
- ac->setAddress(ha, port);
|
|
|
|
|
|
+ ac->setAddress(hostName, hostAddress, port);
|
|
ac->client()->setQuakeFolder(Settings::globalInstance()->quakeFolder().toLatin1().data());
|
|
ac->client()->setQuakeFolder(Settings::globalInstance()->quakeFolder().toLatin1().data());
|
|
ac->client()->setName(Settings::globalInstance()->botName().toLatin1().data());
|
|
ac->client()->setName(Settings::globalInstance()->botName().toLatin1().data());
|
|
ac->client()->setSpectator(Settings::globalInstance()->botSpectator());
|
|
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;
|
|
ActiveClient* ac;
|
|
- QHostAddress ha(host);
|
|
|
|
- QString fullAddress = host + ":" + QString::number(port);
|
|
|
|
foreach(ac, myClients)
|
|
foreach(ac, myClients)
|
|
{
|
|
{
|
|
if(ac->serverAddressString() == fullAddress)
|
|
if(ac->serverAddressString() == fullAddress)
|
|
@@ -390,8 +400,10 @@ void App::requestCachedHostNames()
|
|
ActiveClient* ac;
|
|
ActiveClient* ac;
|
|
foreach(ac, myClients)
|
|
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 +415,10 @@ void App::setServerHostName(const QString &serverAddress, const QString &hostNam
|
|
{
|
|
{
|
|
if(ac->serverAddressString() == serverAddress)
|
|
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;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|