diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-08-16 12:35:34 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-08-16 12:35:34 (GMT) |
commit | 2ef0428c1f9559454654546f3cce32155cf5409d (patch) | |
tree | baf692218db59e29385f128fd2ec3171918df172 /Swift/Controllers/RosterController.cpp | |
parent | c16133bf881a4eeb988d17ff318e4833a524997e (diff) | |
download | swift-2ef0428c1f9559454654546f3cce32155cf5409d.zip swift-2ef0428c1f9559454654546f3cce32155cf5409d.tar.bz2 |
Now show my avatar and JID in the 'me view'.
At the moment it's my JID rather than my Name, because the NickResolver doesn't cope with our own Name.
Also: the name resizing sometimes doesn't work. If it doesn't for you, make the roster very wide and then slowly resize it down.
Diffstat (limited to 'Swift/Controllers/RosterController.cpp')
-rw-r--r-- | Swift/Controllers/RosterController.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index 3662241..322d704 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -5,6 +5,7 @@ #include "Swiften/Base/foreach.h" #include "Swift/Controllers/MainWindow.h" #include "Swift/Controllers/MainWindowFactory.h" +#include "Swift/Controllers/NickResolver.h" #include "Swiften/Queries/Requests/GetRosterRequest.h" #include "Swiften/EventLoop/MainEventLoop.h" #include "Swiften/Roster/Roster.h" @@ -15,13 +16,15 @@ #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Roster/XMPPRoster.h" + namespace Swift { /** * The controller does not gain ownership of these parameters. */ -RosterController::RosterController(boost::shared_ptr<XMPPRoster> xmppRoster, AvatarManager* avatarManager, MainWindowFactory* mainWindowFactory, TreeWidgetFactory* treeWidgetFactory) - : xmppRoster_(xmppRoster), mainWindowFactory_(mainWindowFactory), treeWidgetFactory_(treeWidgetFactory), mainWindow_(mainWindowFactory_->createMainWindow()), roster_(new Roster(mainWindow_->getTreeWidget(), treeWidgetFactory_)), offlineFilter_(new OfflineRosterFilter()) { +RosterController::RosterController(const JID& jid, boost::shared_ptr<XMPPRoster> xmppRoster, AvatarManager* avatarManager, MainWindowFactory* mainWindowFactory, TreeWidgetFactory* treeWidgetFactory, NickResolver* nickResolver) + : myJID_(jid), xmppRoster_(xmppRoster), mainWindowFactory_(mainWindowFactory), treeWidgetFactory_(treeWidgetFactory), mainWindow_(mainWindowFactory_->createMainWindow()), roster_(new Roster(mainWindow_->getTreeWidget(), treeWidgetFactory_)), offlineFilter_(new OfflineRosterFilter()) { + nickResolver_ = nickResolver; roster_->addFilter(offlineFilter_); avatarManager_ = avatarManager; avatarManager_->onAvatarChanged.connect(boost::bind(&RosterController::handleAvatarChanged, this, _1, _2)); @@ -31,6 +34,9 @@ RosterController::RosterController(boost::shared_ptr<XMPPRoster> xmppRoster, Ava mainWindow_->onShowOfflineToggled.connect(boost::bind(&RosterController::handleShowOfflineToggled, this, _1)); roster_->onUserAction.connect(boost::bind(&RosterController::handleUserAction, this, _1)); xmppRoster_->onJIDAdded.connect(boost::bind(&RosterController::handleOnJIDAdded, this, _1)); + + mainWindow_->setMyAvatarPath(avatarManager_->getAvatarPath(myJID_).string()); + mainWindow_->setMyName(nickResolver_->jidToNick(myJID_)); } RosterController::~RosterController() { @@ -78,6 +84,9 @@ void RosterController::handleIncomingPresence(boost::shared_ptr<Presence> presen void RosterController::handleAvatarChanged(const JID& jid, const String& hash) { String path = avatarManager_->getAvatarPath(jid).string(); roster_->applyOnItems(SetAvatar(jid, path)); + if (jid.equals(myJID_, JID::WithoutResource)) { + mainWindow_->setMyAvatarPath(path); + } } void RosterController::handleStartChatRequest(const JID& contact) { |