diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/MainWindow.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/RosterController.cpp | 9 | ||||
-rw-r--r-- | Swift/Controllers/RosterController.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/AddContactUIEvent.h | 17 | ||||
-rw-r--r-- | Swift/Controllers/UnitTest/NickResolverTest.cpp | 10 | ||||
-rw-r--r-- | Swift/Controllers/UnitTest/RosterControllerTest.cpp | 2 |
6 files changed, 34 insertions, 7 deletions
diff --git a/Swift/Controllers/MainWindow.h b/Swift/Controllers/MainWindow.h index b15cbb5..07ff703 100644 --- a/Swift/Controllers/MainWindow.h +++ b/Swift/Controllers/MainWindow.h @@ -21,7 +21,6 @@ namespace Swift { virtual void setMyStatusType(StatusShow::Type type) = 0; boost::signal<void (const JID&)> onStartChatRequest; - boost::signal<void (const JID&, const String&)> onAddContactRequest; boost::signal<void (const JID&, const String&)> onJoinMUCRequest; boost::signal<void (StatusShow::Type, const String&)> onChangeStatusRequest; boost::signal<void (bool)> onShowOfflineToggled; diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index 8d13057..0fc80eb 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -18,6 +18,7 @@ #include "Swiften/Roster/OpenChatRosterAction.h" #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Roster/XMPPRoster.h" +#include "Swift/Controllers/UIEvents/AddContactUIEvent.h" namespace Swift { @@ -41,6 +42,7 @@ RosterController::RosterController(const JID& jid, boost::shared_ptr<XMPPRoster> xmppRoster_->onJIDRemoved.connect(boost::bind(&RosterController::handleOnJIDRemoved, this, _1)); presenceOracle_->onPresenceSubscriptionRequest.connect(boost::bind(&RosterController::handleSubscriptionRequest, this, _1, _2)); presenceOracle_->onPresenceChange.connect(boost::bind(&RosterController::handleIncomingPresence, this, _1, _2)); + uiEventStream->onUIEvent.connect(boost::bind(&RosterController::handleUIEvent, this, _1)); avatarManager_ = NULL; setAvatarManager(avatarManager); setNickResolver(nickResolver); @@ -137,6 +139,13 @@ void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, } +void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) { + boost::shared_ptr<AddContactUIEvent> addContactEvent = boost::dynamic_pointer_cast<AddContactUIEvent>(event); + if (addContactEvent) { + presenceOracle_->requestSubscription(addContactEvent->getJID()); + } +} + void RosterController::handleIncomingPresence(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> /*oldPresence*/) { roster_->applyOnItems(SetPresence(newPresence)); } diff --git a/Swift/Controllers/RosterController.h b/Swift/Controllers/RosterController.h index cef0e48..4f1da1a 100644 --- a/Swift/Controllers/RosterController.h +++ b/Swift/Controllers/RosterController.h @@ -6,6 +6,7 @@ #include "Swiften/Elements/Presence.h" #include "Swiften/Roster/UserRosterAction.h" #include "Swiften/Avatars/AvatarManager.h" +#include "Swift/Controllers/UIEvents/UIEvent.h" #include <boost/signals.hpp> #include <boost/shared_ptr.hpp> @@ -51,6 +52,7 @@ namespace Swift { void handleSubscriptionRequest(const JID& jid, const String& message); void handleSubscriptionRequestAccepted(SubscriptionRequestEvent* event); void handleSubscriptionRequestDeclined(SubscriptionRequestEvent* event); + void handleUIEvent(boost::shared_ptr<UIEvent> event); JID myJID_; boost::shared_ptr<XMPPRoster> xmppRoster_; MainWindowFactory* mainWindowFactory_; diff --git a/Swift/Controllers/UIEvents/AddContactUIEvent.h b/Swift/Controllers/UIEvents/AddContactUIEvent.h new file mode 100644 index 0000000..8ff4d51 --- /dev/null +++ b/Swift/Controllers/UIEvents/AddContactUIEvent.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Swiften/Base/String.h" + +#include "Swift/Controllers/UIEvents/UIEvent.h" + +namespace Swift { + class AddContactUIEvent : public UIEvent { + public: + AddContactUIEvent(const JID& jid, const String& name) : jid_(jid), name_(name) {}; + String getName() {return name_;}; + JID getJID() {return jid_;}; + private: + JID jid_; + String name_; + }; +} diff --git a/Swift/Controllers/UnitTest/NickResolverTest.cpp b/Swift/Controllers/UnitTest/NickResolverTest.cpp index e3123f9..6f509c0 100644 --- a/Swift/Controllers/UnitTest/NickResolverTest.cpp +++ b/Swift/Controllers/UnitTest/NickResolverTest.cpp @@ -33,7 +33,7 @@ class NickResolverTest : public CppUnit::TestFixture boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster()); NickResolver resolver(xmppRoster); JID testJID("foo@bar/baz"); - xmppRoster->addContact(testJID, "", groups_); + xmppRoster->addContact(testJID, "", groups_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver.jidToNick(testJID)); } @@ -41,7 +41,7 @@ class NickResolverTest : public CppUnit::TestFixture boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster()); NickResolver resolver(xmppRoster); JID testJID("foo@bar/baz"); - xmppRoster->addContact(testJID, "Test", groups_); + xmppRoster->addContact(testJID, "Test", groups_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(String("Test"), resolver.jidToNick(testJID)); } @@ -50,8 +50,8 @@ class NickResolverTest : public CppUnit::TestFixture boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster()); NickResolver resolver(xmppRoster); JID testJID("foo@bar/baz"); - xmppRoster->addContact(testJID, "FailTest", groups_); - xmppRoster->addContact(testJID, "Test", groups_); + xmppRoster->addContact(testJID, "FailTest", groups_, RosterItemPayload::Both); + xmppRoster->addContact(testJID, "Test", groups_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(String("Test"), resolver.jidToNick(testJID)); } @@ -60,7 +60,7 @@ class NickResolverTest : public CppUnit::TestFixture boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster()); NickResolver resolver(xmppRoster); JID testJID("foo@bar/baz"); - xmppRoster->addContact(testJID, "FailTest", groups_); + xmppRoster->addContact(testJID, "FailTest", groups_, RosterItemPayload::Both); xmppRoster->removeContact(testJID); CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver.jidToNick(testJID)); } diff --git a/Swift/Controllers/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/UnitTest/RosterControllerTest.cpp index bfd98ac..80b2284 100644 --- a/Swift/Controllers/UnitTest/RosterControllerTest.cpp +++ b/Swift/Controllers/UnitTest/RosterControllerTest.cpp @@ -64,7 +64,7 @@ class RosterControllerTest : public CppUnit::TestFixture std::vector<String> groups; groups.push_back("testGroup1"); groups.push_back("testGroup2"); - xmppRoster_->addContact(JID("test@testdomain.com/bob"), "name", groups); + xmppRoster_->addContact(JID("test@testdomain.com/bob"), "name", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(2, (int)treeWidgetFactory_->getGroups().size()); //CPPUNIT_ASSERT_EQUAL(String("Bob"), xmppRoster_->getNameForJID(JID("foo@bar.com"))); |