Diffstat (limited to 'noncore/net/opieirc/ircsession.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 48 |
1 files changed, 47 insertions, 1 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 | |||
@@ -79,35 +79,81 @@ void IRCSession::sendMessage(IRCChannel *channel, QString message) { | |||
79 | void IRCSession::sendAction(IRCChannel *channel, QString message) { | 79 | void IRCSession::sendAction(IRCChannel *channel, QString message) { |
80 | m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); | 80 | m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); |
81 | } | 81 | } |
82 | 82 | ||
83 | void IRCSession::sendAction(IRCPerson *person, QString message) { | 83 | void IRCSession::sendAction(IRCPerson *person, QString message) { |
84 | m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); | 84 | m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); |
85 | } | 85 | } |
86 | 86 | ||
87 | bool IRCSession::isSessionActive() { | 87 | 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 | } |
97 | 101 | ||
98 | void IRCSession::part(IRCChannel *channel) { | 102 | 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); |
105 | for (; it.current(); ++it) { | 151 | for (; it.current(); ++it) { |
106 | if (it.current()->channelname() == channelname) { | 152 | if (it.current()->channelname() == channelname) { |
107 | return it.current(); | 153 | return it.current(); |
108 | } | 154 | } |
109 | } | 155 | } |
110 | return 0; | 156 | return 0; |
111 | } | 157 | } |
112 | 158 | ||
113 | IRCPerson *IRCSession::getPerson(QString nickname) { | 159 | IRCPerson *IRCSession::getPerson(QString nickname) { |