summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp25
-rw-r--r--Swift/Controllers/Chat/ChatsManager.h1
-rw-r--r--Swift/Controllers/UIInterfaces/ChatListWindow.h9
3 files changed, 30 insertions, 5 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) {
diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h
index a8dd599..b4db523 100644
--- a/Swift/Controllers/Chat/ChatsManager.h
+++ b/Swift/Controllers/Chat/ChatsManager.h
@@ -76,6 +76,7 @@ namespace Swift {
void handleMUCBookmarkActivated(const MUCBookmark&);
void handleRecentActivated(const ChatListWindow::Chat&);
void handleUnreadCountChanged(ChatControllerBase* controller);
+ void handleAvatarChanged(const JID& jid);
ChatController* getChatControllerOrFindAnother(const JID &contact);
ChatController* createNewChatController(const JID &contact);
diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h
index 94d400d..85700cb 100644
--- a/Swift/Controllers/UIInterfaces/ChatListWindow.h
+++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h
@@ -10,6 +10,7 @@
#include <boost/shared_ptr.hpp>
#include <Swiften/MUC/MUCBookmark.h>
#include <Swiften/Elements/StatusShow.h>
+#include <boost/filesystem/path.hpp>
#include <Swiften/Base/boost_bsignals.h>
@@ -18,8 +19,8 @@ namespace Swift {
public:
class Chat {
public:
- Chat(const JID& jid, const std::string& chatName, const std::string& activity, int unreadCount, StatusShow::Type statusType, bool isMUC, const std::string& nick = "")
- : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), unreadCount(unreadCount) {}
+ Chat(const JID& jid, const std::string& chatName, const std::string& activity, int unreadCount, StatusShow::Type statusType, const boost::filesystem::path& avatarPath, bool isMUC, const std::string& nick = "")
+ : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), unreadCount(unreadCount), avatarPath(avatarPath) {}
/** Assume that nicks and other transient features aren't important for equality */
bool operator==(const Chat& other) const {
return jid.toBare() == other.jid.toBare()
@@ -31,6 +32,9 @@ namespace Swift {
void setStatusType(StatusShow::Type type) {
statusType = type;
}
+ void setAvatarPath(const boost::filesystem::path& path) {
+ avatarPath = path;
+ }
JID jid;
std::string chatName;
std::string activity;
@@ -38,6 +42,7 @@ namespace Swift {
bool isMUC;
std::string nick;
int unreadCount;
+ boost::filesystem::path avatarPath;
};
virtual ~ChatListWindow();