Changeset - 5e0208ef296b
[Not reviewed]
0 3 0
Darchigh - 12 years ago 2013-01-10 14:24:54
Darchigh@gmail.com
fixed bad formatting
3 files changed with 33 insertions and 32 deletions:
0 comments (0 inline, 0 general)
include/transport/userregistration.h
Show inline comments
 
@@ -71,7 +71,7 @@ class UserRegistration : public Swift::Responder<Swift::InBandRegistrationPayloa
 
		virtual bool handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::InBandRegistrationPayload> payload);
 
		virtual bool handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::InBandRegistrationPayload> payload);
 
                
 
                void handleRegisterRemoteRosterResponse(boost::shared_ptr<Swift::RosterPayload> payload, Swift::ErrorPayload::ref error, const UserInfo &row);
 
        void handleRegisterRemoteRosterResponse(boost::shared_ptr<Swift::RosterPayload> payload, Swift::ErrorPayload::ref error, const UserInfo &row);
 
		void handleUnregisterRemoteRosterResponse(boost::shared_ptr<Swift::RosterPayload> payload, Swift::ErrorPayload::ref error, const std::string &barejid);
 
		
 
		Component *m_component;
src/tests/userregistration.cpp
Show inline comments
 
@@ -26,7 +26,7 @@ class UserRegistrationTest : public CPPUNIT_NS :: TestFixture, public BasicTest
 
	CPPUNIT_TEST(getForm);
 
	CPPUNIT_TEST(getFormRegistered);
 
	CPPUNIT_TEST(registerUser);
 
        CPPUNIT_TEST(registerUserWithoutRR);
 
    CPPUNIT_TEST(registerUserWithoutRR);
 
	CPPUNIT_TEST(unregisterUser);
 
	CPPUNIT_TEST(unregisterEmptyPayload);
 
	CPPUNIT_TEST(registerUserNotify);
 
@@ -87,7 +87,7 @@ class UserRegistrationTest : public CPPUNIT_NS :: TestFixture, public BasicTest
 
		}
 

	
 
		void registerUser() {
 
                        Swift::InBandRegistrationPayload *reg = new Swift::InBandRegistrationPayload();
 
            Swift::InBandRegistrationPayload *reg = new Swift::InBandRegistrationPayload();
 
			reg->setUsername("legacyname");
 
			reg->setPassword("password");
 
			boost::shared_ptr<Swift::IQ> iq = Swift::IQ::createRequest(Swift::IQ::Set, Swift::JID("localhost"), "id", boost::shared_ptr<Swift::Payload>(reg));
 
@@ -102,27 +102,27 @@ class UserRegistrationTest : public CPPUNIT_NS :: TestFixture, public BasicTest
 
			CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[1])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[1]))->getType());
 
                        
 
                        iq = Swift::IQ::createResult(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID(), boost::shared_ptr<Swift::Payload>(new Swift::RosterPayload()));
 
            iq = Swift::IQ::createResult(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID(), boost::shared_ptr<Swift::Payload>(new Swift::RosterPayload()));
 
			received.clear();
 
			injectIQ(iq);
 
			loop->processEvents();
 
                                                
 
                        CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
 
            CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
 
			CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Set, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
 
                        CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
            CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
                        
 
                        CPPUNIT_ASSERT_EQUAL(std::string("localhost"), getStanza(received[0])->getPayload<Swift::RosterPayload>()->getItems()[0].getJID().toString());
 
            CPPUNIT_ASSERT_EQUAL(std::string("localhost"), getStanza(received[0])->getPayload<Swift::RosterPayload>()->getItems()[0].getJID().toString());
 
                                             
 
                        UserInfo user;
 
            UserInfo user;
 
			CPPUNIT_ASSERT_EQUAL(true, storage->getUser("user@localhost", user));
 

	
 
			CPPUNIT_ASSERT_EQUAL(std::string("legacyname"), user.uin);
 
			CPPUNIT_ASSERT_EQUAL(std::string("password"), user.password);
 
                        }
 
        }
 
                
 
                void registerUserWithoutRR(){
 
                        Swift::InBandRegistrationPayload *reg = new Swift::InBandRegistrationPayload();
 
        void registerUserWithoutRR(){
 
            Swift::InBandRegistrationPayload *reg = new Swift::InBandRegistrationPayload();
 
			reg->setUsername("legacyname");
 
			reg->setPassword("password");
 
			boost::shared_ptr<Swift::IQ> iq = Swift::IQ::createRequest(Swift::IQ::Set, Swift::JID("localhost"), "id", boost::shared_ptr<Swift::Payload>(reg));
 
@@ -132,18 +132,18 @@ class UserRegistrationTest : public CPPUNIT_NS :: TestFixture, public BasicTest
 
                                               
 
			CPPUNIT_ASSERT_EQUAL(2, (int) received.size());
 
                        
 
                        CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
                        CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[1])));
 
            CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
            CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[1])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[1]))->getType());
 
                        
 
                        iq = Swift::IQ::createError(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID());
 
                        received.clear();
 
            iq = Swift::IQ::createError(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID());
 
            received.clear();
 
			injectIQ(iq);
 
			loop->processEvents();
 
                                                             
 
                    	CPPUNIT_ASSERT(dynamic_cast<Swift::Presence *>(getStanza(received[0])));
 
            CPPUNIT_ASSERT(dynamic_cast<Swift::Presence *>(getStanza(received[0])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::Presence::Subscribe, dynamic_cast<Swift::Presence *>(getStanza(received[0]))->getType());
 
                }
 
        }
 
                
 
		void unregisterUser() {
 
			registerUser();
 
@@ -189,23 +189,23 @@ class UserRegistrationTest : public CPPUNIT_NS :: TestFixture, public BasicTest
 
			injectIQ(iq);
 
			loop->processEvents();
 
                      
 
                        CPPUNIT_ASSERT_EQUAL(2, (int) received.size());
 
            CPPUNIT_ASSERT_EQUAL(2, (int) received.size());
 
                        
 
                        CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
            CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
			CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[1])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[1]))->getType());
 
                        
 
                        iq = Swift::IQ::createResult(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID(), boost::shared_ptr<Swift::Payload>(new Swift::RosterPayload()));
 
            iq = Swift::IQ::createResult(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID(), boost::shared_ptr<Swift::Payload>(new Swift::RosterPayload()));
 
			received.clear();
 
			injectIQ(iq);
 
			loop->processEvents();
 
                        
 
                        CPPUNIT_ASSERT_EQUAL(2, (int) received.size());
 
            CPPUNIT_ASSERT_EQUAL(2, (int) received.size());
 
                        
 
                        CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
 
            CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Set, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
 
                        CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
                        CPPUNIT_ASSERT_EQUAL(std::string("localhost"), getStanza(received[0])->getPayload<Swift::RosterPayload>()->getItems()[0].getJID().toString());
 
            CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
            CPPUNIT_ASSERT_EQUAL(std::string("localhost"), getStanza(received[0])->getPayload<Swift::RosterPayload>()->getItems()[0].getJID().toString());
 
                        
 
			CPPUNIT_ASSERT(dynamic_cast<Swift::Message *>(getStanza(received[1])));
 
			CPPUNIT_ASSERT_EQUAL(std::string("registered: user@localhost"), dynamic_cast<Swift::Message *>(getStanza(received[1]))->getBody());
 
@@ -343,17 +343,17 @@ class UserRegistrationTest : public CPPUNIT_NS :: TestFixture, public BasicTest
 
			CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[1])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[1]))->getType());
 
                        
 
                        iq = Swift::IQ::createResult(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID(), boost::shared_ptr<Swift::Payload>(new Swift::RosterPayload()));
 
            iq = Swift::IQ::createResult(Swift::JID("localhost"), getStanza(received[0])->getTo(), getStanza(received[0])->getID(), boost::shared_ptr<Swift::Payload>(new Swift::RosterPayload()));
 
			received.clear();
 
			injectIQ(iq);
 
			loop->processEvents();
 
                                                
 
                        CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
 
            CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
 
			CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Set, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
 
                        CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
            CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::RosterPayload>());
 
                        
 
                        CPPUNIT_ASSERT_EQUAL(std::string("localhost"), getStanza(received[0])->getPayload<Swift::RosterPayload>()->getItems()[0].getJID().toString());
 
            CPPUNIT_ASSERT_EQUAL(std::string("localhost"), getStanza(received[0])->getPayload<Swift::RosterPayload>()->getItems()[0].getJID().toString());
 

	
 
			UserInfo user;
 
			CPPUNIT_ASSERT_EQUAL(true, storage->getUser("user@localhost", user));
src/userregistration.cpp
Show inline comments
 
@@ -56,10 +56,10 @@ bool UserRegistration::registerUser(const UserInfo &row) {
 

	
 
	m_storageBackend->setUser(row);
 
        
 
        //same as in unregisterUser but here we have to pass UserInfo to handleRegisterRRResponse
 
        AddressedRosterRequest::ref request = AddressedRosterRequest::ref(new AddressedRosterRequest(m_component->getIQRouter(),row.jid));
 
        request->onResponse.connect(boost::bind(&UserRegistration::handleRegisterRemoteRosterResponse, this, _1, _2, row));
 
        request->send();
 
    //same as in unregisterUser but here we have to pass UserInfo to handleRegisterRRResponse
 
    AddressedRosterRequest::ref request = AddressedRosterRequest::ref(new AddressedRosterRequest(m_component->getIQRouter(),row.jid));
 
    request->onResponse.connect(boost::bind(&UserRegistration::handleRegisterRemoteRosterResponse, this, _1, _2, row));
 
    request->send();
 

	
 
	return true;
 
}
 
@@ -80,6 +80,7 @@ bool UserRegistration::unregisterUser(const std::string &barejid) {
 

	
 
	return true;
 
}
 

	
 
void UserRegistration::handleRegisterRemoteRosterResponse(boost::shared_ptr<Swift::RosterPayload> payload, Swift::ErrorPayload::ref remoteRosterNotSupported /*error*/, const UserInfo &row){
 
    if (remoteRosterNotSupported || !payload) {     
 
	Swift::Presence::ref response = Swift::Presence::create();
0 comments (0 inline, 0 general)