SYNERGY-694 Handle client name duplication
This commit is contained in:
parent
431433f78a
commit
79f8fbc5d9
2 changed files with 20 additions and 13 deletions
|
|
@ -37,7 +37,7 @@ void ClientConnection::update(const QString& line)
|
||||||
m_checkConnection = false;
|
m_checkConnection = false;
|
||||||
if (!line.contains("server refused client with our name"))
|
if (!line.contains("server refused client with our name"))
|
||||||
{
|
{
|
||||||
showMessage();
|
showMessage(getMessage(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (line.contains("connected to server"))
|
else if (line.contains("connected to server"))
|
||||||
|
|
@ -61,26 +61,33 @@ bool ClientConnection::checkMainWindow()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ClientConnection::getMessage() const
|
QString ClientConnection::getMessage(const QString& line) const
|
||||||
{
|
{
|
||||||
QString message(QObject::tr("We can’t connect to the server IP address.\nCheck your IP on your server and your firewall settings."));
|
QString message(QObject::tr("We can’t connect to the server IP address.\nCheck your IP on your server and your firewall settings."));
|
||||||
|
|
||||||
QHostAddress address(m_parent.appConfig().getServerHostname());
|
if (line.contains("server already has a connected client with our name"))
|
||||||
if (address.isNull())
|
|
||||||
{
|
{
|
||||||
message = QObject::tr("We can’t connect to the server \"%1\" try to connect using the server IP address and check your firewall settings.")
|
message = QObject::tr("Connection failed.\nYou can’t name 2 computers the same");
|
||||||
.arg(m_parent.appConfig().getServerHostname());
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QHostAddress address(m_parent.appConfig().getServerHostname());
|
||||||
|
if (address.isNull())
|
||||||
|
{
|
||||||
|
message = QObject::tr("We can’t connect to the server \"%1\" try to connect using the server IP address and check your firewall settings.")
|
||||||
|
.arg(m_parent.appConfig().getServerHostname());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::showMessage()
|
void ClientConnection::showMessage(const QString& message) const
|
||||||
{
|
{
|
||||||
QMessageBox message(&m_parent);
|
QMessageBox dialog(&m_parent);
|
||||||
message.addButton(QObject::tr("Close"), QMessageBox::RejectRole);
|
dialog.addButton(QObject::tr("Close"), QMessageBox::RejectRole);
|
||||||
message.setText(getMessage());
|
dialog.setText(message);
|
||||||
message.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::setCheckConnection(bool checkConnection)
|
void ClientConnection::setCheckConnection(bool checkConnection)
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ public:
|
||||||
void setCheckConnection(bool checkConnection);
|
void setCheckConnection(bool checkConnection);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getMessage() const;
|
QString getMessage(const QString& line) const;
|
||||||
bool checkMainWindow();
|
bool checkMainWindow();
|
||||||
void showMessage();
|
void showMessage(const QString& message) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLIENTCONNECTION_H
|
#endif // CLIENTCONNECTION_H
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue