diff options
| -rw-r--r-- | src/crsm.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp index 2e14319..05d30ae 100644 --- a/src/crsm.cpp +++ b/src/crsm.cpp @@ -617,40 +617,37 @@ void CRSM::dccChatRequest(const ClientInfo &client, QString extraArgs) { if(dccNickConnections.contains(client.nick)) { - respond(client, "Diesem Nick ist bereits eine DCC-Verbindung zugewiesen.\n"); - } - else - { - QHostInfo info = QHostInfo::fromName(Config.DCC.Address); - connection->sendCommand(IrcCommand::createCtcpRequest(client.nick, "DCC CHAT chat " + QString::number(info.addresses().first().toIPv4Address()) + " " + QString::number(Config.DCC.ListenPort) + (!extraArgs.isEmpty() ? " " + extraArgs: extraArgs))); + QTimer::singleShot(0, dccNickConnections[client.nick].socket, &QTcpSocket::close); } + + QHostInfo info = QHostInfo::fromName(Config.DCC.Address); + connection->sendCommand(IrcCommand::createCtcpRequest(client.nick, "DCC CHAT chat " + QString::number(info.addresses().first().toIPv4Address()) + " " + QString::number(Config.DCC.ListenPort) + (!extraArgs.isEmpty() ? " " + extraArgs: extraArgs))); } // modified version of http://stackoverflow.com/a/18866593 QString GetRandomString(int length = 5) { - static const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + static const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); - QString randomString; - for(int i=0; i<length; ++i) - { - int index = qrand() % possibleCharacters.length(); - QChar nextChar = possibleCharacters.at(index); - randomString.append(nextChar); - } - return randomString; + QString randomString; + for(int i=0; i<length; ++i) + { + int index = qrand() % possibleCharacters.length(); + QChar nextChar = possibleCharacters.at(index); + randomString.append(nextChar); + } + return randomString; } void CRSM::newDCCData() { QTcpSocket* socket = (QTcpSocket*)sender(); const DCCConnection& dccConnection = dccSocketConnections[socket]; - QString message = QString::fromUtf8(socket->readLine()); - if(message.endsWith('\n')) + QString message = QString::fromUtf8(socket->readLine()).trimmed(); + if(message.length() > 0) { - message.chop(1); + handleIrcMessage(dccConnection.client, message, connection->nickName(), true, false); } - handleIrcMessage(dccConnection.client, message, connection->nickName(), true, false); } void CRSM::newDCCConnection() |
