Diffstat (limited to 'noncore/net/opieirc/ircsession.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index 3b176d0..ca0df50 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp | |||
@@ -25,7 +25,7 @@ void IRCSession::beginSession() { | |||
25 | } | 25 | } |
26 | 26 | ||
27 | void IRCSession::join(QString channelname) { | 27 | void IRCSession::join(QString channelname) { |
28 | m_connection->sendLine("JOIN "+channelname); | 28 | m_connection->sendLine("JOIN " + channelname); |
29 | } | 29 | } |
30 | 30 | ||
31 | void IRCSession::quit(){ | 31 | void IRCSession::quit(){ |
@@ -57,15 +57,15 @@ void IRCSession::raw(QString message){ | |||
57 | } | 57 | } |
58 | 58 | ||
59 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { | 59 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { |
60 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); | 60 | m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); |
61 | } | 61 | } |
62 | 62 | ||
63 | void IRCSession::op(IRCChannel *channel, IRCPerson *person) { | 63 | void IRCSession::op(IRCChannel *channel, IRCPerson *person) { |
64 | m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick()); | 64 | m_connection->sendLine("MODE " + channel->channelname() + " +ooo " + person->nick()); |
65 | } | 65 | } |
66 | 66 | ||
67 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { | 67 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { |
68 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); | 68 | m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :" + message); |
69 | } | 69 | } |
70 | 70 | ||
71 | void IRCSession::sendMessage(IRCPerson *person, QString message) { | 71 | void IRCSession::sendMessage(IRCPerson *person, QString message) { |
@@ -88,9 +88,13 @@ bool IRCSession::isSessionActive() { | |||
88 | return m_connection->isConnected(); | 88 | return m_connection->isConnected(); |
89 | } | 89 | } |
90 | 90 | ||
91 | bool IRCSession::isLoggedIn() { | ||
92 | return m_connection->isLoggedIn(); | ||
93 | } | ||
94 | |||
91 | void IRCSession::endSession() { | 95 | void IRCSession::endSession() { |
92 | if (m_connection->isLoggedIn()) | 96 | if (m_connection->isLoggedIn()) |
93 | m_connection->sendLine("QUIT :" APP_VERSION); | 97 | quit(APP_VERSION); |
94 | else | 98 | else |
95 | m_connection->close(); | 99 | m_connection->close(); |
96 | } | 100 | } |
@@ -99,6 +103,48 @@ void IRCSession::part(IRCChannel *channel) { | |||
99 | m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); | 103 | m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); |
100 | } | 104 | } |
101 | 105 | ||
106 | void IRCSession::setValidUsermodes(const QString &modes) { | ||
107 | m_validUsermodes = modes; | ||
108 | } | ||
109 | |||
110 | void IRCSession::setValidChannelmodes(const QString &modes) { | ||
111 | m_validChannelmodes = modes; | ||
112 | } | ||
113 | |||
114 | void IRCSession::updateNickname(const QString &oldNickname, const QString &newNickname) { | ||
115 | QList<IRCChannel> channels; | ||
116 | IRCOutput output; | ||
117 | |||
118 | if (oldNickname == m_server->nick()) { | ||
119 | m_server->setNick(newNickname); | ||
120 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg(newNickname)); | ||
121 | channels = m_channels; | ||
122 | } | ||
123 | |||
124 | else { | ||
125 | IRCPerson *person = getPerson(oldNickname); | ||
126 | |||
127 | if(!person) { | ||
128 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | getChannelsByPerson(person, channels); | ||
133 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg(oldNickname).arg(newNickname)); | ||
134 | } | ||
135 | |||
136 | QListIterator<IRCChannel> it(channels); | ||
137 | for (;it.current(); ++it) { | ||
138 | IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); | ||
139 | it.current()->removePerson(chanperson); | ||
140 | chanperson->person->setNick(newNickname); | ||
141 | it.current()->addPerson(chanperson); | ||
142 | } | ||
143 | |||
144 | emit updateChannels(); | ||
145 | output.addParam(new QString(newNickname)); | ||
146 | emit outputReady(output); | ||
147 | } | ||
102 | 148 | ||
103 | IRCChannel *IRCSession::getChannel(QString channelname) { | 149 | IRCChannel *IRCSession::getChannel(QString channelname) { |
104 | QListIterator<IRCChannel> it(m_channels); | 150 | QListIterator<IRCChannel> it(m_channels); |