Diffstat (limited to 'noncore/net/opieirc/ircconnection.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircconnection.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircconnection.cpp b/noncore/net/opieirc/ircconnection.cpp index 88e63f7..fb7e168 100644 --- a/noncore/net/opieirc/ircconnection.cpp +++ b/noncore/net/opieirc/ircconnection.cpp | |||
@@ -20,25 +20,26 @@ IRCConnection::IRCConnection(IRCServer *server) { | |||
20 | 20 | ||
21 | /* Connect to the IRC server */ | 21 | /* Connect to the IRC server */ |
22 | void IRCConnection::doConnect() { | 22 | void IRCConnection::doConnect() { |
23 | ASSERT(!m_connected); | 23 | ASSERT(!m_connected); |
24 | m_socket->connectToHost(m_server->hostname(), m_server->port()); | 24 | m_socket->connectToHost(m_server->hostname(), m_server->port()); |
25 | } | 25 | } |
26 | 26 | ||
27 | /* Send commands to the IRC server */ | 27 | /* Send commands to the IRC server */ |
28 | void IRCConnection::sendLine(QString line) { | 28 | void IRCConnection::sendLine(QString line) { |
29 | while((line.right(1) == "\n") || (line.right(1) == "\r")) | 29 | while((line.right(1) == "\n") || (line.right(1) == "\r")) |
30 | line = line.left(line.length() - 1); | 30 | line = line.left(line.length() - 1); |
31 | line.append("\r\n"); | 31 | line.append("\r\n"); |
32 | m_socket->writeBlock(line, line.length()); | 32 | QCString uline = line.utf8(); |
33 | m_socket->writeBlock(uline, uline.length()); | ||
33 | } | 34 | } |
34 | 35 | ||
35 | void IRCConnection::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) { | 36 | void IRCConnection::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) { |
36 | sendLine("NOTICE " + nickname + " :\001" + type + " " + args + "\001"); | 37 | sendLine("NOTICE " + nickname + " :\001" + type + " " + args + "\001"); |
37 | } | 38 | } |
38 | 39 | ||
39 | void IRCConnection::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) { | 40 | void IRCConnection::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) { |
40 | sendLine("PRIVMSG " + nickname + " :\001" + type + " " + args + "\001"); | 41 | sendLine("PRIVMSG " + nickname + " :\001" + type + " " + args + "\001"); |
41 | } | 42 | } |
42 | 43 | ||
43 | void IRCConnection::sendCTCPPing(const QString &nickname) { | 44 | void IRCConnection::sendCTCPPing(const QString &nickname) { |
44 | QDateTime tm; | 45 | QDateTime tm; |
@@ -68,25 +69,25 @@ void IRCConnection::login() { | |||
68 | if (m_server->password().length()>0) { | 69 | if (m_server->password().length()>0) { |
69 | loginString += "PASS " + m_server->password() + "\r\n"; | 70 | loginString += "PASS " + m_server->password() + "\r\n"; |
70 | } | 71 | } |
71 | loginString += "NICK " + m_server->nick() + "\r\n" + | 72 | loginString += "NICK " + m_server->nick() + "\r\n" + |
72 | "USER " + m_server->username() + " " + hostname + | 73 | "USER " + m_server->username() + " " + hostname + |
73 | " " + m_server->hostname() + " :" + m_server->realname() + "\r\n"; | 74 | " " + m_server->hostname() + " :" + m_server->realname() + "\r\n"; |
74 | sendLine(loginString); | 75 | sendLine(loginString); |
75 | } | 76 | } |
76 | 77 | ||
77 | /* Called when data arrives on the socket */ | 78 | /* Called when data arrives on the socket */ |
78 | void IRCConnection::dataReady() { | 79 | void IRCConnection::dataReady() { |
79 | while(m_socket->canReadLine()) { | 80 | while(m_socket->canReadLine()) { |
80 | IRCMessage message(m_socket->readLine()); | 81 | IRCMessage message(QString::fromUtf8(m_socket->readLine())); |
81 | if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) { | 82 | if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) { |
82 | /* Now autojoin all channels specified inside the server profile */ | 83 | /* Now autojoin all channels specified inside the server profile */ |
83 | QStringList channels = QStringList::split(QChar(','), m_server->channels()); | 84 | QStringList channels = QStringList::split(QChar(','), m_server->channels()); |
84 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | 85 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { |
85 | QString channelName = (*it).stripWhiteSpace(); | 86 | QString channelName = (*it).stripWhiteSpace(); |
86 | if (channelName.startsWith("#") || channelName.startsWith("+")) { | 87 | if (channelName.startsWith("#") || channelName.startsWith("+")) { |
87 | sendLine("JOIN "+ channelName); | 88 | sendLine("JOIN "+ channelName); |
88 | } | 89 | } |
89 | } | 90 | } |
90 | m_loggedIn = TRUE; | 91 | m_loggedIn = TRUE; |
91 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); | 92 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); |
92 | } | 93 | } |