+
+void IrcUser::setEncrypted(bool encrypted)
+{
+ _encrypted = encrypted;
+ emit encryptedSet(encrypted);
+ SYNC(ARG(encrypted))
+}
+
+
+void IrcUser::updateObjectName()
+{
+ renameObject(QString::number(network()->networkId().toInt()) + "/" + _nick);
+}
+
+
+void IrcUser::updateHostmask(const QString &mask)
+{
+ if (mask == hostmask())
+ return;
+
+ QString user = userFromMask(mask);
+ QString host = hostFromMask(mask);
+ setUser(user);
+ setHost(host);
+}
+
+
+void IrcUser::joinChannel(IrcChannel *channel, bool skip_channel_join)
+{
+ Q_ASSERT(channel);
+ if (!_channels.contains(channel)) {
+ _channels.insert(channel);
+ if (!skip_channel_join)
+ channel->joinIrcUser(this);
+ }
+}
+
+
+void IrcUser::joinChannel(const QString &channelname)
+{
+ joinChannel(network()->newIrcChannel(channelname));
+}
+
+
+void IrcUser::partChannel(IrcChannel *channel)
+{
+ if (_channels.contains(channel)) {
+ _channels.remove(channel);
+ disconnect(channel, 0, this, 0);
+ channel->part(this);
+ QString channelName = channel->name();
+ SYNC_OTHER(partChannel, ARG(channelName))
+ if (_channels.isEmpty() && !network()->isMe(this))
+ quit();
+ }
+}
+
+
+void IrcUser::partChannel(const QString &channelname)
+{
+ IrcChannel *channel = network()->ircChannel(channelname);
+ if (channel == 0) {
+ qWarning() << "IrcUser::partChannel(): received part for unknown Channel" << channelname;
+ }
+ else {
+ partChannel(channel);
+ }
+}
+
+
+void IrcUser::quit()
+{
+ QList<IrcChannel *> channels = _channels.toList();
+ _channels.clear();
+ foreach(IrcChannel *channel, channels) {
+ disconnect(channel, 0, this, 0);
+ channel->part(this);
+ }
+ network()->removeIrcUser(this);
+ SYNC(NO_ARG)
+ emit quited();
+}
+
+
+void IrcUser::channelDestroyed()
+{
+ // private slot!
+ IrcChannel *channel = static_cast<IrcChannel *>(sender());
+ if (_channels.contains(channel)) {
+ _channels.remove(channel);
+ if (_channels.isEmpty() && !network()->isMe(this))
+ quit();
+ }
+}
+
+
+void IrcUser::setUserModes(const QString &modes)
+{
+ if (_userModes != modes) {
+ _userModes = modes;
+ SYNC(ARG(modes))
+ emit userModesSet(modes);
+ }
+}
+
+
+void IrcUser::addUserModes(const QString &modes)
+{
+ if (modes.isEmpty())
+ return;
+
+ // Don't needlessly sync when no changes are made
+ bool changesMade = false;
+ for (int i = 0; i < modes.count(); i++) {
+ if (!_userModes.contains(modes[i])) {
+ _userModes += modes[i];
+ changesMade = true;
+ }
+ }
+
+ if (changesMade) {
+ SYNC(ARG(modes))
+ emit userModesAdded(modes);
+ }
+}
+
+
+void IrcUser::removeUserModes(const QString &modes)
+{
+ if (modes.isEmpty())
+ return;
+
+ for (int i = 0; i < modes.count(); i++) {
+ _userModes.remove(modes[i]);
+ }
+ SYNC(ARG(modes))
+ emit userModesRemoved(modes);
+}
+
+
+void IrcUser::setLastChannelActivity(BufferId buffer, const QDateTime &time)
+{
+ _lastActivity[buffer] = time;
+ emit lastChannelActivityUpdated(buffer, time);
+}
+
+
+void IrcUser::setLastSpokenTo(BufferId buffer, const QDateTime &time)
+{
+ _lastSpokenTo[buffer] = time;
+ emit lastSpokenToUpdated(buffer, time);
+}