summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-10-20 07:58:12 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-10-20 08:04:21 (GMT)
commitd46ebaac1cf7161fd0a551c34cf80f441f6d19ab (patch)
treea47705e770329b386b48b6fb5883965740cf438d /Swift/Controllers/Chat/MUCController.cpp
parenta49ca97a7b2ad61385d0f6f22ec598a63d889ae7 (diff)
downloadswift-d46ebaac1cf7161fd0a551c34cf80f441f6d19ab.zip
swift-d46ebaac1cf7161fd0a551c34cf80f441f6d19ab.tar.bz2
Tell MUCController to handle disconnect/reconnect rejoins.
This causes the MUCController to deal with reconnects by requesting a rejoin. It also prepares for doing time-based context requests. Although I've traced the code down, and confirmed that presenceSender->sendPresence(joinPresence); is being called, the stanza is never sent. This needs further investigation, as currently it prevents the rejoins working. Resolves: #625
Diffstat (limited to 'Swift/Controllers/Chat/MUCController.cpp')
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp47
1 files changed, 34 insertions, 13 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index c4b4086..9cf235e 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -52,6 +52,7 @@ MUCController::MUCController (
parting_ = true;
joined_ = false;
lastWasPresence_ = false;
+ shouldJoinOnReconnect_ = true;
events_ = uiEventStream;
roster_ = new Roster(false, true);
@@ -72,8 +73,7 @@ MUCController::MUCController (
loginCheckTimer_->start();
}
chatWindow_->convertToMUC();
- chatWindow_->addSystemMessage("Trying to join room " + toJID_.toString());
- rejoin();
+ setOnline(true);
if (avatarManager_ != NULL) {
avatarChangedConnection_ = (avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1)));
}
@@ -97,7 +97,12 @@ void MUCController::rejoin() {
if (parting_) {
joined_ = false;
parting_ = false;
- muc_->joinAs(nick_);
+ //FIXME: check for received activity
+ if (/*lastActivityDate_ == none*/true) {
+ muc_->joinAs(nick_);
+ } else {
+ muc_->joinWithContextSince(nick_);
+ }
}
}
@@ -145,6 +150,7 @@ void MUCController::handleJoinComplete(const String& nick) {
nick_ = nick;
chatWindow_->addSystemMessage(joinMessage);
clearPresenceQueue();
+ shouldJoinOnReconnect_ = true;
setEnabled(true);
}
@@ -158,6 +164,7 @@ void MUCController::handleAvatarChanged(const JID& jid) {
void MUCController::handleWindowClosed() {
parting_ = true;
+ shouldJoinOnReconnect_ = false;
muc_->part();
onUserLeft();
}
@@ -273,18 +280,32 @@ String MUCController::roleToGroupName(MUCOccupant::Role role) {
return result;
}
-void MUCController::setEnabled(bool enabled) {
- ChatControllerBase::setEnabled(enabled);
- if (!enabled) {
- roster_->removeAll();
- /* handleUserLeft won't throw a part back up unless this is called
- when it doesn't yet know we've left - which only happens on
- disconnect, so call with disconnect here so if the signal does
- bubble back up, it'll be with the right type.*/
- muc_->handleUserLeft(MUC::Disconnect);
+void MUCController::setOnline(bool online) {
+ ChatControllerBase::setOnline(online);
+ if (!online) {
+ parting_ = true;
+ processUserPart();
+ } else {
+ if (shouldJoinOnReconnect_) {
+ chatWindow_->addSystemMessage("Trying to join room " + toJID_.toString());
+ if (loginCheckTimer_) {
+ loginCheckTimer_->start();
+ }
+ rejoin();
+ }
}
}
+void MUCController::processUserPart() {
+ roster_->removeAll();
+ /* handleUserLeft won't throw a part back up unless this is called
+ when it doesn't yet know we've left - which only happens on
+ disconnect, so call with disconnect here so if the signal does
+ bubble back up, it'll be with the right type.*/
+ muc_->handleUserLeft(MUC::Disconnect);
+ setEnabled(false);
+}
+
bool MUCController::shouldUpdateJoinParts() {
return lastWasPresence_;
}
@@ -310,7 +331,7 @@ void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::Leaving
} else {
addPresenceMessage(partMessage);
parting_ = true;
- setEnabled(false);
+ processUserPart();
}
}