diff options
Diffstat (limited to 'Swift/Controllers/Roster')
-rw-r--r-- | Swift/Controllers/Roster/RosterController.cpp | 16 | ||||
-rw-r--r-- | Swift/Controllers/Roster/RosterController.h | 44 | ||||
-rw-r--r-- | Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp | 34 |
3 files changed, 61 insertions, 33 deletions
diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index 2d35b6a..73efa43 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,9 +9,10 @@ #include <boost/bind.hpp> #include <boost/smart_ptr/make_shared.hpp> +#include <Swiften/Avatars/AvatarManager.h> +#include <Swiften/Base/Path.h> #include <Swiften/Base/foreach.h> #include <Swiften/Base/format.h> -#include <Swiften/Base/Path.h> #include <Swiften/Client/ClientBlockListManager.h> #include <Swiften/Client/NickManager.h> #include <Swiften/Client/NickResolver.h> @@ -27,19 +28,22 @@ #include <Swiften/Roster/SetRosterRequest.h> #include <Swiften/Roster/XMPPRoster.h> #include <Swiften/Roster/XMPPRosterItem.h> +#include <Swiften/VCards/VCardManager.h> +#include <Swift/Controllers/FileTransfer/FileTransferOverview.h> #include <Swift/Controllers/Intl.h> #include <Swift/Controllers/Roster/GroupRosterItem.h> -#include <Swift/Controllers/Roster/OfflineRosterFilter.h> -#include <Swift/Controllers/Roster/Roster.h> -#include <Swift/Controllers/Roster/RosterVCardProvider.h> #include <Swift/Controllers/Roster/ItemOperations/AppearOffline.h> -#include <Swift/Controllers/Roster/ItemOperations/SetAvatar.h> #include <Swift/Controllers/Roster/ItemOperations/SetAvailableFeatures.h> +#include <Swift/Controllers/Roster/ItemOperations/SetAvatar.h> #include <Swift/Controllers/Roster/ItemOperations/SetBlockingState.h> #include <Swift/Controllers/Roster/ItemOperations/SetName.h> #include <Swift/Controllers/Roster/ItemOperations/SetPresence.h> #include <Swift/Controllers/Roster/ItemOperations/SetVCard.h> +#include <Swift/Controllers/Roster/OfflineRosterFilter.h> +#include <Swift/Controllers/Roster/Roster.h> +#include <Swift/Controllers/Roster/RosterGroupExpandinessPersister.h> +#include <Swift/Controllers/Roster/RosterVCardProvider.h> #include <Swift/Controllers/SettingConstants.h> #include <Swift/Controllers/UIEvents/AddContactUIEvent.h> #include <Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h> diff --git a/Swift/Controllers/Roster/RosterController.h b/Swift/Controllers/Roster/RosterController.h index f4ae581..545abfc 100644 --- a/Swift/Controllers/Roster/RosterController.h +++ b/Swift/Controllers/Roster/RosterController.h @@ -1,53 +1,55 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <string> #include <set> +#include <string> #include <boost/shared_ptr.hpp> +#include <Swiften/Avatars/AvatarManager.h> #include <Swiften/Base/boost_bsignals.h> -#include <Swiften/JID/JID.h> -#include <Swiften/Elements/Presence.h> #include <Swiften/Elements/ErrorPayload.h> +#include <Swiften/Elements/Presence.h> #include <Swiften/Elements/RosterPayload.h> -#include <Swiften/Avatars/AvatarManager.h> -#include <Swiften/VCards/VCardManager.h> +#include <Swiften/Elements/VCard.h> +#include <Swiften/JID/JID.h> +#include <Swift/Controllers/Roster/ContactRosterItem.h> #include <Swift/Controllers/UIEvents/UIEvent.h> -#include <Swift/Controllers/FileTransfer/FileTransferOverview.h> -#include <Swift/Controllers/Roster/RosterGroupExpandinessPersister.h> namespace Swift { + class AvatarManager; + class ClientBlockListManager; + class EntityCapsProvider; + class EventController; + class FileTransferManager; + class FileTransferOverview; class IQRouter; - class Roster; - class XMPPRoster; - class XMPPRosterItem; class MainWindow; class MainWindowFactory; - class OfflineRosterFilter; + class NickManager; class NickResolver; + class OfflineRosterFilter; class PresenceOracle; + class Roster; + class RosterGroupExpandinessPersister; + class RosterVCardProvider; + class SettingsProvider; class SubscriptionManager; - class EventController; class SubscriptionRequestEvent; class UIEventStream; - class IQRouter; - class SettingsProvider; - class NickManager; - class EntityCapsProvider; - class FileTransferManager; - class ClientBlockListManager; - class RosterVCardProvider; + class VCardManager; + class XMPPRoster; + class XMPPRosterItem; class RosterController { public: - RosterController(const JID& jid, XMPPRoster* xmppRoster, AvatarManager* avatarManager, MainWindowFactory* mainWindowFactory, NickManager* nickManager, NickResolver* nickResolver, PresenceOracle* presenceOracle, SubscriptionManager* subscriptionManager, EventController* eventController, UIEventStream* uiEventStream, IQRouter* iqRouter_, SettingsProvider* settings, EntityCapsProvider* entityCapsProvider, FileTransferOverview* fileTransferOverview, ClientBlockListManager* clientBlockListManager, VCardManager* vcardManager); + RosterController(const JID& jid, XMPPRoster* xmppRoster, AvatarManager* avatarManager, MainWindowFactory* mainWindowFactory, NickManager* nickManager, NickResolver* nickResolver, PresenceOracle* presenceOracle, SubscriptionManager* subscriptionManager, EventController* eventController, UIEventStream* uiEventStream, IQRouter* iqRouter, SettingsProvider* settings, EntityCapsProvider* entityCapsProvider, FileTransferOverview* fileTransferOverview, ClientBlockListManager* clientBlockListManager, VCardManager* vcardManager); ~RosterController(); void showRosterWindow(); void setJID(const JID& jid) { myJID_ = jid; } diff --git a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp index c396e48..9320af1 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp @@ -1,6 +1,5 @@ - /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -28,11 +27,10 @@ #include <Swiften/Queries/DummyIQChannel.h> #include <Swiften/Queries/IQRouter.h> #include <Swiften/Roster/XMPPRosterImpl.h> +#include <Swiften/VCards/VCardManager.h> #include <Swiften/VCards/VCardMemoryStorage.h> -// #include <Swiften/Elements/Payload.h> -// #include <Swiften/Elements/RosterItemPayload.h> -// #include <Swiften/Elements/RosterPayload.h> +#include <Swift/Controllers/FileTransfer/FileTransferOverview.h> #include <Swift/Controllers/Roster/ContactRosterItem.h> #include <Swift/Controllers/Roster/GroupRosterItem.h> #include <Swift/Controllers/Roster/Roster.h> @@ -62,6 +60,7 @@ class RosterControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST(testHighestPresence); CPPUNIT_TEST(testNotHighestPresence); CPPUNIT_TEST(testUnavailablePresence); + CPPUNIT_TEST(testRemoveResultsInUnavailablePresence); CPPUNIT_TEST_SUITE_END(); public: @@ -75,7 +74,7 @@ class RosterControllerTest : public CppUnit::TestFixture { channel_ = new DummyIQChannel(); router_ = new IQRouter(channel_); stanzaChannel_ = new DummyStanzaChannel(); - presenceOracle_ = new PresenceOracle(stanzaChannel_); + presenceOracle_ = new PresenceOracle(stanzaChannel_, xmppRoster_); subscriptionManager_ = new SubscriptionManager(stanzaChannel_); eventController_ = new EventController(); uiEventStream_ = new UIEventStream(); @@ -319,6 +318,29 @@ class RosterControllerTest : public CppUnit::TestFixture { assertVectorsEqual(groups, item.getGroups(), __LINE__); } + void testRemoveResultsInUnavailablePresence() { + std::vector<std::string> groups; + groups.push_back("testGroup1"); + JID from("test@testdomain.com"); + xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both); + Presence::ref lowPresence(new Presence()); + lowPresence->setFrom(withResource(from, "bob")); + lowPresence->setPriority(2); + lowPresence->setStatus("Not here"); + Presence::ref highPresence(new Presence()); + highPresence->setFrom(withResource(from, "bert")); + highPresence->setPriority(10); + highPresence->setStatus("So totally here"); + stanzaChannel_->onPresenceReceived(highPresence); + stanzaChannel_->onPresenceReceived(lowPresence); + + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), presenceOracle_->getAllPresence("test@testdomain.com").size()); + + xmppRoster_->onJIDRemoved(JID("test@testdomain.com")); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), presenceOracle_->getAllPresence("test@testdomain.com").size()); + CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, presenceOracle_->getAllPresence("test@testdomain.com")[0]->getType()); + } + void assertVectorsEqual(const std::vector<std::string>& v1, const std::vector<std::string>& v2, int line) { foreach (const std::string& entry, v1) { if (std::find(v2.begin(), v2.end(), entry) == v2.end()) { |