summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-07-09 17:58:19 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-07-09 17:58:19 (GMT)
commit54ae49f8485bce7794b1f061f4d1a305f2063f10 (patch)
tree8c19b2bc41d7e5f9fe72390d13f5ed5c2ca2959b /Swift/Controllers/Chat/ChatsManager.cpp
parenta64ee00ca0acd157ad8ddbef5e72608daba163dc (diff)
downloadswift-contrib-54ae49f8485bce7794b1f061f4d1a305f2063f10.zip
swift-contrib-54ae49f8485bce7794b1f061f4d1a305f2063f10.tar.bz2
Store avatar paths in the recent objects.
Resolves: #906
Diffstat (limited to 'Swift/Controllers/Chat/ChatsManager.cpp')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index dbba9a5..2d365a0 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -30,6 +30,7 @@
#include <Swiften/Elements/ChatState.h>
#include <Swiften/MUC/MUCBookmarkManager.h>
#include <Swift/Controllers/ProfileSettingsProvider.h>
+#include <Swiften/Avatars/AvatarManager.h>
namespace Swift {
@@ -138,16 +139,20 @@ void ChatsManager::loadRecents() {
bool isMUC = recent[2] == "true";
std::string nick(recent[3]);
StatusShow::Type type = StatusShow::None;
+ boost::filesystem::path path;
if (isMUC) {
if (mucControllers_.find(jid.toBare()) != mucControllers_.end()) {
type = StatusShow::Online;
}
} else {
+ if (avatarManager_) {
+ path = avatarManager_->getAvatarPath(jid);
+ }
Presence::ref presence = presenceOracle_->getHighestPriorityPresence(jid.toBare());
type = presence ? presence->getShow() : StatusShow::None;
}
- ChatListWindow::Chat chat(jid, nickResolver_->jidToNick(jid), activity, 0, type, isMUC, nick);
+ ChatListWindow::Chat chat(jid, nickResolver_->jidToNick(jid), activity, 0, type, path, isMUC, nick);
prependRecent(chat);
}
handleUnreadCountChanged(NULL);
@@ -199,7 +204,7 @@ ChatListWindow::Chat ChatsManager::createChatListChatItem(const JID& jid, const
}
nick = controller->getNick();
}
- return ChatListWindow::Chat(jid, jid.toString(), activity, unreadCount, type, true, nick);
+ return ChatListWindow::Chat(jid, jid.toString(), activity, unreadCount, type, boost::filesystem::path(), true, nick);
} else {
ChatController* controller = getChatControllerIfExists(jid, false);
@@ -209,7 +214,8 @@ ChatListWindow::Chat ChatsManager::createChatListChatItem(const JID& jid, const
Presence::ref presence = presenceOracle_->getHighestPriorityPresence(jid.toBare());
StatusShow::Type type = presence ? presence->getShow() : StatusShow::None;
- return ChatListWindow::Chat(jid, nickResolver_->jidToNick(jid), activity, unreadCount, type, false);
+ boost::filesystem::path avatarPath = avatarManager_ ? avatarManager_->getAvatarPath(jid) : boost::filesystem::path();
+ return ChatListWindow::Chat(jid, nickResolver_->jidToNick(jid), activity, unreadCount, type, avatarPath, false);
}
}
@@ -337,7 +343,20 @@ void ChatsManager::handlePresenceChange(boost::shared_ptr<Presence> newPresence)
}
void ChatsManager::setAvatarManager(AvatarManager* avatarManager) {
+ if (avatarManager_) {
+ avatarManager_->onAvatarChanged.disconnect(boost::bind(&ChatsManager::handleAvatarChanged, this, _1));
+ }
avatarManager_ = avatarManager;
+ avatarManager_->onAvatarChanged.connect(boost::bind(&ChatsManager::handleAvatarChanged, this, _1));
+}
+
+void ChatsManager::handleAvatarChanged(const JID& jid) {
+ foreach (ChatListWindow::Chat& chat, recentChats_) {
+ if (!chat.isMUC && jid.toBare() == chat.jid.toBare()) {
+ chat.setAvatarPath(avatarManager_->getAvatarPath(jid));
+ break;
+ }
+ }
}
void ChatsManager::setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info) {