summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-10 20:08:10 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-10 20:15:53 (GMT)
commit3a876559c905f324e4bc91cec6c58d93160a5a9d (patch)
tree7120a111b5a05455638142655d468f16c6003593
parentd0bb6fb5a3b58d04a68deabd8d4431b112c6c084 (diff)
downloadswift-3a876559c905f324e4bc91cec6c58d93160a5a9d.zip
swift-3a876559c905f324e4bc91cec6c58d93160a5a9d.tar.bz2
Moved presenceOracle inside Client.
-rw-r--r--Swift/Controllers/MainController.cpp10
-rw-r--r--Swift/Controllers/MainController.h2
-rw-r--r--Swiften/Client/Client.cpp15
-rw-r--r--Swiften/Client/Client.h27
4 files changed, 45 insertions, 9 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index c4599b0..d95557f 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -100,7 +100,6 @@ MainController::MainController(
statusTracker_ = NULL;
client_ = NULL;
presenceSender_ = NULL;
- presenceOracle_ = NULL;
mucRegistry_ = NULL;
vcardManager_ = NULL;
avatarManager_ = NULL;
@@ -217,8 +216,6 @@ void MainController::resetClient() {
vcardManager_ = NULL;
delete mucRegistry_;
mucRegistry_ = NULL;
- delete presenceOracle_;
- presenceOracle_ = NULL;
delete presenceSender_;
presenceSender_ = NULL;
delete client_;
@@ -264,11 +261,11 @@ void MainController::handleConnected() {
bool freshLogin = rosterController_ == NULL;
myStatusLooksOnline_ = true;
if (freshLogin) {
- rosterController_ = new RosterController(jid_, client_->getRoster(), avatarManager_, mainWindowFactory_, nickResolver_, presenceOracle_, presenceSender_, eventController_, uiEventStream_, client_->getIQRouter(), settings_);
+ rosterController_ = new RosterController(jid_, client_->getRoster(), avatarManager_, mainWindowFactory_, nickResolver_, client_->getPresenceOracle(), presenceSender_, eventController_, uiEventStream_, client_->getIQRouter(), settings_);
rosterController_->onChangeStatusRequest.connect(boost::bind(&MainController::handleChangeStatusRequest, this, _1, _2));
rosterController_->onSignOutRequest.connect(boost::bind(&MainController::signOut, this));
- chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, chatWindowFactory_, nickResolver_, presenceOracle_, presenceSender_, uiEventStream_, chatListWindowFactory_, useDelayForLatency_, &timerFactory_, mucRegistry_, entityCapsManager_);
+ chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, chatWindowFactory_, nickResolver_, client_->getPresenceOracle(), presenceSender_, uiEventStream_, chatListWindowFactory_, useDelayForLatency_, &timerFactory_, mucRegistry_, entityCapsManager_);
client_->onMessageReceived.connect(boost::bind(&ChatsManager::handleIncomingMessage, chatsManager_, _1));
chatsManager_->setAvatarManager(avatarManager_);
@@ -405,7 +402,6 @@ void MainController::performLoginFromCachedCredentials() {
client_->setSoftwareVersion(CLIENT_NAME, buildVersion);
presenceSender_ = new PresenceSender(client_->getStanzaChannel());
- presenceOracle_ = new PresenceOracle(client_->getStanzaChannel());
mucRegistry_ = new MUCRegistry();
vcardManager_ = new VCardManager(jid_, client_->getIQRouter(), getVCardStorageForProfile(jid_));
vcardManager_->onVCardChanged.connect(boost::bind(&MainController::handleVCardReceived, this, _1, _2));
@@ -413,7 +409,7 @@ void MainController::performLoginFromCachedCredentials() {
avatarManager_ = new AvatarManagerImpl(vcardManager_, client_->getStanzaChannel(), avatarStorage_, mucRegistry_);
capsManager_ = new CapsManager(capsStorage_, client_->getStanzaChannel(), client_->getIQRouter());
entityCapsManager_ = new EntityCapsManager(capsManager_, client_->getStanzaChannel());
- presenceNotifier_ = new PresenceNotifier(client_->getStanzaChannel(), notifier_, mucRegistry_, avatarManager_, nickResolver_, presenceOracle_, &timerFactory_);
+ presenceNotifier_ = new PresenceNotifier(client_->getStanzaChannel(), notifier_, mucRegistry_, avatarManager_, nickResolver_, client_->getPresenceOracle(), &timerFactory_);
presenceNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
eventNotifier_ = new EventNotifier(eventController_, notifier_, avatarManager_, nickResolver_);
eventNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 7139ce9..e7b4bfd 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -53,7 +53,6 @@ namespace Swift {
class LoginWindowFactory;
class MUCController;
class Notifier;
- class PresenceOracle;
class PresenceNotifier;
class EventNotifier;
class SystemTray;
@@ -153,7 +152,6 @@ namespace Swift {
boost::shared_ptr<CapsInfo> capsInfo_;
JID jid_;
JID boundJID_;
- PresenceOracle* presenceOracle_;
SystemTrayController* systemTrayController_;
SoundEventController* soundEventController_;
AvatarManager* avatarManager_;
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index e3e8a45..20a0c47 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -9,6 +9,7 @@
#include "Swiften/Queries/Responders/SoftwareVersionResponder.h"
#include "Swiften/Roster/XMPPRoster.h"
#include "Swiften/Roster/XMPPRosterController.h"
+#include "Swiften/Presence/PresenceOracle.h"
namespace Swift {
@@ -18,9 +19,15 @@ Client::Client(const JID& jid, const String& password) : CoreClient(jid, passwor
roster = new XMPPRoster();
rosterController = new XMPPRosterController(getIQRouter(), roster);
+
+ presenceOracle = new PresenceOracle(getStanzaChannel());
+ presenceOracle->onPresenceChange.connect(boost::ref(onPresenceChange));
+ presenceOracle->onPresenceSubscriptionRequest.connect(boost::ref(onPresenceSubscriptionRequest));
}
Client::~Client() {
+ delete presenceOracle;
+
delete rosterController;
delete roster;
@@ -37,4 +44,12 @@ void Client::requestRoster() {
}
+Presence::ref Client::getLastPresence(const JID& jid) const {
+ return presenceOracle->getLastPresence(jid);
+}
+
+Presence::ref Client::getHighestPriorityPresence(const JID& bareJID) const {
+ return presenceOracle->getHighestPriorityPresence(bareJID);
+}
+
}
diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h
index 9f3e935..bf19f2f 100644
--- a/Swiften/Client/Client.h
+++ b/Swiften/Client/Client.h
@@ -12,6 +12,7 @@ namespace Swift {
class SoftwareVersionResponder;
class XMPPRoster;
class XMPPRosterController;
+ class PresenceOracle;
/**
* Provides the core functionality for writing XMPP client software.
@@ -56,9 +57,35 @@ namespace Swift {
*/
void requestRoster();
+ /**
+ * Returns the last received presence for the given (full) JID.
+ */
+ Presence::ref getLastPresence(const JID& jid) const;
+
+ /**
+ * Returns the presence with the highest priority received for the given JID.
+ */
+ Presence::ref getHighestPriorityPresence(const JID& bareJID) const;
+
+ PresenceOracle* getPresenceOracle() const {
+ return presenceOracle;
+ }
+
+ public:
+ /**
+ * This signal is emitted when a JID changes presence.
+ */
+ boost::signal<void (boost::shared_ptr<Presence>)> onPresenceChange;
+
+ /**
+ * This signal is emitted when a presence subscription request is received.
+ */
+ boost::signal<void (const JID&, const String&)> onPresenceSubscriptionRequest;
+
private:
SoftwareVersionResponder* softwareVersionResponder;
XMPPRoster* roster;
XMPPRosterController* rosterController;
+ PresenceOracle* presenceOracle;
};
}