[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kopete/dev-0.12/kopete/protocols/irc
From: Tommi Rantala <tommi.rantala () cs ! helsinki ! fi>
Date: 2005-11-02 18:56:01
Message-ID: 1130957761.715855.25260.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 477036 by rantala:
- Fix MODE parsing for User Contacts: add support for setting multiple mode
changes in one mode command.
- Merge my status bit fiddling functions into one.
BUG: 111456
M +77 -35 ircusercontact.cpp
M +2 -2 ircusercontact.h
--- branches/work/kopete/dev-0.12/kopete/protocols/irc/ircusercontact.cpp \
#477035:477036 @@ -116,12 +116,12 @@
if( !(currentStatus.internalStatus() & IRCProtocol::Away) && newStatus == \
m_protocol->m_UserStatusAway ) {
//kdDebug(14120) << k_funcinfo << "was NOT away, but is now, channel " << \
channel->nickName() << endl;
- addBitsToInternalOnlineStatus(channel, IRCProtocol::Away);
+ adjustInternalOnlineStatusBits(channel, IRCProtocol::Away, AddBits);
}
else if( (currentStatus.internalStatus() & IRCProtocol::Away) && newStatus == \
m_protocol->m_UserStatusOnline ) {
//kdDebug(14120) << k_funcinfo << "was away, but not anymore, channel " << \
channel->nickName() << endl;
- removeBitsFromInternalOnlineStatus(channel, IRCProtocol::Away);
+ adjustInternalOnlineStatusBits(channel, IRCProtocol::Away, RemoveBits);
}
else if( newStatus.internalStatus() < IRCProtocol::Away )
@@ -512,62 +512,104 @@
return 0L;
}
-void IRCUserContact::slotIncomingModeChange( const QString &channel, const QString \
&, const QString &mode ) +void IRCUserContact::slotIncomingModeChange( const QString \
&channel, const QString &, const QString &mode_ ) {
+ kdDebug(14120) << k_funcinfo << "channel: " << channel << " mode: " << mode_ << \
endl; +
IRCChannelContact *chan = ircAccount()->contactManager()->findChannel( channel );
- if( chan->locateUser( m_nickName ) )
+
+ if( !chan->locateUser( m_nickName ) )
+ return;
+
+ // :foobar_!~fooobar@dhcp.inet.fi MODE #foofoofoo2 +o kakkonen
+ // :foobar_!~fooobar@dhcp.inet.fi MODE #foofoofoo2 +o-o foobar001 kakkonen
+ // :foobar_!~fooobar@dhcp.inet.fi MODE #foofoofoo2 +oo kakkonen foobar001
+ // :foobar_!~fooobar@dhcp.inet.fi MODE #foofoofoo2 +o-ov foobar001 kakkonen \
foobar001 + //
+ // irssi manual example: /MODE #channel +nto-o+v nick1 nick2 nick3
+
+ QStringList users = QStringList::split(' ', mode_);
+ users.pop_front();
+
+ const QString mode = mode_.section(' ', 0, 0);
+
+ bitAdjustment adjMode = RemoveBits;
+ QStringList::iterator user = users.begin();
+
+ //kdDebug(14120) << "me: " << m_nickName << " users: " << users << " mode: " << \
mode << endl; +
+ for( uint i=0; i < mode.length(); i++ )
{
- QString user = mode.section(' ', 1, 1);
-
- if( user == m_nickName )
+ switch( mode[i] )
{
- kdDebug(14120) << k_funcinfo << "mode: " << mode << ", affected user: " << user \
<< ", my nick: " << m_nickName << endl; + case '+':
+ adjMode = AddBits;
+ break;
- QString modeChange = mode.section(' ', 0, 0);
+ case '-':
+ adjMode = RemoveBits;
+ break;
- if(modeChange == QString::fromLatin1("+o"))
- addBitsToInternalOnlineStatus( chan, IRCProtocol::Operator );
- else if(modeChange == QString::fromLatin1("-o"))
- removeBitsFromInternalOnlineStatus( chan, IRCProtocol::Operator );
- else if(modeChange == QString::fromLatin1("+v"))
- addBitsToInternalOnlineStatus( chan, IRCProtocol::Voiced );
- else if(modeChange == QString::fromLatin1("-v"))
- removeBitsFromInternalOnlineStatus( chan, IRCProtocol::Voiced );
+ default:
+ //kdDebug(14120) << "got " << mode[i] << ", user: " << *user << endl;
+
+ if (mode[i] == 'o') {
+ if (user == users.end())
+ return;
+
+ if ((*user).lower() == m_nickName.lower())
+ adjustInternalOnlineStatusBits(chan, IRCProtocol::Operator, adjMode);
+
+ ++user;
+ }
+ else if (mode[i] == 'v') {
+ if (user == users.end())
+ return;
+
+ if ((*user).lower() == m_nickName.lower())
+ adjustInternalOnlineStatusBits(chan, IRCProtocol::Voiced, adjMode);
+
+ ++user;
+ }
+
+ break;
}
}
}
-/* Removes the given bits for the given channel from the current internal online \
status. +/* Remove or add the given bits for the given channel from the current \
internal online status.
*
- * You could remove bits like IRCProtocol::Operator, IRCProtocol::Voiced, etc.
+ * You could fiddle with bits like IRCProtocol::Operator, IRCProtocol::Voiced, etc.
*/
-void IRCUserContact::removeBitsFromInternalOnlineStatus(IRCChannelContact *channel, \
unsigned statusAdjustment) +void \
IRCUserContact::adjustInternalOnlineStatusBits(IRCChannelContact *channel, unsigned \
statusAdjustment, bitAdjustment adj) {
Kopete::OnlineStatus currentStatus = channel->manager()->contactOnlineStatus(this);
+ Kopete::OnlineStatus newStatus;
- Kopete::OnlineStatus newStatus = m_protocol->statusLookup(
- (IRCProtocol::IRCStatus)(currentStatus.internalStatus() & ~statusAdjustment)
- );
+ if (adj == RemoveBits) {
- channel->manager()->setContactOnlineStatus(this, newStatus);
-}
+ // If the bit is not set in the current internal status, stop here.
+ if ((currentStatus.internalStatus() & ~statusAdjustment) == \
currentStatus.internalStatus()) + return;
+ newStatus = m_protocol->statusLookup(
+ (IRCProtocol::IRCStatus)(currentStatus.internalStatus() & ~statusAdjustment)
+ );
-/* Adds the given bits for the given channel to the current internal online status.
- *
- * You could add bits like IRCProtocol::Operator, IRCProtocol::Voiced, etc.
- */
+ } else if (adj == AddBits) {
-void IRCUserContact::addBitsToInternalOnlineStatus(IRCChannelContact *channel, \
unsigned statusAdjustment)
-{
- Kopete::OnlineStatus currentStatus = channel->manager()->contactOnlineStatus(this);
+ // If the bit is already set in the current internal status, stop here.
+ if ((currentStatus.internalStatus() | statusAdjustment) == \
currentStatus.internalStatus()) + return;
- Kopete::OnlineStatus newStatus = m_protocol->statusLookup(
- (IRCProtocol::IRCStatus)(currentStatus.internalStatus() | statusAdjustment)
- );
+ newStatus = m_protocol->statusLookup(
+ (IRCProtocol::IRCStatus)(currentStatus.internalStatus() | statusAdjustment)
+ );
+ }
+
channel->manager()->setContactOnlineStatus(this, newStatus);
}
--- branches/work/kopete/dev-0.12/kopete/protocols/irc/ircusercontact.h \
#477035:477036 @@ -120,8 +120,8 @@
void slotIncomingModeChange(const QString &nick, const QString &channel, const \
QString &mode);
private:
- void removeBitsFromInternalOnlineStatus(IRCChannelContact *channel, unsigned \
statusAdjustment);
- void addBitsToInternalOnlineStatus(IRCChannelContact *channel, unsigned \
statusAdjustment); + enum bitAdjustment { RemoveBits, AddBits };
+ void adjustInternalOnlineStatusBits(IRCChannelContact *channel, unsigned \
statusAdjustment, bitAdjustment adj);
void contactMode(const QString &mode);
void updateInfo();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic