Testing a new concept for the SyncableObjects.
[quassel.git] / src / common / ircuser.cpp
index eee29a8..fa20698 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -171,6 +171,7 @@ void IrcUser::setLastAwayMessage(const int &lastAwayMessage) {
 }
 
 void IrcUser::setHost(const QString &host) {
+  so_sync(so_arg_cast(host));
   if(!host.isEmpty() && _host != host) {
     _host = host;
     emit hostSet(host);
@@ -218,7 +219,6 @@ void IrcUser::joinChannel(IrcChannel *channel) {
   if(!_channels.contains(channel)) {
     _channels.insert(channel);
     channel->joinIrcUsers(this);
-    connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
   }
 }
 
@@ -232,8 +232,8 @@ void IrcUser::partChannel(IrcChannel *channel) {
     disconnect(channel, 0, this, 0);
     channel->part(this);
     emit channelParted(channel->name());
-    if(_channels.isEmpty() && network()->isMe(this))
-      deleteLater();
+    if(_channels.isEmpty() && !network()->isMe(this))
+      quit();
   }
 }
 
@@ -246,13 +246,24 @@ void IrcUser::partChannel(const QString &channelname) {
   }
 }
 
+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);
+  emit quited();
+}
+
 void IrcUser::channelDestroyed() {
   // private slot!
   IrcChannel *channel = static_cast<IrcChannel*>(sender());
   if(_channels.contains(channel)) {
     _channels.remove(channel);
-    if(_channels.isEmpty())
-      deleteLater();
+    if(_channels.isEmpty() && !network()->isMe(this))
+      quit();
   }
 }
 
@@ -282,3 +293,13 @@ void IrcUser::removeUserModes(const QString &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);
+}