summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-16 12:35:34 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-16 12:35:34 (GMT)
commit2ef0428c1f9559454654546f3cce32155cf5409d (patch)
treebaf692218db59e29385f128fd2ec3171918df172 /Swift/Controllers
parentc16133bf881a4eeb988d17ff318e4833a524997e (diff)
downloadswift-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')
-rw-r--r--Swift/Controllers/MainController.cpp2
-rw-r--r--Swift/Controllers/MainWindow.h3
-rw-r--r--Swift/Controllers/RosterController.cpp13
-rw-r--r--Swift/Controllers/RosterController.h5
4 files changed, 19 insertions, 4 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 0f654e4..7a55d99 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -113,7 +113,7 @@ void MainController::handleConnected() {
avatarManager_ = new AvatarManager(client_, client_, avatarStorage_, this);
delete rosterController_;
- rosterController_ = new RosterController(xmppRoster, avatarManager_, mainWindowFactory_, treeWidgetFactory_);
+ rosterController_ = new RosterController(jid_, xmppRoster, avatarManager_, mainWindowFactory_, treeWidgetFactory_, nickResolver_);
rosterController_->onStartChatRequest.connect(boost::bind(&MainController::handleChatRequest, this, _1));
rosterController_->onJoinMUCRequest.connect(boost::bind(&MainController::handleJoinMUCRequest, this, _1, _2));
rosterController_->onChangeStatusRequest.connect(boost::bind(&MainController::handleChangeStatusRequest, this, _1, _2));
diff --git a/Swift/Controllers/MainWindow.h b/Swift/Controllers/MainWindow.h
index 081fe6e..945439e 100644
--- a/Swift/Controllers/MainWindow.h
+++ b/Swift/Controllers/MainWindow.h
@@ -15,6 +15,9 @@ namespace Swift {
public:
virtual ~MainWindow() {};
virtual TreeWidget* getTreeWidget() = 0;
+ virtual void setMyName(const String& name) = 0;
+ virtual void setMyAvatarPath(const String& path) = 0;
+ virtual void setMyStatusText(const String& status) = 0;
boost::signal<void (const JID&)> onStartChatRequest;
boost::signal<void (const JID&, const String&)> onJoinMUCRequest;
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) {
diff --git a/Swift/Controllers/RosterController.h b/Swift/Controllers/RosterController.h
index f9f2258..2eddaf6 100644
--- a/Swift/Controllers/RosterController.h
+++ b/Swift/Controllers/RosterController.h
@@ -18,10 +18,11 @@ namespace Swift {
class MainWindowFactory;
class TreeWidgetFactory;
class OfflineRosterFilter;
+ class NickResolver;
class RosterController {
public:
- RosterController(boost::shared_ptr<XMPPRoster> xmppRoster, AvatarManager* avatarManager, MainWindowFactory *mainWindowFactory, TreeWidgetFactory *treeWidgetFactory);
+ RosterController(const JID& jid, boost::shared_ptr<XMPPRoster> xmppRoster, AvatarManager* avatarManager, MainWindowFactory* mainWindowFactory, TreeWidgetFactory* treeWidgetFactory, NickResolver* nickResolver);
~RosterController();
void showRosterWindow();
MainWindow* getWindow() {return mainWindow_;};
@@ -38,6 +39,7 @@ namespace Swift {
void handleUserAction(boost::shared_ptr<UserRosterAction> action);
void handleChangeStatusRequest(StatusShow::Type show, const String &statusText);
void handleShowOfflineToggled(bool state);
+ JID myJID_;
boost::shared_ptr<XMPPRoster> xmppRoster_;
MainWindowFactory* mainWindowFactory_;
TreeWidgetFactory* treeWidgetFactory_;
@@ -45,6 +47,7 @@ namespace Swift {
Roster* roster_;
OfflineRosterFilter* offlineFilter_;
AvatarManager* avatarManager_;
+ NickResolver* nickResolver_;
};
}
#endif