summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-09-15 18:45:37 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-09-15 18:45:37 (GMT)
commit8e5d1a11824d7a0900feb44ed5b5464d8d94ab2a (patch)
treecf19e679ad8e9f21e226135a41c94c558fa28662 /Swift/Controllers
parent7c6ca6948f81dc4ee6430d46aeae7f7de806a251 (diff)
downloadswift-contrib-8e5d1a11824d7a0900feb44ed5b5464d8d94ab2a.zip
swift-contrib-8e5d1a11824d7a0900feb44ed5b5464d8d94ab2a.tar.bz2
Use NickResolver for nicks in notifications.
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/MainController.cpp9
-rw-r--r--Swift/Controllers/NickResolver.cpp3
-rw-r--r--Swift/Controllers/NickResolver.h9
-rw-r--r--Swift/Controllers/PresenceNotifier.cpp5
-rw-r--r--Swift/Controllers/PresenceNotifier.h6
-rw-r--r--Swift/Controllers/UnitTest/PresenceNotifierTest.cpp7
6 files changed, 19 insertions, 20 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 4cd9be4..f7f2155 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -197,8 +197,6 @@ void MainController::resetClient() {
chatsManager_ = NULL;
delete rosterController_;
rosterController_ = NULL;
- delete nickResolver_;
- nickResolver_ = NULL;
delete presenceNotifier_;
presenceNotifier_ = NULL;
delete entityCapsManager_;
@@ -207,6 +205,8 @@ void MainController::resetClient() {
capsManager_ = NULL;
delete avatarManager_;
avatarManager_ = NULL;
+ delete nickResolver_;
+ nickResolver_ = NULL;
delete vcardManager_;
vcardManager_ = NULL;
delete xmppRoster_;
@@ -249,8 +249,6 @@ void MainController::handleConnected() {
if (freshLogin) {
serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
- nickResolver_ = new NickResolver(this->jid_.toBare(), xmppRoster_, vcardManager_, mucRegistry_);
-
rosterController_ = new RosterController(jid_, xmppRoster_, avatarManager_, mainWindowFactory_, nickResolver_, presenceOracle_, presenceSender_, eventController_, uiEventStream_, client_->getIQRouter());
rosterController_->onChangeStatusRequest.connect(boost::bind(&MainController::handleChangeStatusRequest, this, _1, _2));
rosterController_->onSignOutRequest.connect(boost::bind(&MainController::signOut, this));
@@ -390,10 +388,11 @@ void MainController::performLoginFromCachedCredentials() {
xmppRoster_ = new XMPPRoster();
vcardManager_ = new VCardManager(jid_, client_->getIQRouter(), getVCardStorageForProfile(jid_));
vcardManager_->onVCardChanged.connect(boost::bind(&MainController::handleVCardReceived, this, _1, _2));
+ nickResolver_ = new NickResolver(this->jid_.toBare(), xmppRoster_, vcardManager_, mucRegistry_);
avatarManager_ = new AvatarManagerImpl(vcardManager_, client_, avatarStorage_, mucRegistry_);
capsManager_ = new CapsManager(capsStorage_, client_, client_->getIQRouter());
entityCapsManager_ = new EntityCapsManager(capsManager_, client_);
- presenceNotifier_ = new PresenceNotifier(client_, notifier_, mucRegistry_, avatarManager_, xmppRoster_, presenceOracle_, &timerFactory_);
+ presenceNotifier_ = new PresenceNotifier(client_, notifier_, mucRegistry_, avatarManager_, nickResolver_, presenceOracle_, &timerFactory_);
presenceNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
client_->onDataRead.connect(boost::bind(
&XMLConsoleController::handleDataRead, xmlConsoleController_, _1));
diff --git a/Swift/Controllers/NickResolver.cpp b/Swift/Controllers/NickResolver.cpp
index 8faada9..5029b7d 100644
--- a/Swift/Controllers/NickResolver.cpp
+++ b/Swift/Controllers/NickResolver.cpp
@@ -42,8 +42,7 @@ String NickResolver::jidToNick(const JID& jid) {
return xmppRoster_->getNameForJID(jid);
}
- std::map<JID, String>::const_iterator it = map_.find(jid);
- return (it == map_.end()) ? jid.toBare() : it->second;
+ return jid.toBare();
}
void NickResolver::handleVCardReceived(const JID& jid, VCard::ref ownVCard) {
diff --git a/Swift/Controllers/NickResolver.h b/Swift/Controllers/NickResolver.h
index b5ed76f..ac58865 100644
--- a/Swift/Controllers/NickResolver.h
+++ b/Swift/Controllers/NickResolver.h
@@ -4,9 +4,6 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_NickResolver_H
-#define SWIFTEN_NickResolver_H
-
#include <map>
#include <boost/signals.hpp>
#include <boost/shared_ptr.hpp>
@@ -29,15 +26,13 @@ namespace Swift {
boost::signal<void (const String&)> onOwnNickChanged;
private:
void handleVCardReceived(const JID& jid, VCard::ref vCard);
+
+ private:
JID ownJID_;
String ownNick_;
- std::map<JID, String> map_;
-
XMPPRoster* xmppRoster_;
MUCRegistry* mucRegistry_;
VCardManager* vcardManager_;
};
}
-#endif
-
diff --git a/Swift/Controllers/PresenceNotifier.cpp b/Swift/Controllers/PresenceNotifier.cpp
index 0c46f9b..74cb4b0 100644
--- a/Swift/Controllers/PresenceNotifier.cpp
+++ b/Swift/Controllers/PresenceNotifier.cpp
@@ -14,10 +14,11 @@
#include "Swiften/Roster/XMPPRoster.h"
#include "Swiften/Presence/PresenceOracle.h"
#include "Swiften/Network/TimerFactory.h"
+#include "Swift/Controllers/NickResolver.h"
namespace Swift {
-PresenceNotifier::PresenceNotifier(StanzaChannel* stanzaChannel, Notifier* notifier, const MUCRegistry* mucRegistry, AvatarManager* avatarManager, const XMPPRoster* roster, const PresenceOracle* presenceOracle, TimerFactory* timerFactory) : stanzaChannel(stanzaChannel), notifier(notifier), mucRegistry(mucRegistry), avatarManager(avatarManager), roster(roster), presenceOracle(presenceOracle), timerFactory(timerFactory) {
+PresenceNotifier::PresenceNotifier(StanzaChannel* stanzaChannel, Notifier* notifier, const MUCRegistry* mucRegistry, AvatarManager* avatarManager, NickResolver* nickResolver, const PresenceOracle* presenceOracle, TimerFactory* timerFactory) : stanzaChannel(stanzaChannel), notifier(notifier), mucRegistry(mucRegistry), avatarManager(avatarManager), nickResolver(nickResolver), presenceOracle(presenceOracle), timerFactory(timerFactory) {
justInitialized = true;
inQuietPeriod = false;
stanzaChannel->onPresenceReceived.connect(boost::bind(&PresenceNotifier::handlePresenceReceived, this, _1));
@@ -84,7 +85,7 @@ void PresenceNotifier::handleStanzaChannelAvailableChanged(bool available) {
}
void PresenceNotifier::showNotification(const JID& jid, Notifier::Type type) {
- String name = roster->getNameForJID(jid);
+ String name = nickResolver->jidToNick(jid);
if (name.isEmpty()) {
name = jid.toBare().toString();
}
diff --git a/Swift/Controllers/PresenceNotifier.h b/Swift/Controllers/PresenceNotifier.h
index f5bf3d4..9b2d9de 100644
--- a/Swift/Controllers/PresenceNotifier.h
+++ b/Swift/Controllers/PresenceNotifier.h
@@ -20,12 +20,12 @@ namespace Swift {
class TimerFactory;
class StanzaChannel;
class MUCRegistry;
- class XMPPRoster;
+ class NickResolver;
class PresenceOracle;
class PresenceNotifier {
public:
- PresenceNotifier(StanzaChannel* stanzaChannel, Notifier* notifier, const MUCRegistry* mucRegistry, AvatarManager* avatarManager, const XMPPRoster* roster, const PresenceOracle* presenceOracle, TimerFactory* timerFactory);
+ PresenceNotifier(StanzaChannel* stanzaChannel, Notifier* notifier, const MUCRegistry* mucRegistry, AvatarManager* avatarManager, NickResolver* nickResolver, const PresenceOracle* presenceOracle, TimerFactory* timerFactory);
~PresenceNotifier();
void setInitialQuietPeriodMS(int ms);
@@ -48,7 +48,7 @@ namespace Swift {
Notifier* notifier;
const MUCRegistry* mucRegistry;
AvatarManager* avatarManager;
- const XMPPRoster* roster;
+ NickResolver* nickResolver;
const PresenceOracle* presenceOracle;
TimerFactory* timerFactory;
boost::shared_ptr<Timer> timer;
diff --git a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp
index a410665..9addab2 100644
--- a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp
+++ b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp
@@ -10,6 +10,7 @@
#include <boost/bind.hpp>
#include "Swift/Controllers/PresenceNotifier.h"
+#include "Swift/Controllers/NickResolver.h"
#include "SwifTools/Notifier/LoggingNotifier.h"
#include "Swiften/Client/DummyStanzaChannel.h"
#include "Swiften/MUC/MUCRegistry.h"
@@ -52,12 +53,15 @@ class PresenceNotifierTest : public CppUnit::TestFixture {
user2 = JID("user2@foo.com/baz");
avatarManager = new DummyAvatarManager();
roster = new XMPPRoster();
+ nickResolver = new NickResolver(JID("foo@bar.com"), roster, NULL, mucRegistry);
presenceOracle = new PresenceOracle(stanzaChannel);
timerFactory = new DummyTimerFactory();
}
void tearDown() {
+ delete timerFactory;
delete presenceOracle;
+ delete nickResolver;
delete roster;
delete avatarManager;
delete mucRegistry;
@@ -269,7 +273,7 @@ class PresenceNotifierTest : public CppUnit::TestFixture {
private:
std::auto_ptr<PresenceNotifier> createNotifier() {
- std::auto_ptr<PresenceNotifier> result(new PresenceNotifier(stanzaChannel, notifier, mucRegistry, avatarManager, roster, presenceOracle, timerFactory));
+ std::auto_ptr<PresenceNotifier> result(new PresenceNotifier(stanzaChannel, notifier, mucRegistry, avatarManager, nickResolver, presenceOracle, timerFactory));
result->onNotificationActivated.connect(boost::bind(&PresenceNotifierTest::handleNotificationActivated, this, _1));
result->setInitialQuietPeriodMS(0);
return result;
@@ -300,6 +304,7 @@ class PresenceNotifierTest : public CppUnit::TestFixture {
MUCRegistry* mucRegistry;
DummyAvatarManager* avatarManager;
XMPPRoster* roster;
+ NickResolver* nickResolver;
PresenceOracle* presenceOracle;
DummyTimerFactory* timerFactory;
JID user1;