diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-02-14 18:57:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-02-14 21:36:32 (GMT) |
commit | cb05f5a908e20006c954ce38755c2e422ecc2388 (patch) | |
tree | a793551a5fe279a57d4330119560e8542f745484 /Swiften/LinkLocal | |
parent | cad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff) | |
download | swift-cb05f5a908e20006c954ce38755c2e422ecc2388.zip swift-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2 |
Removed Swift::String.
Diffstat (limited to 'Swiften/LinkLocal')
28 files changed, 122 insertions, 122 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp index f9f2f8f..dd189d9 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp @@ -25,7 +25,7 @@ boost::shared_ptr<DNSSDBrowseQuery> AvahiQuerier::createBrowseQuery() { return boost::shared_ptr<DNSSDBrowseQuery>(new AvahiBrowseQuery(shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const String& name, int port, const ByteArray& info) { +boost::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) { return boost::shared_ptr<DNSSDRegisterQuery>(new AvahiRegisterQuery(name, port, info, shared_from_this(), eventLoop)); } @@ -33,7 +33,7 @@ boost::shared_ptr<DNSSDResolveServiceQuery> AvahiQuerier::createResolveServiceQu return boost::shared_ptr<DNSSDResolveServiceQuery>(new AvahiResolveServiceQuery(service, shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDResolveHostnameQuery> AvahiQuerier::createResolveHostnameQuery(const String& hostname, int interfaceIndex) { +boost::shared_ptr<DNSSDResolveHostnameQuery> AvahiQuerier::createResolveHostnameQuery(const std::string& hostname, int interfaceIndex) { return boost::shared_ptr<DNSSDResolveHostnameQuery>(new AvahiResolveHostnameQuery(hostname, interfaceIndex, shared_from_this(), eventLoop)); } diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h index d900ade..bfb017e 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h @@ -30,11 +30,11 @@ namespace Swift { boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery(); boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info); + const std::string& name, int port, const ByteArray& info); boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&); boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex); + const std::string& hostname, int interfaceIndex); void start(); void stop(); diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h index 780a0ca..07966af 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h @@ -18,7 +18,7 @@ namespace Swift { class AvahiRegisterQuery : public DNSSDRegisterQuery, public AvahiQuery { public: - AvahiRegisterQuery(const String& name, int port, const ByteArray& txtRecord, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) { + AvahiRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) { } void registerService() { @@ -58,7 +58,7 @@ namespace Swift { AvahiStringList* txtList; avahi_string_list_parse(txtRecord.getData(), txtRecord.getSize(), &txtList); - int result = avahi_entry_group_add_service_strlst(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, static_cast<AvahiPublishFlags>(0), name.getUTF8Data(), "_presence._tcp", NULL, NULL, port, txtList); + int result = avahi_entry_group_add_service_strlst(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, static_cast<AvahiPublishFlags>(0), name.c_str(), "_presence._tcp", NULL, NULL, port, txtList); if (result < 0) { std::cout << "Error registering service: " << avahi_strerror(result) << std::endl; eventLoop->postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); @@ -100,7 +100,7 @@ namespace Swift { /* DNSServiceErrorType result = DNSServiceRegister( - &sdRef, 0, 0, name.getUTF8Data(), "_presence._tcp", NULL, NULL, port, + &sdRef, 0, 0, name.c_str(), "_presence._tcp", NULL, NULL, port, txtRecord.getSize(), txtRecord.getData(), &AvahiRegisterQuery::handleServiceRegisteredStatic, this); if (result != kDNSServiceErr_NoError) { @@ -125,7 +125,7 @@ namespace Swift { */ private: - String name; + std::string name; int port; ByteArray txtRecord; AvahiEntryGroup* group; diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h index ebbc68f..00712f1 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/Avahi/AvahiQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" #include "Swiften/EventLoop/EventLoop.h" @@ -19,7 +19,7 @@ namespace Swift { class AvahiResolveHostnameQuery : public DNSSDResolveHostnameQuery, public AvahiQuery { public: - AvahiResolveHostnameQuery(const String& hostname, int, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), hostname(hostname) { + AvahiResolveHostnameQuery(const std::string& hostname, int, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), hostname(hostname) { std::cout << "Resolving hostname " << hostname << std::endl; } @@ -32,6 +32,6 @@ namespace Swift { private: HostAddress hostAddress; - String hostname; + std::string hostname; }; } diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h index a7985ec..e9c4db1 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h @@ -24,7 +24,7 @@ namespace Swift { std::cout << "Start resolving " << service.getName() << " " << service.getType() << " " << service.getDomain() << std::endl; avahi_threaded_poll_lock(querier->getThreadedPoll()); assert(!resolver); - resolver = avahi_service_resolver_new(querier->getClient(), service.getNetworkInterfaceID(), AVAHI_PROTO_UNSPEC, service.getName().getUTF8Data(), service.getType().getUTF8Data(), service.getDomain().getUTF8Data(), AVAHI_PROTO_UNSPEC, static_cast<AvahiLookupFlags>(0), handleServiceResolvedStatic, this); + resolver = avahi_service_resolver_new(querier->getClient(), service.getNetworkInterfaceID(), AVAHI_PROTO_UNSPEC, service.getName().c_str(), service.getType().c_str(), service.getDomain().c_str(), AVAHI_PROTO_UNSPEC, static_cast<AvahiLookupFlags>(0), handleServiceResolvedStatic, this); if (!resolver) { std::cout << "Error starting resolver" << std::endl; eventLoop->postEvent(boost::bind(boost::ref(onServiceResolved), boost::optional<Result>()), shared_from_this()); @@ -62,12 +62,12 @@ namespace Swift { avahi_string_list_serialize(txt, txtRecord.getData(), txtRecord.getSize()); // FIXME: Probably not accurate - String fullname = String(name) + "." + String(type) + "." + String(domain) + "."; - std::cout << "Result: " << fullname << "->" << String(a) << ":" << port << std::endl; + std::string fullname = std::string(name) + "." + std::string(type) + "." + std::string(domain) + "."; + std::cout << "Result: " << fullname << "->" << std::string(a) << ":" << port << std::endl; eventLoop->postEvent( boost::bind( boost::ref(onServiceResolved), - Result(fullname, String(a), port, txtRecord)), + Result(fullname, std::string(a), port, txtRecord)), shared_from_this()); break; } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp index 03271d6..2d346d9 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp @@ -35,7 +35,7 @@ boost::shared_ptr<DNSSDBrowseQuery> BonjourQuerier::createBrowseQuery() { return boost::shared_ptr<DNSSDBrowseQuery>(new BonjourBrowseQuery(shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const String& name, int port, const ByteArray& info) { +boost::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) { return boost::shared_ptr<DNSSDRegisterQuery>(new BonjourRegisterQuery(name, port, info, shared_from_this(), eventLoop)); } @@ -43,7 +43,7 @@ boost::shared_ptr<DNSSDResolveServiceQuery> BonjourQuerier::createResolveService return boost::shared_ptr<DNSSDResolveServiceQuery>(new BonjourResolveServiceQuery(service, shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDResolveHostnameQuery> BonjourQuerier::createResolveHostnameQuery(const String& hostname, int interfaceIndex) { +boost::shared_ptr<DNSSDResolveHostnameQuery> BonjourQuerier::createResolveHostnameQuery(const std::string& hostname, int interfaceIndex) { return boost::shared_ptr<DNSSDResolveHostnameQuery>(new BonjourResolveHostnameQuery(hostname, interfaceIndex, shared_from_this(), eventLoop)); } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h index 916acc3..edd3056 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h @@ -27,11 +27,11 @@ namespace Swift { boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery(); boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info); + const std::string& name, int port, const ByteArray& info); boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&); boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex); + const std::string& hostname, int interfaceIndex); void start(); void stop(); diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h index 9d8516b..7eb7ae1 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h @@ -16,9 +16,9 @@ namespace Swift { class BonjourRegisterQuery : public DNSSDRegisterQuery, public BonjourQuery { public: - BonjourRegisterQuery(const String& name, int port, const ByteArray& txtRecord, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { + BonjourRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { DNSServiceErrorType result = DNSServiceRegister( - &sdRef, 0, 0, name.getUTF8Data(), "_presence._tcp", NULL, NULL, port, + &sdRef, 0, 0, name.c_str(), "_presence._tcp", NULL, NULL, port, txtRecord.getSize(), txtRecord.getData(), &BonjourRegisterQuery::handleServiceRegisteredStatic, this); if (result != kDNSServiceErr_NoError) { diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h index 16e9be6..b08b0b7 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h @@ -8,7 +8,7 @@ #pragma GCC diagnostic ignored "-Wold-style-cast" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" #include "Swiften/EventLoop/EventLoop.h" @@ -21,10 +21,10 @@ namespace Swift { class BonjourResolveHostnameQuery : public DNSSDResolveHostnameQuery, public BonjourQuery { public: - BonjourResolveHostnameQuery(const String& hostname, int interfaceIndex, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { + BonjourResolveHostnameQuery(const std::string& hostname, int interfaceIndex, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { DNSServiceErrorType result = DNSServiceGetAddrInfo( &sdRef, 0, interfaceIndex, kDNSServiceProtocol_IPv4, - hostname.getUTF8Data(), + hostname.c_str(), &BonjourResolveHostnameQuery::handleHostnameResolvedStatic, this); if (result != kDNSServiceErr_NoError) { sdRef = NULL; diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h index 136b366..0501b56 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h @@ -20,8 +20,8 @@ namespace Swift { BonjourResolveServiceQuery(const DNSSDServiceID& service, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { DNSServiceErrorType result = DNSServiceResolve( &sdRef, 0, service.getNetworkInterfaceID(), - service.getName().getUTF8Data(), service.getType().getUTF8Data(), - service.getDomain().getUTF8Data(), + service.getName().c_str(), service.getType().c_str(), + service.getDomain().c_str(), &BonjourResolveServiceQuery::handleServiceResolvedStatic, this); if (result != kDNSServiceErr_NoError) { sdRef = NULL; @@ -55,7 +55,7 @@ namespace Swift { eventLoop->postEvent( boost::bind( boost::ref(onServiceResolved), - Result(String(fullName), String(host), port, + Result(std::string(fullName), std::string(host), port, ByteArray(reinterpret_cast<const char*>(txtRecord), txtLen))), shared_from_this()); } diff --git a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h index 21c4bdc..cd55fb7 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h +++ b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> namespace Swift { - class String; + class ByteArray; class DNSSDServiceID; class DNSSDBrowseQuery; @@ -26,10 +26,10 @@ namespace Swift { virtual boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery() = 0; virtual boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info) = 0; + const std::string& name, int port, const ByteArray& info) = 0; virtual boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&) = 0; virtual boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex) = 0; + const std::string& hostname, int interfaceIndex) = 0; }; } diff --git a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h index b5ce232..ad73663 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h +++ b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h @@ -16,10 +16,10 @@ namespace Swift { class DNSSDResolveServiceQuery { public: struct Result { - Result(const String& fullName, const String& host, int port, const ByteArray& info) : + Result(const std::string& fullName, const std::string& host, int port, const ByteArray& info) : fullName(fullName), host(host), port(port), info(info) {} - String fullName; - String host; + std::string fullName; + std::string host; int port; ByteArray info; }; diff --git a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h index 1a720a0..9ce0781 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h +++ b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class DNSSDServiceID { @@ -14,9 +14,9 @@ namespace Swift { static const char* PresenceServiceType; DNSSDServiceID( - const String& name, - const String& domain, - const String& type = PresenceServiceType, + const std::string& name, + const std::string& domain, + const std::string& type = PresenceServiceType, int networkInterface = -1) : name(name), domain(domain), @@ -47,15 +47,15 @@ namespace Swift { } } - const String& getName() const { + const std::string& getName() const { return name; } - const String& getDomain() const { + const std::string& getDomain() const { return domain; } - const String& getType() const { + const std::string& getType() const { return type; } @@ -64,9 +64,9 @@ namespace Swift { } private: - String name; - String domain; - String type; + std::string name; + std::string domain; + std::string type; int networkInterface; }; } diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp index 0bcdba1..d7d0228 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp @@ -16,7 +16,7 @@ namespace Swift { -FakeDNSSDQuerier::FakeDNSSDQuerier(const String& domain, EventLoop* eventLoop) : domain(domain), eventLoop(eventLoop) { +FakeDNSSDQuerier::FakeDNSSDQuerier(const std::string& domain, EventLoop* eventLoop) : domain(domain), eventLoop(eventLoop) { } FakeDNSSDQuerier::~FakeDNSSDQuerier() { @@ -29,7 +29,7 @@ boost::shared_ptr<DNSSDBrowseQuery> FakeDNSSDQuerier::createBrowseQuery() { return boost::shared_ptr<DNSSDBrowseQuery>(new FakeDNSSDBrowseQuery(shared_from_this())); } -boost::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const String& name, int port, const ByteArray& info) { +boost::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) { return boost::shared_ptr<DNSSDRegisterQuery>(new FakeDNSSDRegisterQuery(name, port, info, shared_from_this())); } @@ -37,7 +37,7 @@ boost::shared_ptr<DNSSDResolveServiceQuery> FakeDNSSDQuerier::createResolveServi return boost::shared_ptr<DNSSDResolveServiceQuery>(new FakeDNSSDResolveServiceQuery(service, shared_from_this())); } -boost::shared_ptr<DNSSDResolveHostnameQuery> FakeDNSSDQuerier::createResolveHostnameQuery(const String& hostname, int interfaceIndex) { +boost::shared_ptr<DNSSDResolveHostnameQuery> FakeDNSSDQuerier::createResolveHostnameQuery(const std::string& hostname, int interfaceIndex) { return boost::shared_ptr<DNSSDResolveHostnameQuery>(new FakeDNSSDResolveHostnameQuery(hostname, interfaceIndex, shared_from_this())); } @@ -61,7 +61,7 @@ void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) eventLoop->postEvent(boost::bind(boost::ref(registerQuery->onRegisterFinished), service), shared_from_this()); } else if (boost::shared_ptr<FakeDNSSDResolveHostnameQuery> resolveHostnameQuery = boost::dynamic_pointer_cast<FakeDNSSDResolveHostnameQuery>(query)) { - std::map<String,boost::optional<HostAddress> >::const_iterator i = addresses.find(resolveHostnameQuery->hostname); + std::map<std::string,boost::optional<HostAddress> >::const_iterator i = addresses.find(resolveHostnameQuery->hostname); if (i != addresses.end()) { eventLoop->postEvent( boost::bind( @@ -103,7 +103,7 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol } } -bool FakeDNSSDQuerier::isServiceRegistered(const String& name, int port, const ByteArray& info) { +bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, int port, const ByteArray& info) { foreach(const boost::shared_ptr<FakeDNSSDRegisterQuery>& query, getQueries<FakeDNSSDRegisterQuery>()) { if (query->name == name && query->port == port && query->info == info) { return true; @@ -124,7 +124,7 @@ void FakeDNSSDQuerier::setRegisterError() { } } -void FakeDNSSDQuerier::setAddress(const String& hostname, boost::optional<HostAddress> address) { +void FakeDNSSDQuerier::setAddress(const std::string& hostname, boost::optional<HostAddress> address) { addresses[hostname] = address; foreach(const boost::shared_ptr<FakeDNSSDResolveHostnameQuery>& query, getQueries<FakeDNSSDResolveHostnameQuery>()) { if (query->hostname == hostname) { diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h index 9338dd4..b2871c9 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h @@ -12,7 +12,7 @@ #include <set> #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/EventLoop/EventOwner.h" #include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h" @@ -29,7 +29,7 @@ namespace Swift { public EventOwner, public boost::enable_shared_from_this<FakeDNSSDQuerier> { public: - FakeDNSSDQuerier(const String& domain, EventLoop* eventLoop); + FakeDNSSDQuerier(const std::string& domain, EventLoop* eventLoop); ~FakeDNSSDQuerier(); void start() {} @@ -41,11 +41,11 @@ namespace Swift { boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery(); boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info); + const std::string& name, int port, const ByteArray& info); boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&); boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex); + const std::string& hostname, int interfaceIndex); void addRunningQuery(boost::shared_ptr<FakeDNSSDQuery>); void removeRunningQuery(boost::shared_ptr<FakeDNSSDQuery>); @@ -53,8 +53,8 @@ namespace Swift { void addService(const DNSSDServiceID& id); void removeService(const DNSSDServiceID& id); void setServiceInfo(const DNSSDServiceID& id, const DNSSDResolveServiceQuery::Result& info); - bool isServiceRegistered(const String& name, int port, const ByteArray& info); - void setAddress(const String& hostname, boost::optional<HostAddress> address); + bool isServiceRegistered(const std::string& name, int port, const ByteArray& info); + void setAddress(const std::string& hostname, boost::optional<HostAddress> address); void setBrowseError(); void setRegisterError(); @@ -84,13 +84,13 @@ namespace Swift { } private: - String domain; + std::string domain; EventLoop* eventLoop; std::list< boost::shared_ptr<FakeDNSSDQuery> > runningQueries; std::list< boost::shared_ptr<FakeDNSSDQuery> > allQueriesEverRun; std::set<DNSSDServiceID> services; typedef std::map<DNSSDServiceID,DNSSDResolveServiceQuery::Result> ServiceInfoMap; ServiceInfoMap serviceInfo; - std::map<String, boost::optional<HostAddress> > addresses; + std::map<std::string, boost::optional<HostAddress> > addresses; }; } diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h index dc144b3..a6ae17a 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h @@ -9,14 +9,14 @@ #include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDRegisterQuery.h" #include "Swiften/Base/ByteArray.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class FakeDNSSDQuerier; class FakeDNSSDRegisterQuery : public DNSSDRegisterQuery, public FakeDNSSDQuery { public: - FakeDNSSDRegisterQuery(const String& name, int port, const ByteArray& info, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) { + FakeDNSSDRegisterQuery(const std::string& name, int port, const ByteArray& info, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) { } void registerService() { @@ -31,7 +31,7 @@ namespace Swift { finish(); } - String name; + std::string name; int port; ByteArray info; }; diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h index b19bfe9..cbaa6e6 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" #include "Swiften/Network/HostAddress.h" @@ -16,7 +16,7 @@ namespace Swift { class FakeDNSSDResolveHostnameQuery : public DNSSDResolveHostnameQuery, public FakeDNSSDQuery { public: - FakeDNSSDResolveHostnameQuery(const String& hostname, int interfaceIndex, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), hostname(hostname), interfaceIndex(interfaceIndex) { + FakeDNSSDResolveHostnameQuery(const std::string& hostname, int interfaceIndex, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), hostname(hostname), interfaceIndex(interfaceIndex) { } void run() { @@ -27,7 +27,7 @@ namespace Swift { FakeDNSSDQuery::finish(); } - String hostname; + std::string hostname; int interfaceIndex; }; } diff --git a/Swiften/LinkLocal/IncomingLinkLocalSession.h b/Swiften/LinkLocal/IncomingLinkLocalSession.h index 2973330..a586a2e 100644 --- a/Swiften/LinkLocal/IncomingLinkLocalSession.h +++ b/Swiften/LinkLocal/IncomingLinkLocalSession.h @@ -15,7 +15,7 @@ namespace Swift { class ProtocolHeader; - class String; + class Element; class PayloadParserFactoryCollection; class PayloadSerializerCollection; diff --git a/Swiften/LinkLocal/LinkLocalService.cpp b/Swiften/LinkLocal/LinkLocalService.cpp index d67361c..c8d707d 100644 --- a/Swiften/LinkLocal/LinkLocalService.cpp +++ b/Swiften/LinkLocal/LinkLocalService.cpp @@ -8,19 +8,19 @@ namespace Swift { -String LinkLocalService::getDescription() const { +std::string LinkLocalService::getDescription() const { LinkLocalServiceInfo info = getInfo(); - if (!info.getNick().isEmpty()) { + if (!info.getNick().empty()) { return info.getNick(); } - else if (!info.getFirstName().isEmpty()) { - String result = info.getFirstName(); - if (!info.getLastName().isEmpty()) { + else if (!info.getFirstName().empty()) { + std::string result = info.getFirstName(); + if (!info.getLastName().empty()) { result += " " + info.getLastName(); } return result; } - else if (!info.getLastName().isEmpty()) { + else if (!info.getLastName().empty()) { return info.getLastName(); } return getName(); diff --git a/Swiften/LinkLocal/LinkLocalService.h b/Swiften/LinkLocal/LinkLocalService.h index 27491e4..2e74338 100644 --- a/Swiften/LinkLocal/LinkLocalService.h +++ b/Swiften/LinkLocal/LinkLocalService.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/LinkLocal/DNSSD/DNSSDServiceID.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h" @@ -25,7 +25,7 @@ namespace Swift { return id; } - const String& getName() const { + const std::string& getName() const { return id.getName(); } @@ -33,7 +33,7 @@ namespace Swift { return info.port; } - const String& getHostname() const { + const std::string& getHostname() const { return info.host; } @@ -41,7 +41,7 @@ namespace Swift { return LinkLocalServiceInfo::createFromTXTRecord(info.info); } - String getDescription() const; + std::string getDescription() const; JID getJID() const; diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp index efd56e3..8393ade 100644 --- a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp @@ -63,7 +63,7 @@ bool LinkLocalServiceBrowser::isRegistered() const { return registerQuery; } -void LinkLocalServiceBrowser::registerService(const String& name, int port, const LinkLocalServiceInfo& info) { +void LinkLocalServiceBrowser::registerService(const std::string& name, int port, const LinkLocalServiceInfo& info) { assert(!registerQuery); registerQuery = querier->createRegisterQuery(name, port, info.toTXTRecord()); registerQuery->onRegisterFinished.connect( diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.h b/Swiften/LinkLocal/LinkLocalServiceBrowser.h index 6918150..56b4aa4 100644 --- a/Swiften/LinkLocal/LinkLocalServiceBrowser.h +++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.h @@ -12,7 +12,7 @@ #include <map> #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDRegisterQuery.h" @@ -32,7 +32,7 @@ namespace Swift { bool hasError() const; void registerService( - const String& name, + const std::string& name, int port, const LinkLocalServiceInfo& info = LinkLocalServiceInfo()); void updateService( diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp index cdde354..bec2e97 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp @@ -12,26 +12,26 @@ namespace Swift { ByteArray LinkLocalServiceInfo::toTXTRecord() const { ByteArray result(getEncoded("txtvers=1")); - if (!firstName.isEmpty()) { + if (!firstName.empty()) { result += getEncoded("1st=" + firstName); } - if (!lastName.isEmpty()) { + if (!lastName.empty()) { result += getEncoded("last=" + lastName); } - if (!email.isEmpty()) { + if (!email.empty()) { result += getEncoded("email=" + email); } if (jid.isValid()) { result += getEncoded("jid=" + jid.toString()); } - if (!message.isEmpty()) { + if (!message.empty()) { result += getEncoded("msg=" + message); } - if (!nick.isEmpty()) { + if (!nick.empty()) { result += getEncoded("nick=" + nick); } if (port) { - result += getEncoded("port.p2pj=" + String(boost::lexical_cast<std::string>(*port))); + result += getEncoded("port.p2pj=" + std::string(boost::lexical_cast<std::string>(*port))); } switch (status) { @@ -43,10 +43,10 @@ ByteArray LinkLocalServiceInfo::toTXTRecord() const { return result; } -ByteArray LinkLocalServiceInfo::getEncoded(const String& s) { +ByteArray LinkLocalServiceInfo::getEncoded(const std::string& s) { ByteArray sizeByte; sizeByte.resize(1); - sizeByte[0] = s.getUTF8Size(); + sizeByte[0] = s.size(); return sizeByte + ByteArray(s); } @@ -54,8 +54,8 @@ LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray& LinkLocalServiceInfo info; size_t i = 0; while (i < record.getSize()) { - std::pair<String,String> entry = readEntry(record, &i); - if (entry.first.isEmpty()) { + std::pair<std::string,std::string> entry = readEntry(record, &i); + if (entry.first.empty()) { break; } else if (entry.first == "1st") { @@ -91,10 +91,10 @@ LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray& return info; } -std::pair<String,String> LinkLocalServiceInfo::readEntry(const ByteArray& record, size_t* index) { +std::pair<std::string,std::string> LinkLocalServiceInfo::readEntry(const ByteArray& record, size_t* index) { size_t& i = *index; - String key; - String value; + std::string key; + std::string value; size_t entryEnd = i + 1 + record[i]; ++i; diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.h b/Swiften/LinkLocal/LinkLocalServiceInfo.h index efe9245..a166c64 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.h +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.h @@ -9,7 +9,7 @@ #include <boost/optional.hpp> #include "Swiften/Base/ByteArray.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -20,23 +20,23 @@ namespace Swift { LinkLocalServiceInfo() : status(Available) {} - const String& getFirstName() const { return firstName; } - void setFirstName(const String& f) { firstName = f; } + const std::string& getFirstName() const { return firstName; } + void setFirstName(const std::string& f) { firstName = f; } - const String& getLastName() const { return lastName; } - void setLastName(const String& l) { lastName = l; } + const std::string& getLastName() const { return lastName; } + void setLastName(const std::string& l) { lastName = l; } - const String& getEMail() const { return email; } - void setEMail(const String& e) { email = e; } + const std::string& getEMail() const { return email; } + void setEMail(const std::string& e) { email = e; } const JID& getJID() const { return jid; } void setJID(const JID& j) { jid = j; } - const String& getMessage() const { return message; } - void setMessage(const String& m) { message = m; } + const std::string& getMessage() const { return message; } + void setMessage(const std::string& m) { message = m; } - const String& getNick() const { return nick; } - void setNick(const String& n) { nick = n; } + const std::string& getNick() const { return nick; } + void setNick(const std::string& n) { nick = n; } Status getStatus() const { return status; } void setStatus(Status s) { status = s; } @@ -49,16 +49,16 @@ namespace Swift { static LinkLocalServiceInfo createFromTXTRecord(const ByteArray& record); private: - static ByteArray getEncoded(const String&); - static std::pair<String,String> readEntry(const ByteArray&, size_t*); + static ByteArray getEncoded(const std::string&); + static std::pair<std::string,std::string> readEntry(const ByteArray&, size_t*); private: - String firstName; - String lastName; - String email; + std::string firstName; + std::string lastName; + std::string email; JID jid; - String message; - String nick; + std::string message; + std::string nick; Status status; boost::optional<int> port; }; diff --git a/Swiften/LinkLocal/OutgoingLinkLocalSession.h b/Swiften/LinkLocal/OutgoingLinkLocalSession.h index 2c339bb..34ea411 100644 --- a/Swiften/LinkLocal/OutgoingLinkLocalSession.h +++ b/Swiften/LinkLocal/OutgoingLinkLocalSession.h @@ -16,7 +16,7 @@ namespace Swift { class ConnectionFactory; - class String; + class Element; class PayloadParserFactoryCollection; class PayloadSerializerCollection; diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp index 65b8a67..98deed1 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp @@ -51,7 +51,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(connectFinished); CPPUNIT_ASSERT(!connectError); CPPUNIT_ASSERT(connection->connectedTo); - CPPUNIT_ASSERT_EQUAL(String(connection->connectedTo->getAddress().toString()), String("192.168.1.1")); + CPPUNIT_ASSERT_EQUAL(std::string(connection->connectedTo->getAddress().toString()), std::string("192.168.1.1")); CPPUNIT_ASSERT_EQUAL(connection->connectedTo->getPort(), 1234); } @@ -113,7 +113,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture { } private: - boost::shared_ptr<LinkLocalConnector> createConnector(const String& hostname, int port) { + boost::shared_ptr<LinkLocalConnector> createConnector(const std::string& hostname, int port) { LinkLocalService service( DNSSDServiceID("myname", "local."), DNSSDResolveServiceQuery::Result( diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp index 1e0ee8a..3943e31 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp @@ -28,21 +28,21 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture { info.setLastName("Tron\xc3\xe7on"); info.setStatus(LinkLocalServiceInfo::Away); - CPPUNIT_ASSERT_EQUAL(ByteArray("\x09txtvers=1\x09" + String("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), info.toTXTRecord()); + CPPUNIT_ASSERT_EQUAL(ByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), info.toTXTRecord()); } void testCreateFromTXTRecord() { - LinkLocalServiceInfo info = LinkLocalServiceInfo::createFromTXTRecord(ByteArray("\x09txtvers=1\x09" + String("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away"))); + LinkLocalServiceInfo info = LinkLocalServiceInfo::createFromTXTRecord(ByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away"))); - CPPUNIT_ASSERT_EQUAL(String("Remko"), info.getFirstName()); - CPPUNIT_ASSERT_EQUAL(String("Tron\xc3\xe7on"), info.getLastName()); + CPPUNIT_ASSERT_EQUAL(std::string("Remko"), info.getFirstName()); + CPPUNIT_ASSERT_EQUAL(std::string("Tron\xc3\xe7on"), info.getLastName()); CPPUNIT_ASSERT_EQUAL(LinkLocalServiceInfo::Away, info.getStatus()); } void testCreateFromTXTRecord_InvalidSize() { LinkLocalServiceInfo info = LinkLocalServiceInfo::createFromTXTRecord(ByteArray("\x10last=a")); - CPPUNIT_ASSERT_EQUAL(String("a"), info.getLastName()); + CPPUNIT_ASSERT_EQUAL(std::string("a"), info.getLastName()); } void testGetTXTRecordCreateFromTXTRecord_RoundTrip() { diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp index 0d4de13..4835bde 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp @@ -24,35 +24,35 @@ class LinkLocalServiceTest : public CppUnit::TestFixture { void testGetDescription_WithNick() { LinkLocalService testling = createService("alice@wonderland", "Alice", "Alice In", "Wonderland"); - CPPUNIT_ASSERT_EQUAL(String("Alice"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), testling.getDescription()); } void testGetDescription_WithFirstName() { LinkLocalService testling = createService("alice@wonderland", "", "Alice In"); - CPPUNIT_ASSERT_EQUAL(String("Alice In"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In"), testling.getDescription()); } void testGetDescription_WithLastName() { LinkLocalService testling = createService("alice@wonderland", "", "", "Wonderland"); - CPPUNIT_ASSERT_EQUAL(String("Wonderland"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), testling.getDescription()); } void testGetDescription_WithFirstAndLastName() { LinkLocalService testling = createService("alice@wonderland", "", "Alice In", "Wonderland"); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), testling.getDescription()); } void testGetDescription_NoInfo() { LinkLocalService testling = createService("alice@wonderland"); - CPPUNIT_ASSERT_EQUAL(String("alice@wonderland"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("alice@wonderland"), testling.getDescription()); } private: - LinkLocalService createService(const String& name, const String& nickName = String(), const String& firstName = String(), const String& lastName = String()) { + LinkLocalService createService(const std::string& name, const std::string& nickName = std::string(), const std::string& firstName = std::string(), const std::string& lastName = std::string()) { DNSSDServiceID service(name, "local."); LinkLocalServiceInfo info; info.setFirstName(firstName); |