diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-03-22 21:51:36 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-03-22 21:51:36 (GMT) |
commit | 2e86507010e1f8754049a3bb37ce9041bb19d870 (patch) | |
tree | ecd3b8ed0b33c12bf123f4042af41fbc2d245e4b | |
parent | 0c377fa93ffd8538da9e71ddc71d4e8c07600a22 (diff) | |
download | swift-contrib-2e86507010e1f8754049a3bb37ce9041bb19d870.zip swift-contrib-2e86507010e1f8754049a3bb37ce9041bb19d870.tar.bz2 |
Fixing up the unit tests again. Oops.
-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 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 5 | ||||
-rw-r--r-- | Swiften/Roster/UnitTest/XMPPRosterTest.cpp | 16 |
8 files changed, 46 insertions, 16 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"))); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index ebafaff..618a887 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -5,6 +5,8 @@ #include "QtSwiftUtil.h" #include "Roster/QtTreeWidgetFactory.h" #include "Roster/QtTreeWidget.h" +#include "Swift/Controllers/UIEvents/AddContactUIEvent.h" + #include <QBoxLayout> #include <QComboBox> @@ -89,7 +91,8 @@ void QtMainWindow::handleSignOutAction() { } void QtMainWindow::handleAddContactDialogComplete(const JID& contact, const QString& name) { - onAddContactRequest(contact, Q2PSTRING(name)); + boost::shared_ptr<UIEvent> event(new AddContactUIEvent(contact, Q2PSTRING(name))); + uiEventStream_->send(event); } TreeWidget* QtMainWindow::getTreeWidget() { diff --git a/Swiften/Roster/UnitTest/XMPPRosterTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterTest.cpp index 96de30c..d03953e 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterTest.cpp @@ -102,13 +102,13 @@ class XMPPRosterTest : public CppUnit::TestFixture } void testJIDAdded() { - roster_->addContact(jid1_, "NewName", groups1_); + roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); - roster_->addContact(jid2_, "NameTwo", groups1_); + roster_->addContact(jid2_, "NameTwo", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid2_)); @@ -116,7 +116,7 @@ class XMPPRosterTest : public CppUnit::TestFixture CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid2_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); - roster_->addContact(jid3_, "NewName", groups2_); + roster_->addContact(jid3_, "NewName", groups2_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid3_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid3_)); @@ -124,17 +124,17 @@ class XMPPRosterTest : public CppUnit::TestFixture } void testJIDRemoved() { - roster_->addContact(jid1_, "NewName", groups1_); + roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both); handler_->reset(); roster_->removeContact(jid1_); CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); handler_->reset(); - roster_->addContact(jid1_, "NewName2", groups1_); + roster_->addContact(jid1_, "NewName2", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(String("NewName2"), roster_->getNameForJID(jid1_)); - roster_->addContact(jid2_, "NewName3", groups1_); + roster_->addContact(jid2_, "NewName3", groups1_, RosterItemPayload::Both); handler_->reset(); roster_->removeContact(jid2_); CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent()); @@ -146,13 +146,13 @@ class XMPPRosterTest : public CppUnit::TestFixture } void testJIDUpdated() { - roster_->addContact(jid1_, "NewName", groups1_); + roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); - roster_->addContact(jid1_, "NameTwo", groups2_); + roster_->addContact(jid1_, "NameTwo", groups2_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid1_)); |