diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-11-26 14:26:18 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-11-26 14:26:18 (GMT) |
commit | 808a8047237d663e770cb8aec45c7978862b09ac (patch) | |
tree | 899a2217b2615876cae5ab9342894422f93df0a0 /Swift/Controllers | |
parent | 7b1df614ebfdbdb7d12c1d5618a74b8cdc308133 (diff) | |
download | swift-808a8047237d663e770cb8aec45c7978862b09ac.zip swift-808a8047237d663e770cb8aec45c7978862b09ac.tar.bz2 |
Plugin Avatars into MUCs.
Provides the extra plumbing needed for the MUC faux-roster to be populated with Avatars. This is adding yet another linear time roster operation, and these are going to start adding up eventually.
Resolves: #251
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/MUCController.cpp | 16 | ||||
-rw-r--r-- | Swift/Controllers/MUCController.h | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/Swift/Controllers/MUCController.cpp b/Swift/Controllers/MUCController.cpp index da7a9e7..4d0acca 100644 --- a/Swift/Controllers/MUCController.cpp +++ b/Swift/Controllers/MUCController.cpp @@ -5,9 +5,11 @@ #include "Swiften/Base/foreach.h" #include "Swift/Controllers/ChatWindow.h" #include "Swift/Controllers/ChatWindowFactory.h" +#include "Swiften/Avatars/AvatarManager.h" #include "Swiften/MUC/MUC.h" #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Roster/Roster.h" +#include "Swiften/Roster/SetAvatar.h" #include "Swiften/Roster/SetPresence.h" #include "Swiften/Roster/TreeWidgetFactory.h" @@ -39,6 +41,9 @@ MUCController::MUCController ( muc_->onOccupantLeft.connect(boost::bind(&MUCController::handleOccupantLeft, this, _1, _2, _3)); chatWindow_->convertToMUC(); chatWindow_->show(); + if (avatarManager_ != NULL) { + avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1, _2)); + } } MUCController::~MUCController() { @@ -46,12 +51,21 @@ MUCController::~MUCController() { delete roster_; } +void MUCController::handleAvatarChanged(const JID& jid, const String&) { + String path = avatarManager_->getAvatarPath(jid).string(); + roster_->applyOnItems(SetAvatar(jid, path, JID::WithResource)); +} + void MUCController::handleWindowClosed() { muc_->part(); } void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { - roster_->addContact(JID(toJID_.getNode(), toJID_.getDomain(), occupant.getNick()), occupant.getNick(), "Occupants"); + JID jid(JID(toJID_.getNode(), toJID_.getDomain(), occupant.getNick())); + roster_->addContact(jid, occupant.getNick(), "Occupants"); + if (avatarManager_ != NULL) { + handleAvatarChanged(jid, "dummy"); + } } void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType, const String& /*reason*/) { diff --git a/Swift/Controllers/MUCController.h b/Swift/Controllers/MUCController.h index 7ee6e81..aa5a274 100644 --- a/Swift/Controllers/MUCController.h +++ b/Swift/Controllers/MUCController.h @@ -32,6 +32,7 @@ namespace Swift { private: void handleWindowClosed(); + void handleAvatarChanged(const JID& jid, const String&); void handleOccupantJoined(const MUCOccupant& occupant); void handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType type, const String& reason); void handleOccupantPresenceChange(boost::shared_ptr<Presence> presence); |