diff options
| author | Remko Tronçon <git@el-tramo.be> | 2009-11-24 21:56:19 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2009-11-24 22:31:48 (GMT) |
| commit | 9b1e36b4fe08f32896e92abdb6fc7e3dad501160 (patch) | |
| tree | 092ba87f84238665b938198af29fc5894c55382a /Swift/Controllers | |
| parent | 48fc9e9fb0abd42d47a95042837a026730f20f34 (diff) | |
| download | swift-9b1e36b4fe08f32896e92abdb6fc7e3dad501160.zip swift-9b1e36b4fe08f32896e92abdb6fc7e3dad501160.tar.bz2 | |
Added PresenceSender object.
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/MUCController.cpp | 3 | ||||
| -rw-r--r-- | Swift/Controllers/MUCController.h | 2 | ||||
| -rw-r--r-- | Swift/Controllers/MainController.cpp | 10 | ||||
| -rw-r--r-- | Swift/Controllers/MainController.h | 2 |
4 files changed, 12 insertions, 5 deletions
diff --git a/Swift/Controllers/MUCController.cpp b/Swift/Controllers/MUCController.cpp index 848f540..da7a9e7 100644 --- a/Swift/Controllers/MUCController.cpp +++ b/Swift/Controllers/MUCController.cpp @@ -18,19 +18,20 @@ namespace Swift { */ MUCController::MUCController ( const JID& self, const JID &muc, const String &nick, StanzaChannel* stanzaChannel, + PresenceSender* presenceSender, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, TreeWidgetFactory *treeWidgetFactory, PresenceOracle* presenceOracle, AvatarManager* avatarManager) : ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, muc, presenceOracle, avatarManager), - muc_(new MUC(stanzaChannel, muc)), + muc_(new MUC(stanzaChannel, presenceSender, muc)), nick_(nick), treeWidgetFactory_(treeWidgetFactory) { roster_ = new Roster(chatWindow_->getTreeWidget(), treeWidgetFactory_); chatWindow_->onClosed.connect(boost::bind(&MUCController::handleWindowClosed, this)); muc_->joinAs(nick); muc_->onOccupantJoined.connect(boost::bind(&MUCController::handleOccupantJoined, this, _1)); diff --git a/Swift/Controllers/MUCController.h b/Swift/Controllers/MUCController.h index af4a23a..7ee6e81 100644 --- a/Swift/Controllers/MUCController.h +++ b/Swift/Controllers/MUCController.h @@ -19,13 +19,13 @@ namespace Swift { class Roster; class TreeWidgetFactory; class AvatarManager; class MUCController : public ChatControllerBase { public: - MUCController(const JID& self, const JID &muc, const String &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, TreeWidgetFactory *treeWidgetFactory, PresenceOracle* presenceOracle, AvatarManager* avatarManager); + MUCController(const JID& self, const JID &muc, const String &nick, StanzaChannel* stanzaChannel, PresenceSender* presenceSender, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, TreeWidgetFactory *treeWidgetFactory, PresenceOracle* presenceOracle, AvatarManager* avatarManager); ~MUCController(); protected: void preSendMessageRequest(boost::shared_ptr<Message> message); bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); String senderDisplayNameFromMessage(const JID& from); diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index f54e0a2..22d71e5 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -23,12 +23,13 @@ #include "Swift/Controllers/SystemTray.h" #include "Swift/Controllers/SystemTrayController.h" #include "Swift/Controllers/XMPPRosterController.h" #include "Swiften/Base/foreach.h" #include "Swiften/Base/String.h" #include "Swiften/Client/Client.h" +#include "Swiften/Presence/PresenceSender.h" #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/VCardUpdate.h" #include "Swiften/Queries/Responders/SoftwareVersionResponder.h" #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Settings/SettingsProvider.h" #include "Swiften/Elements/DiscoInfo.h" @@ -57,13 +58,13 @@ static const String CLIENT_VERSION = "0.3"; static const String CLIENT_NODE = "http://swift.im"; typedef std::pair<JID, ChatController*> JIDChatControllerPair; typedef std::pair<JID, MUCController*> JIDMUCControllerPair; MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory *treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer) - : timerFactory_(&boostIOServiceThread_.getIOService()), idleDetector_(&idleQuerier_, &timerFactory_, 100), client_(NULL), chatWindowFactory_(chatWindowFactory), mainWindowFactory_(mainWindowFactory), loginWindowFactory_(loginWindowFactory), treeWidgetFactory_(treeWidgetFactory), settings_(settings), xmppRosterController_(NULL), rosterController_(NULL), loginWindow_(NULL), clientVersionResponder_(NULL), nickResolver_(NULL), discoResponder_(NULL) { + : timerFactory_(&boostIOServiceThread_.getIOService()), idleDetector_(&idleQuerier_, &timerFactory_, 100), client_(NULL), presenceSender_(NULL), chatWindowFactory_(chatWindowFactory), mainWindowFactory_(mainWindowFactory), loginWindowFactory_(loginWindowFactory), treeWidgetFactory_(treeWidgetFactory), settings_(settings), xmppRosterController_(NULL), rosterController_(NULL), loginWindow_(NULL), clientVersionResponder_(NULL), nickResolver_(NULL), discoResponder_(NULL) { application_ = application; presenceOracle_ = NULL; avatarManager_ = NULL; avatarStorage_ = new AvatarFileStorage(application_->getAvatarDir()); @@ -111,12 +112,14 @@ void MainController::resetClient() { delete xmppRosterController_; xmppRosterController_ = NULL; delete clientVersionResponder_; clientVersionResponder_ = NULL; delete discoResponder_; discoResponder_ = NULL; + delete presenceSender_; + presenceSender_ = NULL; delete client_; client_ = NULL; } void MainController::handleConnected() { @@ -207,13 +210,13 @@ void MainController::handleChangeStatusRequest(StatusShow::Type show, const Stri void MainController::sendPresence(boost::shared_ptr<Presence> presence) { if (!vCardPhotoHash_.isEmpty()) { presence->addPayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate(vCardPhotoHash_))); } presence->addPayload(capsInfo_); lastSentPresence_ = presence; - client_->sendPresence(presence); + presenceSender_->sendPresence(presence); if (presence->getType() == Presence::Unavailable) { logout(); } } void MainController::handleInputIdleChanged(bool idle) { @@ -255,12 +258,13 @@ void MainController::handleLoginRequest(const String &username, const String &pa performLoginFromCachedCredentials(); } void MainController::performLoginFromCachedCredentials() { if (!client_) { client_ = new Swift::Client(jid_, password_); + presenceSender_ = new PresenceSender(client_); //client_->onDataRead.connect(&printIncomingData); //client_->onDataWritten.connect(&printOutgoingData); if (!certificateFile_.isEmpty()) { client_->setCertificate(certificateFile_); } client_->onError.connect(boost::bind(&MainController::handleError, this, _1)); @@ -365,13 +369,13 @@ ChatController* MainController::getChatController(const JID &contact) { void MainController::handleChatControllerJIDChanged(const JID& from, const JID& to) { chatControllers_[to] = chatControllers_[from]; chatControllers_.erase(from); } void MainController::handleJoinMUCRequest(const JID &muc, const String &nick) { - mucControllers_[muc] = new MUCController(jid_, muc, nick, client_, client_, chatWindowFactory_, treeWidgetFactory_, presenceOracle_, avatarManager_); + mucControllers_[muc] = new MUCController(jid_, muc, nick, client_, presenceSender_, client_, chatWindowFactory_, treeWidgetFactory_, presenceOracle_, avatarManager_); mucControllers_[muc]->setAvailableServerFeatures(serverDiscoInfo_); } void MainController::handleIncomingMessage(boost::shared_ptr<Message> message) { JID jid = message->getFrom(); boost::shared_ptr<MessageEvent> event(new MessageEvent(message)); diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 270b131..78e49a2 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -30,12 +30,13 @@ namespace Swift { class EventController; class MainWindowFactory; class MainWindow; class NickResolver; class RosterController; class XMPPRosterController; + class PresenceSender; class DiscoInfoResponder; class AvatarManager; class LoginWindow; class EventLoop; class SoftwareVersionResponder; class LoginWindowFactory; @@ -83,12 +84,13 @@ namespace Swift { BoostIOServiceThread boostIOServiceThread_; BoostTimerFactory timerFactory_; PlatformIdleQuerier idleQuerier_; ActualIdleDetector idleDetector_; Client* client_; + PresenceSender* presenceSender_; ChatWindowFactory* chatWindowFactory_; MainWindowFactory* mainWindowFactory_; LoginWindowFactory* loginWindowFactory_; TreeWidgetFactory* treeWidgetFactory_; SettingsProvider *settings_; Application* application_; |
Swift