summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-03 17:11:45 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-03 17:11:45 (GMT)
commit3dd69f2f852953638b220352b0eeee10464da5d8 (patch)
tree9edda54359e2624ef8221d8148213e0060811ead /Swiften/Controllers
parentbc41379bdb1ea19757914f45743ed97c999ce9e1 (diff)
downloadswift-contrib-3dd69f2f852953638b220352b0eeee10464da5d8.zip
swift-contrib-3dd69f2f852953638b220352b0eeee10464da5d8.tar.bz2
Pull requesting the roster out of the XMPPRosterController constructor.
Diffstat (limited to 'Swiften/Controllers')
-rw-r--r--Swiften/Controllers/MainController.cpp3
-rw-r--r--Swiften/Controllers/UnitTest/XMPPRosterControllerTest.cpp11
-rw-r--r--Swiften/Controllers/XMPPRosterController.cpp11
-rw-r--r--Swiften/Controllers/XMPPRosterController.h4
4 files changed, 21 insertions, 8 deletions
diff --git a/Swiften/Controllers/MainController.cpp b/Swiften/Controllers/MainController.cpp
index e0d0fe7..5535bf8 100644
--- a/Swiften/Controllers/MainController.cpp
+++ b/Swiften/Controllers/MainController.cpp
@@ -87,6 +87,7 @@ void MainController::handleConnected() {
delete xmppRosterController_;
xmppRosterController_ = new XMPPRosterController(client_, xmppRoster);
+ xmppRosterController_->requestRoster();
delete clientVersionResponder_;
clientVersionResponder_ = new SoftwareVersionResponder(CLIENT_NAME, CLIENT_VERSION, client_);
@@ -106,7 +107,7 @@ void MainController::handleConnected() {
//Send presence last to catch all the incoming presences.
boost::shared_ptr<Presence> initialPresence(new Presence());
- initialPresence->addPayload(capsInfo_);
+ initialPresence->addPayload(capsInfo_);
client_->sendPresence(initialPresence);
}
diff --git a/Swiften/Controllers/UnitTest/XMPPRosterControllerTest.cpp b/Swiften/Controllers/UnitTest/XMPPRosterControllerTest.cpp
index 3bff8f3..17cc31c 100644
--- a/Swiften/Controllers/UnitTest/XMPPRosterControllerTest.cpp
+++ b/Swiften/Controllers/UnitTest/XMPPRosterControllerTest.cpp
@@ -22,9 +22,14 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture
DummyIQChannel* channel_;
IQRouter* router_;
public:
- XMPPRosterControllerTest() : channel_(new DummyIQChannel()), router_(new IQRouter(channel_)) {}
-
- ~XMPPRosterControllerTest() {
+ XMPPRosterControllerTest() {}
+
+ void setUp() {
+ channel_ = new DummyIQChannel();
+ router_ = new IQRouter(channel_);
+ }
+
+ void tearDown() {
delete channel_;
delete router_;
}
diff --git a/Swiften/Controllers/XMPPRosterController.cpp b/Swiften/Controllers/XMPPRosterController.cpp
index b6c36d7..d1e6f80 100644
--- a/Swiften/Controllers/XMPPRosterController.cpp
+++ b/Swiften/Controllers/XMPPRosterController.cpp
@@ -22,16 +22,19 @@ namespace Swift {
* The controller does not gain ownership of these parameters.
*/
XMPPRosterController::XMPPRosterController(IQRouter* iqRouter, boost::shared_ptr<XMPPRoster> xmppRoster)
- : IQHandler(iqRouter), xmppRoster_(xmppRoster) {
- GetRosterRequest* rosterRequest = new GetRosterRequest(iqRouter, Request::AutoDeleteAfterResponse);
- rosterRequest->onResponse.connect(boost::bind(&XMPPRosterController::handleRosterReceived, this, _1));
- rosterRequest->send();
+ : IQHandler(iqRouter), iqRouter_(iqRouter), xmppRoster_(xmppRoster) {
}
XMPPRosterController::~XMPPRosterController() {
}
+void XMPPRosterController::requestRoster() {
+ GetRosterRequest* rosterRequest = new GetRosterRequest(iqRouter_, Request::AutoDeleteAfterResponse);
+ rosterRequest->onResponse.connect(boost::bind(&XMPPRosterController::handleRosterReceived, this, _1));
+ rosterRequest->send();
+}
+
void XMPPRosterController::handleRosterReceived(boost::shared_ptr<RosterPayload> rosterPayload) {
foreach(const RosterItemPayload& item, rosterPayload->getItems()) {
if (item.getSubscription() == RosterItemPayload::Remove) {
diff --git a/Swiften/Controllers/XMPPRosterController.h b/Swiften/Controllers/XMPPRosterController.h
index 2eaa6f5..7695ff5 100644
--- a/Swiften/Controllers/XMPPRosterController.h
+++ b/Swiften/Controllers/XMPPRosterController.h
@@ -17,10 +17,14 @@ namespace Swift {
public:
XMPPRosterController(IQRouter *iqRouter, boost::shared_ptr<XMPPRoster> xmppRoster);
~XMPPRosterController();
+
+ void requestRoster();
+
boost::shared_ptr<XMPPRoster> getXMPPRoster() {return xmppRoster_;};
bool handleIQ(boost::shared_ptr<IQ>);
private:
+ IQRouter* iqRouter_;
void handleRosterReceived(boost::shared_ptr<RosterPayload> rosterPayload);
boost::shared_ptr<XMPPRoster> xmppRoster_;
};