diff options
-rw-r--r-- | Slimber/Server.cpp | 2 | ||||
-rw-r--r-- | Slimber/Server.h | 2 | ||||
-rw-r--r-- | Swiften/LinkLocal/DNSSD/DNSSDServiceID.cpp | 2 | ||||
-rw-r--r-- | Swiften/LinkLocal/DNSSD/DNSSDServiceID.h | 2 | ||||
-rw-r--r-- | Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp | 2 | ||||
-rw-r--r-- | Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp | 23 |
6 files changed, 29 insertions, 4 deletions
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index c3c3d22..39f4233 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -69,7 +69,7 @@ void Server::handleNewLinkLocalConnection(boost::shared_ptr<Connection> connecti registerLinkLocalSession(session); } -void Server::handleServiceRegistered(const LinkLocalServiceID& service) { +void Server::handleServiceRegistered(const DNSSDServiceID& service) { std::cout << "Service registered " << service.getName() << " " << service.getType() << " " << service.getDomain() << std::endl; selfJID_ = JID(service.getName()); } diff --git a/Slimber/Server.h b/Slimber/Server.h index b40f576..9167106 100644 --- a/Slimber/Server.h +++ b/Slimber/Server.h @@ -33,7 +33,7 @@ namespace Swift { private: void handleNewClientConnection(boost::shared_ptr<Connection> c); void handleNewLinkLocalConnection(boost::shared_ptr<Connection> connection); - void handleServiceRegistered(const LinkLocalServiceID& service); + void handleServiceRegistered(const DNSSDServiceID& service); void handleSessionStarted(); void handleSessionFinished(boost::shared_ptr<ServerFromClientSession>); void handleLinkLocalSessionFinished(boost::shared_ptr<Session> session); diff --git a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.cpp b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.cpp index 06a5b81..b360ee5 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.cpp +++ b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.cpp @@ -2,6 +2,6 @@ namespace Swift { -const String DNSSDServiceID::PresenceServiceType = String("_presence._tcp"); +const char* DNSSDServiceID::PresenceServiceType = "_presence._tcp"; } diff --git a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h index 5243662..ba7828b 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h +++ b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h @@ -5,7 +5,7 @@ namespace Swift { class DNSSDServiceID { public: - static const String PresenceServiceType; + static const char* PresenceServiceType; DNSSDServiceID( const String& name, diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp index 4b66398..e9501cb 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp @@ -49,6 +49,8 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { removedServices.clear(); changedServices.clear(); + delete aliceServiceID; + delete aliceServiceInfo; delete testServiceInfo2; delete testServiceInfo; delete testServiceID; diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp index b850f14..68f191a 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp @@ -10,6 +10,7 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture { CPPUNIT_TEST(testGetTXTRecord); CPPUNIT_TEST(testCreateFromTXTRecord); CPPUNIT_TEST(testCreateFromTXTRecord_InvalidSize); + CPPUNIT_TEST(testGetTXTRecordCreateFromTXTRecord_RoundTrip); CPPUNIT_TEST_SUITE_END(); public: @@ -37,6 +38,28 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(String("a"), info.getLastName()); } + + void testGetTXTRecordCreateFromTXTRecord_RoundTrip() { + LinkLocalServiceInfo info; + info.setFirstName("Remko"); + info.setLastName("Tron\xc3\xe7on"); + info.setEMail("remko-email@swift.im"); + info.setJID(JID("remko-jid@swift.im")); + info.setMessage("I'm busy"); + info.setNick("el-tramo"); + info.setStatus(LinkLocalServiceInfo::DND); + info.setPort(1234); + + LinkLocalServiceInfo info2 = LinkLocalServiceInfo::createFromTXTRecord(info.toTXTRecord()); + CPPUNIT_ASSERT_EQUAL(info.getFirstName(), info2.getFirstName()); + CPPUNIT_ASSERT_EQUAL(info.getLastName(), info2.getLastName()); + CPPUNIT_ASSERT_EQUAL(info.getEMail(), info2.getEMail()); + CPPUNIT_ASSERT_EQUAL(info.getJID(), info2.getJID()); + CPPUNIT_ASSERT_EQUAL(info.getMessage(), info2.getMessage()); + CPPUNIT_ASSERT_EQUAL(info.getNick(), info2.getNick()); + CPPUNIT_ASSERT(info.getStatus() == info2.getStatus()); + CPPUNIT_ASSERT(info.getPort() == info2.getPort()); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(LinkLocalServiceInfoTest); |