From 127b96597bcb1b5d5a823222f3dd28f4b7aa354a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Wed, 15 Sep 2010 23:10:25 +0200 Subject: Moved events from Swiften to Swift. diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index c4bd788..dc15242 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -16,7 +16,7 @@ #include "Swift/Controllers/UIInterfaces/ChatWindow.h" #include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" #include "Swift/Controllers/NickResolver.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" namespace Swift { diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index ffaf3af..177cdf0 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -15,7 +15,7 @@ #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Elements/Delay.h" #include "Swiften/Base/foreach.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swift/Controllers/UIInterfaces/ChatWindow.h" #include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" #include "Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h" diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index d537d84..4bad1db 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -20,7 +20,7 @@ #include "Swiften/Elements/Stanza.h" #include "Swiften/Base/String.h" #include "Swiften/Elements/DiscoInfo.h" -#include "Swiften/Events/MessageEvent.h" +#include "Swift/Controllers/XMPPEvents/MessageEvent.h" #include "Swiften/JID/JID.h" #include "Swiften/Elements/SecurityLabelsCatalog.h" #include "Swiften/Elements/ErrorPayload.h" diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 933d3cb..bd4fcb8 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -9,7 +9,7 @@ #include <boost/bind.hpp> #include "Swift/Controllers/Chat/ChatController.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swift/Controllers/Chat/MUCController.h" #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" #include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 533c9ed..5b98fcd 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -13,7 +13,7 @@ #include "Swiften/Base/foreach.h" #include "SwifTools/TabComplete.h" #include "Swiften/Base/foreach.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swift/Controllers/UIInterfaces/ChatWindow.h" #include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" #include "Swift/Controllers/UIEvents/UIEventStream.h" diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index bd49cd4..a17575c 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -15,7 +15,7 @@ #include "Swift/Controllers/UIInterfaces/ChatListWindowFactory.h" #include "Swiften/Client/Client.h" #include "Swift/Controllers/Chat/ChatController.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swift/Controllers/Chat/MUCController.h" #include "Swiften/Presence/PresenceSender.h" #include "Swiften/Avatars/NullAvatarManager.h" diff --git a/Swift/Controllers/EventController.cpp b/Swift/Controllers/EventController.cpp deleted file mode 100644 index bf24ff0..0000000 --- a/Swift/Controllers/EventController.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include "Swift/Controllers/EventController.h" - -#include <boost/bind.hpp> -#include <algorithm> - -#include "Swiften/Events/MessageEvent.h" -#include "Swiften/Events/ErrorEvent.h" -#include "Swiften/Events/SubscriptionRequestEvent.h" - -namespace Swift { - -EventController::EventController() { -} - -void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent) { - boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(sourceEvent); - boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(sourceEvent); - boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(sourceEvent); - if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent) { - events_.push_back(sourceEvent); - sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); - onEventQueueLengthChange(events_.size()); - onEventQueueEventAdded(sourceEvent); - } -} - -void EventController::handleEventConcluded(boost::shared_ptr<StanzaEvent> event) { - events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); - onEventQueueLengthChange(events_.size()); -} - -} diff --git a/Swift/Controllers/EventController.h b/Swift/Controllers/EventController.h deleted file mode 100644 index f96f4d8..0000000 --- a/Swift/Controllers/EventController.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#ifndef SWIFTEN_EventController_H -#define SWIFTEN_EventController_H - - -#include "Swiften/Base/boost_bsignals.h" -#include <boost/shared_ptr.hpp> -#include <vector> - -#include "Swiften/Events/StanzaEvent.h" -#include "Swiften/Events/MessageEvent.h" - -namespace Swift { - class EventController { - public: - EventController(); - void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent); - boost::signal<void (int)> onEventQueueLengthChange; - boost::signal<void (boost::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; - - private: - void handleEventConcluded(boost::shared_ptr<StanzaEvent> event); - std::vector<boost::shared_ptr<StanzaEvent> > events_; - }; -} -#endif - - diff --git a/Swift/Controllers/EventNotifier.cpp b/Swift/Controllers/EventNotifier.cpp index 09ad1da..7a293b6 100644 --- a/Swift/Controllers/EventNotifier.cpp +++ b/Swift/Controllers/EventNotifier.cpp @@ -8,14 +8,14 @@ #include <boost/bind.hpp> -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "SwifTools/Notifier/Notifier.h" #include "Swiften/Avatars/AvatarManager.h" #include "Swift/Controllers/NickResolver.h" #include "Swiften/JID/JID.h" -#include "Swiften/Events/MessageEvent.h" -#include "Swiften/Events/SubscriptionRequestEvent.h" -#include "Swiften/Events/ErrorEvent.h" +#include "Swift/Controllers/XMPPEvents/MessageEvent.h" +#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" +#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" namespace Swift { diff --git a/Swift/Controllers/EventNotifier.h b/Swift/Controllers/EventNotifier.h index 49c2c6c..8b4dc23 100644 --- a/Swift/Controllers/EventNotifier.h +++ b/Swift/Controllers/EventNotifier.h @@ -10,7 +10,7 @@ #include "SwifTools/Notifier/Notifier.h" #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Events/StanzaEvent.h" +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" #include "Swiften/JID/JID.h" namespace Swift { diff --git a/Swift/Controllers/EventWindowController.h b/Swift/Controllers/EventWindowController.h index 0710da5..28b9bf6 100644 --- a/Swift/Controllers/EventWindowController.h +++ b/Swift/Controllers/EventWindowController.h @@ -8,7 +8,7 @@ #include "Swift/Controllers/UIInterfaces/EventWindowFactory.h" #include "Swift/Controllers/UIInterfaces/EventWindow.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" namespace Swift { diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index aab7cff..3cfa2a7 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -21,7 +21,7 @@ #include "Swiften/VCards/VCardStorage.h" #include "Swift/Controllers/Chat/MUCSearchController.h" #include "Swift/Controllers/Chat/ChatsManager.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swift/Controllers/EventWindowController.h" #include "Swift/Controllers/UIInterfaces/LoginWindow.h" #include "Swift/Controllers/UIInterfaces/LoginWindowFactory.h" diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 63a6063..c0885b6 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -24,7 +24,7 @@ #include "Swiften/Settings/SettingsProvider.h" #include "Swift/Controllers/ProfileSettingsProvider.h" #include "Swiften/Elements/CapsInfo.h" -#include "Swiften/Events/ErrorEvent.h" +#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" #include "Swiften/Roster/XMPPRoster.h" namespace Swift { diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index da10e5b..c8f94f1 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -14,11 +14,11 @@ #include "Swift/Controllers/NickResolver.h" #include "Swiften/Queries/Requests/GetRosterRequest.h" #include "Swiften/Queries/Requests/SetRosterRequest.h" -#include "Swiften/Events/SubscriptionRequestEvent.h" -#include "Swiften/Events/ErrorEvent.h" +#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" +#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" #include "Swiften/Presence/PresenceOracle.h" #include "Swiften/Presence/PresenceSender.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swiften/Queries/IQRouter.h" #include "Swiften/Roster/Roster.h" #include "Swiften/Roster/SetPresence.h" diff --git a/Swift/Controllers/SConscript b/Swift/Controllers/SConscript index 1a850b1..d37b370 100644 --- a/Swift/Controllers/SConscript +++ b/Swift/Controllers/SConscript @@ -29,7 +29,6 @@ if env["SCONS_STAGE"] == "build" : "MainController.cpp", "NickResolver.cpp", "RosterController.cpp", - "EventController.cpp", "EventWindowController.cpp", "SoundEventController.cpp", "SystemTrayController.cpp", @@ -37,6 +36,7 @@ if env["SCONS_STAGE"] == "build" : "StatusTracker.cpp", "PresenceNotifier.cpp", "EventNotifier.cpp", + "XMPPEvents/EventController.cpp", "UIEvents/UIEvent.cpp", "UIInterfaces/XMLConsoleWidget.cpp", "UIInterfaces/ChatListWindow.cpp", diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp index 3d6a80a..0351445 100644 --- a/Swift/Controllers/SoundEventController.cpp +++ b/Swift/Controllers/SoundEventController.cpp @@ -8,7 +8,7 @@ #include <boost/bind.hpp> -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swift/Controllers/SoundPlayer.h" #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" diff --git a/Swift/Controllers/SoundEventController.h b/Swift/Controllers/SoundEventController.h index c9e0da7..556a811 100644 --- a/Swift/Controllers/SoundEventController.h +++ b/Swift/Controllers/SoundEventController.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Events/StanzaEvent.h" +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" #include "Swiften/Settings/SettingsProvider.h" #include "Swift/Controllers/UIEvents/UIEvent.h" diff --git a/Swift/Controllers/SystemTrayController.cpp b/Swift/Controllers/SystemTrayController.cpp index 758bdd8..23a94fa 100644 --- a/Swift/Controllers/SystemTrayController.cpp +++ b/Swift/Controllers/SystemTrayController.cpp @@ -8,7 +8,7 @@ #include <boost/bind.hpp> -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swift/Controllers/SystemTray.h" namespace Swift { diff --git a/Swift/Controllers/UIInterfaces/EventWindow.h b/Swift/Controllers/UIInterfaces/EventWindow.h index d174d8d..0999e0e 100644 --- a/Swift/Controllers/UIInterfaces/EventWindow.h +++ b/Swift/Controllers/UIInterfaces/EventWindow.h @@ -7,7 +7,7 @@ #pragma once #include "boost/shared_ptr.hpp" -#include "Swiften/Events/StanzaEvent.h" +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" namespace Swift { class EventWindow { diff --git a/Swift/Controllers/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/UnitTest/RosterControllerTest.cpp index 174b682..de46588 100644 --- a/Swift/Controllers/UnitTest/RosterControllerTest.cpp +++ b/Swift/Controllers/UnitTest/RosterControllerTest.cpp @@ -21,7 +21,7 @@ #include "Swiften/Roster/GroupRosterItem.h" #include "Swiften/Roster/ContactRosterItem.h" #include "Swiften/Avatars/NullAvatarManager.h" -#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/XMPPEvents/EventController.h" #include "Swiften/Presence/PresenceOracle.h" #include "Swiften/Presence/PresenceSender.h" #include "Swift/Controllers/NickResolver.h" diff --git a/Swift/Controllers/XMPPEvents/ErrorEvent.h b/Swift/Controllers/XMPPEvents/ErrorEvent.h new file mode 100644 index 0000000..3f78109 --- /dev/null +++ b/Swift/Controllers/XMPPEvents/ErrorEvent.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2010 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <cassert> + +#include "Swiften/Base/boost_bsignals.h" +#include <boost/shared_ptr.hpp> + +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" +#include "Swiften/Base/String.h" +#include "Swiften/JID/JID.h" + +namespace Swift { + class ErrorEvent : public StanzaEvent { + public: + ErrorEvent(const JID& jid, const String& text) : jid_(jid), text_(text){}; + virtual ~ErrorEvent(){}; + const JID& getJID() const {return jid_;}; + const String& getText() const {return text_;}; + + private: + JID jid_; + String text_; + }; +} + diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp new file mode 100644 index 0000000..b14ff46 --- /dev/null +++ b/Swift/Controllers/XMPPEvents/EventController.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2010 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include "Swift/Controllers/XMPPEvents/EventController.h" + +#include <boost/bind.hpp> +#include <algorithm> + +#include "Swift/Controllers/XMPPEvents/MessageEvent.h" +#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" +#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" + +namespace Swift { + +EventController::EventController() { +} + +void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent) { + boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(sourceEvent); + boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(sourceEvent); + boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(sourceEvent); + if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent) { + events_.push_back(sourceEvent); + sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); + onEventQueueLengthChange(events_.size()); + onEventQueueEventAdded(sourceEvent); + } +} + +void EventController::handleEventConcluded(boost::shared_ptr<StanzaEvent> event) { + events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); + onEventQueueLengthChange(events_.size()); +} + +} diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h new file mode 100644 index 0000000..b405556 --- /dev/null +++ b/Swift/Controllers/XMPPEvents/EventController.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#ifndef SWIFTEN_EventController_H +#define SWIFTEN_EventController_H + + +#include "Swiften/Base/boost_bsignals.h" +#include <boost/shared_ptr.hpp> +#include <vector> + +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" +#include "Swift/Controllers/XMPPEvents/MessageEvent.h" + +namespace Swift { + class EventController { + public: + EventController(); + void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent); + boost::signal<void (int)> onEventQueueLengthChange; + boost::signal<void (boost::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; + + private: + void handleEventConcluded(boost::shared_ptr<StanzaEvent> event); + std::vector<boost::shared_ptr<StanzaEvent> > events_; + }; +} +#endif + + diff --git a/Swift/Controllers/XMPPEvents/MessageEvent.h b/Swift/Controllers/XMPPEvents/MessageEvent.h new file mode 100644 index 0000000..313ad78 --- /dev/null +++ b/Swift/Controllers/XMPPEvents/MessageEvent.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#ifndef SWIFTEN_MessageEvent_H +#define SWIFTEN_MessageEvent_H + +#include <cassert> + +#include "Swiften/Base/boost_bsignals.h" +#include <boost/shared_ptr.hpp> + +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" +#include "Swiften/Elements/Message.h" + +namespace Swift { + class MessageEvent : public StanzaEvent { + public: + MessageEvent(boost::shared_ptr<Message> stanza) : stanza_(stanza){}; + + boost::shared_ptr<Message> getStanza() {return stanza_;} + + bool isReadable() { + return getStanza()->isError() || !getStanza()->getBody().isEmpty(); + } + + void read() { + assert (isReadable()); + conclude(); + } + + private: + boost::shared_ptr<Message> stanza_; + }; +} + +#endif diff --git a/Swift/Controllers/XMPPEvents/StanzaEvent.h b/Swift/Controllers/XMPPEvents/StanzaEvent.h new file mode 100644 index 0000000..78dd4dc --- /dev/null +++ b/Swift/Controllers/XMPPEvents/StanzaEvent.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2010 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +#include "Swiften/Base/boost_bsignals.h" + +namespace Swift { + class StanzaEvent { + public: + StanzaEvent() : time_(boost::posix_time::microsec_clock::universal_time()) {concluded_ = false;}; + virtual ~StanzaEvent() {}; + void conclude() {concluded_ = true; onConclusion();}; + /** Do not call this directly from outside the class */ + boost::signal<void()> onConclusion; + bool getConcluded() {return concluded_;}; + boost::posix_time::ptime getTime() {return time_;} + private: + bool concluded_; + boost::posix_time::ptime time_; + }; +} diff --git a/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h new file mode 100644 index 0000000..704a86c --- /dev/null +++ b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <cassert> + +#include "Swiften/Base/boost_bsignals.h" +#include <boost/shared_ptr.hpp> + +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" +#include "Swiften/Base/String.h" +#include "Swiften/JID/JID.h" + +namespace Swift { + class SubscriptionRequestEvent : public StanzaEvent { + public: + SubscriptionRequestEvent(const JID& jid, const String& reason) : jid_(jid), reason_(reason){}; + virtual ~SubscriptionRequestEvent(){}; + const JID& getJID() const {return jid_;}; + const String& getReason() const {return reason_;}; + boost::signal<void()> onAccept; + boost::signal<void()> onDecline; + void accept() { + onAccept(); + conclude(); + }; + + void decline() { + onDecline(); + conclude(); + }; + + void defer() { + conclude(); + } + + private: + JID jid_; + String reason_; + }; +} + diff --git a/Swift/QtUI/EventViewer/EventDelegate.cpp b/Swift/QtUI/EventViewer/EventDelegate.cpp index 334dbd7..79b8854 100644 --- a/Swift/QtUI/EventViewer/EventDelegate.cpp +++ b/Swift/QtUI/EventViewer/EventDelegate.cpp @@ -8,9 +8,9 @@ #include <QDebug> -#include "Swiften/Events/MessageEvent.h" -#include "Swiften/Events/ErrorEvent.h" -#include "Swiften/Events/SubscriptionRequestEvent.h" +#include "Swift/Controllers/XMPPEvents/MessageEvent.h" +#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" +#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" namespace Swift { diff --git a/Swift/QtUI/EventViewer/EventModel.h b/Swift/QtUI/EventViewer/EventModel.h index f031c0b..acbbb68 100644 --- a/Swift/QtUI/EventViewer/EventModel.h +++ b/Swift/QtUI/EventViewer/EventModel.h @@ -11,7 +11,7 @@ #include <QAbstractListModel> #include <QList> -#include "Swiften/Events/StanzaEvent.h" +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" #include "Swift/QtUI/EventViewer/QtEvent.h" diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp index 5305db2..21d713f 100644 --- a/Swift/QtUI/EventViewer/QtEvent.cpp +++ b/Swift/QtUI/EventViewer/QtEvent.cpp @@ -8,9 +8,9 @@ #include <QDateTime> -#include "Swiften/Events/MessageEvent.h" -#include "Swiften/Events/ErrorEvent.h" -#include "Swiften/Events/SubscriptionRequestEvent.h" +#include "Swift/Controllers/XMPPEvents/MessageEvent.h" +#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" +#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" #include "Swift/QtUI/QtSwiftUtil.h" diff --git a/Swift/QtUI/EventViewer/QtEvent.h b/Swift/QtUI/EventViewer/QtEvent.h index be036dd..f5e3dee 100644 --- a/Swift/QtUI/EventViewer/QtEvent.h +++ b/Swift/QtUI/EventViewer/QtEvent.h @@ -10,7 +10,7 @@ #include <QVariant> -#include "Swiften/Events/StanzaEvent.h" +#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" namespace Swift { class QtEvent { diff --git a/Swift/QtUI/EventViewer/QtEventWindow.cpp b/Swift/QtUI/EventViewer/QtEventWindow.cpp index 03050f5..826e360 100644 --- a/Swift/QtUI/EventViewer/QtEventWindow.cpp +++ b/Swift/QtUI/EventViewer/QtEventWindow.cpp @@ -11,10 +11,10 @@ #include <QBoxLayout> #include <QPushButton> -#include "Swiften/Events/MessageEvent.h" -#include "Swiften/Events/ErrorEvent.h" +#include "Swift/Controllers/XMPPEvents/MessageEvent.h" +#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" #include "Swift/QtUI/QtSubscriptionRequestWindow.h" -#include "Swiften/Events/SubscriptionRequestEvent.h" +#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" #include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" diff --git a/Swift/QtUI/QtSubscriptionRequestWindow.h b/Swift/QtUI/QtSubscriptionRequestWindow.h index 06240a6..7392aac 100644 --- a/Swift/QtUI/QtSubscriptionRequestWindow.h +++ b/Swift/QtUI/QtSubscriptionRequestWindow.h @@ -10,7 +10,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Events/SubscriptionRequestEvent.h" +#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" namespace Swift { class QtSubscriptionRequestWindow : public QDialog { diff --git a/Swiften/Events/ErrorEvent.h b/Swiften/Events/ErrorEvent.h deleted file mode 100644 index 6ab9d03..0000000 --- a/Swiften/Events/ErrorEvent.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include <cassert> - -#include "Swiften/Base/boost_bsignals.h" -#include <boost/shared_ptr.hpp> - -#include "Swiften/Events/StanzaEvent.h" -#include "Swiften/Base/String.h" -#include "Swiften/JID/JID.h" - -namespace Swift { - class ErrorEvent : public StanzaEvent { - public: - ErrorEvent(const JID& jid, const String& text) : jid_(jid), text_(text){}; - virtual ~ErrorEvent(){}; - const JID& getJID() const {return jid_;}; - const String& getText() const {return text_;}; - - private: - JID jid_; - String text_; - }; -} - diff --git a/Swiften/Events/MessageEvent.h b/Swiften/Events/MessageEvent.h deleted file mode 100644 index 60a6c8c..0000000 --- a/Swiften/Events/MessageEvent.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#ifndef SWIFTEN_MessageEvent_H -#define SWIFTEN_MessageEvent_H - -#include <cassert> - -#include "Swiften/Base/boost_bsignals.h" -#include <boost/shared_ptr.hpp> - -#include "Swiften/Events/StanzaEvent.h" -#include "Swiften/Elements/Message.h" - -namespace Swift { - class MessageEvent : public StanzaEvent { - public: - MessageEvent(boost::shared_ptr<Message> stanza) : stanza_(stanza){}; - - boost::shared_ptr<Message> getStanza() {return stanza_;} - - bool isReadable() { - return getStanza()->isError() || !getStanza()->getBody().isEmpty(); - } - - void read() { - assert (isReadable()); - conclude(); - } - - private: - boost::shared_ptr<Message> stanza_; - }; -} - -#endif diff --git a/Swiften/Events/StanzaEvent.h b/Swiften/Events/StanzaEvent.h deleted file mode 100644 index 78dd4dc..0000000 --- a/Swiften/Events/StanzaEvent.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include <boost/shared_ptr.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> - -#include "Swiften/Base/boost_bsignals.h" - -namespace Swift { - class StanzaEvent { - public: - StanzaEvent() : time_(boost::posix_time::microsec_clock::universal_time()) {concluded_ = false;}; - virtual ~StanzaEvent() {}; - void conclude() {concluded_ = true; onConclusion();}; - /** Do not call this directly from outside the class */ - boost::signal<void()> onConclusion; - bool getConcluded() {return concluded_;}; - boost::posix_time::ptime getTime() {return time_;} - private: - bool concluded_; - boost::posix_time::ptime time_; - }; -} diff --git a/Swiften/Events/SubscriptionRequestEvent.h b/Swiften/Events/SubscriptionRequestEvent.h deleted file mode 100644 index 4a998d7..0000000 --- a/Swiften/Events/SubscriptionRequestEvent.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include <cassert> - -#include "Swiften/Base/boost_bsignals.h" -#include <boost/shared_ptr.hpp> - -#include "Swiften/Events/StanzaEvent.h" -#include "Swiften/Base/String.h" -#include "Swiften/JID/JID.h" - -namespace Swift { - class SubscriptionRequestEvent : public StanzaEvent { - public: - SubscriptionRequestEvent(const JID& jid, const String& reason) : jid_(jid), reason_(reason){}; - virtual ~SubscriptionRequestEvent(){}; - const JID& getJID() const {return jid_;}; - const String& getReason() const {return reason_;}; - boost::signal<void()> onAccept; - boost::signal<void()> onDecline; - void accept() { - onAccept(); - conclude(); - }; - - void decline() { - onDecline(); - conclude(); - }; - - void defer() { - conclude(); - } - - private: - JID jid_; - String reason_; - }; -} - -- cgit v0.10.2-6-g49f6