From cb05f5a908e20006c954ce38755c2e422ecc2388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Mon, 14 Feb 2011 19:57:18 +0100 Subject: Removed Swift::String. diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h index 1354ebf..7533a1e 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h @@ -14,14 +14,14 @@ class EchoPayload : public Payload { public: EchoPayload() {} - const String& getMessage() const { + const std::string& getMessage() const { return message; } - void setMessage(const String& message) { + void setMessage(const std::string& message) { this->message = message; } private: - String message; + std::string message; }; diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h index 3af616c..9cbb795 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h @@ -16,24 +16,24 @@ class EchoPayloadParser : public GenericPayloadParser { EchoPayloadParser() : currentDepth(0) {} void handleStartElement( - const String& /* element */, const String& /* ns */, const AttributeMap&) { + const std::string& /* element */, const std::string& /* ns */, const AttributeMap&) { currentDepth++; } - void handleEndElement(const String& /* element */, const String& /* ns */) { + void handleEndElement(const std::string& /* element */, const std::string& /* ns */) { currentDepth--; if (currentDepth == 0) { getPayloadInternal()->setMessage(currentText); } } - void handleCharacterData(const String& data) { + void handleCharacterData(const std::string& data) { currentText += data; } private: int currentDepth; - String currentText; + std::string currentText; }; class EchoPayloadParserFactory : public GenericPayloadParserFactory { diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h index 1b18be4..85e8e67 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h @@ -13,7 +13,7 @@ using namespace Swift; class EchoPayloadSerializer : public GenericPayloadSerializer { public: - String serializePayload(boost::shared_ptr payload) const { + std::string serializePayload(boost::shared_ptr payload) const { XMLElement element("echo", "http://swift.im/protocol/echo"); element.addNode(XMLTextNode::ref(new XMLTextNode(payload->getMessage()))); return element.serialize(); diff --git a/Slimber/CLI/DummyMenulet.h b/Slimber/CLI/DummyMenulet.h index e0bcb2f..56cc9ce 100644 --- a/Slimber/CLI/DummyMenulet.h +++ b/Slimber/CLI/DummyMenulet.h @@ -16,7 +16,7 @@ class DummyMenulet : public Menulet { void clear() { } - void addItem(const Swift::String&, const Swift::String&) { + void addItem(const std::string&, const std::string&) { } void addAboutItem() { @@ -31,6 +31,6 @@ class DummyMenulet : public Menulet { void addSeparator() { } - void setIcon(const Swift::String&) { + void setIcon(const std::string&) { } }; diff --git a/Slimber/Cocoa/CocoaMenulet.h b/Slimber/Cocoa/CocoaMenulet.h index 292c8b9..7f2758b 100644 --- a/Slimber/Cocoa/CocoaMenulet.h +++ b/Slimber/Cocoa/CocoaMenulet.h @@ -18,9 +18,9 @@ class CocoaMenulet : public Menulet { private: virtual void clear(); - virtual void addItem(const Swift::String& name, const Swift::String& icon); + virtual void addItem(const std::string& name, const std::string& icon); virtual void addSeparator(); - void setIcon(const Swift::String& icon); + void setIcon(const std::string& icon); virtual void addAboutItem(); virtual void addRestartItem(); virtual void addExitItem(); diff --git a/Slimber/Cocoa/CocoaMenulet.mm b/Slimber/Cocoa/CocoaMenulet.mm index 90e699f..de9e9e9 100644 --- a/Slimber/Cocoa/CocoaMenulet.mm +++ b/Slimber/Cocoa/CocoaMenulet.mm @@ -4,8 +4,6 @@ #include -using namespace Swift; - CocoaMenulet::CocoaMenulet() { restartAction = [[CocoaAction alloc] initWithFunction: new boost::function(boost::ref(onRestartClicked))]; @@ -25,9 +23,9 @@ CocoaMenulet::~CocoaMenulet() { [restartAction release]; } -void CocoaMenulet::setIcon(const String& icon) { +void CocoaMenulet::setIcon(const std::string& icon) { NSString* path = [[NSBundle mainBundle] pathForResource: - [NSString stringWithUTF8String: icon.getUTF8Data()] ofType:@"png"]; + [NSString stringWithUTF8String: icon.c_str()] ofType:@"png"]; NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; [statusItem setImage: image]; [image release]; @@ -39,13 +37,13 @@ void CocoaMenulet::clear() { } } -void CocoaMenulet::addItem(const Swift::String& name, const String& icon) { +void CocoaMenulet::addItem(const std::string& name, const std::string& icon) { NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: - [NSString stringWithUTF8String: name.getUTF8Data()] + [NSString stringWithUTF8String: name.c_str()] action: NULL keyEquivalent: @""]; - if (!icon.isEmpty()) { + if (!icon.empty()) { NSString* path = [[NSBundle mainBundle] pathForResource: - [NSString stringWithUTF8String: icon.getUTF8Data()] ofType:@"png"]; + [NSString stringWithUTF8String: icon.c_str()] ofType:@"png"]; NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; [item setImage: [[NSImage alloc] initWithContentsOfFile: path]]; [image release]; diff --git a/Slimber/FileVCardCollection.cpp b/Slimber/FileVCardCollection.cpp index 6a8b6b1..9fab068 100644 --- a/Slimber/FileVCardCollection.cpp +++ b/Slimber/FileVCardCollection.cpp @@ -26,7 +26,7 @@ boost::shared_ptr FileVCardCollection::getOwnVCard() const { VCardParser parser; PayloadParserTester tester(&parser); - tester.parse(String(data.getData(), data.getSize())); + tester.parse(std::string(data.getData(), data.getSize())); return boost::dynamic_pointer_cast(parser.getPayload()); } else { diff --git a/Slimber/LinkLocalPresenceManager.cpp b/Slimber/LinkLocalPresenceManager.cpp index 465d849..edb7e91 100644 --- a/Slimber/LinkLocalPresenceManager.cpp +++ b/Slimber/LinkLocalPresenceManager.cpp @@ -70,19 +70,19 @@ RosterItemPayload LinkLocalPresenceManager::getRosterItem(const LinkLocalService return RosterItemPayload(service.getJID(), getRosterName(service), RosterItemPayload::Both); } -String LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const { +std::string LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const { LinkLocalServiceInfo info = service.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 ""; diff --git a/Slimber/LinkLocalPresenceManager.h b/Slimber/LinkLocalPresenceManager.h index 25069fa..26bb7ce 100644 --- a/Slimber/LinkLocalPresenceManager.h +++ b/Slimber/LinkLocalPresenceManager.h @@ -10,7 +10,7 @@ #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Elements/RosterItemPayload.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" namespace Swift { @@ -37,7 +37,7 @@ namespace Swift { void handleServiceRemoved(const LinkLocalService&); RosterItemPayload getRosterItem(const LinkLocalService& service) const; - String getRosterName(const LinkLocalService& service) const; + std::string getRosterName(const LinkLocalService& service) const; boost::shared_ptr getPresence(const LinkLocalService& service) const; private: diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp index e6c2ab5..e39a660 100644 --- a/Slimber/MainController.cpp +++ b/Slimber/MainController.cpp @@ -86,9 +86,9 @@ void MainController::handleSelfConnected(bool b) { } void MainController::handleServicesChanged() { - std::vector names; + std::vector names; foreach(const LinkLocalService& service, linkLocalServiceBrowser->getServices()) { - String description = service.getDescription(); + std::string description = service.getDescription(); if (description != service.getName()) { description += " (" + service.getName() + ")"; } @@ -99,19 +99,19 @@ void MainController::handleServicesChanged() { void MainController::handleServerStopped(boost::optional error) { if (error) { - String message; + std::string message; switch (error->getType()) { case ServerError::C2SPortConflict: - message = String("Error: Port ") + boost::lexical_cast(server->getClientToServerPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast(server->getClientToServerPort()) + std::string(" in use"); break; case ServerError::C2SError: - message = String("Local connection server error"); + message = std::string("Local connection server error"); break; case ServerError::LinkLocalPortConflict: - message = String("Error: Port ") + boost::lexical_cast(server->getLinkLocalPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast(server->getLinkLocalPort()) + std::string(" in use"); break; case ServerError::LinkLocalError: - message = String("External connection server error"); + message = std::string("External connection server error"); break; } menuletController->setXMPPStatus(message, MenuletController::Offline); diff --git a/Slimber/Menulet.h b/Slimber/Menulet.h index 6ecdcc5..df3c32c 100644 --- a/Slimber/Menulet.h +++ b/Slimber/Menulet.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/boost_bsignals.h" class Menulet { @@ -14,12 +14,12 @@ class Menulet { virtual ~Menulet(); virtual void clear() = 0; - virtual void addItem(const Swift::String& name, const Swift::String& icon = Swift::String()) = 0; + virtual void addItem(const std::string& name, const std::string& icon = std::string()) = 0; virtual void addAboutItem() = 0; virtual void addRestartItem() = 0; virtual void addExitItem() = 0; virtual void addSeparator() = 0; - virtual void setIcon(const Swift::String&) = 0; + virtual void setIcon(const std::string&) = 0; boost::signal onRestartClicked; }; diff --git a/Slimber/MenuletController.cpp b/Slimber/MenuletController.cpp index 1155c81..351db21 100644 --- a/Slimber/MenuletController.cpp +++ b/Slimber/MenuletController.cpp @@ -7,13 +7,11 @@ #include "Slimber/MenuletController.h" #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include #include "Slimber/Menulet.h" #include -using namespace Swift; - MenuletController::MenuletController(Menulet* menulet) : menulet(menulet), xmppStatus(Offline) { menulet->onRestartClicked.connect(boost::ref(onRestartRequested)); @@ -23,13 +21,13 @@ MenuletController::MenuletController(Menulet* menulet) : MenuletController::~MenuletController() { } -void MenuletController::setXMPPStatus(const String& message, Status status) { +void MenuletController::setXMPPStatus(const std::string& message, Status status) { xmppStatus = status; xmppStatusMessage = message; update(); } -void MenuletController::setUserNames(const std::vector& users) { +void MenuletController::setUserNames(const std::vector& users) { linkLocalUsers = users; update(); } @@ -43,8 +41,8 @@ void MenuletController::update() { else { menulet->setIcon("UsersOnline"); menulet->addItem("Online users:"); - foreach(const String& user, linkLocalUsers) { - menulet->addItem(String(" ") + user); + foreach(const std::string& user, linkLocalUsers) { + menulet->addItem(std::string(" ") + user); } } menulet->addSeparator(); diff --git a/Slimber/MenuletController.h b/Slimber/MenuletController.h index 6b7f6fd..31b2d83 100644 --- a/Slimber/MenuletController.h +++ b/Slimber/MenuletController.h @@ -9,7 +9,7 @@ #include #include -#include "Swiften/Base/String.h" +#include class Menulet; @@ -23,8 +23,8 @@ class MenuletController { MenuletController(Menulet*); virtual ~MenuletController(); - void setXMPPStatus(const Swift::String& message, Status status); - void setUserNames(const std::vector&); + void setXMPPStatus(const std::string& message, Status status); + void setUserNames(const std::vector&); boost::signal onRestartRequested; @@ -34,6 +34,6 @@ class MenuletController { private: Menulet* menulet; Status xmppStatus; - Swift::String xmppStatusMessage; - std::vector linkLocalUsers; + std::string xmppStatusMessage; + std::vector linkLocalUsers; }; diff --git a/Slimber/Qt/QtMenulet.h b/Slimber/Qt/QtMenulet.h index 08bae0c..01a9db1 100644 --- a/Slimber/Qt/QtMenulet.h +++ b/Slimber/Qt/QtMenulet.h @@ -30,8 +30,8 @@ class QtMenulet : public QObject, public Menulet { menu.clear(); } - void addItem(const Swift::String& name, const Swift::String& icon) { - menu.addAction(getIcon(icon), QString::fromUtf8(name.getUTF8Data())); + void addItem(const std::string& name, const std::string& icon) { + menu.addAction(getIcon(icon), QString::fromUtf8(name.c_str())); } void addAboutItem() { @@ -50,13 +50,13 @@ class QtMenulet : public QObject, public Menulet { menu.addSeparator(); } - void setIcon(const Swift::String& icon) { + void setIcon(const std::string& icon) { trayIcon.setIcon(getIcon(icon)); } private: - QPixmap getIcon(const Swift::String& name) { - return QPixmap(":/icons/" + QString::fromUtf8(name.getUTF8Data()) + ".png"); + QPixmap getIcon(const std::string& name) { + return QPixmap(":/icons/" + QString::fromUtf8(name.c_str()) + ".png"); } private slots: diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index b8cffb0..380ce6a 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -9,6 +9,7 @@ #include #include +#include "Swiften/Base/String.h" #include "Swiften/LinkLocal/LinkLocalConnector.h" #include "Swiften/Network/Connection.h" #include "Swiften/Session/SessionTracer.h" @@ -21,7 +22,7 @@ #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/VCard.h" #include "Swiften/Server/UserRegistry.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/LinkLocal/LinkLocalServiceInfo.h" #include "Swiften/LinkLocal/OutgoingLinkLocalSession.h" #include "Swiften/LinkLocal/IncomingLinkLocalSession.h" @@ -397,19 +398,19 @@ void Server::handleLinkLocalConnectionServerStopped(boost::optional presence) { LinkLocalServiceInfo info; boost::shared_ptr vcard = vCardCollection->getOwnVCard(); - if (!vcard->getFamilyName().isEmpty() || !vcard->getGivenName().isEmpty()) { + if (!vcard->getFamilyName().empty() || !vcard->getGivenName().empty()) { info.setFirstName(vcard->getGivenName()); info.setLastName(vcard->getFamilyName()); } - else if (!vcard->getFullName().isEmpty()) { - std::pair p = vcard->getFullName().getSplittedAtFirst(' '); + else if (!vcard->getFullName().empty()) { + std::pair p = String::getSplittedAtFirst(vcard->getFullName(), ' '); info.setFirstName(p.first); info.setLastName(p.second); } - if (!vcard->getNickname().isEmpty()) { + if (!vcard->getNickname().empty()) { info.setNick(vcard->getNickname()); } - if (!vcard->getPreferredEMailAddress().address.isEmpty()) { + if (!vcard->getPreferredEMailAddress().address.empty()) { info.setEMail(vcard->getPreferredEMailAddress().address); } info.setMessage(presence->getStatus()); diff --git a/Slimber/Server.h b/Slimber/Server.h index 039f351..98332fd 100644 --- a/Slimber/Server.h +++ b/Slimber/Server.h @@ -23,7 +23,7 @@ namespace Swift { class DNSSDServiceID; - class String; + class VCardCollection; class LinkLocalConnector; class LinkLocalServiceBrowser; @@ -87,7 +87,7 @@ namespace Swift { public: DummyUserRegistry() {} - virtual bool isValidUserPassword(const JID&, const String&) const { + virtual bool isValidUserPassword(const JID&, const std::string&) const { return true; } }; diff --git a/Slimber/ServerError.h b/Slimber/ServerError.h index ad09275..ec80f0a 100644 --- a/Slimber/ServerError.h +++ b/Slimber/ServerError.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include namespace Swift { class ServerError { @@ -18,7 +18,7 @@ namespace Swift { LinkLocalError }; - ServerError(Type type, const String& message = String()) : + ServerError(Type type, const std::string& message = std::string()) : type(type), message(message) { } @@ -26,12 +26,12 @@ namespace Swift { return type; } - const String& getMessage() const { + const std::string& getMessage() const { return message; } private: Type type; - String message; + std::string message; }; } diff --git a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp index 8c6710a..47eb05c 100644 --- a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp +++ b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp @@ -71,7 +71,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(rosterChanges[0]->getItems().size())); boost::optional item = rosterChanges[0]->getItem(JID("alice@wonderland")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); CPPUNIT_ASSERT_EQUAL(1, static_cast(presenceChanges.size())); CPPUNIT_ASSERT(StatusShow::Online == presenceChanges[0]->getShow()); @@ -101,7 +101,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(2, static_cast(presenceChanges.size())); CPPUNIT_ASSERT(StatusShow::Away == presenceChanges[1]->getShow()); CPPUNIT_ASSERT(JID("alice@wonderland") == presenceChanges[1]->getFrom()); - CPPUNIT_ASSERT_EQUAL(String("I'm Away"), presenceChanges[1]->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("I'm Away"), presenceChanges[1]->getStatus()); } void testGetAllPresence() { @@ -131,11 +131,11 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { boost::optional item; item = roster->getItem(JID("alice@wonderland")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); item = roster->getItem(JID("rabbit@teaparty")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Rabbit"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Rabbit"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); } @@ -145,7 +145,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "Alice", "Alice In", "Wonderland"); boost::optional item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); } void testGetRoster_InfoWithFirstName() { @@ -154,7 +154,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "Alice In", ""); boost::optional item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice In"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In"), item->getName()); } void testGetRoster_InfoWithLastName() { @@ -163,7 +163,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "", "Wonderland"); boost::optional item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Wonderland"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), item->getName()); } void testGetRoster_InfoWithFirstAndLastName() { @@ -172,7 +172,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "Alice In", "Wonderland"); boost::optional item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), item->getName()); } void testGetRoster_NoInfo() { @@ -181,7 +181,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland"); boost::optional item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String(""), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string(""), item->getName()); } void testGetServiceForJID() { @@ -193,7 +193,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { boost::optional service = testling->getServiceForJID(JID("rabbit@teaparty")); CPPUNIT_ASSERT(service); - CPPUNIT_ASSERT_EQUAL(String("rabbit@teaparty"), service->getID().getName()); + CPPUNIT_ASSERT_EQUAL(std::string("rabbit@teaparty"), service->getID().getName()); } void testGetServiceForJID_NoMatch() { @@ -216,7 +216,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { return testling; } - void addService(const String& name, const String& nickName = String(), const String& firstName = String(), const String& lastName = String()) { + void addService(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); @@ -227,13 +227,13 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { eventLoop->processEvents(); } - void removeService(const String& name) { + void removeService(const std::string& name) { DNSSDServiceID service(name, "local."); querier->removeService(DNSSDServiceID(name, "local.")); eventLoop->processEvents(); } - void updateServicePresence(const String& name, LinkLocalServiceInfo::Status status, const String& message) { + void updateServicePresence(const std::string& name, LinkLocalServiceInfo::Status status, const std::string& message) { DNSSDServiceID service(name, "local."); LinkLocalServiceInfo info; info.setStatus(status); diff --git a/Slimber/UnitTest/MenuletControllerTest.cpp b/Slimber/UnitTest/MenuletControllerTest.cpp index 9722125..092a886 100644 --- a/Slimber/UnitTest/MenuletControllerTest.cpp +++ b/Slimber/UnitTest/MenuletControllerTest.cpp @@ -10,8 +10,6 @@ #include "Slimber/Menulet.h" #include "Slimber/MenuletController.h" -using namespace Swift; - class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(MenuletControllerTest); CPPUNIT_TEST(testConstructor); @@ -36,14 +34,14 @@ class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(8, static_cast(menulet->items.size())); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Offline] "), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*About*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Restart*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Exit*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Offline] "), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]); } void testUpdate() { @@ -53,14 +51,14 @@ class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(8, static_cast(menulet->items.size())); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Online] You are connected"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*About*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Restart*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Exit*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]); } void testSetXMPPStatus_Online() { @@ -69,9 +67,9 @@ class MenuletControllerTest : public CppUnit::TestFixture { testling.setXMPPStatus("You are connected", MenuletController::Online); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Online] You are connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]); } @@ -81,35 +79,35 @@ class MenuletControllerTest : public CppUnit::TestFixture { testling.setXMPPStatus("You are not connected", MenuletController::Offline); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Offline] You are not connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Offline] You are not connected"), menulet->items[i++]); } void testSetUserNames() { MenuletController testling(menulet); - std::vector users; + std::vector users; users.push_back("Alice In Wonderland"); users.push_back("The Mad Hatter"); testling.setUserNames(users); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("Online users:"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String(" Alice In Wonderland"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String(" The Mad Hatter"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("Online users:"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string(" Alice In Wonderland"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string(" The Mad Hatter"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); } void testSetUserNames_NoUsers() { MenuletController testling(menulet); - std::vector users; + std::vector users; testling.setUserNames(users); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); } private: @@ -118,9 +116,9 @@ class MenuletControllerTest : public CppUnit::TestFixture { items.clear(); } - virtual void addItem(const String& name, const String& icon = String()) { - String result; - if (!icon.isEmpty()) { + virtual void addItem(const std::string& name, const std::string& icon = std::string()) { + std::string result; + if (!icon.empty()) { result += "[" + icon + "] "; } result += name; @@ -143,12 +141,12 @@ class MenuletControllerTest : public CppUnit::TestFixture { items.push_back("-"); } - virtual void setIcon(const String& i) { + virtual void setIcon(const std::string& i) { icon = i; } - std::vector items; - String icon; + std::vector items; + std::string icon; }; FakeMenulet* menulet; diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp index 8457f88..e683563 100644 --- a/SwifTools/Application/ApplicationPathProvider.cpp +++ b/SwifTools/Application/ApplicationPathProvider.cpp @@ -13,14 +13,14 @@ namespace Swift { -ApplicationPathProvider::ApplicationPathProvider(const String& applicationName) : applicationName(applicationName) { +ApplicationPathProvider::ApplicationPathProvider(const std::string& applicationName) : applicationName(applicationName) { } ApplicationPathProvider::~ApplicationPathProvider() { } -boost::filesystem::path ApplicationPathProvider::getProfileDir(const String& profile) const { - boost::filesystem::path result(getHomeDir() / profile.getUTF8String()); +boost::filesystem::path ApplicationPathProvider::getProfileDir(const std::string& profile) const { + boost::filesystem::path result(getHomeDir() / profile); try { boost::filesystem::create_directory(result); } @@ -30,10 +30,10 @@ boost::filesystem::path ApplicationPathProvider::getProfileDir(const String& pro return result; } -boost::filesystem::path ApplicationPathProvider::getResourcePath(const String& resource) const { +boost::filesystem::path ApplicationPathProvider::getResourcePath(const std::string& resource) const { std::vector resourcePaths = getResourceDirs(); foreach(const boost::filesystem::path& resourcePath, resourcePaths) { - boost::filesystem::path r(resourcePath / resource.getUTF8String()); + boost::filesystem::path r(resourcePath / resource); if (boost::filesystem::exists(r)) { return r; } diff --git a/SwifTools/Application/ApplicationPathProvider.h b/SwifTools/Application/ApplicationPathProvider.h index 722f1ad..48a9602 100644 --- a/SwifTools/Application/ApplicationPathProvider.h +++ b/SwifTools/Application/ApplicationPathProvider.h @@ -9,27 +9,27 @@ #include #include -#include "Swiften/Base/String.h" +#include namespace Swift { class ApplicationPathProvider { public: - ApplicationPathProvider(const String& applicationName); + ApplicationPathProvider(const std::string& applicationName); virtual ~ApplicationPathProvider(); virtual boost::filesystem::path getHomeDir() const = 0; virtual boost::filesystem::path getDataDir() const = 0; virtual boost::filesystem::path getExecutableDir() const; - boost::filesystem::path getProfileDir(const String& profile) const; - boost::filesystem::path getResourcePath(const String& resource) const; + boost::filesystem::path getProfileDir(const std::string& profile) const; + boost::filesystem::path getResourcePath(const std::string& resource) const; protected: virtual std::vector getResourceDirs() const = 0; - const String& getApplicationName() const { + const std::string& getApplicationName() const { return applicationName; } private: - String applicationName; + std::string applicationName; }; } diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.cpp b/SwifTools/Application/MacOSXApplicationPathProvider.cpp index fb6523c..0ed4d40 100644 --- a/SwifTools/Application/MacOSXApplicationPathProvider.cpp +++ b/SwifTools/Application/MacOSXApplicationPathProvider.cpp @@ -13,13 +13,13 @@ namespace Swift { -MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const String& name) : ApplicationPathProvider(name) { +MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) { resourceDirs.push_back(getExecutableDir() / "../Resources"); resourceDirs.push_back(getExecutableDir() / "../resources"); // Development } boost::filesystem::path MacOSXApplicationPathProvider::getDataDir() const { - boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName().getUTF8String()); + boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName()); try { boost::filesystem::create_directory(result); } diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.h b/SwifTools/Application/MacOSXApplicationPathProvider.h index d2613f8..fec1944 100644 --- a/SwifTools/Application/MacOSXApplicationPathProvider.h +++ b/SwifTools/Application/MacOSXApplicationPathProvider.h @@ -11,7 +11,7 @@ namespace Swift { class MacOSXApplicationPathProvider : public ApplicationPathProvider { public: - MacOSXApplicationPathProvider(const String& name); + MacOSXApplicationPathProvider(const std::string& name); virtual boost::filesystem::path getHomeDir() const; boost::filesystem::path getDataDir() const; diff --git a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp index cd171cb..a418bc2 100644 --- a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp +++ b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp @@ -6,9 +6,10 @@ #include #include +#include +#include #include "SwifTools/Application/PlatformApplicationPathProvider.h" -#include "Swiften/Base/String.h" using namespace Swift; @@ -39,7 +40,7 @@ class ApplicationPathProviderTest : public CppUnit::TestFixture { void testGetExecutableDir() { boost::filesystem::path dir = testling_->getExecutableDir(); CPPUNIT_ASSERT(boost::filesystem::is_directory(dir)); - CPPUNIT_ASSERT(String(dir.string()).endsWith("UnitTest")); + CPPUNIT_ASSERT(boost::ends_with(dir.string(), "UnitTest")); } private: diff --git a/SwifTools/Application/UnixApplicationPathProvider.cpp b/SwifTools/Application/UnixApplicationPathProvider.cpp index 06fa977..2ac39ab 100644 --- a/SwifTools/Application/UnixApplicationPathProvider.cpp +++ b/SwifTools/Application/UnixApplicationPathProvider.cpp @@ -8,14 +8,14 @@ namespace Swift { -UnixApplicationPathProvider::UnixApplicationPathProvider(const String& name) : ApplicationPathProvider(name) { +UnixApplicationPathProvider::UnixApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) { resourceDirs.push_back(getExecutableDir() / "../resources"); // Development char* xdgDataDirs = getenv("XDG_DATA_DIRS"); if (xdgDataDirs) { - std::vector dataDirs = String(xdgDataDirs).split(':'); + std::vector dataDirs = std::string(xdgDataDirs).split(':'); if (!dataDirs.empty()) { - foreach(const String& dir, dataDirs) { - resourceDirs.push_back(boost::filesystem::path(dir.getUTF8String()) / "swift"); + foreach(const std::string& dir, dataDirs) { + resourceDirs.push_back(boost::filesystem::path(dir) / "swift"); } return; } @@ -31,14 +31,14 @@ boost::filesystem::path UnixApplicationPathProvider::getHomeDir() const { boost::filesystem::path UnixApplicationPathProvider::getDataDir() const { char* xdgDataHome = getenv("XDG_DATA_HOME"); - String dataDir; + std::string dataDir; if (xdgDataHome) { - dataDir = String(xdgDataHome); + dataDir = std::string(xdgDataHome); } - boost::filesystem::path dataPath = (dataDir.isEmpty() ? + boost::filesystem::path dataPath = (dataDir.empty() ? getHomeDir() / ".local" / "share" - : boost::filesystem::path(dataDir.getUTF8String())) / getApplicationName().getLowerCase().getUTF8String(); + : boost::filesystem::path(dataDir)) / getApplicationName().getLowerCase(); try { boost::filesystem::create_directories(dataPath); diff --git a/SwifTools/Application/UnixApplicationPathProvider.h b/SwifTools/Application/UnixApplicationPathProvider.h index 0c2f643..e043976 100644 --- a/SwifTools/Application/UnixApplicationPathProvider.h +++ b/SwifTools/Application/UnixApplicationPathProvider.h @@ -17,7 +17,7 @@ namespace Swift { class UnixApplicationPathProvider : public ApplicationPathProvider { public: - UnixApplicationPathProvider(const String& name); + UnixApplicationPathProvider(const std::string& name); virtual boost::filesystem::path getHomeDir() const; boost::filesystem::path getDataDir() const; diff --git a/SwifTools/Application/WindowsApplicationPathProvider.cpp b/SwifTools/Application/WindowsApplicationPathProvider.cpp index e19606f..d645b90 100644 --- a/SwifTools/Application/WindowsApplicationPathProvider.cpp +++ b/SwifTools/Application/WindowsApplicationPathProvider.cpp @@ -12,7 +12,7 @@ namespace Swift { -WindowsApplicationPathProvider::WindowsApplicationPathProvider(const String& name) : ApplicationPathProvider(name) { +WindowsApplicationPathProvider::WindowsApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) { resourceDirs.push_back(getExecutableDir()); resourceDirs.push_back(getExecutableDir() / "../resources"); // Development } diff --git a/SwifTools/Application/WindowsApplicationPathProvider.h b/SwifTools/Application/WindowsApplicationPathProvider.h index 26f7045..9428908 100644 --- a/SwifTools/Application/WindowsApplicationPathProvider.h +++ b/SwifTools/Application/WindowsApplicationPathProvider.h @@ -11,11 +11,11 @@ namespace Swift { class WindowsApplicationPathProvider : public ApplicationPathProvider { public: - WindowsApplicationPathProvider(const String& name); + WindowsApplicationPathProvider(const std::string& name); boost::filesystem::path getDataDir() const { char* appDirRaw = getenv("APPDATA"); - boost::filesystem::path result(boost::filesystem::path(appDirRaw) / getApplicationName().getUTF8String()); + boost::filesystem::path result(boost::filesystem::path(appDirRaw) / getApplicationName()); boost::filesystem::create_directory(result); return result; } diff --git a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp index adc6d2d..4dd06c7 100644 --- a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp +++ b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp @@ -22,7 +22,7 @@ bool PlatformAutoUpdaterFactory::isSupported() const { #endif } -AutoUpdater* PlatformAutoUpdaterFactory::createAutoUpdater(const String& appcastURL) { +AutoUpdater* PlatformAutoUpdaterFactory::createAutoUpdater(const std::string& appcastURL) { #ifdef HAVE_SPARKLE return new SparkleAutoUpdater(appcastURL); #else diff --git a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h index 11528a3..59df238 100644 --- a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h +++ b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h @@ -4,7 +4,7 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Base/String.h" +#include namespace Swift { class AutoUpdater; @@ -13,6 +13,6 @@ namespace Swift { public: bool isSupported() const; - AutoUpdater* createAutoUpdater(const String& appcastURL); + AutoUpdater* createAutoUpdater(const std::string& appcastURL); }; } diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.h b/SwifTools/AutoUpdater/SparkleAutoUpdater.h index 5fddda5..fc08975 100644 --- a/SwifTools/AutoUpdater/SparkleAutoUpdater.h +++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.h @@ -6,13 +6,13 @@ #pragma once -#include "Swiften/Base/String.h" +#include #include "SwifTools/AutoUpdater/AutoUpdater.h" namespace Swift { class SparkleAutoUpdater : public AutoUpdater { public: - SparkleAutoUpdater(const String& url); + SparkleAutoUpdater(const std::string& url); ~SparkleAutoUpdater(); void checkForUpdates(); diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm index a8ae60a..440e178 100644 --- a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm +++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm @@ -10,7 +10,7 @@ class SparkleAutoUpdater::Private { SUUpdater* updater; }; -SparkleAutoUpdater::SparkleAutoUpdater(const String& url) { +SparkleAutoUpdater::SparkleAutoUpdater(const std::string& url) { d = new Private; d->updater = [SUUpdater sharedUpdater]; @@ -18,7 +18,7 @@ SparkleAutoUpdater::SparkleAutoUpdater(const String& url) { [d->updater setAutomaticallyChecksForUpdates: true]; NSURL* nsurl = [NSURL URLWithString: - [NSString stringWithUTF8String: url.getUTF8Data()]]; + [NSString stringWithUTF8String: url.c_str()]]; [d->updater setFeedURL: nsurl]; } diff --git a/SwifTools/Dock/Dock.h b/SwifTools/Dock/Dock.h index 2dd312c..1bd96fb 100644 --- a/SwifTools/Dock/Dock.h +++ b/SwifTools/Dock/Dock.h @@ -7,7 +7,7 @@ #pragma once namespace Swift { - class String; + class Dock { public: diff --git a/SwifTools/Dock/MacOSXDock.h b/SwifTools/Dock/MacOSXDock.h index 511a652..64cc737 100644 --- a/SwifTools/Dock/MacOSXDock.h +++ b/SwifTools/Dock/MacOSXDock.h @@ -9,7 +9,7 @@ #include "SwifTools/Dock/Dock.h" namespace Swift { - class String; + class CocoaApplication; class MacOSXDock : public Dock { diff --git a/SwifTools/Dock/MacOSXDock.mm b/SwifTools/Dock/MacOSXDock.mm index 0438353..a7a3d55 100644 --- a/SwifTools/Dock/MacOSXDock.mm +++ b/SwifTools/Dock/MacOSXDock.mm @@ -12,8 +12,8 @@ MacOSXDock::MacOSXDock(CocoaApplication*) { } void MacOSXDock::setNumberOfPendingMessages(int i) { - String label(i > 0 ? boost::lexical_cast(i) : ""); - NSString *labelString = [[NSString alloc] initWithUTF8String: label.getUTF8Data()]; + std::string label(i > 0 ? boost::lexical_cast(i) : ""); + NSString *labelString = [[NSString alloc] initWithUTF8String: label.c_str()]; [[NSApp dockTile] setBadgeLabel: labelString]; [labelString release]; [NSApp requestUserAttention: NSInformationalRequest]; diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp index 822536e..91c713f 100644 --- a/SwifTools/Linkify.cpp +++ b/SwifTools/Linkify.cpp @@ -14,18 +14,18 @@ namespace Swift { static boost::regex linkifyRegexp("^https?://.*"); -String Linkify::linkify(const String& input) { +std::string Linkify::linkify(const std::string& input) { std::ostringstream result; std::vector currentURL; bool inURL = false; - for (size_t i = 0; i < input.getUTF8Size(); ++i) { + for (size_t i = 0; i < input.size(); ++i) { char c = input[i]; if (inURL) { if (c != ' ' && c != '\t' && c != '\n') { currentURL.push_back(c); } else { - String url(¤tURL[0], currentURL.size()); + std::string url(¤tURL[0], currentURL.size()); result << "" << url << ""; currentURL.clear(); inURL = false; @@ -33,7 +33,7 @@ String Linkify::linkify(const String& input) { } } else { - if (boost::regex_match(input.getSubstring(i, 8).getUTF8String(), linkifyRegexp)) { + if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) { currentURL.push_back(c); inURL = true; } @@ -43,10 +43,10 @@ String Linkify::linkify(const String& input) { } } if (currentURL.size() > 0) { - String url(¤tURL[0], currentURL.size()); + std::string url(¤tURL[0], currentURL.size()); result << "" << url << ""; } - return String(result.str()); + return std::string(result.str()); } } diff --git a/SwifTools/Linkify.h b/SwifTools/Linkify.h index cb5e806..ebe232f 100644 --- a/SwifTools/Linkify.h +++ b/SwifTools/Linkify.h @@ -6,10 +6,10 @@ #pragma once -#include "Swiften/Base/String.h" +#include namespace Swift { namespace Linkify { - String linkify(const String&); + std::string linkify(const std::string&); } } diff --git a/SwifTools/Notifier/GNTPNotifier.cpp b/SwifTools/Notifier/GNTPNotifier.cpp index 924b921..9a20c33 100644 --- a/SwifTools/Notifier/GNTPNotifier.cpp +++ b/SwifTools/Notifier/GNTPNotifier.cpp @@ -18,7 +18,7 @@ namespace Swift { -GNTPNotifier::GNTPNotifier(const String& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory) : name(name), icon(icon), connectionFactory(connectionFactory), initialized(false), registered(false) { +GNTPNotifier::GNTPNotifier(const std::string& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory) : name(name), icon(icon), connectionFactory(connectionFactory), initialized(false), registered(false) { // Registration message std::ostringstream message; message << "GNTP/1.0 REGISTER NONE\r\n"; @@ -51,7 +51,7 @@ void GNTPNotifier::send(const std::string& message) { currentConnection->connect(HostAddressPort(HostAddress("127.0.0.1"), 23053)); } -void GNTPNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function) { +void GNTPNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function) { if (registered) { std::ostringstream message; message << "GNTP/1.0 NOTIFY NONE\r\n"; diff --git a/SwifTools/Notifier/GNTPNotifier.h b/SwifTools/Notifier/GNTPNotifier.h index 47b0c01..a740c27 100644 --- a/SwifTools/Notifier/GNTPNotifier.h +++ b/SwifTools/Notifier/GNTPNotifier.h @@ -16,10 +16,10 @@ namespace Swift { class GNTPNotifier : public Notifier { public: - GNTPNotifier(const String& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory); + GNTPNotifier(const std::string& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory); ~GNTPNotifier(); - virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback); private: void handleConnectFinished(bool error); @@ -27,7 +27,7 @@ namespace Swift { void send(const std::string& message); private: - String name; + std::string name; boost::filesystem::path icon; ConnectionFactory* connectionFactory; bool initialized; diff --git a/SwifTools/Notifier/GrowlNotifier.cpp b/SwifTools/Notifier/GrowlNotifier.cpp index 8b5920f..5ecd34c 100644 --- a/SwifTools/Notifier/GrowlNotifier.cpp +++ b/SwifTools/Notifier/GrowlNotifier.cpp @@ -8,6 +8,7 @@ #include +#include "Swiften/Base/String.h" #include "Swiften/Base/ByteArray.h" #include "SwifTools/Notifier/GrowlNotifier.h" #include "Swiften/Base/foreach.h" @@ -47,7 +48,7 @@ namespace { namespace Swift { -GrowlNotifier::GrowlNotifier(const String& name) { +GrowlNotifier::GrowlNotifier(const std::string& name) { // All notifications CFMutableArrayRef allNotifications = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); foreach(Type type, getAllTypes()) { @@ -71,7 +72,7 @@ GrowlNotifier::GrowlNotifier(const String& name) { Growl_SetDelegate(&delegate_); } -void GrowlNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picturePath, boost::function callback) { +void GrowlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picturePath, boost::function callback) { ByteArray picture; picture.readFromFile(picturePath.string()); diff --git a/SwifTools/Notifier/GrowlNotifier.h b/SwifTools/Notifier/GrowlNotifier.h index f7c4260..d4a6178 100644 --- a/SwifTools/Notifier/GrowlNotifier.h +++ b/SwifTools/Notifier/GrowlNotifier.h @@ -21,9 +21,9 @@ namespace Swift { */ class GrowlNotifier : public Notifier { public: - GrowlNotifier(const String& name); + GrowlNotifier(const std::string& name); - virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback); private: Growl_Delegate delegate_; diff --git a/SwifTools/Notifier/LoggingNotifier.h b/SwifTools/Notifier/LoggingNotifier.h index eea07ef..18ae0e2 100644 --- a/SwifTools/Notifier/LoggingNotifier.h +++ b/SwifTools/Notifier/LoggingNotifier.h @@ -12,15 +12,15 @@ namespace Swift { class LoggingNotifier : public Notifier { public: - virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback) { + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback) { notifications.push_back(Notification(type, subject, description, picture, callback)); } struct Notification { - Notification(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback) : type(type), subject(subject), description(description), picture(picture), callback(callback) {} + Notification(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback) : type(type), subject(subject), description(description), picture(picture), callback(callback) {} Type type; - String subject; - String description; + std::string subject; + std::string description; boost::filesystem::path picture; boost::function callback; }; diff --git a/SwifTools/Notifier/Notifier.cpp b/SwifTools/Notifier/Notifier.cpp index 2c2660e..1673400 100644 --- a/SwifTools/Notifier/Notifier.cpp +++ b/SwifTools/Notifier/Notifier.cpp @@ -14,7 +14,7 @@ const int Notifier::DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS = 5; Notifier::~Notifier() { } -String Notifier::typeToString(Type type) { +std::string Notifier::typeToString(Type type) { switch (type) { case ContactAvailable: return "Contact Becomes Available"; case ContactUnavailable: return "Contact Becomes Unavailable"; diff --git a/SwifTools/Notifier/Notifier.h b/SwifTools/Notifier/Notifier.h index a8424bf..d6bd878 100644 --- a/SwifTools/Notifier/Notifier.h +++ b/SwifTools/Notifier/Notifier.h @@ -8,8 +8,8 @@ #include #include - -#include "Swiften/Base/String.h" +#include +#include namespace Swift { class Notifier { @@ -23,8 +23,8 @@ namespace Swift { */ virtual void showMessage( Type type, - const String& subject, - const String& description, + const std::string& subject, + const std::string& description, const boost::filesystem::path& picture, boost::function callback) = 0; @@ -33,7 +33,7 @@ namespace Swift { } protected: - String typeToString(Type type); + std::string typeToString(Type type); static std::vector getAllTypes(); static std::vector getDefaultTypes(); diff --git a/SwifTools/Notifier/NullNotifier.h b/SwifTools/Notifier/NullNotifier.h index e97329b..24b4476 100644 --- a/SwifTools/Notifier/NullNotifier.h +++ b/SwifTools/Notifier/NullNotifier.h @@ -11,7 +11,7 @@ namespace Swift { class NullNotifier : public Notifier { public: - virtual void showMessage(Type, const String&, const String&, const boost::filesystem::path&, boost::function) { + virtual void showMessage(Type, const std::string&, const std::string&, const boost::filesystem::path&, boost::function) { } }; } diff --git a/SwifTools/Notifier/SnarlNotifier.cpp b/SwifTools/Notifier/SnarlNotifier.cpp index 8d7407a..e93a539 100644 --- a/SwifTools/Notifier/SnarlNotifier.cpp +++ b/SwifTools/Notifier/SnarlNotifier.cpp @@ -17,11 +17,11 @@ namespace Swift { -SnarlNotifier::SnarlNotifier(const String& name, Win32NotifierWindow* window, const boost::filesystem::path& icon) : window(window), available(false) { +SnarlNotifier::SnarlNotifier(const std::string& name, Win32NotifierWindow* window, const boost::filesystem::path& icon) : window(window), available(false) { window->onMessageReceived.connect(boost::bind(&SnarlNotifier::handleMessageReceived, this, _1)); - available = snarl.RegisterApp(name.getUTF8Data(), name.getUTF8Data(), icon.string().c_str(), window->getID(), SWIFT_SNARLNOTIFIER_MESSAGE_ID); + available = snarl.RegisterApp(name.c_str(), name.c_str(), icon.string().c_str(), window->getID(), SWIFT_SNARLNOTIFIER_MESSAGE_ID); foreach(Notifier::Type type, getAllTypes()) { - snarl.AddClass(typeToString(type).getUTF8Data(), typeToString(type).getUTF8Data()); + snarl.AddClass(typeToString(type).c_str(), typeToString(type).c_str()); } } @@ -38,12 +38,12 @@ bool SnarlNotifier::isAvailable() const { } -void SnarlNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback) { +void SnarlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback) { int timeout = (type == IncomingMessage || type == SystemMessage) ? DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS : DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS; int notificationID = snarl.EZNotify( - typeToString(type).getUTF8Data(), - subject.getUTF8Data(), - description.getUTF8Data(), + typeToString(type).c_str(), + subject.c_str(), + description.c_str(), timeout, picture.string().c_str()); if (notificationID > 0) { diff --git a/SwifTools/Notifier/SnarlNotifier.h b/SwifTools/Notifier/SnarlNotifier.h index 9aa75f6..9e2cddf 100644 --- a/SwifTools/Notifier/SnarlNotifier.h +++ b/SwifTools/Notifier/SnarlNotifier.h @@ -16,10 +16,10 @@ namespace Swift { class SnarlNotifier : public Notifier { public: - SnarlNotifier(const String& name, Win32NotifierWindow* window, const boost::filesystem::path& icon); + SnarlNotifier(const std::string& name, Win32NotifierWindow* window, const boost::filesystem::path& icon); ~SnarlNotifier(); - virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback); virtual bool isAvailable() const; private: diff --git a/SwifTools/Notifier/TogglableNotifier.h b/SwifTools/Notifier/TogglableNotifier.h index 1e87807..415caf6 100644 --- a/SwifTools/Notifier/TogglableNotifier.h +++ b/SwifTools/Notifier/TogglableNotifier.h @@ -40,7 +40,7 @@ namespace Swift { return persistentEnabled && !temporarilyDisabled; } - virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback) { + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback) { if (getCurrentlyEnabled()) { notifier->showMessage(type, subject, description, picture, callback); } diff --git a/SwifTools/TabComplete.cpp b/SwifTools/TabComplete.cpp index 1e15595..b123360 100644 --- a/SwifTools/TabComplete.cpp +++ b/SwifTools/TabComplete.cpp @@ -7,25 +7,26 @@ #include "SwifTools/TabComplete.h" #include +#include #include "Swiften/Base/foreach.h" namespace Swift { -void TabComplete::addWord(const String& word) { +void TabComplete::addWord(const std::string& word) { words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end()); words_.insert(words_.begin(), word); - if (word.getLowerCase().beginsWith(lastShort_)) { + if (boost::starts_with(boost::to_lower_copy(word), lastShort_)) { lastCompletionCandidates_.insert(lastCompletionCandidates_.begin(), word); } } -void TabComplete::removeWord(const String& word) { +void TabComplete::removeWord(const std::string& word) { words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end()); lastCompletionCandidates_.erase(std::remove(lastCompletionCandidates_.begin(), lastCompletionCandidates_.end(), word), lastCompletionCandidates_.end()); } -String TabComplete::completeWord(const String& word) { +std::string TabComplete::completeWord(const std::string& word) { if (word == lastCompletion_) { if (lastCompletionCandidates_.size() != 0) { size_t match = 0; @@ -39,10 +40,10 @@ String TabComplete::completeWord(const String& word) { lastCompletion_ = lastCompletionCandidates_[nextIndex]; } } else { - lastShort_ = word.getLowerCase(); + lastShort_ = boost::to_lower_copy(word); lastCompletionCandidates_.clear(); - foreach (String candidate, words_) { - if (candidate.getLowerCase().beginsWith(word.getLowerCase())) { + foreach (std::string candidate, words_) { + if (boost::starts_with(boost::to_lower_copy(candidate), boost::to_lower_copy(word))) { lastCompletionCandidates_.push_back(candidate); } } diff --git a/SwifTools/TabComplete.h b/SwifTools/TabComplete.h index 01e294f..d01174f 100644 --- a/SwifTools/TabComplete.h +++ b/SwifTools/TabComplete.h @@ -8,18 +8,18 @@ #include -#include "Swiften/Base/String.h" +#include namespace Swift { class TabComplete { public: - void addWord(const String& word); - void removeWord(const String& word); - String completeWord(const String& word); + void addWord(const std::string& word); + void removeWord(const std::string& word); + std::string completeWord(const std::string& word); private: - std::vector words_; - String lastCompletion_; - String lastShort_; - std::vector lastCompletionCandidates_; + std::vector words_; + std::string lastCompletion_; + std::string lastShort_; + std::vector lastCompletionCandidates_; }; } diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp index a35a686..f7e2a37 100644 --- a/SwifTools/UnitTest/LinkifyTest.cpp +++ b/SwifTools/UnitTest/LinkifyTest.cpp @@ -35,147 +35,147 @@ class LinkifyTest : public CppUnit::TestFixture { public: void testLinkify_URLWithResource() { - String result = Linkify::linkify("http://swift.im/blog"); + std::string result = Linkify::linkify("http://swift.im/blog"); CPPUNIT_ASSERT_EQUAL( - String("http://swift.im/blog"), + std::string("http://swift.im/blog"), result); } void testLinkify_HTTPSURLWithResource() { - String result = Linkify::linkify("https://swift.im/blog"); + std::string result = Linkify::linkify("https://swift.im/blog"); CPPUNIT_ASSERT_EQUAL( - String("https://swift.im/blog"), + std::string("https://swift.im/blog"), result); } void testLinkify_URLWithEmptyResource() { - String result = Linkify::linkify("http://swift.im/"); + std::string result = Linkify::linkify("http://swift.im/"); CPPUNIT_ASSERT_EQUAL( - String("http://swift.im/"), + std::string("http://swift.im/"), result); } void testLinkify_BareURL() { - String result = Linkify::linkify("http://swift.im"); + std::string result = Linkify::linkify("http://swift.im"); CPPUNIT_ASSERT_EQUAL( - String("http://swift.im"), + std::string("http://swift.im"), result); } void testLinkify_URLSurroundedByWhitespace() { - String result = Linkify::linkify("Foo http://swift.im/blog Bar"); + std::string result = Linkify::linkify("Foo http://swift.im/blog Bar"); CPPUNIT_ASSERT_EQUAL( - String("Foo http://swift.im/blog Bar"), + std::string("Foo http://swift.im/blog Bar"), result); } void testLinkify_MultipleURLs() { - String result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz"); + std::string result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz"); CPPUNIT_ASSERT_EQUAL( - String("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz"), + std::string("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz"), result); } void testLinkify_CamelCase() { - String result = Linkify::linkify("http://fOo.cOm/bAz"); + std::string result = Linkify::linkify("http://fOo.cOm/bAz"); CPPUNIT_ASSERT_EQUAL( - String("http://fOo.cOm/bAz"), + std::string("http://fOo.cOm/bAz"), result); } void testLinkify_HierarchicalResource() { - String result = Linkify::linkify("http://foo.com/bar/baz/"); + std::string result = Linkify::linkify("http://foo.com/bar/baz/"); CPPUNIT_ASSERT_EQUAL( - String("http://foo.com/bar/baz/"), + std::string("http://foo.com/bar/baz/"), result); } void testLinkify_Anchor() { - String result = Linkify::linkify("http://foo.com/bar#baz"); + std::string result = Linkify::linkify("http://foo.com/bar#baz"); CPPUNIT_ASSERT_EQUAL( - String("http://foo.com/bar#baz"), + std::string("http://foo.com/bar#baz"), result); } void testLinkify_Plus() { - String result = Linkify::linkify("http://foo.com/bar+baz"); + std::string result = Linkify::linkify("http://foo.com/bar+baz"); CPPUNIT_ASSERT_EQUAL( - String("http://foo.com/bar+baz"), + std::string("http://foo.com/bar+baz"), result); } void testLinkify_Tilde() { - String result = Linkify::linkify("http://foo.com/~kev/"); + std::string result = Linkify::linkify("http://foo.com/~kev/"); CPPUNIT_ASSERT_EQUAL( - String("http://foo.com/~kev/"), + std::string("http://foo.com/~kev/"), result); } void testLinkify_Equal() { - String result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0"); + std::string result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0"); CPPUNIT_ASSERT_EQUAL( - String("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0"), + std::string("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0"), result); } void testLinkify_Authentication() { - String result = Linkify::linkify("http://bob:bla@swift.im/foo/bar"); + std::string result = Linkify::linkify("http://bob:bla@swift.im/foo/bar"); CPPUNIT_ASSERT_EQUAL( - String("http://bob:bla@swift.im/foo/bar"), + std::string("http://bob:bla@swift.im/foo/bar"), result); } void testLinkify_At() { - String result = Linkify::linkify("http://swift.im/foo@bar"); + std::string result = Linkify::linkify("http://swift.im/foo@bar"); CPPUNIT_ASSERT_EQUAL( - String("http://swift.im/foo@bar"), + std::string("http://swift.im/foo@bar"), result); } void testLinkify_Amps() { - String result = Linkify::linkify("http://swift.im/foo&bar&baz"); + std::string result = Linkify::linkify("http://swift.im/foo&bar&baz"); CPPUNIT_ASSERT_EQUAL( - String("http://swift.im/foo&bar&baz"), + std::string("http://swift.im/foo&bar&baz"), result); } void testLinkify_UnicodeCharacter() { - String result = Linkify::linkify("http://\xe2\x98\x83.net"); + std::string result = Linkify::linkify("http://\xe2\x98\x83.net"); CPPUNIT_ASSERT_EQUAL( - String("http://\xe2\x98\x83.net"), + std::string("http://\xe2\x98\x83.net"), result); } void testLinkify_NewLine() { - String result = Linkify::linkify("http://swift.im\nfoo"); + std::string result = Linkify::linkify("http://swift.im\nfoo"); CPPUNIT_ASSERT_EQUAL( - String("http://swift.im\nfoo"), + std::string("http://swift.im\nfoo"), result); } void testLinkify_Tab() { - String result = Linkify::linkify("http://swift.im\tfoo"); + std::string result = Linkify::linkify("http://swift.im\tfoo"); CPPUNIT_ASSERT_EQUAL( - String("http://swift.im\tfoo"), + std::string("http://swift.im\tfoo"), result); } }; diff --git a/SwifTools/UnitTest/TabCompleteTest.cpp b/SwifTools/UnitTest/TabCompleteTest.cpp index b7b643f..2224839 100644 --- a/SwifTools/UnitTest/TabCompleteTest.cpp +++ b/SwifTools/UnitTest/TabCompleteTest.cpp @@ -31,7 +31,7 @@ public: } void testEmpty() { - String blah("Blah"); + std::string blah("Blah"); CPPUNIT_ASSERT_EQUAL( blah, completer_.completeWord(blah)); @@ -42,7 +42,7 @@ public: void testNoMatch() { completer_.addWord("Bleh"); - String blah("Blah"); + std::string blah("Blah"); CPPUNIT_ASSERT_EQUAL( blah, completer_.completeWord(blah)); @@ -52,8 +52,8 @@ public: } void testOneMatch() { - String short1("Bl"); - String long1("Blehling"); + std::string short1("Bl"); + std::string long1("Blehling"); completer_.addWord(long1); CPPUNIT_ASSERT_EQUAL( long1, @@ -64,9 +64,9 @@ public: } void testTwoMatch() { - String short1("Hur"); - String long1("Hurgle"); - String long2("Hurdler"); + std::string short1("Hur"); + std::string long1("Hurgle"); + std::string long2("Hurdler"); completer_.addWord(long1); completer_.addWord("Blah"); completer_.addWord(long2); @@ -83,10 +83,10 @@ public: } void testChangeMatch() { - String short1("Hur"); - String short2("Rub"); - String long1("Hurgle"); - String long2("Rubbish"); + std::string short1("Hur"); + std::string short2("Rub"); + std::string long1("Hurgle"); + std::string long2("Rubbish"); completer_.addWord(long2); completer_.addWord("Blah"); completer_.addWord(long1); @@ -106,9 +106,9 @@ public: } void testRemoveDuringComplete() { - String short1("Kev"); - String long1("Kevin"); - String long2("Kevlar"); + std::string short1("Kev"); + std::string long1("Kevin"); + std::string long2("Kevlar"); completer_.addWord(long1); completer_.addWord("Blah"); completer_.addWord(long2); @@ -126,10 +126,10 @@ public: } void testAddDuringComplete() { - String short1("Rem"); - String long1("Remko"); - String long2("Remove"); - String long3("Remedial"); + std::string short1("Rem"); + std::string long1("Remko"); + std::string long2("Remove"); + std::string long3("Remedial"); completer_.addWord(long1); completer_.addWord("Blah"); completer_.addWord(long2); @@ -147,16 +147,16 @@ public: } void testSwiftRoomSample() { - String t("t"); - String Anpan("Anpan"); - String cdubouloz("cdubouloz"); - String Tobias("Tobias"); - String Zash("Zash"); - String lastsky("lastsky"); - String Steve("Steve Kille"); - String Flo("Flo"); - String Test("Test"); - String test("test"); + std::string t("t"); + std::string Anpan("Anpan"); + std::string cdubouloz("cdubouloz"); + std::string Tobias("Tobias"); + std::string Zash("Zash"); + std::string lastsky("lastsky"); + std::string Steve("Steve Kille"); + std::string Flo("Flo"); + std::string Test("Test"); + std::string test("test"); completer_.addWord(Anpan); completer_.addWord(cdubouloz); completer_.addWord(Tobias); diff --git a/Swift/Controllers/CertificateFileStorage.cpp b/Swift/Controllers/CertificateFileStorage.cpp index 65da1ec..4462556 100644 --- a/Swift/Controllers/CertificateFileStorage.cpp +++ b/Swift/Controllers/CertificateFileStorage.cpp @@ -55,7 +55,7 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) { } boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const { - return path / Hexify::hexify(SHA1::getHash(certificate->toDER())).getUTF8String(); + return path / Hexify::hexify(SHA1::getHash(certificate->toDER())); } } diff --git a/Swift/Controllers/CertificateFileStorageFactory.h b/Swift/Controllers/CertificateFileStorageFactory.h index bcac56d..7ed8287 100644 --- a/Swift/Controllers/CertificateFileStorageFactory.h +++ b/Swift/Controllers/CertificateFileStorageFactory.h @@ -17,7 +17,7 @@ namespace Swift { CertificateFileStorageFactory(const boost::filesystem::path& basePath, CertificateFactory* certificateFactory) : basePath(basePath), certificateFactory(certificateFactory) {} virtual CertificateStorage* createCertificateStorage(const JID& profile) const { - boost::filesystem::path profilePath = basePath / profile.toString().getUTF8String(); + boost::filesystem::path profilePath = basePath / profile.toString(); return new CertificateFileStorage(profilePath / "certificates", certificateFactory); } diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 3fffbb1..e4ad9c8 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -35,9 +35,9 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ chatStateTracker_->onChatStateChange.connect(boost::bind(&ChatWindow::setContactChatState, chatWindow_, _1)); stanzaChannel_->onStanzaAcked.connect(boost::bind(&ChatController::handleStanzaAcked, this, _1)); nickResolver_->onNickChanged.connect(boost::bind(&ChatController::handleContactNickChanged, this, _1, _2)); - String nick = nickResolver_->jidToNick(toJID_); + std::string nick = nickResolver_->jidToNick(toJID_); chatWindow_->setName(nick); - String startMessage("Starting chat with " + nick); + std::string startMessage("Starting chat with " + nick); Presence::ref theirPresence; if (isInMUC) { startMessage += " in chatroom " + contact.toBare().toString(); @@ -47,7 +47,7 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ theirPresence = contact.isBare() ? presenceOracle->getHighestPriorityPresence(contact.toBare()) : presenceOracle->getLastPresence(contact); } startMessage += ": " + StatusShow::typeToFriendlyName(theirPresence ? theirPresence->getShow() : StatusShow::None); - if (theirPresence && !theirPresence->getStatus().isEmpty()) { + if (theirPresence && !theirPresence->getStatus().empty()) { startMessage += " (" + theirPresence->getStatus() + ")"; } lastShownStatus_ = theirPresence ? theirPresence->getShow() : StatusShow::None; @@ -59,7 +59,7 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ } -void ChatController::handleContactNickChanged(const JID& jid, const String& /*oldNick*/) { +void ChatController::handleContactNickChanged(const JID& jid, const std::string& /*oldNick*/) { if (jid.toBare() == toJID_.toBare()) { chatWindow_->setName(nickResolver_->jidToNick(jid)); } @@ -108,8 +108,8 @@ void ChatController::preSendMessageRequest(boost::shared_ptr message) { chatStateNotifier_->addChatStateRequest(message); } -void ChatController::postSendMessage(const String& body, boost::shared_ptr sentStanza) { - String id = addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional(), String(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); +void ChatController::postSendMessage(const std::string& body, boost::shared_ptr sentStanza) { + std::string id = addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional(), std::string(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); if (stanzaChannel_->getStreamManagementEnabled()) { chatWindow_->setAckState(id, ChatWindow::Pending); unackedStanzas_[sentStanza] = id; @@ -119,7 +119,7 @@ void ChatController::postSendMessage(const String& body, boost::shared_ptr stanza) { - String id = unackedStanzas_[stanza]; + std::string id = unackedStanzas_[stanza]; if (id != "") { chatWindow_->setAckState(id, ChatWindow::Received); } @@ -128,7 +128,7 @@ void ChatController::handleStanzaAcked(boost::shared_ptr stanza) { void ChatController::setOnline(bool online) { if (!online) { - std::map, String>::iterator it = unackedStanzas_.begin(); + std::map, std::string>::iterator it = unackedStanzas_.begin(); for ( ; it != unackedStanzas_.end(); it++) { chatWindow_->setAckState(it->second, ChatWindow::Failed); } @@ -142,13 +142,13 @@ void ChatController::setOnline(bool online) { ChatControllerBase::setOnline(online); } -String ChatController::senderDisplayNameFromMessage(const JID& from) { +std::string ChatController::senderDisplayNameFromMessage(const JID& from) { return nickResolver_->jidToNick(from); } -String ChatController::getStatusChangeString(boost::shared_ptr presence) { - String nick = senderDisplayNameFromMessage(presence->getFrom()); - String response = nick; +std::string ChatController::getStatusChangeString(boost::shared_ptr presence) { + std::string nick = senderDisplayNameFromMessage(presence->getFrom()); + std::string response = nick; if (!presence || presence->getType() == Presence::Unavailable || presence->getType() == Presence::Error) { response += " has gone offline"; } else if (presence->getType() == Presence::Available) { @@ -161,7 +161,7 @@ String ChatController::getStatusChangeString(boost::shared_ptr presenc response += " is now busy"; } } - if (!presence->getStatus().isEmpty()) { + if (!presence->getStatus().empty()) { response += " (" + presence->getStatus() + ")"; } return response + "."; @@ -188,7 +188,7 @@ void ChatController::handlePresenceChange(boost::shared_ptr newPresenc chatStateTracker_->handlePresenceChange(newPresence); chatStateNotifier_->setContactIsOnline(newPresence->getType() == Presence::Available); - String newStatusChangeString = getStatusChangeString(newPresence); + std::string newStatusChangeString = getStatusChangeString(newPresence); if (newStatusChangeString != lastStatusChangeString_) { if (lastWasPresence_) { chatWindow_->replaceLastMessage(newStatusChangeString); diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h index c013387..b8ac1cd 100644 --- a/Swift/Controllers/Chat/ChatController.h +++ b/Swift/Controllers/Chat/ChatController.h @@ -24,16 +24,16 @@ namespace Swift { private: void handlePresenceChange(boost::shared_ptr newPresence); - String getStatusChangeString(boost::shared_ptr presence); + std::string getStatusChangeString(boost::shared_ptr presence); bool isIncomingMessageFromMe(boost::shared_ptr message); - void postSendMessage(const String &body, boost::shared_ptr sentStanza); + void postSendMessage(const std::string &body, boost::shared_ptr sentStanza); void preHandleIncomingMessage(boost::shared_ptr messageEvent); void preSendMessageRequest(boost::shared_ptr); - String senderDisplayNameFromMessage(const JID& from); + std::string senderDisplayNameFromMessage(const JID& from); virtual boost::optional getMessageTimestamp(boost::shared_ptr) const; void handleStanzaAcked(boost::shared_ptr stanza); void dayTicked() {lastWasPresence_ = false;} - void handleContactNickChanged(const JID& jid, const String& /*oldNick*/); + void handleContactNickChanged(const JID& jid, const std::string& /*oldNick*/); private: NickResolver* nickResolver_; @@ -41,8 +41,8 @@ namespace Swift { ChatStateTracker* chatStateTracker_; bool isInMUC_; bool lastWasPresence_; - String lastStatusChangeString_; - std::map, String> unackedStanzas_; + std::string lastStatusChangeString_; + std::map, std::string> unackedStanzas_; StatusShow::Type lastShownStatus_; }; } diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index ca0916d..f70ec81 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -11,7 +11,9 @@ #include #include #include +#include +#include "Swiften/Base/String.h" #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Elements/Delay.h" #include "Swiften/Base/foreach.h" @@ -49,7 +51,7 @@ void ChatControllerBase::createDayChangeTimer() { void ChatControllerBase::handleDayChangeTick() { dateChangeTimer_->stop(); boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); - chatWindow_->addSystemMessage("The day is now " + String(boost::posix_time::to_iso_extended_string(now)).getSubstring(0,10)); + chatWindow_->addSystemMessage("The day is now " + std::string(boost::posix_time::to_iso_extended_string(now)).substr(0,10)); dayTicked(); createDayChangeTimer(); } @@ -84,8 +86,8 @@ void ChatControllerBase::handleAllMessagesRead() { chatWindow_->setUnreadMessageCount(0); } -void ChatControllerBase::handleSendMessageRequest(const String &body) { - if (!stanzaChannel_->isAvailable() || body.isEmpty()) { +void ChatControllerBase::handleSendMessageRequest(const std::string &body) { + if (!stanzaChannel_->isAvailable() || body.empty()) { return; } boost::shared_ptr message(new Message()); @@ -130,9 +132,9 @@ void ChatControllerBase::activateChatWindow() { chatWindow_->activate(); } -String ChatControllerBase::addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time) { - if (message.beginsWith("/me ")) { - return chatWindow_->addAction(message.getSplittedAtFirst(' ').second, senderName, senderIsSelf, label, avatarPath, time); +std::string ChatControllerBase::addMessage(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { + if (boost::starts_with(message, "/me ")) { + return chatWindow_->addAction(String::getSplittedAtFirst(message, ' ').second, senderName, senderIsSelf, label, avatarPath, time); } else { return chatWindow_->addMessage(message, senderName, senderIsSelf, label, avatarPath, time); } @@ -148,9 +150,9 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr m unreadMessages_.push_back(messageEvent); } boost::shared_ptr message = messageEvent->getStanza(); - String body = message->getBody(); + std::string body = message->getBody(); if (message->isError()) { - String errorMessage = getErrorMessage(message->getPayload()); + std::string errorMessage = getErrorMessage(message->getPayload()); chatWindow_->addErrorMessage(errorMessage); } else { @@ -167,7 +169,7 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr m boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time(); std::ostringstream s; s << "The following message took " << (now - delayPayloads[i]->getStamp()).total_milliseconds() / 1000.0 << " seconds to be delivered from " << delayPayloads[i]->getFrom()->toString() << "."; - chatWindow_->addSystemMessage(String(s.str())); + chatWindow_->addSystemMessage(std::string(s.str())); } boost::shared_ptr label = message->getPayload(); boost::optional maybeLabel = label ? boost::optional(*label) : boost::optional(); @@ -179,15 +181,15 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr m timeStamp = *messageTimeStamp; } - addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), maybeLabel, String(avatarManager_->getAvatarPath(from).string()), timeStamp); + addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), maybeLabel, std::string(avatarManager_->getAvatarPath(from).string()), timeStamp); } chatWindow_->show(); chatWindow_->setUnreadMessageCount(unreadMessages_.size()); } -String ChatControllerBase::getErrorMessage(boost::shared_ptr error) { - String defaultMessage = "Error sending message"; - if (!error->getText().isEmpty()) { +std::string ChatControllerBase::getErrorMessage(boost::shared_ptr error) { + std::string defaultMessage = "Error sending message"; + if (!error->getText().empty()) { return error->getText(); } else { diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index e1e5e62..4a1f8e0 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -18,7 +18,7 @@ #include "Swiften/Network/Timer.h" #include "Swiften/Network/TimerFactory.h" #include "Swiften/Elements/Stanza.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/DiscoInfo.h" #include "Swift/Controllers/XMPPEvents/MessageEvent.h" #include "Swiften/JID/JID.h" @@ -43,7 +43,7 @@ namespace Swift { void activateChatWindow(); void setAvailableServerFeatures(boost::shared_ptr info); void handleIncomingMessage(boost::shared_ptr message); - String addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time); + std::string addMessage(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time); virtual void setOnline(bool online); virtual void setEnabled(bool enabled); virtual void setToJID(const JID& jid) {toJID_ = jid;}; @@ -53,8 +53,8 @@ namespace Swift { /** * Pass the Message appended, and the stanza used to send it. */ - virtual void postSendMessage(const String&, boost::shared_ptr) {}; - virtual String senderDisplayNameFromMessage(const JID& from) = 0; + virtual void postSendMessage(const std::string&, boost::shared_ptr) {}; + virtual std::string senderDisplayNameFromMessage(const JID& from) = 0; virtual bool isIncomingMessageFromMe(boost::shared_ptr) = 0; virtual void preHandleIncomingMessage(boost::shared_ptr) {}; virtual void preSendMessageRequest(boost::shared_ptr) {}; @@ -64,10 +64,10 @@ namespace Swift { private: void createDayChangeTimer(); - void handleSendMessageRequest(const String &body); + void handleSendMessageRequest(const std::string &body); void handleAllMessagesRead(); void handleSecurityLabelsCatalogResponse(boost::shared_ptr, ErrorPayload::ref error); - String getErrorMessage(boost::shared_ptr); + std::string getErrorMessage(boost::shared_ptr); void handleDayChangeTick(); protected: diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index b7e8432..94d4b9a 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -221,7 +221,7 @@ void ChatsManager::setOnline(bool enabled) { } -void ChatsManager::handleChatRequest(const String &contact) { +void ChatsManager::handleChatRequest(const std::string &contact) { ChatController* controller = getChatControllerOrFindAnother(JID(contact)); controller->activateChatWindow(); } @@ -280,7 +280,7 @@ void ChatsManager::rebindControllerJID(const JID& from, const JID& to) { chatControllers_[to]->setToJID(to); } -void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional& nickMaybe, bool autoJoin) { +void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional& nickMaybe, bool autoJoin) { if (autoJoin) { MUCBookmark bookmark(mucJID, mucJID.getNode()); bookmark.setAutojoin(true); @@ -294,7 +294,7 @@ void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional if (it != mucControllers_.end()) { it->second->rejoin(); } else { - String nick = nickMaybe ? nickMaybe.get() : jid_.getNode(); + std::string nick = nickMaybe ? nickMaybe.get() : jid_.getNode(); MUC::ref muc = mucManager->createMUC(mucJID); MUCController* controller = new MUCController(jid_, muc, nick, stanzaChannel_, iqRouter_, chatWindowFactory_, presenceOracle_, avatarManager_, uiEventStream_, false, timerFactory_, eventController_); mucControllers_[mucJID] = controller; @@ -311,7 +311,7 @@ void ChatsManager::handleSearchMUCRequest() { void ChatsManager::handleIncomingMessage(boost::shared_ptr message) { JID jid = message->getFrom(); boost::shared_ptr event(new MessageEvent(message)); - if (!event->isReadable() && !message->getPayload() && message->getSubject().isEmpty()) { + if (!event->isReadable() && !message->getPayload() && message->getSubject().empty()) { return; } diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index 62b14d9..3740186 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -10,7 +10,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/DiscoInfo.h" #include "Swiften/Elements/Message.h" #include "Swiften/Elements/Presence.h" @@ -52,8 +52,8 @@ namespace Swift { void setServerDiscoInfo(boost::shared_ptr info); void handleIncomingMessage(boost::shared_ptr message); private: - void handleChatRequest(const String& contact); - void handleJoinMUCRequest(const JID& muc, const boost::optional& nick, bool autoJoin); + void handleChatRequest(const std::string& contact); + void handleJoinMUCRequest(const JID& muc, const boost::optional& nick, bool autoJoin); void handleSearchMUCRequest(); void handleMUCSelectedAfterSearch(const JID&); void rebindControllerJID(const JID& from, const JID& to); diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 0ed2b35..765c49d 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "Swiften/Network/Timer.h" #include "Swiften/Network/TimerFactory.h" @@ -38,7 +39,7 @@ namespace Swift { MUCController::MUCController ( const JID& self, MUC::ref muc, - const String &nick, + const std::string &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, @@ -119,8 +120,8 @@ void MUCController::receivedActivity() { void MUCController::handleJoinFailed(boost::shared_ptr error) { receivedActivity(); - String errorMessage = "Unable to join this room"; - String rejoinNick; + std::string errorMessage = "Unable to join this room"; + std::string rejoinNick; if (error) { switch (error->getCondition()) { case ErrorPayload::Conflict: rejoinNick = nick_ + "_"; errorMessage += " as " + nick_ + ", retrying as " + rejoinNick; break; @@ -136,17 +137,17 @@ void MUCController::handleJoinFailed(boost::shared_ptr error) { } errorMessage += "."; chatWindow_->addErrorMessage(errorMessage); - if (!rejoinNick.isEmpty()) { + if (!rejoinNick.empty()) { nick_ = rejoinNick; parting_ = true; rejoin(); } } -void MUCController::handleJoinComplete(const String& nick) { +void MUCController::handleJoinComplete(const std::string& nick) { receivedActivity(); joined_ = true; - String joinMessage = "You have joined room " + toJID_.toString() + " as " + nick; + std::string joinMessage = "You have joined room " + toJID_.toString() + " as " + nick; nick_ = nick; chatWindow_->addSystemMessage(joinMessage); clearPresenceQueue(); @@ -158,7 +159,7 @@ void MUCController::handleAvatarChanged(const JID& jid) { if (parting_ || !jid.equals(toJID_, JID::WithoutResource)) { return; } - String path = avatarManager_->getAvatarPath(jid).string(); + std::string path = avatarManager_->getAvatarPath(jid).string(); roster_->applyOnItems(SetAvatar(jid, path, JID::WithResource)); } @@ -184,7 +185,7 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { appendToJoinParts(joinParts_, event); roster_->addContact(jid, realJID, occupant.getNick(), roleToGroupName(occupant.getRole()), avatarManager_->getAvatarPath(jid).string()); if (joined_) { - String joinString = occupant.getNick() + " has joined the room"; + std::string joinString = occupant.getNick() + " has joined the room"; MUCOccupant::Role role = occupant.getRole(); if (role != MUCOccupant::NoRole && role != MUCOccupant::Participant) { joinString += " as a " + roleToFriendlyName(role); @@ -203,7 +204,7 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { } } -void MUCController::addPresenceMessage(const String& message) { +void MUCController::addPresenceMessage(const std::string& message) { lastWasPresence_ = true; chatWindow_->addPresenceMessage(message); } @@ -213,7 +214,7 @@ void MUCController::clearPresenceQueue() { joinParts_.clear(); } -String MUCController::roleToFriendlyName(MUCOccupant::Role role) { +std::string MUCController::roleToFriendlyName(MUCOccupant::Role role) { switch (role) { case MUCOccupant::Moderator: return "moderator"; case MUCOccupant::Participant: return "participant"; @@ -223,14 +224,14 @@ String MUCController::roleToFriendlyName(MUCOccupant::Role role) { return ""; } -JID MUCController::nickToJID(const String& nick) { +JID MUCController::nickToJID(const std::string& nick) { return JID(toJID_.getNode(), toJID_.getDomain(), nick); } bool MUCController::messageTargetsMe(boost::shared_ptr message) { - String stringRegexp(".*\\b" + nick_.getLowerCase() + "\\b.*"); - boost::regex myRegexp(stringRegexp.getUTF8String()); - return boost::regex_match(message->getBody().getLowerCase().getUTF8String(), myRegexp); + std::string stringRegexp(".*\\b" + boost::to_lower_copy(nick_) + "\\b.*"); + boost::regex myRegexp(stringRegexp); + return boost::regex_match(boost::to_lower_copy(message->getBody()), myRegexp); } void MUCController::preHandleIncomingMessage(boost::shared_ptr messageEvent) { @@ -246,7 +247,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr mes } } if (joined_) { - String nick = message->getFrom().getResource(); + std::string nick = message->getFrom().getResource(); if (nick != nick_ && currentOccupants_.find(nick) != currentOccupants_.end()) { completer_->addWord(nick); } @@ -255,7 +256,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr mes receivedActivity(); joined_ = true; - if (!message->getSubject().isEmpty() && message->getBody().isEmpty()) { + if (!message->getSubject().empty() && message->getBody().empty()) { chatWindow_->addSystemMessage("The room subject is now: " + message->getSubject()); doneGettingHistory_ = true; } @@ -269,7 +270,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr mes } } -void MUCController::handleOccupantRoleChanged(const String& nick, const MUCOccupant& occupant, const MUCOccupant::Role& oldRole) { +void MUCController::handleOccupantRoleChanged(const std::string& nick, const MUCOccupant& occupant, const MUCOccupant::Role& oldRole) { clearPresenceQueue(); receivedActivity(); JID jid(nickToJID(nick)); @@ -282,8 +283,8 @@ void MUCController::handleOccupantRoleChanged(const String& nick, const MUCOccup chatWindow_->addSystemMessage(nick + " is now a " + roleToFriendlyName(occupant.getRole())); } -String MUCController::roleToGroupName(MUCOccupant::Role role) { - String result; +std::string MUCController::roleToGroupName(MUCOccupant::Role role) { + std::string result; switch (role) { case MUCOccupant::Moderator: result = "Moderators"; break; case MUCOccupant::Participant: result = "Participants"; break; @@ -326,13 +327,13 @@ bool MUCController::shouldUpdateJoinParts() { return lastWasPresence_; } -void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType, const String& reason) { +void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType, const std::string& reason) { NickJoinPart event(occupant.getNick(), Part); appendToJoinParts(joinParts_, event); currentOccupants_.erase(occupant.getNick()); completer_->removeWord(occupant.getNick()); - String partMessage = (occupant.getNick() != nick_) ? occupant.getNick() + " has left the room" : "You have left the room"; - if (!reason.isEmpty()) { + std::string partMessage = (occupant.getNick() != nick_) ? occupant.getNick() + " has left the room" : "You have left the room"; + if (!reason.empty()) { partMessage += " (" + reason + ")"; } partMessage += "."; @@ -361,7 +362,7 @@ bool MUCController::isIncomingMessageFromMe(boost::shared_ptr message) return nick_ == from.getResource(); } -String MUCController::senderDisplayNameFromMessage(const JID& from) { +std::string MUCController::senderDisplayNameFromMessage(const JID& from) { return from.getResource(); } @@ -398,8 +399,8 @@ void MUCController::appendToJoinParts(std::vector& joinParts, cons } } -String MUCController::concatenateListOfNames(const std::vector& joinParts) { - String result; +std::string MUCController::concatenateListOfNames(const std::vector& joinParts) { + std::string result; for (size_t i = 0; i < joinParts.size(); i++) { if (i > 0) { if (i < joinParts.size() - 1) { @@ -414,18 +415,18 @@ String MUCController::concatenateListOfNames(const std::vector& jo return result; } -String MUCController::generateJoinPartString(const std::vector& joinParts) { +std::string MUCController::generateJoinPartString(const std::vector& joinParts) { std::vector sorted[4]; - String eventStrings[4]; + std::string eventStrings[4]; foreach (NickJoinPart event, joinParts) { sorted[event.type].push_back(event); } - String result; + std::string result; std::vector populatedEvents; for (size_t i = 0; i < 4; i++) { - String eventString = concatenateListOfNames(sorted[i]); - if (!eventString.isEmpty()) { - String haveHas = sorted[i].size() > 1 ? " have" : " has"; + std::string eventString = concatenateListOfNames(sorted[i]); + if (!eventString.empty()) { + std::string haveHas = sorted[i].size() > 1 ? " have" : " has"; switch (i) { case Join: eventString += haveHas + " joined";break; case Part: eventString += haveHas + " left";break; diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index 258b730..30f7aa5 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -11,7 +11,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Network/Timer.h" #include "Swift/Controllers/Chat/ChatControllerBase.h" #include "Swiften/Elements/Message.h" @@ -34,44 +34,44 @@ namespace Swift { enum JoinPart {Join, Part, JoinThenPart, PartThenJoin}; struct NickJoinPart { - NickJoinPart(const String& nick, JoinPart type) : nick(nick), type(type) {}; - String nick; + NickJoinPart(const std::string& nick, JoinPart type) : nick(nick), type(type) {}; + std::string nick; JoinPart type; }; class MUCController : public ChatControllerBase { public: - MUCController(const JID& self, MUC::ref muc, const String &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, PresenceOracle* presenceOracle, AvatarManager* avatarManager, UIEventStream* events, bool useDelayForLatency, TimerFactory* timerFactory, EventController* eventController); + MUCController(const JID& self, MUC::ref muc, const std::string &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, PresenceOracle* presenceOracle, AvatarManager* avatarManager, UIEventStream* events, bool useDelayForLatency, TimerFactory* timerFactory, EventController* eventController); ~MUCController(); boost::signal onUserLeft; virtual void setOnline(bool online); void rejoin(); static void appendToJoinParts(std::vector& joinParts, const NickJoinPart& newEvent); - static String generateJoinPartString(const std::vector& joinParts); - static String concatenateListOfNames(const std::vector& joinParts); + static std::string generateJoinPartString(const std::vector& joinParts); + static std::string concatenateListOfNames(const std::vector& joinParts); protected: void preSendMessageRequest(boost::shared_ptr message); bool isIncomingMessageFromMe(boost::shared_ptr message); - String senderDisplayNameFromMessage(const JID& from); + std::string senderDisplayNameFromMessage(const JID& from); boost::optional getMessageTimestamp(boost::shared_ptr message) const; void preHandleIncomingMessage(boost::shared_ptr); private: void clearPresenceQueue(); - void addPresenceMessage(const String& message); + void addPresenceMessage(const std::string& message); void handleWindowClosed(); void handleAvatarChanged(const JID& jid); void handleOccupantJoined(const MUCOccupant& occupant); - void handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType type, const String& reason); + void handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType type, const std::string& reason); void handleOccupantPresenceChange(boost::shared_ptr presence); - void handleOccupantRoleChanged(const String& nick, const MUCOccupant& occupant,const MUCOccupant::Role& oldRole); - void handleJoinComplete(const String& nick); + void handleOccupantRoleChanged(const std::string& nick, const MUCOccupant& occupant,const MUCOccupant::Role& oldRole); + void handleJoinComplete(const std::string& nick); void handleJoinFailed(boost::shared_ptr error); void handleJoinTimeoutTick(); - String roleToGroupName(MUCOccupant::Role role); - JID nickToJID(const String& nick); - String roleToFriendlyName(MUCOccupant::Role role); + std::string roleToGroupName(MUCOccupant::Role role); + JID nickToJID(const std::string& nick); + std::string roleToFriendlyName(MUCOccupant::Role role); void receivedActivity(); bool messageTargetsMe(boost::shared_ptr message); void updateJoinParts(); @@ -82,8 +82,8 @@ namespace Swift { private: MUC::ref muc_; UIEventStream* events_; - String nick_; - String desiredNick_; + std::string nick_; + std::string desiredNick_; Roster* roster_; TabComplete* completer_; bool parting_; @@ -93,7 +93,7 @@ namespace Swift { bool doneGettingHistory_; boost::bsignals::scoped_connection avatarChangedConnection_; boost::shared_ptr loginCheckTimer_; - std::set currentOccupants_; + std::set currentOccupants_; std::vector joinParts_; boost::posix_time::ptime lastActivity_; }; diff --git a/Swift/Controllers/Chat/MUCSearchController.cpp b/Swift/Controllers/Chat/MUCSearchController.cpp index 2b25e2a..743aabb 100644 --- a/Swift/Controllers/Chat/MUCSearchController.cpp +++ b/Swift/Controllers/Chat/MUCSearchController.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -20,7 +21,7 @@ namespace Swift { -static const String SEARCHED_SERVICES = "searchedServices"; +static const std::string SEARCHED_SERVICES = "searchedServices"; MUCSearchController::MUCSearchController(const JID& jid, MUCSearchWindowFactory* factory, IQRouter* iqRouter, SettingsProvider* settings) : jid_(jid), factory_(factory), iqRouter_(iqRouter), settings_(settings), window_(NULL), walker_(NULL) { itemsInProgress_ = 0; @@ -45,7 +46,7 @@ void MUCSearchController::openSearchWindow() { void MUCSearchController::loadSavedServices() { savedServices_.clear(); - foreach (String stringItem, settings_->getStringSetting(SEARCHED_SERVICES).split('\n')) { + foreach (std::string stringItem, String::split(settings_->getStringSetting(SEARCHED_SERVICES), '\n')) { savedServices_.push_back(JID(stringItem)); } } @@ -54,13 +55,13 @@ void MUCSearchController::addToSavedServices(const JID& jid) { savedServices_.erase(std::remove(savedServices_.begin(), savedServices_.end(), jid), savedServices_.end()); savedServices_.push_front(jid); - String collapsed; + std::string collapsed; int i = 0; foreach (JID jidItem, savedServices_) { if (i >= 15) { break; } - if (!collapsed.isEmpty()) { + if (!collapsed.empty()) { collapsed += "\n"; } collapsed += jidItem.toString(); @@ -100,7 +101,7 @@ void MUCSearchController::handleSearchService(const JID& jid) { void MUCSearchController::handleDiscoServiceFound(const JID& jid, boost::shared_ptr info) { bool isMUC = false; - String name; + std::string name; foreach (DiscoInfo::Identity identity, info->getIdentities()) { if ((identity.getCategory() == "directory" && identity.getType() == "chatroom") diff --git a/Swift/Controllers/Chat/MUCSearchController.h b/Swift/Controllers/Chat/MUCSearchController.h index 6d3afd1..b348886 100644 --- a/Swift/Controllers/Chat/MUCSearchController.h +++ b/Swift/Controllers/Chat/MUCSearchController.h @@ -12,7 +12,7 @@ #include #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swift/Controllers/UIEvents/UIEvent.h" @@ -34,13 +34,13 @@ namespace Swift { public: class MUCRoom { public: - MUCRoom(const String& node, const String& name, int occupants) : node_(node), name_(name), occupants_(occupants) {} - String getNode() {return node_;} - String getName() {return name_;} + MUCRoom(const std::string& node, const std::string& name, int occupants) : node_(node), name_(name), occupants_(occupants) {} + std::string getNode() {return node_;} + std::string getName() {return name_;} int getOccupantCount() {return occupants_;} private: - String node_; - String name_; + std::string node_; + std::string name_; int occupants_; }; @@ -50,7 +50,7 @@ namespace Swift { complete_ = complete; } - void setName(const String& name) { + void setName(const std::string& name) { name_ = name; } @@ -66,11 +66,11 @@ namespace Swift { return jid_; } - String getName() const { + std::string getName() const { return name_; } - void setError(const String& errorText) {error_ = true; errorText_ = errorText;} + void setError(const std::string& errorText) {error_ = true; errorText_ = errorText;} void clearRooms() {rooms_.clear();} @@ -78,12 +78,12 @@ namespace Swift { std::vector getRooms() const {return rooms_;} private: - String name_; + std::string name_; JID jid_; std::vector rooms_; bool complete_; bool error_; - String errorText_; + std::string errorText_; }; class MUCSearchController { diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index 4d6ca08..40f7445 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -43,7 +43,7 @@ using namespace Swift; class DummyCapsProvider : public CapsProvider { - DiscoInfo::ref getCaps(const String&) const {return DiscoInfo::ref(new DiscoInfo());} + DiscoInfo::ref getCaps(const std::string&) const {return DiscoInfo::ref(new DiscoInfo());} }; class ChatsManagerTest : public CppUnit::TestFixture { @@ -119,7 +119,7 @@ public: boost::shared_ptr message(new Message()); message->setFrom(messageJID); - String body("This is a legible message. >HEH@)oeueu"); + std::string body("This is a legible message. >HEH@)oeueu"); message->setBody(body); manager_->handleIncomingMessage(message); CPPUNIT_ASSERT_EQUAL(body, window->lastMessageBody_); @@ -133,7 +133,7 @@ public: boost::shared_ptr message1(new Message()); message1->setFrom(messageJID1); - String body1("This is a legible message. >HEH@)oeueu"); + std::string body1("This is a legible message. >HEH@)oeueu"); message1->setBody(body1); manager_->handleIncomingMessage(message1); CPPUNIT_ASSERT_EQUAL(body1, window1->lastMessageBody_); @@ -145,14 +145,14 @@ public: boost::shared_ptr message2(new Message()); message2->setFrom(messageJID2); - String body2("This is a legible message. .cmaulm.chul"); + std::string body2("This is a legible message. .cmaulm.chul"); message2->setBody(body2); manager_->handleIncomingMessage(message2); CPPUNIT_ASSERT_EQUAL(body2, window1->lastMessageBody_); } void testFirstOpenWindowOutgoing() { - String messageJIDString("testling@test.com"); + std::string messageJIDString("testling@test.com"); ChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString), uiEventStream_).Return(window); @@ -162,8 +162,8 @@ public: void testFirstOpenWindowBareToFull() { - String bareJIDString("testling@test.com"); - String fullJIDString("testling@test.com/resource1"); + std::string bareJIDString("testling@test.com"); + std::string fullJIDString("testling@test.com/resource1"); MockChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(bareJIDString), uiEventStream_).Return(window); @@ -171,19 +171,19 @@ public: boost::shared_ptr message(new Message()); message->setFrom(JID(fullJIDString)); - String body("This is a legible message. mjuga3089gm8G(*>M)@*("); + std::string body("This is a legible message. mjuga3089gm8G(*>M)@*("); message->setBody(body); manager_->handleIncomingMessage(message); CPPUNIT_ASSERT_EQUAL(body, window->lastMessageBody_); } void testSecondWindow() { - String messageJIDString1("testling1@test.com"); + std::string messageJIDString1("testling1@test.com"); ChatWindow* window1 = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1); uiEventStream_->send(boost::shared_ptr(new RequestChatUIEvent(JID(messageJIDString1)))); - String messageJIDString2("testling2@test.com"); + std::string messageJIDString2("testling2@test.com"); ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString2), uiEventStream_).Return(window2); @@ -197,9 +197,9 @@ public: Rebind it. */ void testUnbindRebind() { - String bareJIDString("testling@test.com"); - String fullJIDString1("testling@test.com/resource1"); - String fullJIDString2("testling@test.com/resource2"); + std::string bareJIDString("testling@test.com"); + std::string fullJIDString1("testling@test.com/resource1"); + std::string fullJIDString2("testling@test.com/resource2"); MockChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(bareJIDString), uiEventStream_).Return(window); @@ -207,7 +207,7 @@ public: boost::shared_ptr message1(new Message()); message1->setFrom(JID(fullJIDString1)); - String messageBody1("This is a legible message."); + std::string messageBody1("This is a legible message."); message1->setBody(messageBody1); manager_->handleIncomingMessage(message1); CPPUNIT_ASSERT_EQUAL(messageBody1, window->lastMessageBody_); @@ -221,7 +221,7 @@ public: boost::shared_ptr message2(new Message()); message2->setFrom(JID(fullJIDString2)); - String messageBody2("This is another legible message."); + std::string messageBody2("This is another legible message."); message2->setBody(messageBody2); manager_->handleIncomingMessage(message2); CPPUNIT_ASSERT_EQUAL(messageBody2, window->lastMessageBody_); @@ -234,21 +234,21 @@ public: JID muc("testling@test.com"); ChatWindow* mucWindow = new MockChatWindow(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(muc, uiEventStream_).Return(mucWindow); - uiEventStream_->send(boost::shared_ptr(new JoinMUCUIEvent(muc, String("nick")))); + uiEventStream_->send(boost::shared_ptr(new JoinMUCUIEvent(muc, std::string("nick")))); - String messageJIDString1("testling@test.com/1"); + std::string messageJIDString1("testling@test.com/1"); ChatWindow* window1 = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1); uiEventStream_->send(boost::shared_ptr(new RequestChatUIEvent(JID(messageJIDString1)))); - String messageJIDString2("testling@test.com/2"); + std::string messageJIDString2("testling@test.com/2"); ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString2), uiEventStream_).Return(window2); uiEventStream_->send(boost::shared_ptr(new RequestChatUIEvent(JID(messageJIDString2)))); - String messageJIDString3("testling@test.com/3"); + std::string messageJIDString3("testling@test.com/3"); ChatWindow* window3 = new MockChatWindow();//mocks_->InterfaceMock(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString3), uiEventStream_).Return(window3); @@ -308,14 +308,14 @@ public: boost::shared_ptr message3(new Message()); message3->setFrom(messageJID3); - String body3("This is a legible message3."); + std::string body3("This is a legible message3."); message3->setBody(body3); manager_->handleIncomingMessage(message3); CPPUNIT_ASSERT_EQUAL(body3, window1->lastMessageBody_); boost::shared_ptr message2b(new Message()); message2b->setFrom(messageJID2); - String body2b("This is a legible message2b."); + std::string body2b("This is a legible message2b."); message2b->setBody(body2b); manager_->handleIncomingMessage(message2b); CPPUNIT_ASSERT_EQUAL(body2b, window1->lastMessageBody_); diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index 62f0ccd..7c7a8b9 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "3rdParty/hippomocks.h" #include "Swift/Controllers/XMPPEvents/EventController.h" @@ -112,7 +113,7 @@ public: message = Message::ref(new Message()); message->setFrom(JID(muc_->getJID().toString() + "/other2")); - message->setBody("Hi " + nick_.getLowerCase() + "."); + message->setBody("Hi " + boost::to_lower_copy(nick_) + "."); message->setType(Message::Groupchat); controller_->handleIncomingMessage(MessageEvent::ref(new MessageEvent(message))); CPPUNIT_ASSERT_EQUAL((size_t)4, eventController_->getEvents().size()); @@ -126,7 +127,7 @@ public: message = Message::ref(new Message()); message->setFrom(JID(muc_->getJID().toString() + "/other2")); - message->setBody("Hi " + nick_.getLowerCase() + "ie."); + message->setBody("Hi " + boost::to_lower_copy(nick_) + "ie."); message->setType(Message::Groupchat); controller_->handleIncomingMessage(MessageEvent::ref(new MessageEvent(message))); CPPUNIT_ASSERT_EQUAL((size_t)4, eventController_->getEvents().size()); @@ -199,31 +200,31 @@ public: void testJoinPartStringContructionSimple() { std::vector list; list.push_back(NickJoinPart("Kev", Join)); - CPPUNIT_ASSERT_EQUAL(String("Kev has joined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Remko", Part)); - CPPUNIT_ASSERT_EQUAL(String("Kev has joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined and Remko has left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Bert", Join)); - CPPUNIT_ASSERT_EQUAL(String("Kev and Bert have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev and Bert have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Ernie", Join)); - CPPUNIT_ASSERT_EQUAL(String("Kev, Bert and Ernie have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev, Bert and Ernie have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); } void testJoinPartStringContructionMixed() { std::vector list; list.push_back(NickJoinPart("Kev", JoinThenPart)); - CPPUNIT_ASSERT_EQUAL(String("Kev joined then left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev joined then left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Remko", Part)); - CPPUNIT_ASSERT_EQUAL(String("Remko has left and Kev joined then left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left and Kev joined then left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Bert", PartThenJoin)); - CPPUNIT_ASSERT_EQUAL(String("Remko has left, Kev joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left, Kev joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Ernie", JoinThenPart)); - CPPUNIT_ASSERT_EQUAL(String("Remko has left, Kev and Ernie joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left, Kev and Ernie joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); } private: JID self_; MUC::ref muc_; - String nick_; + std::string nick_; StanzaChannel* stanzaChannel_; IQChannel* iqChannel_; IQRouter* iqRouter_; diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index 7473849..37059c2 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -92,7 +92,7 @@ void UserSearchController::handleDiscoServiceFound(const JID& jid, boost::shared isUserDirectory = true; } } - std::vector features = info->getFeatures(); + std::vector features = info->getFeatures(); supports55 = std::find(features.begin(), features.end(), DiscoInfo::JabberSearchFeature) != features.end(); if (/*isUserDirectory && */supports55) { //FIXME: once M-Link correctly advertises directoryness. /* Abort further searches.*/ @@ -125,7 +125,7 @@ void UserSearchController::handleSearchResponse(boost::shared_ptr std::vector results; foreach (SearchPayload::Item item, resultsPayload->getItems()) { JID jid(item.jid); - std::map fields; + std::map fields; fields["first"] = item.first; fields["last"] = item.last; fields["nick"] = item.nick; diff --git a/Swift/Controllers/Chat/UserSearchController.h b/Swift/Controllers/Chat/UserSearchController.h index 9b81020..69795fb 100644 --- a/Swift/Controllers/Chat/UserSearchController.h +++ b/Swift/Controllers/Chat/UserSearchController.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -28,12 +28,12 @@ namespace Swift { class UserSearchResult { public: - UserSearchResult(const JID& jid, const std::map& fields) : jid_(jid), fields_(fields) {} + UserSearchResult(const JID& jid, const std::map& fields) : jid_(jid), fields_(fields) {} const JID& getJID() const {return jid_;} - const std::map& getFields() const {return fields_;} + const std::map& getFields() const {return fields_;} private: JID jid_; - std::map fields_; + std::map fields_; }; class UserSearchController { diff --git a/Swift/Controllers/ContactEditController.cpp b/Swift/Controllers/ContactEditController.cpp index de99895..b4729a8 100644 --- a/Swift/Controllers/ContactEditController.cpp +++ b/Swift/Controllers/ContactEditController.cpp @@ -60,13 +60,13 @@ void ContactEditController::handleRemoveContactRequest() { contactEditWindow->hide(); } -void ContactEditController::handleChangeContactRequest(const String& name, const std::set& newGroups) { - std::vector oldGroupsVector = currentContact->getGroups(); - std::set oldGroups(oldGroupsVector.begin(), oldGroupsVector.end()); +void ContactEditController::handleChangeContactRequest(const std::string& name, const std::set& newGroups) { + std::vector oldGroupsVector = currentContact->getGroups(); + std::set oldGroups(oldGroupsVector.begin(), oldGroupsVector.end()); if (oldGroups != newGroups || currentContact->getName() != name) { XMPPRosterItem newContact(*currentContact); newContact.setName(name); - newContact.setGroups(std::vector(newGroups.begin(), newGroups.end())); + newContact.setGroups(std::vector(newGroups.begin(), newGroups.end())); rosterController->updateItem(newContact); } contactEditWindow->hide(); diff --git a/Swift/Controllers/ContactEditController.h b/Swift/Controllers/ContactEditController.h index b5c8101..1947944 100644 --- a/Swift/Controllers/ContactEditController.h +++ b/Swift/Controllers/ContactEditController.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -30,7 +30,7 @@ namespace Swift { private: void handleRemoveContactRequest(); - void handleChangeContactRequest(const String& name, const std::set& groups); + void handleChangeContactRequest(const std::string& name, const std::set& groups); private: void handleUIEvent(UIEvent::ref event); diff --git a/Swift/Controllers/DiscoServiceWalker.cpp b/Swift/Controllers/DiscoServiceWalker.cpp index 15d2aaa..ce29927 100644 --- a/Swift/Controllers/DiscoServiceWalker.cpp +++ b/Swift/Controllers/DiscoServiceWalker.cpp @@ -110,7 +110,7 @@ void DiscoServiceWalker::handleDiscoItemsResponse(boost::shared_ptr return; } foreach (DiscoItems::Item item, items->getItems()) { - if (item.getNode().isEmpty()) { + if (item.getNode().empty()) { /* Don't look at noded items. It's possible that this will exclude some services, * but I've never seen one in the wild, and it's an easy fix for not looping. */ diff --git a/Swift/Controllers/DiscoServiceWalker.h b/Swift/Controllers/DiscoServiceWalker.h index 00e2436..7982bbc 100644 --- a/Swift/Controllers/DiscoServiceWalker.h +++ b/Swift/Controllers/DiscoServiceWalker.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include diff --git a/Swift/Controllers/EventNotifier.cpp b/Swift/Controllers/EventNotifier.cpp index 343abd9..405fa77 100644 --- a/Swift/Controllers/EventNotifier.cpp +++ b/Swift/Controllers/EventNotifier.cpp @@ -31,8 +31,8 @@ EventNotifier::~EventNotifier() { void EventNotifier::handleEventAdded(boost::shared_ptr event) { if (boost::shared_ptr messageEvent = boost::dynamic_pointer_cast(event)) { JID jid = messageEvent->getStanza()->getFrom(); - String title = nickResolver->jidToNick(jid); - if (!messageEvent->getStanza()->isError() && !messageEvent->getStanza()->getBody().isEmpty()) { + std::string title = nickResolver->jidToNick(jid); + if (!messageEvent->getStanza()->isError() && !messageEvent->getStanza()->getBody().empty()) { JID activationJID = jid; if (messageEvent->getStanza()->getType() == Message::Groupchat) { activationJID = jid.toBare(); @@ -42,8 +42,8 @@ void EventNotifier::handleEventAdded(boost::shared_ptr event) { } else if(boost::shared_ptr subscriptionEvent = boost::dynamic_pointer_cast(event)) { JID jid = subscriptionEvent->getJID(); - String title = ""; - String message = nickResolver->jidToNick(jid) + " wants to add you to his/her roster"; + std::string title = ""; + std::string message = nickResolver->jidToNick(jid) + " wants to add you to his/her roster"; notifier->showMessage(Notifier::SystemMessage, title, message, boost::filesystem::path(), boost::function()); } else if(boost::shared_ptr errorEvent = boost::dynamic_pointer_cast(event)) { diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 31a1d5a..1257845 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -41,7 +41,7 @@ #include "SwifTools/Dock/Dock.h" #include "SwifTools/Notifier/TogglableNotifier.h" #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Client/Client.h" #include "Swiften/Presence/PresenceSender.h" #include "Swiften/Elements/ChatState.h" @@ -66,10 +66,10 @@ namespace Swift { -static const String CLIENT_NAME = "Swift"; -static const String CLIENT_NODE = "http://swift.im"; +static const std::string CLIENT_NAME = "Swift"; +static const std::string CLIENT_NODE = "http://swift.im"; -static const String SHOW_NOTIFICATIONS = "showNotifications"; +static const std::string SHOW_NOTIFICATIONS = "showNotifications"; MainController::MainController( EventLoop* eventLoop, @@ -119,15 +119,15 @@ MainController::MainController( loginWindow_ = uiFactory_->createLoginWindow(uiEventStream_); soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings, uiEventStream_); - String selectedLoginJID = settings_->getStringSetting("lastLoginJID"); + std::string selectedLoginJID = settings_->getStringSetting("lastLoginJID"); bool loginAutomatically = settings_->getBoolSetting("loginAutomatically", false); - String cachedPassword; - String cachedCertificate; - foreach (String profile, settings->getAvailableProfiles()) { + std::string cachedPassword; + std::string cachedCertificate; + foreach (std::string profile, settings->getAvailableProfiles()) { ProfileSettingsProvider profileSettings(profile, settings); - String password = profileSettings.getStringSetting("pass"); - String certificate = profileSettings.getStringSetting("certificate"); - String jid = profileSettings.getStringSetting("jid"); + std::string password = profileSettings.getStringSetting("pass"); + std::string certificate = profileSettings.getStringSetting("certificate"); + std::string jid = profileSettings.getStringSetting("jid"); loginWindow_->addAvailableAccount(jid, password, certificate); if (jid == selectedLoginJID) { cachedPassword = password; @@ -292,7 +292,7 @@ void MainController::reconnectAfterError() { performLoginFromCachedCredentials(); } -void MainController::handleChangeStatusRequest(StatusShow::Type show, const String &statusText) { +void MainController::handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText) { boost::shared_ptr presence(new Presence()); if (show == StatusShow::None) { // Note: this is misleading, None doesn't mean unavailable on the wire. @@ -323,7 +323,7 @@ void MainController::sendPresence(boost::shared_ptr presence) { notifier_->setTemporarilyDisabled(presence->getShow() == StatusShow::DND); // Add information and send - if (!vCardPhotoHash_.isEmpty()) { + if (!vCardPhotoHash_.empty()) { presence->updatePayload(boost::shared_ptr(new VCardUpdate(vCardPhotoHash_))); } client_->getPresenceSender()->sendPresence(presence); @@ -352,7 +352,7 @@ void MainController::handleInputIdleChanged(bool idle) { } } -void MainController::handleLoginRequest(const String &username, const String &password, const String& certificateFile, bool remember, bool loginAutomatically) { +void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificateFile, bool remember, bool loginAutomatically) { loginWindow_->setMessage(""); loginWindow_->setIsLoggingIn(true); profileSettings_ = new ProfileSettingsProvider(username, settings_); @@ -368,7 +368,7 @@ void MainController::handleLoginRequest(const String &username, const String &pa performLoginFromCachedCredentials(); } -void MainController::handlePurgeSavedLoginRequest(const String& username) { +void MainController::handlePurgeSavedLoginRequest(const std::string& username) { settings_->removeProfile(username); loginWindow_->removeAvailableAccount(username); } @@ -404,7 +404,7 @@ void MainController::performLoginFromCachedCredentials() { presenceNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1)); eventNotifier_ = new EventNotifier(eventController_, notifier_, client_->getAvatarManager(), client_->getNickResolver()); eventNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1)); - if (!certificateFile_.isEmpty()) { + if (!certificateFile_.empty()) { client_->setCertificate(certificateFile_); } boost::shared_ptr presence(new Presence()); @@ -429,8 +429,8 @@ void MainController::handleDisconnected(const boost::optional& erro loginWindow_->quit(); } else if (error) { - String message; - String certificateErrorMessage; + std::string message; + std::string certificateErrorMessage; switch(error->getType()) { case ClientError::UnknownError: message = "Unknown Error"; break; case ClientError::DomainNameResolveError: message = "Unable to find server"; break; @@ -464,7 +464,7 @@ void MainController::handleDisconnected(const boost::optional& erro } bool forceReconnectAfterCertificateTrust = false; - if (!certificateErrorMessage.isEmpty()) { + if (!certificateErrorMessage.empty()) { Certificate::ref certificate = certificateTrustChecker_->getLastCertificate(); if (loginWindow_->askUserToTrustCertificatePermanently(certificateErrorMessage, certificate)) { certificateStorage_->addCertificate(certificate); diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 07bf661..f402f8f 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -13,7 +13,7 @@ #include "Swiften/Network/Timer.h" #include "SwifTools/Idle/PlatformIdleQuerier.h" #include "SwifTools/Idle/ActualIdleDetector.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Client/ClientError.h" #include "Swiften/JID/JID.h" #include "Swiften/Elements/DiscoInfo.h" @@ -83,16 +83,16 @@ namespace Swift { private: void resetClient(); void handleConnected(); - void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember, bool loginAutomatically); + void handleLoginRequest(const std::string& username, const std::string& password, const std::string& certificateFile, bool remember, bool loginAutomatically); void handleCancelLoginRequest(); void handleQuitRequest(); - void handleChangeStatusRequest(StatusShow::Type show, const String &statusText); + void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText); void handleDisconnected(const boost::optional& error); void handleServerDiscoInfoResponse(boost::shared_ptr, ErrorPayload::ref); void handleEventQueueLengthChange(int count); void handleVCardReceived(const JID& j, VCard::ref vCard); void handleUIEvent(boost::shared_ptr event); - void handlePurgeSavedLoginRequest(const String& username); + void handlePurgeSavedLoginRequest(const std::string& username); void sendPresence(boost::shared_ptr presence); void handleInputIdleChanged(bool); void logout(); @@ -139,9 +139,9 @@ namespace Swift { JID boundJID_; SystemTrayController* systemTrayController_; SoundEventController* soundEventController_; - String vCardPhotoHash_; - String password_; - String certificateFile_; + std::string vCardPhotoHash_; + std::string password_; + std::string certificateFile_; boost::shared_ptr lastDisconnectError_; bool useDelayForLatency_; UserSearchController* userSearchControllerChat_; diff --git a/Swift/Controllers/PresenceNotifier.cpp b/Swift/Controllers/PresenceNotifier.cpp index de6b2c9..3d5d71e 100644 --- a/Swift/Controllers/PresenceNotifier.cpp +++ b/Swift/Controllers/PresenceNotifier.cpp @@ -85,9 +85,9 @@ void PresenceNotifier::handleStanzaChannelAvailableChanged(bool available) { } void PresenceNotifier::showNotification(const JID& jid, Notifier::Type type) { - String name = nickResolver->jidToNick(jid); - String title = name + " (" + getStatusType(jid) + ")"; - String message = getStatusMessage(jid); + std::string name = nickResolver->jidToNick(jid); + std::string title = name + " (" + getStatusType(jid) + ")"; + std::string message = getStatusMessage(jid); notifier->showMessage(type, title, message, avatarManager->getAvatarPath(jid), boost::bind(&PresenceNotifier::handleNotificationActivated, this, jid)); } @@ -95,7 +95,7 @@ void PresenceNotifier::handleNotificationActivated(JID jid) { onNotificationActivated(jid); } -String PresenceNotifier::getStatusType(const JID& jid) const { +std::string PresenceNotifier::getStatusType(const JID& jid) const { Presence::ref presence = presenceOracle->getLastPresence(jid); if (presence) { return StatusShow::typeToFriendlyName(presence->getShow()); @@ -105,13 +105,13 @@ String PresenceNotifier::getStatusType(const JID& jid) const { } } -String PresenceNotifier::getStatusMessage(const JID& jid) const { +std::string PresenceNotifier::getStatusMessage(const JID& jid) const { Presence::ref presence = presenceOracle->getLastPresence(jid); if (presence) { return presence->getStatus(); } else { - return String(); + return std::string(); } } diff --git a/Swift/Controllers/PresenceNotifier.h b/Swift/Controllers/PresenceNotifier.h index 9b2d9de..0d187bd 100644 --- a/Swift/Controllers/PresenceNotifier.h +++ b/Swift/Controllers/PresenceNotifier.h @@ -37,8 +37,8 @@ namespace Swift { void handleStanzaChannelAvailableChanged(bool); void handleNotificationActivated(JID jid); void handleTimerTick(); - String getStatusType(const JID&) const; - String getStatusMessage(const JID&) const; + std::string getStatusType(const JID&) const; + std::string getStatusMessage(const JID&) const; private: void showNotification(const JID& jid, Notifier::Type type); diff --git a/Swift/Controllers/PreviousStatusStore.cpp b/Swift/Controllers/PreviousStatusStore.cpp index 271658f..947cdc7 100644 --- a/Swift/Controllers/PreviousStatusStore.cpp +++ b/Swift/Controllers/PreviousStatusStore.cpp @@ -18,25 +18,25 @@ PreviousStatusStore::~PreviousStatusStore() { } -void PreviousStatusStore::addStatus(StatusShow::Type status, const String& message) { +void PreviousStatusStore::addStatus(StatusShow::Type status, const std::string& message) { //FIXME: remove old entries store_.push_back(TypeStringPair(status, message)); } -std::vector PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const String& message) { +std::vector PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const std::string& message) { std::vector suggestions; suggestions.push_back(TypeStringPair(status, message)); return suggestions; } -std::vector PreviousStatusStore::getSuggestions(const String& message) { +std::vector PreviousStatusStore::getSuggestions(const std::string& message) { std::vector suggestions; foreach (TypeStringPair status, store_) { if (status.second == message) { suggestions.clear(); suggestions.push_back(status); break; - } else if (status.second.contains(message)) { + } else if (status.second.find(message) != std::string::npos) { suggestions.push_back(status); } } diff --git a/Swift/Controllers/PreviousStatusStore.h b/Swift/Controllers/PreviousStatusStore.h index 66c49e4..6403123 100644 --- a/Swift/Controllers/PreviousStatusStore.h +++ b/Swift/Controllers/PreviousStatusStore.h @@ -9,20 +9,20 @@ #include /* std::pair */ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/StatusShow.h" namespace Swift { - typedef std::pair TypeStringPair; + typedef std::pair TypeStringPair; class PreviousStatusStore { public: PreviousStatusStore(); ~PreviousStatusStore(); - void addStatus(StatusShow::Type status, const String& message); - std::vector getSuggestions(const String& message); + void addStatus(StatusShow::Type status, const std::string& message); + std::vector getSuggestions(const std::string& message); private: - std::vector exactMatchSuggestions(StatusShow::Type status, const String& message); + std::vector exactMatchSuggestions(StatusShow::Type status, const std::string& message); std::vector store_; }; } diff --git a/Swift/Controllers/ProfileSettingsProvider.h b/Swift/Controllers/ProfileSettingsProvider.h index defe6ca..74bcd12 100644 --- a/Swift/Controllers/ProfileSettingsProvider.h +++ b/Swift/Controllers/ProfileSettingsProvider.h @@ -12,10 +12,10 @@ namespace Swift { class ProfileSettingsProvider { public: - ProfileSettingsProvider(const String& profile, SettingsProvider* provider) : profile_(profile) { + ProfileSettingsProvider(const std::string& profile, SettingsProvider* provider) : profile_(profile) { provider_ = provider; bool found = false; - foreach (String existingProfile, provider->getAvailableProfiles()) { + foreach (std::string existingProfile, provider->getAvailableProfiles()) { if (existingProfile == profile) { found = true; } @@ -25,15 +25,15 @@ class ProfileSettingsProvider { } }; virtual ~ProfileSettingsProvider() {}; - virtual String getStringSetting(const String &settingPath) {return provider_->getStringSetting(profileSettingPath(settingPath));}; - virtual void storeString(const String &settingPath, const String &settingValue) {provider_->storeString(profileSettingPath(settingPath), settingValue);}; - virtual int getIntSetting(const String& settingPath, int defaultValue) {return provider_->getIntSetting(settingPath, defaultValue);} - virtual void storeInt(const String& settingPath, int settingValue) {provider_->storeInt(settingPath, settingValue);} + virtual std::string getStringSetting(const std::string &settingPath) {return provider_->getStringSetting(profileSettingPath(settingPath));}; + virtual void storeString(const std::string &settingPath, const std::string &settingValue) {provider_->storeString(profileSettingPath(settingPath), settingValue);}; + virtual int getIntSetting(const std::string& settingPath, int defaultValue) {return provider_->getIntSetting(settingPath, defaultValue);} + virtual void storeInt(const std::string& settingPath, int settingValue) {provider_->storeInt(settingPath, settingValue);} private: - String profileSettingPath(const String &settingPath) {return profile_ + ":" + settingPath;}; + std::string profileSettingPath(const std::string &settingPath) {return profile_ + ":" + settingPath;}; SettingsProvider* provider_; - String profile_; + std::string profile_; }; } diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp index df0eb7b..c6064d6 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.cpp +++ b/Swift/Controllers/Roster/ContactRosterItem.cpp @@ -10,7 +10,7 @@ namespace Swift { -ContactRosterItem::ContactRosterItem(const JID& jid, const JID& displayJID, const String& name, GroupRosterItem* parent) : RosterItem(name, parent), jid_(jid), displayJID_(displayJID) { +ContactRosterItem::ContactRosterItem(const JID& jid, const JID& displayJID, const std::string& name, GroupRosterItem* parent) : RosterItem(name, parent), jid_(jid), displayJID_(displayJID) { } ContactRosterItem::~ContactRosterItem() { @@ -33,15 +33,15 @@ StatusShow::Type ContactRosterItem::getSimplifiedStatusShow() const { return StatusShow::None; } -String ContactRosterItem::getStatusText() const { +std::string ContactRosterItem::getStatusText() const { return shownPresence_ ? shownPresence_->getStatus() : ""; } -void ContactRosterItem::setAvatarPath(const String& path) { +void ContactRosterItem::setAvatarPath(const std::string& path) { avatarPath_ = path; onDataChanged(); } -const String& ContactRosterItem::getAvatarPath() const { +const std::string& ContactRosterItem::getAvatarPath() const { return avatarPath_; } @@ -58,7 +58,7 @@ const JID& ContactRosterItem::getDisplayJID() const { } -typedef std::pair > StringPresencePair; +typedef std::pair > StringPresencePair; void ContactRosterItem::calculateShownPresence() { shownPresence_ = offlinePresence_; @@ -76,12 +76,12 @@ void ContactRosterItem::clearPresence() { onDataChanged(); } -void ContactRosterItem::applyPresence(const String& resource, boost::shared_ptr presence) { +void ContactRosterItem::applyPresence(const std::string& resource, boost::shared_ptr presence) { if (offlinePresence_) { offlinePresence_ = boost::shared_ptr(); } if (presence->getType() == Presence::Unavailable) { - if (resource.isEmpty()) { + if (resource.empty()) { /* Unavailable from the bare JID means all resources are offline.*/ presences_.clear(); } else { @@ -99,15 +99,15 @@ void ContactRosterItem::applyPresence(const String& resource, boost::shared_ptr< onDataChanged(); } -const std::vector ContactRosterItem::getGroups() const { +const std::vector ContactRosterItem::getGroups() const { return groups_; } /** Only used so a contact can know about the groups it's in*/ -void ContactRosterItem::addGroup(const String& group) { +void ContactRosterItem::addGroup(const std::string& group) { groups_.push_back(group); } -void ContactRosterItem::removeGroup(const String& group) { +void ContactRosterItem::removeGroup(const std::string& group) { groups_.erase(std::remove(groups_.begin(), groups_.end(), group), groups_.end()); } diff --git a/Swift/Controllers/Roster/ContactRosterItem.h b/Swift/Controllers/Roster/ContactRosterItem.h index ca9d727..ae8d5b0 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.h +++ b/Swift/Controllers/Roster/ContactRosterItem.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swift/Controllers/Roster/RosterItem.h" #include "Swiften/Elements/StatusShow.h" @@ -22,32 +22,32 @@ namespace Swift { class GroupRosterItem; class ContactRosterItem : public RosterItem { public: - ContactRosterItem(const JID& jid, const JID& displayJID, const String& name, GroupRosterItem* parent); + ContactRosterItem(const JID& jid, const JID& displayJID, const std::string& name, GroupRosterItem* parent); virtual ~ContactRosterItem(); StatusShow::Type getStatusShow() const; StatusShow::Type getSimplifiedStatusShow() const; - String getStatusText() const; - void setAvatarPath(const String& path); - const String& getAvatarPath() const; + std::string getStatusText() const; + void setAvatarPath(const std::string& path); + const std::string& getAvatarPath() const; const JID& getJID() const; void setDisplayJID(const JID& jid); const JID& getDisplayJID() const; - void applyPresence(const String& resource, boost::shared_ptr presence); + void applyPresence(const std::string& resource, boost::shared_ptr presence); void clearPresence(); void calculateShownPresence(); - const std::vector getGroups() const; + const std::vector getGroups() const; /** Only used so a contact can know about the groups it's in*/ - void addGroup(const String& group); - void removeGroup(const String& group); + void addGroup(const std::string& group); + void removeGroup(const std::string& group); private: JID jid_; JID displayJID_; - String avatarPath_; - std::map > presences_; + std::string avatarPath_; + std::map > presences_; boost::shared_ptr offlinePresence_; boost::shared_ptr shownPresence_; - std::vector groups_; + std::vector groups_; }; } diff --git a/Swift/Controllers/Roster/GroupRosterItem.cpp b/Swift/Controllers/Roster/GroupRosterItem.cpp index 7d0cf85..f0a377a 100644 --- a/Swift/Controllers/Roster/GroupRosterItem.cpp +++ b/Swift/Controllers/Roster/GroupRosterItem.cpp @@ -12,7 +12,7 @@ namespace Swift { -GroupRosterItem::GroupRosterItem(const String& name, GroupRosterItem* parent, bool sortByStatus) : RosterItem(name, parent), sortByStatus_(sortByStatus) { +GroupRosterItem::GroupRosterItem(const std::string& name, GroupRosterItem* parent, bool sortByStatus) : RosterItem(name, parent), sortByStatus_(sortByStatus) { expanded_ = true; } @@ -110,7 +110,7 @@ ContactRosterItem* GroupRosterItem::removeChild(const JID& jid) { return removed; } -GroupRosterItem* GroupRosterItem::removeGroupChild(const String& groupName) { +GroupRosterItem* GroupRosterItem::removeGroupChild(const std::string& groupName) { std::vector::iterator it = children_.begin(); GroupRosterItem* removed = NULL; while (it != children_.end()) { diff --git a/Swift/Controllers/Roster/GroupRosterItem.h b/Swift/Controllers/Roster/GroupRosterItem.h index ff5e798..57fa9fa 100644 --- a/Swift/Controllers/Roster/GroupRosterItem.h +++ b/Swift/Controllers/Roster/GroupRosterItem.h @@ -7,7 +7,7 @@ #pragma once #include "Swift/Controllers/Roster/RosterItem.h" -#include "Swiften/Base/String.h" +#include #include "Swift/Controllers/Roster/ContactRosterItem.h" #include @@ -16,13 +16,13 @@ namespace Swift { class GroupRosterItem : public RosterItem { public: - GroupRosterItem(const String& name, GroupRosterItem* parent, bool sortByStatus); + GroupRosterItem(const std::string& name, GroupRosterItem* parent, bool sortByStatus); virtual ~GroupRosterItem(); const std::vector& getChildren() const; const std::vector& getDisplayedChildren() const; void addChild(RosterItem* item); ContactRosterItem* removeChild(const JID& jid); - GroupRosterItem* removeGroupChild(const String& group); + GroupRosterItem* removeGroupChild(const std::string& group); void removeAll(); void setDisplayed(RosterItem* item, bool displayed); boost::signal onChildrenChanged; @@ -35,7 +35,7 @@ class GroupRosterItem : public RosterItem { void handleChildrenChanged(GroupRosterItem* group); void handleDataChanged(RosterItem* item); bool sortDisplayed(); - String name_; + std::string name_; bool expanded_; std::vector children_; std::vector displayedChildren_; diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp index 9edcaaf..4e34105 100644 --- a/Swift/Controllers/Roster/Roster.cpp +++ b/Swift/Controllers/Roster/Roster.cpp @@ -7,7 +7,7 @@ #include "Swift/Controllers/Roster/Roster.h" #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swift/Controllers/Roster/ContactRosterItem.h" #include "Swift/Controllers/Roster/RosterItem.h" @@ -46,7 +46,7 @@ GroupRosterItem* Roster::getRoot() { return root_; } -GroupRosterItem* Roster::getGroup(const String& groupName) { +GroupRosterItem* Roster::getGroup(const std::string& groupName) { foreach (RosterItem *item, root_->getChildren()) { GroupRosterItem *group = dynamic_cast(item); if (group && group->getDisplayName() == groupName) { @@ -60,7 +60,7 @@ GroupRosterItem* Roster::getGroup(const String& groupName) { return group; } -void Roster::removeGroup(const String& group) { +void Roster::removeGroup(const std::string& group) { root_->removeGroupChild(group); } @@ -72,13 +72,13 @@ void Roster::handleChildrenChanged(GroupRosterItem* item) { onChildrenChanged(item); } -void Roster::addContact(const JID& jid, const JID& displayJID, const String& name, const String& groupName, const String& avatarPath) { +void Roster::addContact(const JID& jid, const JID& displayJID, const std::string& name, const std::string& groupName, const std::string& avatarPath) { GroupRosterItem* group(getGroup(groupName)); ContactRosterItem *item = new ContactRosterItem(jid, displayJID, name, group); item->setAvatarPath(avatarPath); group->addChild(item); if (itemMap_[fullJIDMapping_ ? jid : jid.toBare()].size() > 0) { - foreach (String existingGroup, itemMap_[fullJIDMapping_ ? jid : jid.toBare()][0]->getGroups()) { + foreach (std::string existingGroup, itemMap_[fullJIDMapping_ ? jid : jid.toBare()][0]->getGroups()) { item->addGroup(existingGroup); } } @@ -114,7 +114,7 @@ void Roster::removeContact(const JID& jid) { root_->removeChild(jid); } -void Roster::removeContactFromGroup(const JID& jid, const String& groupName) { +void Roster::removeContactFromGroup(const JID& jid, const std::string& groupName) { std::vector children = root_->getChildren(); std::vector::iterator it = children.begin(); while (it != children.end()) { diff --git a/Swift/Controllers/Roster/Roster.h b/Swift/Controllers/Roster/Roster.h index 5589f97..53161a8 100644 --- a/Swift/Controllers/Roster/Roster.h +++ b/Swift/Controllers/Roster/Roster.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swift/Controllers/Roster/RosterItemOperation.h" #include "Swift/Controllers/Roster/RosterFilter.h" @@ -27,10 +27,10 @@ class Roster { Roster(bool sortByStatus = true, bool fullJIDMapping = false); ~Roster(); - void addContact(const JID& jid, const JID& displayJID, const String& name, const String& group, const String& avatarPath); + void addContact(const JID& jid, const JID& displayJID, const std::string& name, const std::string& group, const std::string& avatarPath); void removeContact(const JID& jid); - void removeContactFromGroup(const JID& jid, const String& group); - void removeGroup(const String& group); + void removeContactFromGroup(const JID& jid, const std::string& group); + void removeGroup(const std::string& group); void removeAll(); void applyOnItems(const RosterItemOperation& operation); void applyOnAllItems(const RosterItemOperation& operation); @@ -42,7 +42,7 @@ class Roster { boost::signal onChildrenChanged; boost::signal onGroupAdded; boost::signal onDataChanged; - GroupRosterItem* getGroup(const String& groupName); + GroupRosterItem* getGroup(const std::string& groupName); private: void handleDataChanged(RosterItem* item); void handleChildrenChanged(GroupRosterItem* item); diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index 758d4f2..e03a8d4 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -9,6 +9,7 @@ #include #include +#include "Swiften/JID/JID.h" #include "Swiften/Base/foreach.h" #include "Swift/Controllers/UIInterfaces/MainWindow.h" #include "Swift/Controllers/UIInterfaces/MainWindowFactory.h" @@ -39,7 +40,7 @@ namespace Swift { -static const String SHOW_OFFLINE = "showOffline"; +static const std::string SHOW_OFFLINE = "showOffline"; /** * The controller does not gain ownership of these parameters. @@ -107,15 +108,15 @@ void RosterController::handleShowOfflineToggled(bool state) { } } -void RosterController::handleChangeStatusRequest(StatusShow::Type show, const String &statusText) { +void RosterController::handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText) { onChangeStatusRequest(show, statusText); } void RosterController::handleOnJIDAdded(const JID& jid) { - std::vector groups = xmppRoster_->getGroupsForJID(jid); - String name = nickResolver_->jidToNick(jid); + std::vector groups = xmppRoster_->getGroupsForJID(jid); + std::string name = nickResolver_->jidToNick(jid); if (!groups.empty()) { - foreach(const String& group, groups) { + foreach(const std::string& group, groups) { roster_->addContact(jid, jid, name, group, avatarManager_->getAvatarPath(jid).string()); } } @@ -139,26 +140,26 @@ void RosterController::handleOnJIDRemoved(const JID& jid) { roster_->removeContact(jid); } -void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, const std::vector passedOldGroups) { +void RosterController::handleOnJIDUpdated(const JID& jid, const std::string& oldName, const std::vector passedOldGroups) { if (oldName != xmppRoster_->getNameForJID(jid)) { roster_->applyOnItems(SetName(nickResolver_->jidToNick(jid), jid)); } - std::vector groups = xmppRoster_->getGroupsForJID(jid); - std::vector oldGroups = passedOldGroups; - String name = nickResolver_->jidToNick(jid); - String contactsGroup = "Contacts"; + std::vector groups = xmppRoster_->getGroupsForJID(jid); + std::vector oldGroups = passedOldGroups; + std::string name = nickResolver_->jidToNick(jid); + std::string contactsGroup = "Contacts"; if (oldGroups.empty()) { oldGroups.push_back(contactsGroup); } if (groups.empty()) { groups.push_back(contactsGroup); } - foreach(const String& group, groups) { + foreach(const std::string& group, groups) { if (std::find(oldGroups.begin(), oldGroups.end(), group) == oldGroups.end()) { roster_->addContact(jid, jid, name, group, avatarManager_->getAvatarPath(jid).string()); } } - foreach(const String& group, oldGroups) { + foreach(const std::string& group, oldGroups) { if (std::find(groups.begin(), groups.end(), group) == groups.end()) { roster_->removeContactFromGroup(jid, group); if (roster_->getGroup(group)->getChildren().size() == 0) { @@ -205,14 +206,14 @@ void RosterController::handleUIEvent(boost::shared_ptr event) { } else if (boost::shared_ptr renameGroupEvent = boost::dynamic_pointer_cast(event)) { std::vector items = xmppRoster_->getItems(); - String group = renameGroupEvent->getGroup(); + std::string group = renameGroupEvent->getGroup(); // FIXME: We should handle contacts groups specially to avoid clashes if (group == "Contacts") { group = ""; } foreach(XMPPRosterItem& item, items) { - std::vector groups = item.getGroups(); - if ( (group.isEmpty() && groups.empty()) || std::find(groups.begin(), groups.end(), group) != groups.end()) { + std::vector groups = item.getGroups(); + if ( (group.empty() && groups.empty()) || std::find(groups.begin(), groups.end(), group) != groups.end()) { groups.erase(std::remove(groups.begin(), groups.end(), group), groups.end()); if (std::find(groups.begin(), groups.end(), renameGroupEvent->getNewName()) == groups.end()) { groups.push_back(renameGroupEvent->getNewName()); @@ -224,7 +225,7 @@ void RosterController::handleUIEvent(boost::shared_ptr event) { } } -void RosterController::setContactGroups(const JID& jid, const std::vector& groups) { +void RosterController::setContactGroups(const JID& jid, const std::vector& groups) { updateItem(XMPPRosterItem(jid, xmppRoster_->getNameForJID(jid), groups, xmppRoster_->getSubscriptionStateForJID(jid))); } @@ -244,8 +245,8 @@ void RosterController::handleRosterSetError(ErrorPayload::ref error, boost::shar if (!error) { return; } - String text = "Server " + myJID_.getDomain() + " rejected roster change to item '" + rosterPayload->getItems()[0].getJID() + "'"; - if (!error->getText().isEmpty()) { + std::string text = "Server " + myJID_.getDomain() + " rejected roster change to item '" + rosterPayload->getItems()[0].getJID().toString() + "'"; + if (!error->getText().empty()) { text += ": " + error->getText(); } boost::shared_ptr errorEvent(new ErrorEvent(JID(myJID_.getDomain()), text)); @@ -259,7 +260,7 @@ void RosterController::handleIncomingPresence(Presence::ref newPresence) { roster_->applyOnItems(SetPresence(newPresence)); } -void RosterController::handleSubscriptionRequest(const JID& jid, const String& message) { +void RosterController::handleSubscriptionRequest(const JID& jid, const std::string& message) { if (xmppRoster_->containsJID(jid) && (xmppRoster_->getSubscriptionStateForJID(jid) == RosterItemPayload::To || xmppRoster_->getSubscriptionStateForJID(jid) == RosterItemPayload::Both)) { subscriptionManager_->confirmSubscription(jid); return; @@ -283,7 +284,7 @@ void RosterController::handleSubscriptionRequestDeclined(SubscriptionRequestEven } void RosterController::handleAvatarChanged(const JID& jid) { - String path = avatarManager_->getAvatarPath(jid).string(); + std::string path = avatarManager_->getAvatarPath(jid).string(); roster_->applyOnItems(SetAvatar(jid, path)); if (jid.equals(myJID_, JID::WithoutResource)) { mainWindow_->setMyAvatarPath(path); @@ -294,7 +295,7 @@ boost::optional RosterController::getItem(const JID& jid) const return xmppRoster_->getItem(jid); } -std::set RosterController::getGroups() const { +std::set RosterController::getGroups() const { return xmppRoster_->getGroups(); } diff --git a/Swift/Controllers/Roster/RosterController.h b/Swift/Controllers/Roster/RosterController.h index b0641c3..f224180 100644 --- a/Swift/Controllers/Roster/RosterController.h +++ b/Swift/Controllers/Roster/RosterController.h @@ -7,7 +7,7 @@ #pragma once #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/ErrorPayload.h" #include "Swiften/Elements/RosterPayload.h" @@ -42,27 +42,27 @@ namespace Swift { ~RosterController(); void showRosterWindow(); MainWindow* getWindow() {return mainWindow_;}; - boost::signal onChangeStatusRequest; + boost::signal onChangeStatusRequest; boost::signal onSignOutRequest; void handleAvatarChanged(const JID& jid); void setEnabled(bool enabled); boost::optional getItem(const JID&) const; - std::set getGroups() const; + std::set getGroups() const; - void setContactGroups(const JID& jid, const std::vector& groups); + void setContactGroups(const JID& jid, const std::vector& groups); void updateItem(const XMPPRosterItem&); private: void handleOnJIDAdded(const JID &jid); void handleRosterCleared(); void handleOnJIDRemoved(const JID &jid); - void handleOnJIDUpdated(const JID &jid, const String& oldName, const std::vector oldGroups); + void handleOnJIDUpdated(const JID &jid, const std::string& oldName, const std::vector oldGroups); void handleStartChatRequest(const JID& contact); - void handleChangeStatusRequest(StatusShow::Type show, const String &statusText); + void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText); void handleShowOfflineToggled(bool state); void handleIncomingPresence(boost::shared_ptr newPresence); - void handleSubscriptionRequest(const JID& jid, const String& message); + void handleSubscriptionRequest(const JID& jid, const std::string& message); void handleSubscriptionRequestAccepted(SubscriptionRequestEvent* event); void handleSubscriptionRequestDeclined(SubscriptionRequestEvent* event); void handleUIEvent(boost::shared_ptr event); diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp index 64baac9..c1045ee 100644 --- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp +++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp @@ -9,6 +9,7 @@ #include #include +#include "Swiften/Base/String.h" #include "Swift/Controllers/Roster/GroupRosterItem.h" namespace Swift { @@ -29,7 +30,7 @@ void RosterGroupExpandinessPersister::handleGroupAdded(GroupRosterItem* group) { void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* group, bool expanded) { if (expanded) { - String displayName = group->getDisplayName(); + std::string displayName = group->getDisplayName(); //collapsed_.erase(std::remove(collapsed_.begin(), collapsed_.end(), displayName), collapsed_.end()); collapsed_.erase(displayName); } else { @@ -39,9 +40,9 @@ void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* gro } void RosterGroupExpandinessPersister::save() { - String setting; - foreach (const String& group, collapsed_) { - if (!setting.isEmpty()) { + std::string setting; + foreach (const std::string& group, collapsed_) { + if (!setting.empty()) { setting += "\n"; } setting += group; @@ -50,11 +51,11 @@ void RosterGroupExpandinessPersister::save() { } void RosterGroupExpandinessPersister::load() { - String saved = settings_->getStringSetting(SettingPath); - std::vector collapsed = saved.split('\n'); + std::string saved = settings_->getStringSetting(SettingPath); + std::vector collapsed = String::split(saved, '\n'); collapsed_.insert(collapsed.begin(), collapsed.end()); } -const String RosterGroupExpandinessPersister::SettingPath = "GroupExpandiness"; +const std::string RosterGroupExpandinessPersister::SettingPath = "GroupExpandiness"; } diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h index f73afa8..63affe4 100644 --- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h +++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h @@ -19,9 +19,9 @@ namespace Swift { void handleGroupAdded(GroupRosterItem* group); void load(); void save(); - std::set collapsed_; + std::set collapsed_; Roster* roster_; SettingsProvider* settings_; - static const String SettingPath; + static const std::string SettingPath; }; } diff --git a/Swift/Controllers/Roster/RosterItem.cpp b/Swift/Controllers/Roster/RosterItem.cpp index 61c5aea..3f130bb 100644 --- a/Swift/Controllers/Roster/RosterItem.cpp +++ b/Swift/Controllers/Roster/RosterItem.cpp @@ -6,11 +6,13 @@ #include "Swift/Controllers/Roster/RosterItem.h" +#include + #include "Swift/Controllers/Roster/GroupRosterItem.h" namespace Swift { -RosterItem::RosterItem(const String& name, GroupRosterItem* parent) : name_(name), sortableDisplayName_(name_.getLowerCase()), parent_(parent) { +RosterItem::RosterItem(const std::string& name, GroupRosterItem* parent) : name_(name), sortableDisplayName_(boost::to_lower_copy(name_)), parent_(parent) { /* The following would be good, but because of C++'s inheritance not working in constructors, it's not going to work. */ //if (parent) { // parent_->addChild(this); @@ -25,17 +27,17 @@ GroupRosterItem* RosterItem::getParent() const { return parent_; } -void RosterItem::setDisplayName(const String& name) { +void RosterItem::setDisplayName(const std::string& name) { name_ = name; - sortableDisplayName_ = name_.getLowerCase(); + sortableDisplayName_ = boost::to_lower_copy(name_); onDataChanged(); } -String RosterItem::getDisplayName() const { +std::string RosterItem::getDisplayName() const { return name_; } -String RosterItem::getSortableDisplayName() const { +std::string RosterItem::getSortableDisplayName() const { return sortableDisplayName_; } diff --git a/Swift/Controllers/Roster/RosterItem.h b/Swift/Controllers/Roster/RosterItem.h index 35dbe73..ed8cb16 100644 --- a/Swift/Controllers/Roster/RosterItem.h +++ b/Swift/Controllers/Roster/RosterItem.h @@ -9,22 +9,22 @@ #include "Swiften/Base/boost_bsignals.h" #include -#include "Swiften/Base/String.h" +#include namespace Swift { class GroupRosterItem; class RosterItem { public: - RosterItem(const String& name, GroupRosterItem* parent); + RosterItem(const std::string& name, GroupRosterItem* parent); virtual ~RosterItem(); boost::signal onDataChanged; GroupRosterItem* getParent() const; - void setDisplayName(const String& name); - String getDisplayName() const; - String getSortableDisplayName() const; + void setDisplayName(const std::string& name); + std::string getDisplayName() const; + std::string getSortableDisplayName() const; private: - String name_; - String sortableDisplayName_; + std::string name_; + std::string sortableDisplayName_; GroupRosterItem* parent_; }; diff --git a/Swift/Controllers/Roster/SetAvatar.h b/Swift/Controllers/Roster/SetAvatar.h index 2b9cfa8..241b741 100644 --- a/Swift/Controllers/Roster/SetAvatar.h +++ b/Swift/Controllers/Roster/SetAvatar.h @@ -17,7 +17,7 @@ class RosterItem; class SetAvatar : public RosterItemOperation { public: - SetAvatar(const JID& jid, const String& path, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), jid_(jid), path_(path), compareType_(compareType) { + SetAvatar(const JID& jid, const std::string& path, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), jid_(jid), path_(path), compareType_(compareType) { } virtual void operator() (RosterItem* item) const { @@ -29,7 +29,7 @@ class SetAvatar : public RosterItemOperation { private: JID jid_; - String path_; + std::string path_; JID::CompareType compareType_; }; diff --git a/Swift/Controllers/Roster/SetName.h b/Swift/Controllers/Roster/SetName.h index 4d75392..aefb0dc 100644 --- a/Swift/Controllers/Roster/SetName.h +++ b/Swift/Controllers/Roster/SetName.h @@ -16,7 +16,7 @@ class RosterItem; class SetName : public RosterItemOperation { public: - SetName(const String& name, const JID& jid, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), name_(name), jid_(jid), compareType_(compareType) { + SetName(const std::string& name, const JID& jid, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), name_(name), jid_(jid), compareType_(compareType) { } virtual void operator() (RosterItem* item) const { @@ -27,7 +27,7 @@ class SetName : public RosterItemOperation { } private: - String name_; + std::string name_; JID jid_; JID::CompareType compareType_; }; diff --git a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp index 466a528..16f2745 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp @@ -91,12 +91,12 @@ class RosterControllerTest : public CppUnit::TestFixture { return dynamic_cast(CHILDREN[i]); } - JID withResource(const JID& jid, const String& resource) { + JID withResource(const JID& jid, const std::string& resource) { return JID(jid.toBare().toString() + "/" + resource); } void testPresence() { - std::vector groups; + std::vector groups; groups.push_back("testGroup1"); groups.push_back("testGroup2"); JID from("test@testdomain.com"); @@ -116,7 +116,7 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testHighestPresence() { - std::vector groups; + std::vector groups; groups.push_back("testGroup1"); JID from("test@testdomain.com"); xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both); @@ -136,7 +136,7 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testNotHighestPresence() { - std::vector groups; + std::vector groups; groups.push_back("testGroup1"); JID from("test@testdomain.com"); xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both); @@ -156,7 +156,7 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testUnavailablePresence() { - std::vector groups; + std::vector groups; groups.push_back("testGroup1"); JID from("test@testdomain.com"); xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both); @@ -198,17 +198,17 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testAdd() { - std::vector groups; + std::vector groups; groups.push_back("testGroup1"); groups.push_back("testGroup2"); xmppRoster_->addContact(JID("test@testdomain.com/bob"), "name", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(2, static_cast(CHILDREN.size())); - //CPPUNIT_ASSERT_EQUAL(String("Bob"), xmppRoster_->getNameForJID(JID("foo@bar.com"))); + //CPPUNIT_ASSERT_EQUAL(std::string("Bob"), xmppRoster_->getNameForJID(JID("foo@bar.com"))); }; void testAddSubscription() { - std::vector groups; + std::vector groups; JID jid("test@testdomain.com"); xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::None); @@ -225,24 +225,24 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testReceiveRename() { - std::vector groups; + std::vector groups; JID jid("test@testdomain.com"); xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("name"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("name"), groupChild(0)->getChildren()[0]->getDisplayName()); xmppRoster_->addContact(jid, "NewName", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("NewName"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), groupChild(0)->getChildren()[0]->getDisplayName()); }; void testReceiveRegroup() { - std::vector oldGroups; - std::vector newGroups; + std::vector oldGroups; + std::vector newGroups; newGroups.push_back("A Group"); - std::vector newestGroups; + std::vector newestGroups; newestGroups.push_back("Best Group"); JID jid("test@testdomain.com"); xmppRoster_->addContact(jid, "", oldGroups, RosterItemPayload::Both); @@ -254,19 +254,19 @@ class RosterControllerTest : public CppUnit::TestFixture { xmppRoster_->addContact(jid, "new name", newGroups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("A Group"), groupChild(0)->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("A Group"), groupChild(0)->getDisplayName()); xmppRoster_->addContact(jid, "new name", newestGroups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Best Group"), groupChild(0)->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Best Group"), groupChild(0)->getDisplayName()); }; void testSendRename() { JID jid("testling@wonderland.lit"); - std::vector groups; + std::vector groups; groups.push_back("Friends"); groups.push_back("Enemies"); xmppRoster_->addContact(jid, "Bob", groups, RosterItemPayload::From); @@ -278,17 +278,17 @@ class RosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast(1), payload->getItems().size()); RosterItemPayload item = payload->getItems()[0]; CPPUNIT_ASSERT_EQUAL(jid, item.getJID()); - CPPUNIT_ASSERT_EQUAL(String("Robert"), item.getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Robert"), item.getName()); CPPUNIT_ASSERT_EQUAL(groups.size(), item.getGroups().size()); assertVectorsEqual(groups, item.getGroups(), __LINE__); } - void assertVectorsEqual(const std::vector& v1, const std::vector& v2, int line) { - foreach (const String& entry, v1) { + void assertVectorsEqual(const std::vector& v1, const std::vector& v2, int line) { + foreach (const std::string& entry, v1) { if (std::find(v2.begin(), v2.end(), entry) == v2.end()) { std::stringstream stream; - stream << "Couldn't find " << entry.getUTF8String() << " in v2 (line " << line << ")"; + stream << "Couldn't find " << entry << " in v2 (line " << line << ")"; CPPUNIT_FAIL(stream.str()); } } diff --git a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp index 754f3e1..cbef787 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp @@ -41,17 +41,17 @@ class RosterTest : public CppUnit::TestFixture { roster_->addContact(jid3_, JID(), "Cookie", "group1", ""); CPPUNIT_ASSERT_EQUAL(2, static_cast(roster_->getRoot()->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("group1"), roster_->getRoot()->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("group2"), roster_->getRoot()->getChildren()[1]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Ernie"), static_cast(roster_->getRoot()->getChildren()[1])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("group1"), roster_->getRoot()->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("group2"), roster_->getRoot()->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Ernie"), static_cast(roster_->getRoot()->getChildren()[1])->getChildren()[0]->getDisplayName()); } void testRemoveContact() { roster_->addContact(jid1_, jid1_, "Bert", "group1", ""); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); roster_->removeContact(jid1_); CPPUNIT_ASSERT_EQUAL(0, static_cast(static_cast(roster_->getRoot()->getChildren()[0])->getChildren().size())); @@ -60,11 +60,11 @@ class RosterTest : public CppUnit::TestFixture { void testRemoveSecondContact() { roster_->addContact(jid1_, jid1_, "Bert", "group1", ""); roster_->addContact(jid2_, jid2_, "Cookie", "group1", ""); - CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid2_); CPPUNIT_ASSERT_EQUAL(1, static_cast(static_cast(roster_->getRoot()->getChildren()[0])->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); } void testRemoveSecondContactSameBare() { @@ -72,11 +72,11 @@ class RosterTest : public CppUnit::TestFixture { JID jid4b("a@b/d"); roster_->addContact(jid4a, JID(), "Bert", "group1", ""); roster_->addContact(jid4b, JID(), "Cookie", "group1", ""); - CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid4b); CPPUNIT_ASSERT_EQUAL(1, static_cast(static_cast(roster_->getRoot()->getChildren()[0])->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); } void testApplyPresenceLikeMUC() { @@ -105,9 +105,9 @@ class RosterTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(3, static_cast(children.size())); /* Check order */ - CPPUNIT_ASSERT_EQUAL(String("Ernie"), children[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Bert"), children[1]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Bird"), children[2]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Ernie"), children[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), children[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bird"), children[2]->getDisplayName()); presence = boost::shared_ptr(new Presence()); presence->setFrom(jid4c); diff --git a/Swift/Controllers/Settings/DummySettingsProvider.h b/Swift/Controllers/Settings/DummySettingsProvider.h index 631b68d..90e1921 100644 --- a/Swift/Controllers/Settings/DummySettingsProvider.h +++ b/Swift/Controllers/Settings/DummySettingsProvider.h @@ -13,15 +13,15 @@ namespace Swift { class DummySettingsProvider : public SettingsProvider { public: virtual ~DummySettingsProvider() {} - virtual String getStringSetting(const String&) {return "";} - virtual void storeString(const String &, const String &) {} - virtual bool getBoolSetting(const String &, bool ) {return true;} - virtual void storeBool(const String &, bool ) {} - virtual int getIntSetting(const String &, int ) {return 0;} - virtual void storeInt(const String &, int ) {} - virtual std::vector getAvailableProfiles() {return std::vector();} - virtual void createProfile(const String& ) {} - virtual void removeProfile(const String& ) {} + virtual std::string getStringSetting(const std::string&) {return "";} + virtual void storeString(const std::string &, const std::string &) {} + virtual bool getBoolSetting(const std::string &, bool ) {return true;} + virtual void storeBool(const std::string &, bool ) {} + virtual int getIntSetting(const std::string &, int ) {return 0;} + virtual void storeInt(const std::string &, int ) {} + virtual std::vector getAvailableProfiles() {return std::vector();} + virtual void createProfile(const std::string& ) {} + virtual void removeProfile(const std::string& ) {} }; } diff --git a/Swift/Controllers/Settings/SettingsProvider.h b/Swift/Controllers/Settings/SettingsProvider.h index a2cdad4..a5ff4eb 100644 --- a/Swift/Controllers/Settings/SettingsProvider.h +++ b/Swift/Controllers/Settings/SettingsProvider.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_SettingsProvider_H #define SWIFTEN_SettingsProvider_H -#include "Swiften/Base/String.h" +#include #include @@ -16,15 +16,15 @@ namespace Swift { class SettingsProvider { public: virtual ~SettingsProvider() {} - virtual String getStringSetting(const String &settingPath) = 0; - virtual void storeString(const String &settingPath, const String &settingValue) = 0; - virtual bool getBoolSetting(const String &settingPath, bool defaultValue) = 0; - virtual void storeBool(const String &settingPath, bool settingValue) = 0; - virtual int getIntSetting(const String &settingPath, int defaultValue) = 0; - virtual void storeInt(const String &settingPath, int settingValue) = 0; - virtual std::vector getAvailableProfiles() = 0; - virtual void createProfile(const String& profile) = 0; - virtual void removeProfile(const String& profile) = 0; + virtual std::string getStringSetting(const std::string &settingPath) = 0; + virtual void storeString(const std::string &settingPath, const std::string &settingValue) = 0; + virtual bool getBoolSetting(const std::string &settingPath, bool defaultValue) = 0; + virtual void storeBool(const std::string &settingPath, bool settingValue) = 0; + virtual int getIntSetting(const std::string &settingPath, int defaultValue) = 0; + virtual void storeInt(const std::string &settingPath, int settingValue) = 0; + virtual std::vector getAvailableProfiles() = 0; + virtual void createProfile(const std::string& profile) = 0; + virtual void removeProfile(const std::string& profile) = 0; }; } diff --git a/Swift/Controllers/UIEvents/AddContactUIEvent.h b/Swift/Controllers/UIEvents/AddContactUIEvent.h index 1c5e54b..b2bf5ce 100644 --- a/Swift/Controllers/UIEvents/AddContactUIEvent.h +++ b/Swift/Controllers/UIEvents/AddContactUIEvent.h @@ -6,18 +6,18 @@ #pragma once -#include "Swiften/Base/String.h" +#include #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_;}; + AddContactUIEvent(const JID& jid, const std::string& name) : jid_(jid), name_(name) {}; + std::string getName() {return name_;}; JID getJID() {return jid_;}; private: JID jid_; - String name_; + std::string name_; }; } diff --git a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h index 2a2cd96..c7f8be6 100644 --- a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h +++ b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h @@ -8,7 +8,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swift/Controllers/UIEvents/UIEvent.h" @@ -16,11 +16,11 @@ namespace Swift { class JoinMUCUIEvent : public UIEvent { public: typedef boost::shared_ptr ref; - JoinMUCUIEvent(const JID& jid, const boost::optional& nick = boost::optional()) : jid_(jid), nick_(nick) {}; - boost::optional getNick() {return nick_;}; + JoinMUCUIEvent(const JID& jid, const boost::optional& nick = boost::optional()) : jid_(jid), nick_(nick) {}; + boost::optional getNick() {return nick_;}; JID getJID() {return jid_;}; private: JID jid_; - boost::optional nick_; + boost::optional nick_; }; } diff --git a/Swift/Controllers/UIEvents/RenameGroupUIEvent.h b/Swift/Controllers/UIEvents/RenameGroupUIEvent.h index 1825d77..9773b9e 100644 --- a/Swift/Controllers/UIEvents/RenameGroupUIEvent.h +++ b/Swift/Controllers/UIEvents/RenameGroupUIEvent.h @@ -7,24 +7,24 @@ #pragma once #include -#include +#include namespace Swift { class RenameGroupUIEvent : public UIEvent { public: - RenameGroupUIEvent(const String& group, const String& newName) : group(group), newName(newName) { + RenameGroupUIEvent(const std::string& group, const std::string& newName) : group(group), newName(newName) { } - const String& getGroup() const { + const std::string& getGroup() const { return group; } - const String& getNewName() const { + const std::string& getNewName() const { return newName; } private: - String group; - String newName; + std::string group; + std::string newName; }; } diff --git a/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h b/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h index 4b550e6..f3542fe 100644 --- a/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h +++ b/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h @@ -14,13 +14,13 @@ namespace Swift { class RenameRosterItemUIEvent : public UIEvent { public: - RenameRosterItemUIEvent(const JID& jid, const String& newName) : jid_(jid), newName_(newName) {} + RenameRosterItemUIEvent(const JID& jid, const std::string& newName) : jid_(jid), newName_(newName) {} const JID& getJID() const {return jid_;} - const String& getNewName() const {return newName_;} + const std::string& getNewName() const {return newName_;} private: JID jid_; - String newName_; + std::string newName_; }; } diff --git a/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h b/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h index 1415140..dd2ff6c 100644 --- a/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h +++ b/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace Swift { diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index a07f90b..b90ae46 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -13,7 +13,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/SecurityLabel.h" #include "Swiften/Elements/ChatState.h" @@ -32,17 +32,17 @@ namespace Swift { /** Add message to window. * @return id of added message (for acks). */ - virtual String addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time) = 0; + virtual std::string addMessage(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time) = 0; /** Adds action to window. * @return id of added message (for acks); */ - virtual String addAction(const String& message, const String& senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time) = 0; - virtual void addSystemMessage(const String& message) = 0; - virtual void addPresenceMessage(const String& message) = 0; - virtual void addErrorMessage(const String& message) = 0; + virtual std::string addAction(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time) = 0; + virtual void addSystemMessage(const std::string& message) = 0; + virtual void addPresenceMessage(const std::string& message) = 0; + virtual void addErrorMessage(const std::string& message) = 0; virtual void setContactChatState(ChatState::ChatStateType state) = 0; - virtual void setName(const String& name) = 0; + virtual void setName(const std::string& name) = 0; virtual void show() = 0; virtual void activate() = 0; virtual void setAvailableSecurityLabels(const std::vector& labels) = 0; @@ -55,13 +55,13 @@ namespace Swift { virtual void setInputEnabled(bool enabled) = 0; virtual void setRosterModel(Roster* model) = 0; virtual void setTabComplete(TabComplete* completer) = 0; - virtual void replaceLastMessage(const String& message) = 0; - virtual void setAckState(const String& id, AckState state) = 0; + virtual void replaceLastMessage(const std::string& message) = 0; + virtual void setAckState(const std::string& id, AckState state) = 0; virtual void flash() = 0; boost::signal onClosed; boost::signal onAllMessagesRead; - boost::signal onSendMessageRequest; + boost::signal onSendMessageRequest; boost::signal onUserTyping; boost::signal onUserCancelsTyping; }; diff --git a/Swift/Controllers/UIInterfaces/ContactEditWindow.h b/Swift/Controllers/UIInterfaces/ContactEditWindow.h index fe552c2..2445456 100644 --- a/Swift/Controllers/UIInterfaces/ContactEditWindow.h +++ b/Swift/Controllers/UIInterfaces/ContactEditWindow.h @@ -11,7 +11,7 @@ #include #include -#include +#include namespace Swift { class JID; @@ -22,12 +22,12 @@ namespace Swift { virtual void setEnabled(bool b) = 0; - virtual void setContact(const JID& jid, const String& name, const std::vector& groups, const std::set& allGroups) = 0; + virtual void setContact(const JID& jid, const std::string& name, const std::vector& groups, const std::set& allGroups) = 0; virtual void show() = 0; virtual void hide() = 0; boost::signal onRemoveContactRequest; - boost::signal& /* groups */)> onChangeContactRequest; + boost::signal& /* groups */)> onChangeContactRequest; }; } diff --git a/Swift/Controllers/UIInterfaces/JoinMUCWindow.h b/Swift/Controllers/UIInterfaces/JoinMUCWindow.h index 8cf712c..2e3d43c 100644 --- a/Swift/Controllers/UIInterfaces/JoinMUCWindow.h +++ b/Swift/Controllers/UIInterfaces/JoinMUCWindow.h @@ -8,7 +8,7 @@ #include -#include +#include #include #include @@ -17,11 +17,11 @@ namespace Swift { public: virtual ~JoinMUCWindow() {}; - virtual void setNick(const String& nick) = 0; - virtual void setMUC(const String& nick) = 0; + virtual void setNick(const std::string& nick) = 0; + virtual void setMUC(const std::string& nick) = 0; virtual void show() = 0; - boost::signal onJoinMUC; + boost::signal onJoinMUC; boost::signal onSearchMUC; }; } diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h index fc28424..61fcaa1 100644 --- a/Swift/Controllers/UIInterfaces/LoginWindow.h +++ b/Swift/Controllers/UIInterfaces/LoginWindow.h @@ -9,7 +9,7 @@ #include "Swiften/Base/boost_bsignals.h" #include -#include +#include #include namespace Swift { @@ -17,21 +17,21 @@ namespace Swift { class LoginWindow { public: virtual ~LoginWindow() {}; - virtual void selectUser(const String&) = 0; + virtual void selectUser(const std::string&) = 0; virtual void morphInto(MainWindow *mainWindow) = 0; virtual void loggedOut() = 0; - virtual void setMessage(const String&) = 0; + virtual void setMessage(const std::string&) = 0; virtual void setIsLoggingIn(bool loggingIn) = 0; - virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) = 0; - virtual void removeAvailableAccount(const String& jid) = 0; - boost::signal onLoginRequest; + virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate) = 0; + virtual void removeAvailableAccount(const std::string& jid) = 0; + boost::signal onLoginRequest; virtual void setLoginAutomatically(bool loginAutomatically) = 0; virtual void quit() = 0; /** Blocking request whether a cert should be permanently trusted.*/ - virtual bool askUserToTrustCertificatePermanently(const String& message, Certificate::ref) = 0; + virtual bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref) = 0; boost::signal onCancelLoginRequest; boost::signal onQuitRequest; - boost::signal onPurgeSavedLoginRequest; + boost::signal onPurgeSavedLoginRequest; }; } diff --git a/Swift/Controllers/UIInterfaces/LoginWindowFactory.h b/Swift/Controllers/UIInterfaces/LoginWindowFactory.h index 81fde93..1cead2a 100644 --- a/Swift/Controllers/UIInterfaces/LoginWindowFactory.h +++ b/Swift/Controllers/UIInterfaces/LoginWindowFactory.h @@ -11,7 +11,7 @@ namespace Swift { class LoginWindow; - class String; + class UIEventStream; class LoginWindowFactory { diff --git a/Swift/Controllers/UIInterfaces/MUCSearchWindow.h b/Swift/Controllers/UIInterfaces/MUCSearchWindow.h index ded2a0a..5814b06 100644 --- a/Swift/Controllers/UIInterfaces/MUCSearchWindow.h +++ b/Swift/Controllers/UIInterfaces/MUCSearchWindow.h @@ -11,7 +11,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include diff --git a/Swift/Controllers/UIInterfaces/MainWindow.h b/Swift/Controllers/UIInterfaces/MainWindow.h index 125aae5..2fd463b 100644 --- a/Swift/Controllers/UIInterfaces/MainWindow.h +++ b/Swift/Controllers/UIInterfaces/MainWindow.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swiften/Elements/StatusShow.h" @@ -25,16 +25,16 @@ namespace Swift { return canDelete_; } - virtual void setMyNick(const String& name) = 0; + virtual void setMyNick(const std::string& name) = 0; virtual void setMyJID(const JID& jid) = 0; - virtual void setMyAvatarPath(const String& path) = 0; - virtual void setMyStatusText(const String& status) = 0; + virtual void setMyAvatarPath(const std::string& path) = 0; + virtual void setMyStatusText(const std::string& status) = 0; virtual void setMyStatusType(StatusShow::Type type) = 0; /** Must be able to cope with NULL to clear the roster */ virtual void setRosterModel(Roster* roster) = 0; virtual void setConnecting() = 0; - boost::signal onChangeStatusRequest; + boost::signal onChangeStatusRequest; boost::signal onSignOutRequest; private: diff --git a/Swift/Controllers/UIInterfaces/ProfileWindow.h b/Swift/Controllers/UIInterfaces/ProfileWindow.h index e9c9a63..5d5c754 100644 --- a/Swift/Controllers/UIInterfaces/ProfileWindow.h +++ b/Swift/Controllers/UIInterfaces/ProfileWindow.h @@ -20,7 +20,7 @@ namespace Swift { virtual void setEnabled(bool b) = 0; virtual void setProcessing(bool b) = 0; - virtual void setError(const String&) = 0; + virtual void setError(const std::string&) = 0; virtual void show() = 0; virtual void hide() = 0; diff --git a/Swift/Controllers/UIInterfaces/UserSearchWindow.h b/Swift/Controllers/UIInterfaces/UserSearchWindow.h index e4a665b..0bb7400 100644 --- a/Swift/Controllers/UIInterfaces/UserSearchWindow.h +++ b/Swift/Controllers/UIInterfaces/UserSearchWindow.h @@ -10,7 +10,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swift/Controllers/Chat/UserSearchController.h" diff --git a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h index 9061b07..3cd0947 100644 --- a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h +++ b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h @@ -6,15 +6,15 @@ #pragma once -namespace Swift { - class String; +#include +namespace Swift { class XMLConsoleWidget { public: virtual ~XMLConsoleWidget(); - virtual void handleDataRead(const String& data) = 0; - virtual void handleDataWritten(const String& data) = 0; + virtual void handleDataRead(const std::string& data) = 0; + virtual void handleDataWritten(const std::string& data) = 0; virtual void show() = 0; virtual void activate() = 0; diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index 03adcfe..27b9c9e 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -14,14 +14,14 @@ namespace Swift { MockChatWindow() {}; virtual ~MockChatWindow(); - virtual String addMessage(const String& message, const String& /*senderName*/, bool /*senderIsSelf*/, const boost::optional& /*label*/, const String& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; - virtual String addAction(const String& message, const String& /*senderName*/, bool /*senderIsSelf*/, const boost::optional& /*label*/, const String& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; - virtual void addSystemMessage(const String& /*message*/) {}; - virtual void addErrorMessage(const String& /*message*/) {}; - virtual void addPresenceMessage(const String& /*message*/) {}; + virtual std::string addMessage(const std::string& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, const boost::optional& /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; + virtual std::string addAction(const std::string& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, const boost::optional& /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; + virtual void addSystemMessage(const std::string& /*message*/) {}; + virtual void addErrorMessage(const std::string& /*message*/) {}; + virtual void addPresenceMessage(const std::string& /*message*/) {}; virtual void setContactChatState(ChatState::ChatStateType /*state*/) {}; - virtual void setName(const String& name) {name_ = name;}; + virtual void setName(const std::string& name) {name_ = name;}; virtual void show() {}; virtual void activate() {}; virtual void setAvailableSecurityLabels(const std::vector& labels) {labels_ = labels;}; @@ -33,16 +33,16 @@ namespace Swift { virtual void setInputEnabled(bool /*enabled*/) {}; virtual void setRosterModel(Roster* /*roster*/) {}; virtual void setTabComplete(TabComplete*) {}; - virtual void replaceLastMessage(const Swift::String&) {}; - void setAckState(const String& /*id*/, AckState /*state*/) {}; + virtual void replaceLastMessage(const std::string&) {}; + void setAckState(const std::string& /*id*/, AckState /*state*/) {}; virtual void flash() {}; boost::signal onClosed; boost::signal onAllMessagesRead; - boost::signal onSendMessageRequest; + boost::signal onSendMessageRequest; - String name_; - String lastMessageBody_; + std::string name_; + std::string lastMessageBody_; std::vector labels_; bool labelsEnabled_; }; diff --git a/Swift/Controllers/UnitTest/MockMainWindow.h b/Swift/Controllers/UnitTest/MockMainWindow.h index 9da5490..afa5c2a 100644 --- a/Swift/Controllers/UnitTest/MockMainWindow.h +++ b/Swift/Controllers/UnitTest/MockMainWindow.h @@ -15,10 +15,10 @@ namespace Swift { MockMainWindow() : roster(NULL) {}; virtual ~MockMainWindow() {}; virtual void setRosterModel(Roster* roster) {this->roster = roster;}; - virtual void setMyNick(const String& /*name*/) {};; + virtual void setMyNick(const std::string& /*name*/) {};; virtual void setMyJID(const JID& /*jid*/) {};; - virtual void setMyAvatarPath(const String& /*path*/) {}; - virtual void setMyStatusText(const String& /*status*/) {}; + virtual void setMyAvatarPath(const std::string& /*path*/) {}; + virtual void setMyStatusText(const std::string& /*status*/) {}; virtual void setMyStatusType(StatusShow::Type /*type*/) {}; virtual void setConnecting() {}; Roster* roster; diff --git a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp index 969555c..42cfc5f 100644 --- a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp +++ b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp @@ -165,12 +165,13 @@ class PresenceNotifierTest : public CppUnit::TestFixture { void testNotificationSubjectContainsNameForJIDInRoster() { std::auto_ptr testling = createNotifier(); - roster->addContact(user1.toBare(), "User 1", std::vector(), RosterItemPayload::Both); + roster->addContact(user1.toBare(), "User 1", std::vector(), RosterItemPayload::Both); sendPresence(user1, StatusShow::Online); CPPUNIT_ASSERT_EQUAL(1, static_cast(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].subject.contains("User 1")); + std::string subject = notifier->notifications[0].subject; + CPPUNIT_ASSERT(subject.find("User 1") != std::string::npos); } void testNotificationSubjectContainsJIDForJIDNotInRoster() { @@ -179,7 +180,8 @@ class PresenceNotifierTest : public CppUnit::TestFixture { sendPresence(user1, StatusShow::Online); CPPUNIT_ASSERT_EQUAL(1, static_cast(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].subject.contains(user1.toBare().toString())); + std::string subject = notifier->notifications[0].subject; + CPPUNIT_ASSERT(subject.find(user1.toBare().toString()) != std::string::npos); } void testNotificationSubjectContainsStatus() { @@ -188,7 +190,8 @@ class PresenceNotifierTest : public CppUnit::TestFixture { sendPresence(user1, StatusShow::Away); CPPUNIT_ASSERT_EQUAL(1, static_cast(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].subject.contains("Away")); + std::string subject = notifier->notifications[0].subject; + CPPUNIT_ASSERT(subject.find("Away") != std::string::npos); } void testNotificationMessageContainsStatusMessage() { @@ -197,7 +200,7 @@ class PresenceNotifierTest : public CppUnit::TestFixture { sendPresence(user1, StatusShow::Away); CPPUNIT_ASSERT_EQUAL(1, static_cast(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].description.contains("Status Message")); + CPPUNIT_ASSERT(notifier->notifications[0].description.find("Status Message") != std::string::npos); } void testReceiveFirstPresenceWithQuietPeriodDoesNotNotify() { diff --git a/Swift/Controllers/XMLConsoleController.cpp b/Swift/Controllers/XMLConsoleController.cpp index ce0b24f..a3510d1 100644 --- a/Swift/Controllers/XMLConsoleController.cpp +++ b/Swift/Controllers/XMLConsoleController.cpp @@ -30,13 +30,13 @@ void XMLConsoleController::handleUIEvent(boost::shared_ptr rawEvent) { } } -void XMLConsoleController::handleDataRead(const String& data) { +void XMLConsoleController::handleDataRead(const std::string& data) { if (xmlConsoleWidget) { xmlConsoleWidget->handleDataRead(data); } } -void XMLConsoleController::handleDataWritten(const String& data) { +void XMLConsoleController::handleDataWritten(const std::string& data) { if (xmlConsoleWidget) { xmlConsoleWidget->handleDataWritten(data); } diff --git a/Swift/Controllers/XMLConsoleController.h b/Swift/Controllers/XMLConsoleController.h index 3e1d990..d12982f 100644 --- a/Swift/Controllers/XMLConsoleController.h +++ b/Swift/Controllers/XMLConsoleController.h @@ -13,7 +13,7 @@ #include "Swift/Controllers/UIEvents/UIEventStream.h" namespace Swift { - class String; + class XMLConsoleWidgetFactory; class XMLConsoleWidget; @@ -23,8 +23,8 @@ namespace Swift { ~XMLConsoleController(); public: - void handleDataRead(const String& data); - void handleDataWritten(const String& data); + void handleDataRead(const std::string& data); + void handleDataWritten(const std::string& data); private: void handleUIEvent(boost::shared_ptr event); diff --git a/Swift/Controllers/XMPPEvents/ErrorEvent.h b/Swift/Controllers/XMPPEvents/ErrorEvent.h index 3f78109..cbfc471 100644 --- a/Swift/Controllers/XMPPEvents/ErrorEvent.h +++ b/Swift/Controllers/XMPPEvents/ErrorEvent.h @@ -12,20 +12,20 @@ #include #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" namespace Swift { class ErrorEvent : public StanzaEvent { public: - ErrorEvent(const JID& jid, const String& text) : jid_(jid), text_(text){}; + ErrorEvent(const JID& jid, const std::string& text) : jid_(jid), text_(text){}; virtual ~ErrorEvent(){}; const JID& getJID() const {return jid_;}; - const String& getText() const {return text_;}; + const std::string& getText() const {return text_;}; private: JID jid_; - String text_; + std::string text_; }; } diff --git a/Swift/Controllers/XMPPEvents/MessageEvent.h b/Swift/Controllers/XMPPEvents/MessageEvent.h index e02995d..d1021dc 100644 --- a/Swift/Controllers/XMPPEvents/MessageEvent.h +++ b/Swift/Controllers/XMPPEvents/MessageEvent.h @@ -25,7 +25,7 @@ namespace Swift { boost::shared_ptr getStanza() {return stanza_;} bool isReadable() { - return getStanza()->isError() || !getStanza()->getBody().isEmpty(); + return getStanza()->isError() || !getStanza()->getBody().empty(); } void read() { diff --git a/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h index 704a86c..1f7812e 100644 --- a/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h +++ b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h @@ -12,16 +12,16 @@ #include #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" namespace Swift { class SubscriptionRequestEvent : public StanzaEvent { public: - SubscriptionRequestEvent(const JID& jid, const String& reason) : jid_(jid), reason_(reason){}; + SubscriptionRequestEvent(const JID& jid, const std::string& reason) : jid_(jid), reason_(reason){}; virtual ~SubscriptionRequestEvent(){}; const JID& getJID() const {return jid_;}; - const String& getReason() const {return reason_;}; + const std::string& getReason() const {return reason_;}; boost::signal onAccept; boost::signal onDecline; void accept() { @@ -40,7 +40,7 @@ namespace Swift { private: JID jid_; - String reason_; + std::string reason_; }; } diff --git a/Swift/QtUI/ApplicationTest/main.cpp b/Swift/QtUI/ApplicationTest/main.cpp index 4e93452..a5f3820 100644 --- a/Swift/QtUI/ApplicationTest/main.cpp +++ b/Swift/QtUI/ApplicationTest/main.cpp @@ -9,7 +9,7 @@ #include #include #include "../QtSwiftUtil.h" -#include "Swiften/Base/String.h" +#include #include "SwifTools/Application/Platform/PlatformApplication.h" using namespace Swift; diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp index 21d713f..f0bc276 100644 --- a/Swift/QtUI/EventViewer/QtEvent.cpp +++ b/Swift/QtUI/EventViewer/QtEvent.cpp @@ -57,8 +57,8 @@ QString QtEvent::text() { } boost::shared_ptr subscriptionRequestEvent = boost::dynamic_pointer_cast(event_); if (subscriptionRequestEvent) { - String reason = subscriptionRequestEvent->getReason(); - String message = subscriptionRequestEvent->getJID().toBare().toString() + " would like to add you to their roster" + (reason.isEmpty() ? "." : ", saying '" + reason + "'."); + std::string reason = subscriptionRequestEvent->getReason(); + std::string message = subscriptionRequestEvent->getJID().toBare().toString() + " would like to add you to their roster" + (reason.empty() ? "." : ", saying '" + reason + "'."); return P2QSTRING(message); } boost::shared_ptr errorEvent = boost::dynamic_pointer_cast(event_); diff --git a/Swift/QtUI/FreeDesktopNotifier.cpp b/Swift/QtUI/FreeDesktopNotifier.cpp index 1edf19c..037f67b 100644 --- a/Swift/QtUI/FreeDesktopNotifier.cpp +++ b/Swift/QtUI/FreeDesktopNotifier.cpp @@ -18,10 +18,10 @@ namespace Swift { -FreeDesktopNotifier::FreeDesktopNotifier(const String& name) : applicationName(name) { +FreeDesktopNotifier::FreeDesktopNotifier(const std::string& name) : applicationName(name) { } -void FreeDesktopNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function) { +void FreeDesktopNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function) { QDBusConnection bus = QDBusConnection::sessionBus(); if (!bus.isConnected()) { return; diff --git a/Swift/QtUI/FreeDesktopNotifier.h b/Swift/QtUI/FreeDesktopNotifier.h index 0bbf6bb..2214a1a 100644 --- a/Swift/QtUI/FreeDesktopNotifier.h +++ b/Swift/QtUI/FreeDesktopNotifier.h @@ -12,12 +12,12 @@ namespace Swift { class FreeDesktopNotifier : public Notifier { public: - FreeDesktopNotifier(const String& name); + FreeDesktopNotifier(const std::string& name); - virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback); private: - String applicationName; + std::string applicationName; QtCachedImageScaler imageScaler; }; } diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp index bdc121c..1e624b3 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp @@ -185,7 +185,7 @@ MUCSearchRoomItem* QtMUCSearchWindow::getSelectedRoom() const { } } } - if (lstIndex.empty()) { + if (lstIndex.isEmpty()) { return NULL; } else { diff --git a/Swift/QtUI/NotifierTest/NotifierTest.cpp b/Swift/QtUI/NotifierTest/NotifierTest.cpp index 65641b0..e165993 100644 --- a/Swift/QtUI/NotifierTest/NotifierTest.cpp +++ b/Swift/QtUI/NotifierTest/NotifierTest.cpp @@ -7,14 +7,14 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" #include "Swiften/Notifier/GrowlNotifier.h" #include using namespace Swift; -void notificationClicked(const String& message) { +void notificationClicked(const std::string& message) { std::cout << "Notification clicked: " << message << std::endl; } diff --git a/Swift/QtUI/QtAvatarWidget.cpp b/Swift/QtUI/QtAvatarWidget.cpp index 941e20e..0879d46 100644 --- a/Swift/QtUI/QtAvatarWidget.cpp +++ b/Swift/QtUI/QtAvatarWidget.cpp @@ -42,7 +42,7 @@ QtAvatarWidget::QtAvatarWidget(QWidget* parent) : QWidget(parent) { layout->addWidget(label); } -void QtAvatarWidget::setAvatar(const ByteArray& data, const String& type) { +void QtAvatarWidget::setAvatar(const ByteArray& data, const std::string& type) { this->data = data; this->type = type; diff --git a/Swift/QtUI/QtAvatarWidget.h b/Swift/QtUI/QtAvatarWidget.h index ce4d192..8830d82 100644 --- a/Swift/QtUI/QtAvatarWidget.h +++ b/Swift/QtUI/QtAvatarWidget.h @@ -18,13 +18,13 @@ namespace Swift { public: QtAvatarWidget(QWidget* parent); - void setAvatar(const ByteArray& data, const String& type); + void setAvatar(const ByteArray& data, const std::string& type); const ByteArray& getAvatarData() const { return data; } - const String& getAvatarType() const { + const std::string& getAvatarType() const { return type; } @@ -32,7 +32,7 @@ namespace Swift { private: ByteArray data; - String type; + std::string type; QLabel* label; }; } diff --git a/Swift/QtUI/QtBookmarkDetailWindow.cpp b/Swift/QtUI/QtBookmarkDetailWindow.cpp index d83e2eb..c0f04e2 100644 --- a/Swift/QtUI/QtBookmarkDetailWindow.cpp +++ b/Swift/QtUI/QtBookmarkDetailWindow.cpp @@ -27,23 +27,23 @@ boost::optional QtBookmarkDetailWindow::createBookmarkFromForm() { //check room //check bookmarkName JID room(Q2PSTRING(room_->text())); - if (!room.isValid() || room.getNode().isEmpty() || !room.getResource().isEmpty()) { + if (!room.isValid() || room.getNode().empty() || !room.getResource().empty()) { QMessageBox::warning(this, "Bookmark not valid", "You must specify a valid room address (e.g. myroom@chats.example.com)."); return boost::optional(); } - String name(Q2PSTRING(name_->text())); - if (name.isEmpty()) { + std::string name(Q2PSTRING(name_->text())); + if (name.empty()) { name = room.toString(); } MUCBookmark bookmark(room, name); - String nick(Q2PSTRING(nick_->text())); - String password(Q2PSTRING(password_->text())); + std::string nick(Q2PSTRING(nick_->text())); + std::string password(Q2PSTRING(password_->text())); bookmark.setAutojoin(autojoin_->isChecked()); - if (!nick.isEmpty()) { + if (!nick.empty()) { bookmark.setNick(nick); } - if (!password.isEmpty()) { + if (!password.empty()) { bookmark.setPassword(password); } return bookmark; diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 62a696e..dac9e93 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -233,7 +233,7 @@ QtTabbable::AlertType QtChatWindow::getWidgetAlertState() { return NoActivity; } -void QtChatWindow::setName(const String& name) { +void QtChatWindow::setName(const std::string& name) { contact_ = P2QSTRING(name); updateTitleWithUnreadCount(); } @@ -247,11 +247,11 @@ void QtChatWindow::updateTitleWithUnreadCount() { emit titleUpdated(); } -String QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { return addMessage(message, senderName, senderIsSelf, label, avatarPath, "", time); } -String QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const QString& style, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -269,8 +269,8 @@ String QtChatWindow::addMessage(const String &message, const String &senderName, htmlString += styleSpanStart + messageHTML + styleSpanEnd; bool appendToPrevious = !previousMessageWasSystem_ && !previousMessageWasPresence_ && ((senderIsSelf && previousMessageWasSelf_) || (!senderIsSelf && !previousMessageWasSelf_ && previousSenderName_ == P2QSTRING(senderName))); - QString qAvatarPath = avatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(P2QSTRING(avatarPath)).toEncoded(); - String id = id_.generateID(); + QString qAvatarPath = avatarPath.empty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(P2QSTRING(avatarPath)).toEncoded(); + std::string id = id_.generateID(); messageLog_->addMessage(boost::shared_ptr(new MessageSnippet(htmlString, Qt::escape(P2QSTRING(senderName)), B2QDATE(time), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id)))); previousMessageWasSelf_ = senderIsSelf; @@ -284,7 +284,7 @@ void QtChatWindow::flash() { emit requestFlash(); } -void QtChatWindow::setAckState(String const& id, ChatWindow::AckState state) { +void QtChatWindow::setAckState(std::string const& id, ChatWindow::AckState state) { QString xml; switch (state) { case ChatWindow::Pending: xml = "This message has not been received by your server yet."; break; @@ -298,11 +298,11 @@ int QtChatWindow::getCount() { return unreadCount_; } -String QtChatWindow::addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { return addMessage(" *" + message + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time); } -void QtChatWindow::addErrorMessage(const String& errorMessage) { +void QtChatWindow::addErrorMessage(const std::string& errorMessage) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -316,7 +316,7 @@ void QtChatWindow::addErrorMessage(const String& errorMessage) { previousMessageWasPresence_ = false; } -void QtChatWindow::addSystemMessage(const String& message) { +void QtChatWindow::addSystemMessage(const std::string& message) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -331,7 +331,7 @@ void QtChatWindow::addSystemMessage(const String& message) { previousMessageWasPresence_ = false; } -void QtChatWindow::addPresenceMessage(const String& message) { +void QtChatWindow::addPresenceMessage(const std::string& message) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -390,7 +390,7 @@ void QtChatWindow::moveEvent(QMoveEvent*) { emit geometryChanged(); } -void QtChatWindow::replaceLastMessage(const String& message) { +void QtChatWindow::replaceLastMessage(const std::string& message) { messageLog_->replaceLastMessage(P2QSTRING(Linkify::linkify(message))); } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 20c8685..dbcfe9c 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -30,11 +30,11 @@ namespace Swift { public: QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream); ~QtChatWindow(); - String addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time); - String addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const boost::posix_time::ptime& time); - void addSystemMessage(const String& message); - void addPresenceMessage(const String& message); - void addErrorMessage(const String& errorMessage); + std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time); + std::string addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const boost::posix_time::ptime& time); + void addSystemMessage(const std::string& message); + void addPresenceMessage(const std::string& message); + void addErrorMessage(const std::string& errorMessage); void show(); void activate(); void setUnreadMessageCount(int count); @@ -44,15 +44,15 @@ namespace Swift { void setSecurityLabelsEnabled(bool enabled); void setSecurityLabelsError(); SecurityLabel getSelectedSecurityLabel(); - void setName(const String& name); + void setName(const std::string& name); void setInputEnabled(bool enabled); QtTabbable::AlertType getWidgetAlertState(); void setContactChatState(ChatState::ChatStateType state); void setRosterModel(Roster* roster); void setTabComplete(TabComplete* completer); int getCount(); - void replaceLastMessage(const String& message); - void setAckState(const String& id, AckState state); + void replaceLastMessage(const std::string& message); + void setAckState(const std::string& id, AckState state); void flash(); signals: @@ -75,7 +75,7 @@ namespace Swift { private: void updateTitleWithUnreadCount(); void tabComplete(); - String addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional& label, const String& avatarPath, const QString& style, const boost::posix_time::ptime& time); + std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional& label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time); int unreadCount_; bool contactIsTyping_; diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index 1f97a37..e8fe24a 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -18,7 +18,7 @@ namespace Swift { -QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, QWidget* parent) : QWidget(parent), groups_(NULL) { +QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, QWidget* parent) : QWidget(parent), groups_(NULL) { QBoxLayout* layout = new QVBoxLayout(this); setContentsMargins(0,0,0,0); layout->setContentsMargins(0,0,0,0); @@ -43,7 +43,7 @@ QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, QWid groupsArea->setWidget(groups); QVBoxLayout* scrollLayout = new QVBoxLayout(groups); - foreach (String group, allGroups) { + foreach (std::string group, allGroups) { QCheckBox* check = new QCheckBox(groups); check->setText(P2QSTRING(group)); check->setCheckState(Qt::Unchecked); @@ -63,22 +63,22 @@ QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, QWid scrollLayout->addItem(new QSpacerItem(20, 73, QSizePolicy::Minimum, QSizePolicy::Expanding)); } -void QtContactEditWidget::setName(const String& name) { +void QtContactEditWidget::setName(const std::string& name) { name_->setText(P2QSTRING(name)); } -String QtContactEditWidget::getName() const { +std::string QtContactEditWidget::getName() const { return Q2PSTRING(name_->text()); } -void QtContactEditWidget::setSelectedGroups(const std::vector& groups) { - foreach (String group, groups) { +void QtContactEditWidget::setSelectedGroups(const std::vector& groups) { + foreach (std::string group, groups) { checkBoxes_[group]->setCheckState(Qt::Checked); } } -std::set QtContactEditWidget::getSelectedGroups() const { - std::set groups; +std::set QtContactEditWidget::getSelectedGroups() const { + std::set groups; foreach(const CheckBoxMap::value_type& group, checkBoxes_) { if (group.second->checkState() == Qt::Checked) { groups.insert(group.first); diff --git a/Swift/QtUI/QtContactEditWidget.h b/Swift/QtUI/QtContactEditWidget.h index b855b6c..26a9968 100644 --- a/Swift/QtUI/QtContactEditWidget.h +++ b/Swift/QtUI/QtContactEditWidget.h @@ -12,7 +12,7 @@ #include -#include +#include class QLineEdit; class QCheckBox; @@ -22,16 +22,16 @@ namespace Swift { Q_OBJECT public: - QtContactEditWidget(const std::set& allGroups, QWidget* parent); + QtContactEditWidget(const std::set& allGroups, QWidget* parent); - void setName(const String&); - String getName() const; + void setName(const std::string&); + std::string getName() const; - void setSelectedGroups(const std::vector& groups); - std::set getSelectedGroups() const; + void setSelectedGroups(const std::vector& groups); + std::set getSelectedGroups() const; private: - typedef std::map CheckBoxMap; + typedef std::map CheckBoxMap; CheckBoxMap checkBoxes_; QLineEdit* name_; QWidget* groups_; diff --git a/Swift/QtUI/QtContactEditWindow.cpp b/Swift/QtUI/QtContactEditWindow.cpp index 0781f64..97b8f95 100644 --- a/Swift/QtUI/QtContactEditWindow.cpp +++ b/Swift/QtUI/QtContactEditWindow.cpp @@ -47,7 +47,7 @@ QtContactEditWindow::QtContactEditWindow() : contactEditWidget_(NULL) { buttonLayout->addWidget(okButton); } -void QtContactEditWindow::setContact(const JID& jid, const String& name, const std::vector& groups, const std::set& allGroups) { +void QtContactEditWindow::setContact(const JID& jid, const std::string& name, const std::vector& groups, const std::set& allGroups) { delete contactEditWidget_; jid_ = jid; jidLabel_->setText("" + P2QSTRING(jid.toString()) + ""); diff --git a/Swift/QtUI/QtContactEditWindow.h b/Swift/QtUI/QtContactEditWindow.h index 25ea9b7..2d283de 100644 --- a/Swift/QtUI/QtContactEditWindow.h +++ b/Swift/QtUI/QtContactEditWindow.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include class QLabel; @@ -24,7 +24,7 @@ namespace Swift { public: QtContactEditWindow(); - virtual void setContact(const JID& jid, const String& name, const std::vector& groups, const std::set& allGroups); + virtual void setContact(const JID& jid, const std::string& name, const std::vector& groups, const std::set& allGroups); void setEnabled(bool); void show(); diff --git a/Swift/QtUI/QtJoinMUCWindow.cpp b/Swift/QtUI/QtJoinMUCWindow.cpp index 60558ad..5ffc34d 100644 --- a/Swift/QtUI/QtJoinMUCWindow.cpp +++ b/Swift/QtUI/QtJoinMUCWindow.cpp @@ -39,12 +39,12 @@ void QtJoinMUCWindow::handleSearch() { onSearchMUC(); } -void QtJoinMUCWindow::setNick(const String& nick) { +void QtJoinMUCWindow::setNick(const std::string& nick) { ui.nickName->setText(P2QSTRING(nick)); lastSetNick = nick; } -void QtJoinMUCWindow::setMUC(const String& nick) { +void QtJoinMUCWindow::setMUC(const std::string& nick) { ui.room->setText(P2QSTRING(nick)); } diff --git a/Swift/QtUI/QtJoinMUCWindow.h b/Swift/QtUI/QtJoinMUCWindow.h index 2d12319..6e8e846 100644 --- a/Swift/QtUI/QtJoinMUCWindow.h +++ b/Swift/QtUI/QtJoinMUCWindow.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -16,8 +16,8 @@ namespace Swift { public: QtJoinMUCWindow(); - virtual void setNick(const String& nick); - virtual void setMUC(const String& nick); + virtual void setNick(const std::string& nick); + virtual void setMUC(const std::string& nick); virtual void show(); @@ -27,6 +27,6 @@ namespace Swift { private: Ui::QtJoinMUCWindow ui; - String lastSetNick; + std::string lastSetNick; }; } diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index c3fdac2..aae11d1 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -215,7 +215,7 @@ void QtLoginWindow::handleUIEvent(boost::shared_ptr event) { } } -void QtLoginWindow::selectUser(const String& username) { +void QtLoginWindow::selectUser(const std::string& username) { for (int i = 0; i < usernames_.count(); i++) { if (P2QSTRING(username) == usernames_[i]) { username_->setCurrentIndex(i); @@ -225,7 +225,7 @@ void QtLoginWindow::selectUser(const String& username) { } } -void QtLoginWindow::removeAvailableAccount(const String& jid) { +void QtLoginWindow::removeAvailableAccount(const std::string& jid) { QString username = P2QSTRING(jid); int index = -1; for (int i = 0; i < usernames_.count(); i++) { @@ -241,7 +241,7 @@ void QtLoginWindow::removeAvailableAccount(const String& jid) { } } -void QtLoginWindow::addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) { +void QtLoginWindow::addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate) { QString username = P2QSTRING(defaultJID); int index = -1; for (int i = 0; i < usernames_.count(); i++) { @@ -371,8 +371,8 @@ void QtLoginWindow::morphInto(MainWindow *mainWindow) { } } -void QtLoginWindow::setMessage(const String& message) { - if (!message.isEmpty()) { +void QtLoginWindow::setMessage(const std::string& message) { + if (!message.empty()) { message_->setText("
" + P2QSTRING(message) + "
"); } else { @@ -406,7 +406,7 @@ void QtLoginWindow::moveEvent(QMoveEvent*) { emit geometryChanged(); } -bool QtLoginWindow::askUserToTrustCertificatePermanently(const String& message, Certificate::ref certificate) { +bool QtLoginWindow::askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate) { QMessageBox dialog(this); dialog.setText("The certificate presented by the server is not valid."); diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 6987906..3f3b5f8 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -32,13 +32,13 @@ namespace Swift { void morphInto(MainWindow *mainWindow); virtual void loggedOut(); - virtual void setMessage(const String& message); - virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate); - virtual void removeAvailableAccount(const String& jid); + virtual void setMessage(const std::string& message); + virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate); + virtual void removeAvailableAccount(const std::string& jid); virtual void setLoginAutomatically(bool loginAutomatically); virtual void setIsLoggingIn(bool loggingIn); - void selectUser(const String& user); - bool askUserToTrustCertificatePermanently(const String& message, Certificate::ref certificate); + void selectUser(const std::string& user); + bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate); void hide(); virtual void quit(); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 2fd5700..6ebd8aa 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -175,7 +175,7 @@ void QtMainWindow::handleShowOfflineToggled(bool state) { } } -void QtMainWindow::setMyNick(const String& nick) { +void QtMainWindow::setMyNick(const std::string& nick) { meView_->setNick(P2QSTRING(nick)); } @@ -183,11 +183,11 @@ void QtMainWindow::setMyJID(const JID& jid) { meView_->setJID(P2QSTRING(jid.toBare().toString())); } -void QtMainWindow::setMyAvatarPath(const String& path) { +void QtMainWindow::setMyAvatarPath(const std::string& path) { meView_->setAvatar(P2QSTRING(path)); } -void QtMainWindow::setMyStatusText(const String& status) { +void QtMainWindow::setMyStatusText(const std::string& status) { meView_->setStatusText(P2QSTRING(status)); } diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index 66b0caf..0dc9d36 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -37,10 +37,10 @@ namespace Swift { QtMainWindow(QtSettingsProvider*, UIEventStream* eventStream); ~QtMainWindow(); std::vector getMenus() {return menus_;} - void setMyNick(const String& name); + void setMyNick(const std::string& name); void setMyJID(const JID& jid); - void setMyAvatarPath(const String& path); - void setMyStatusText(const String& status); + void setMyAvatarPath(const std::string& path); + void setMyStatusText(const std::string& status); void setMyStatusType(StatusShow::Type type); void setConnecting(); QtEventWindow* getEventWindow(); diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp index 0a53f11..c4fe400 100644 --- a/Swift/QtUI/QtProfileWindow.cpp +++ b/Swift/QtUI/QtProfileWindow.cpp @@ -118,8 +118,8 @@ void QtProfileWindow::handleSave() { onVCardChangeRequest(vcard); } -void QtProfileWindow::setError(const String& error) { - if (!error.isEmpty()) { +void QtProfileWindow::setError(const std::string& error) { + if (!error.empty()) { errorLabel->setText("" + P2QSTRING(error) + ""); } else { diff --git a/Swift/QtUI/QtProfileWindow.h b/Swift/QtUI/QtProfileWindow.h index 1ad73e8..edb9cce 100644 --- a/Swift/QtUI/QtProfileWindow.h +++ b/Swift/QtUI/QtProfileWindow.h @@ -26,7 +26,7 @@ namespace Swift { void setVCard(Swift::VCard::ref); void setEnabled(bool); void setProcessing(bool); - virtual void setError(const String&); + virtual void setError(const std::string&); void show(); void hide(); diff --git a/Swift/QtUI/QtRosterHeader.h b/Swift/QtUI/QtRosterHeader.h index 0dc611d..3380610 100644 --- a/Swift/QtUI/QtRosterHeader.h +++ b/Swift/QtUI/QtRosterHeader.h @@ -12,7 +12,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/StatusShow.h" #include "QtTextEdit.h" diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp index 4bddce3..4a8a868 100644 --- a/Swift/QtUI/QtSettingsProvider.cpp +++ b/Swift/QtUI/QtSettingsProvider.cpp @@ -18,35 +18,35 @@ QtSettingsProvider::~QtSettingsProvider() { } -String QtSettingsProvider::getStringSetting(const String &settingPath) { +std::string QtSettingsProvider::getStringSetting(const std::string &settingPath) { QVariant setting = settings_.value(P2QSTRING(settingPath)); return setting.isNull() ? "" : Q2PSTRING(setting.toString()); } -void QtSettingsProvider::storeString(const String &settingPath, const String &settingValue) { +void QtSettingsProvider::storeString(const std::string &settingPath, const std::string &settingValue) { settings_.setValue(P2QSTRING(settingPath), P2QSTRING(settingValue)); } -bool QtSettingsProvider::getBoolSetting(const String &settingPath, bool defaultValue) { +bool QtSettingsProvider::getBoolSetting(const std::string &settingPath, bool defaultValue) { QVariant setting = settings_.value(P2QSTRING(settingPath)); return setting.isNull() ? defaultValue : setting.toBool(); } -void QtSettingsProvider::storeBool(const String &settingPath, bool settingValue) { +void QtSettingsProvider::storeBool(const std::string &settingPath, bool settingValue) { settings_.setValue(P2QSTRING(settingPath), settingValue); } -int QtSettingsProvider::getIntSetting(const String &settingPath, int defaultValue) { +int QtSettingsProvider::getIntSetting(const std::string &settingPath, int defaultValue) { QVariant setting = settings_.value(P2QSTRING(settingPath)); return setting.isNull() ? defaultValue : setting.toInt(); } -void QtSettingsProvider::storeInt(const String &settingPath, int settingValue) { +void QtSettingsProvider::storeInt(const std::string &settingPath, int settingValue) { settings_.setValue(P2QSTRING(settingPath), settingValue); } -std::vector QtSettingsProvider::getAvailableProfiles() { - std::vector profiles; +std::vector QtSettingsProvider::getAvailableProfiles() { + std::vector profiles; QVariant profilesVariant = settings_.value("profileList"); foreach(QString profileQString, profilesVariant.toStringList()) { profiles.push_back(Q2PSTRING(profileQString)); @@ -54,13 +54,13 @@ std::vector QtSettingsProvider::getAvailableProfiles() { return profiles; } -void QtSettingsProvider::createProfile(const String& profile) { +void QtSettingsProvider::createProfile(const std::string& profile) { QStringList stringList = settings_.value("profileList").toStringList(); stringList.append(P2QSTRING(profile)); settings_.setValue("profileList", stringList); } -void QtSettingsProvider::removeProfile(const String& profile) { +void QtSettingsProvider::removeProfile(const std::string& profile) { QString profileStart(P2QSTRING(profile) + ":"); foreach (QString key, settings_.allKeys()) { if (key.startsWith(profileStart)) { diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h index d1dbc5e..ca05fe1 100644 --- a/Swift/QtUI/QtSettingsProvider.h +++ b/Swift/QtUI/QtSettingsProvider.h @@ -17,15 +17,15 @@ class QtSettingsProvider : public SettingsProvider { public: QtSettingsProvider(); virtual ~QtSettingsProvider(); - virtual String getStringSetting(const String &settingPath); - virtual void storeString(const String &settingPath, const String &settingValue); - virtual bool getBoolSetting(const String &settingPath, bool defaultValue); - virtual void storeBool(const String &settingPath, bool settingValue); - virtual int getIntSetting(const String &settingPath, int defaultValue); - virtual void storeInt(const String &settingPath, int settingValue); - virtual std::vector getAvailableProfiles(); - virtual void createProfile(const String& profile); - virtual void removeProfile(const String& profile); + virtual std::string getStringSetting(const std::string &settingPath); + virtual void storeString(const std::string &settingPath, const std::string &settingValue); + virtual bool getBoolSetting(const std::string &settingPath, bool defaultValue); + virtual void storeBool(const std::string &settingPath, bool settingValue); + virtual int getIntSetting(const std::string &settingPath, int defaultValue); + virtual void storeInt(const std::string &settingPath, int settingValue); + virtual std::vector getAvailableProfiles(); + virtual void createProfile(const std::string& profile); + virtual void removeProfile(const std::string& profile); QSettings* getQSettings(); private: QSettings settings_; diff --git a/Swift/QtUI/QtSoundPlayer.cpp b/Swift/QtUI/QtSoundPlayer.cpp index b967cef..387c6f3 100644 --- a/Swift/QtUI/QtSoundPlayer.cpp +++ b/Swift/QtUI/QtSoundPlayer.cpp @@ -24,7 +24,7 @@ void QtSoundPlayer::playSound(SoundEffect sound) { } } -void QtSoundPlayer::playSound(const String& soundResource) { +void QtSoundPlayer::playSound(const std::string& soundResource) { boost::filesystem::path resourcePath = applicationPathProvider->getResourcePath(soundResource); if (boost::filesystem::exists(resourcePath)) { QSound::play(resourcePath.string().c_str()); diff --git a/Swift/QtUI/QtSoundPlayer.h b/Swift/QtUI/QtSoundPlayer.h index 21ad8bb..6945f45 100644 --- a/Swift/QtUI/QtSoundPlayer.h +++ b/Swift/QtUI/QtSoundPlayer.h @@ -12,7 +12,7 @@ namespace Swift { class ApplicationPathProvider; - class String; + class QtSoundPlayer : public QObject, public SoundPlayer { Q_OBJECT @@ -22,7 +22,7 @@ namespace Swift { void playSound(SoundEffect sound); private: - void playSound(const String& soundResource); + void playSound(const std::string& soundResource); private: ApplicationPathProvider* applicationPathProvider; diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 1c14dee..d4c306f 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -22,7 +22,7 @@ #include "SwifTools/Application/PlatformApplicationPathProvider.h" #include "Swiften/Avatars/AvatarFileStorage.h" #include "Swiften/Disco/CapsFileStorage.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/Platform.h" #include "Swift/Controllers/FileStoragesFactory.h" #include "Swiften/Elements/Presence.h" diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index cc9eb38..978fa14 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -11,7 +11,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/Platform.h" #include "Swiften/EventLoop/Qt/QtEventLoop.h" #include "QtSettingsProvider.h" diff --git a/Swift/QtUI/QtSwiftUtil.h b/Swift/QtUI/QtSwiftUtil.h index 3f1ad3b..60a9f18 100644 --- a/Swift/QtUI/QtSwiftUtil.h +++ b/Swift/QtUI/QtSwiftUtil.h @@ -7,8 +7,8 @@ #ifndef SWIFT_QtSwiftUtil_H #define SWIFT_QtSwiftUtil_H -#define P2QSTRING(a) QString::fromUtf8(a.getUTF8Data()) -#define Q2PSTRING(a) Swift::String(a.toUtf8()) +#define P2QSTRING(a) QString::fromUtf8(a.c_str()) +#define Q2PSTRING(a) std::string(a.toUtf8()) #define B2QDATE(a) QDateTime::fromTime_t((a - boost::posix_time::from_time_t(0)).total_seconds()) diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp index 57e1278..42c8a8f 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.cpp +++ b/Swift/QtUI/QtXMLConsoleWidget.cpp @@ -14,7 +14,7 @@ #include #include "QtSwiftUtil.h" -#include "Swiften/Base/String.h" +#include namespace Swift { @@ -71,15 +71,15 @@ void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) { event->accept(); } -void QtXMLConsoleWidget::handleDataRead(const String& data) { +void QtXMLConsoleWidget::handleDataRead(const std::string& data) { appendTextIfEnabled("\n" + data + "\n", QColor(33,98,33)); } -void QtXMLConsoleWidget::handleDataWritten(const String& data) { +void QtXMLConsoleWidget::handleDataWritten(const std::string& data) { appendTextIfEnabled("\n" + data + "\n", QColor(155,1,0)); } -void QtXMLConsoleWidget::appendTextIfEnabled(const String& data, const QColor& color) { +void QtXMLConsoleWidget::appendTextIfEnabled(const std::string& data, const QColor& color) { if (enabled->isChecked()) { QScrollBar* scrollBar = textEdit->verticalScrollBar(); bool scrollToBottom = (!scrollBar || scrollBar->value() == scrollBar->maximum()); diff --git a/Swift/QtUI/QtXMLConsoleWidget.h b/Swift/QtUI/QtXMLConsoleWidget.h index 1cfe54f..a345495 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.h +++ b/Swift/QtUI/QtXMLConsoleWidget.h @@ -23,14 +23,14 @@ namespace Swift { void show(); void activate(); - virtual void handleDataRead(const String& data); - virtual void handleDataWritten(const String& data); + virtual void handleDataRead(const std::string& data); + virtual void handleDataWritten(const std::string& data); private: virtual void closeEvent(QCloseEvent* event); virtual void showEvent(QShowEvent* event); - void appendTextIfEnabled(const String& data, const QColor& color); + void appendTextIfEnabled(const std::string& data, const QColor& color); private: QTextEdit* textEdit; diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp index 97b2028..fcd8691 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp @@ -20,18 +20,18 @@ QtTreeWidgetItem::QtTreeWidgetItem(QtTreeWidgetItem* parentItem) : QObject(), te } -void QtTreeWidgetItem::setText(const String& text) { +void QtTreeWidgetItem::setText(const std::string& text) { displayName_ = P2QSTRING(text); displayNameLower_ = displayName_.toLower(); emit changed(this); } -void QtTreeWidgetItem::setStatusText(const String& text) { +void QtTreeWidgetItem::setStatusText(const std::string& text) { statusText_ = P2QSTRING(text); emit changed(this); } -void QtTreeWidgetItem::setAvatarPath(const String& path) { +void QtTreeWidgetItem::setAvatarPath(const std::string& path) { avatar_ = QIcon(P2QSTRING(path)); emit changed(this); } diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h index c042ae0..a2d0cdd 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.h +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h @@ -10,7 +10,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Roster/TreeWidget.h" #include "Swiften/Roster/TreeWidgetItem.h" @@ -43,9 +43,9 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem { QVariant data(int role); QIcon getPresenceIcon(); QtTreeWidgetItem(QtTreeWidgetItem* parentItem); - void setText(const String& text); - void setAvatarPath(const String& path); - void setStatusText(const String& text); + void setText(const std::string& text); + void setAvatarPath(const std::string& path); + void setStatusText(const std::string& text); void setStatusShow(StatusShow::Type show); void setTextColor(unsigned long color); void setBackgroundColor(unsigned long color); diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp index 95452c8..306b76f 100644 --- a/Swift/QtUI/Roster/RosterModel.cpp +++ b/Swift/QtUI/Roster/RosterModel.cpp @@ -137,9 +137,9 @@ QString RosterModel::getToolTip(RosterItem* item) const { QIcon RosterModel::getAvatar(RosterItem* item) const { ContactRosterItem* contact = dynamic_cast(item); if (!contact) return QIcon(); - String path = contact->getAvatarPath(); + std::string path = contact->getAvatarPath(); - return path.isEmpty() ? QIcon() : QIcon(P2QSTRING(path)); + return path.empty() ? QIcon() : QIcon(P2QSTRING(path)); } QString RosterModel::getStatusText(RosterItem* item) const { diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index ad06654..c6fb004 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -209,7 +209,7 @@ void QtUserSearchWindow::show() { // //void QtUserSearchWindow::handleOkClicked() { // JID contact = JID(Q2PSTRING(jid_->text())); -// String nick = Q2PSTRING(nickName_->text()); +// std::string nick = Q2PSTRING(nickName_->text()); // if (addToRoster_->isChecked()) { // boost::shared_ptr event(new AddContactUIEvent(contact, nick)); // eventStream_->send(event); diff --git a/Swift/QtUI/UserSearch/UserSearchModel.cpp b/Swift/QtUI/UserSearch/UserSearchModel.cpp index 1187c29..aafd789 100644 --- a/Swift/QtUI/UserSearch/UserSearchModel.cpp +++ b/Swift/QtUI/UserSearch/UserSearchModel.cpp @@ -46,12 +46,12 @@ QVariant UserSearchModel::data(UserSearchResult* item, int role) { QString UserSearchModel::nameLine(UserSearchResult* item) { QString result; - const std::map fields = item->getFields(); - std::map::const_iterator first = fields.find("first"); + const std::map fields = item->getFields(); + std::map::const_iterator first = fields.find("first"); if (first != fields.end()) { result += P2QSTRING((*first).second); } - std::map::const_iterator last = fields.find("last"); + std::map::const_iterator last = fields.find("last"); if (last != fields.end()) { if (!result.isEmpty()) { result += " "; diff --git a/Swift/QtUI/WindowsNotifier.cpp b/Swift/QtUI/WindowsNotifier.cpp index 9646b90..49489a3 100644 --- a/Swift/QtUI/WindowsNotifier.cpp +++ b/Swift/QtUI/WindowsNotifier.cpp @@ -16,7 +16,7 @@ namespace Swift { -WindowsNotifier::WindowsNotifier(const String& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray) : tray(tray) { +WindowsNotifier::WindowsNotifier(const std::string& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray) : tray(tray) { notifierWindow = new QtWin32NotifierWindow(); snarlNotifier = new SnarlNotifier(name, notifierWindow, icon); connect(tray, SIGNAL(messageClicked()), SLOT(handleMessageClicked())); @@ -27,7 +27,7 @@ WindowsNotifier::~WindowsNotifier() { delete notifierWindow; } -void WindowsNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback) { +void WindowsNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback) { if (snarlNotifier->isAvailable()) { snarlNotifier->showMessage(type, subject, description, picture, callback); return; diff --git a/Swift/QtUI/WindowsNotifier.h b/Swift/QtUI/WindowsNotifier.h index dbf86a2..062b76f 100644 --- a/Swift/QtUI/WindowsNotifier.h +++ b/Swift/QtUI/WindowsNotifier.h @@ -19,10 +19,10 @@ namespace Swift { Q_OBJECT public: - WindowsNotifier(const String& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray); + WindowsNotifier(const std::string& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray); ~WindowsNotifier(); - virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function callback); private slots: void handleMessageClicked(); diff --git a/Swift/QtUI/tmp/QtRosterContextMenu.cpp b/Swift/QtUI/tmp/QtRosterContextMenu.cpp index a59a2f7..c8375ba 100644 --- a/Swift/QtUI/tmp/QtRosterContextMenu.cpp +++ b/Swift/QtUI/tmp/QtRosterContextMenu.cpp @@ -18,7 +18,7 @@ #include "Swiften/Roster/ContactRosterItem.h" #include "Swiften/Roster/GroupRosterItem.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Roster/Roster.h" #include "Swift/Controllers/UIEvents/UIEvent.h" #include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h" @@ -92,8 +92,8 @@ void QtRosterContextMenu::handleRenameGroup() { bool ok; QString newName = QInputDialog::getText(NULL, "Rename group", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok); if (ok) { - std::vector addedGroups; - std::vector removedGroups; + std::vector addedGroups; + std::vector removedGroups; addedGroups.push_back(Q2PSTRING(newName)); removedGroups.push_back(group->getDisplayName()); foreach (RosterItem* child, group->getChildren()) { diff --git a/Swiften/Avatars/AvatarFileStorage.cpp b/Swiften/Avatars/AvatarFileStorage.cpp index f76adee..046ac16 100644 --- a/Swiften/Avatars/AvatarFileStorage.cpp +++ b/Swiften/Avatars/AvatarFileStorage.cpp @@ -14,11 +14,11 @@ namespace Swift { AvatarFileStorage::AvatarFileStorage(const boost::filesystem::path& path) : path_(path) { } -bool AvatarFileStorage::hasAvatar(const String& hash) const { +bool AvatarFileStorage::hasAvatar(const std::string& hash) const { return boost::filesystem::exists(getAvatarPath(hash)); } -void AvatarFileStorage::addAvatar(const String& hash, const ByteArray& avatar) { +void AvatarFileStorage::addAvatar(const std::string& hash, const ByteArray& avatar) { boost::filesystem::path avatarPath = getAvatarPath(hash); if (!boost::filesystem::exists(avatarPath.parent_path())) { try { @@ -33,11 +33,11 @@ void AvatarFileStorage::addAvatar(const String& hash, const ByteArray& avatar) { file.close(); } -boost::filesystem::path AvatarFileStorage::getAvatarPath(const String& hash) const { - return path_ / hash.getUTF8String(); +boost::filesystem::path AvatarFileStorage::getAvatarPath(const std::string& hash) const { + return path_ / hash; } -ByteArray AvatarFileStorage::getAvatar(const String& hash) const { +ByteArray AvatarFileStorage::getAvatar(const std::string& hash) const { ByteArray data; data.readFromFile(getAvatarPath(hash).string()); return data; diff --git a/Swiften/Avatars/AvatarFileStorage.h b/Swiften/Avatars/AvatarFileStorage.h index 5ade779..e803430 100644 --- a/Swiften/Avatars/AvatarFileStorage.h +++ b/Swiften/Avatars/AvatarFileStorage.h @@ -9,7 +9,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" #include "Swiften/Avatars/AvatarStorage.h" @@ -18,11 +18,11 @@ namespace Swift { public: AvatarFileStorage(const boost::filesystem::path& path); - virtual bool hasAvatar(const String& hash) const; - virtual void addAvatar(const String& hash, const ByteArray& avatar); - virtual ByteArray getAvatar(const String& hash) const; + virtual bool hasAvatar(const std::string& hash) const; + virtual void addAvatar(const std::string& hash, const ByteArray& avatar); + virtual ByteArray getAvatar(const std::string& hash) const; - virtual boost::filesystem::path getAvatarPath(const String& hash) const; + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const; private: boost::filesystem::path path_; diff --git a/Swiften/Avatars/AvatarManagerImpl.cpp b/Swiften/Avatars/AvatarManagerImpl.cpp index 9813aed..6b77f8d 100644 --- a/Swiften/Avatars/AvatarManagerImpl.cpp +++ b/Swiften/Avatars/AvatarManagerImpl.cpp @@ -33,16 +33,16 @@ AvatarManagerImpl::~AvatarManagerImpl() { } boost::filesystem::path AvatarManagerImpl::getAvatarPath(const JID& jid) const { - String hash = combinedAvatarProvider.getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = combinedAvatarProvider.getAvatarHash(jid); + if (!hash.empty()) { return avatarStorage->getAvatarPath(hash); } return boost::filesystem::path(); } ByteArray AvatarManagerImpl::getAvatar(const JID& jid) const { - String hash = combinedAvatarProvider.getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = combinedAvatarProvider.getAvatarHash(jid); + if (!hash.empty()) { return avatarStorage->getAvatar(hash); } return ByteArray(); diff --git a/Swiften/Avatars/AvatarMemoryStorage.h b/Swiften/Avatars/AvatarMemoryStorage.h index 6f1ba49..3fa770a 100644 --- a/Swiften/Avatars/AvatarMemoryStorage.h +++ b/Swiften/Avatars/AvatarMemoryStorage.h @@ -8,25 +8,25 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" #include "Swiften/Avatars/AvatarStorage.h" namespace Swift { class AvatarMemoryStorage : public AvatarStorage { public: - virtual bool hasAvatar(const String& hash) const { return avatars.find(hash) != avatars.end(); } - virtual void addAvatar(const String& hash, const ByteArray& avatar) { avatars[hash] = avatar; } - virtual ByteArray getAvatar(const String& hash) const { - std::map::const_iterator i = avatars.find(hash); + virtual bool hasAvatar(const std::string& hash) const { return avatars.find(hash) != avatars.end(); } + virtual void addAvatar(const std::string& hash, const ByteArray& avatar) { avatars[hash] = avatar; } + virtual ByteArray getAvatar(const std::string& hash) const { + std::map::const_iterator i = avatars.find(hash); return i == avatars.end() ? ByteArray() : i->second; } - virtual boost::filesystem::path getAvatarPath(const String& hash) const { - return boost::filesystem::path("/avatars") / hash.getUTF8String(); + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const { + return boost::filesystem::path("/avatars") / hash; } private: - std::map avatars; + std::map avatars; }; } diff --git a/Swiften/Avatars/AvatarProvider.h b/Swiften/Avatars/AvatarProvider.h index b953ad3..0f66904 100644 --- a/Swiften/Avatars/AvatarProvider.h +++ b/Swiften/Avatars/AvatarProvider.h @@ -7,7 +7,7 @@ #pragma once #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include namespace Swift { class JID; @@ -16,7 +16,7 @@ namespace Swift { public: virtual ~AvatarProvider(); - virtual String getAvatarHash(const JID&) const = 0; + virtual std::string getAvatarHash(const JID&) const = 0; boost::signal onAvatarChanged; }; diff --git a/Swiften/Avatars/AvatarStorage.h b/Swiften/Avatars/AvatarStorage.h index d699f40..826a648 100644 --- a/Swiften/Avatars/AvatarStorage.h +++ b/Swiften/Avatars/AvatarStorage.h @@ -9,17 +9,17 @@ #include namespace Swift { - class String; + class ByteArray; class AvatarStorage { public: virtual ~AvatarStorage(); - virtual bool hasAvatar(const String& hash) const = 0; - virtual void addAvatar(const String& hash, const ByteArray& avatar) = 0; - virtual ByteArray getAvatar(const String& hash) const = 0; - virtual boost::filesystem::path getAvatarPath(const String& hash) const = 0; + virtual bool hasAvatar(const std::string& hash) const = 0; + virtual void addAvatar(const std::string& hash, const ByteArray& avatar) = 0; + virtual ByteArray getAvatar(const std::string& hash) const = 0; + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const = 0; }; } diff --git a/Swiften/Avatars/CombinedAvatarProvider.cpp b/Swiften/Avatars/CombinedAvatarProvider.cpp index 4f0b04a..6ac31e3 100644 --- a/Swiften/Avatars/CombinedAvatarProvider.cpp +++ b/Swiften/Avatars/CombinedAvatarProvider.cpp @@ -11,14 +11,14 @@ namespace Swift { -String CombinedAvatarProvider::getAvatarHash(const JID& jid) const { +std::string CombinedAvatarProvider::getAvatarHash(const JID& jid) const { for (size_t i = 0; i < providers.size(); ++i) { - String hash = providers[i]->getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = providers[i]->getAvatarHash(jid); + if (!hash.empty()) { return hash; } } - return String(); + return std::string(); } void CombinedAvatarProvider::addProvider(AvatarProvider* provider) { @@ -35,11 +35,11 @@ void CombinedAvatarProvider::removeProvider(AvatarProvider* provider) { } void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) { - String hash = getAvatarHash(jid); - std::map::iterator i = avatars.find(jid); + std::string hash = getAvatarHash(jid); + std::map::iterator i = avatars.find(jid); if (i != avatars.end()) { if (i->second != hash) { - if (hash.isEmpty()) { + if (hash.empty()) { avatars.erase(i); } else { @@ -48,7 +48,7 @@ void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) { onAvatarChanged(jid); } } - else if (!hash.isEmpty()) { + else if (!hash.empty()) { avatars.insert(std::make_pair(jid, hash)); onAvatarChanged(jid); } diff --git a/Swiften/Avatars/CombinedAvatarProvider.h b/Swiften/Avatars/CombinedAvatarProvider.h index fbd6ce7..9c83732 100644 --- a/Swiften/Avatars/CombinedAvatarProvider.h +++ b/Swiften/Avatars/CombinedAvatarProvider.h @@ -15,7 +15,7 @@ namespace Swift { class CombinedAvatarProvider : public AvatarProvider { public: - virtual String getAvatarHash(const JID&) const; + virtual std::string getAvatarHash(const JID&) const; void addProvider(AvatarProvider*); void removeProvider(AvatarProvider*); @@ -25,6 +25,6 @@ namespace Swift { private: std::vector providers; - std::map avatars; + std::map avatars; }; } diff --git a/Swiften/Avatars/DummyAvatarManager.h b/Swiften/Avatars/DummyAvatarManager.h index 12bbe42..e73c61e 100644 --- a/Swiften/Avatars/DummyAvatarManager.h +++ b/Swiften/Avatars/DummyAvatarManager.h @@ -15,7 +15,7 @@ namespace Swift { class DummyAvatarManager : public AvatarManager { public: virtual boost::filesystem::path getAvatarPath(const JID& j) const { - return boost::filesystem::path("/avatars") / j.toString().getUTF8String(); + return boost::filesystem::path("/avatars") / j.toString(); } virtual ByteArray getAvatar(const JID& jid) const { diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp index ad3a0f1..6153d29 100644 --- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp +++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp @@ -9,7 +9,7 @@ #include #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Avatars/CombinedAvatarProvider.h" using namespace Swift; @@ -47,7 +47,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { void testGetAvatarWithNoAvatarProviderReturnsEmpty() { std::auto_ptr testling(createProvider()); - CPPUNIT_ASSERT(testling->getAvatarHash(user1).isEmpty()); + CPPUNIT_ASSERT(testling->getAvatarHash(user1).empty()); } void testGetAvatarWithSingleAvatarProvider() { @@ -168,26 +168,26 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { private: struct DummyAvatarProvider : public AvatarProvider { - String getAvatarHash(const JID& jid) const { - std::map::const_iterator i = avatars.find(jid); + std::string getAvatarHash(const JID& jid) const { + std::map::const_iterator i = avatars.find(jid); if (i != avatars.end()) { return i->second; } else { - return String(); + return std::string(); } } - std::map avatars; + std::map avatars; }; DummyAvatarProvider* avatarProvider1; DummyAvatarProvider* avatarProvider2; JID user1; JID user2; - String avatarHash1; - String avatarHash2; - String avatarHash3; + std::string avatarHash1; + std::string avatarHash2; + std::string avatarHash3; std::vector changes; }; diff --git a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp index 8cb9ccb..be5eaea 100644 --- a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp +++ b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp @@ -62,7 +62,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { storeVCardWithPhoto(user1.toBare(), avatar1); avatarStorage->addAvatar(avatar1Hash, avatar1); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); CPPUNIT_ASSERT_EQUAL(avatar1Hash, result); } @@ -71,16 +71,16 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { std::auto_ptr testling = createManager(); storeEmptyVCard(user1.toBare()); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); - CPPUNIT_ASSERT_EQUAL(String(), result); + CPPUNIT_ASSERT_EQUAL(std::string(), result); } void testGetAvatarHashUnknownAvatarKnownVCardStoresAvatar() { std::auto_ptr testling = createManager(); storeVCardWithPhoto(user1.toBare(), avatar1); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); CPPUNIT_ASSERT_EQUAL(avatar1Hash, result); CPPUNIT_ASSERT(avatarStorage->hasAvatar(avatar1Hash)); @@ -90,9 +90,9 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { void testGetAvatarHashUnknownAvatarUnknownVCard() { std::auto_ptr testling = createManager(); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); - CPPUNIT_ASSERT_EQUAL(String(), result); + CPPUNIT_ASSERT_EQUAL(std::string(), result); } void testVCardUpdateTriggersUpdate() { @@ -145,7 +145,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { VCardManager* vcardManager; VCardMemoryStorage* vcardStorage; ByteArray avatar1; - String avatar1Hash; + std::string avatar1Hash; std::vector changes; JID user1; JID user2; diff --git a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp index a928ced..cde4a45 100644 --- a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp +++ b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp @@ -113,7 +113,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { stanzaChannel->onIQReceived(createVCardResult(ByteArray())); CPPUNIT_ASSERT(!avatarStorage->hasAvatar(Hexify::hexify(SHA1::getHash(ByteArray())))); - CPPUNIT_ASSERT_EQUAL(String(), testling->getAvatarHash(JID("foo@bar.com"))); + CPPUNIT_ASSERT_EQUAL(std::string(), testling->getAvatarHash(JID("foo@bar.com"))); } void testStanzaChannelReset_ClearsHash() { @@ -128,7 +128,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(changes.size())); CPPUNIT_ASSERT_EQUAL(user1.toBare(), changes[0]); - CPPUNIT_ASSERT_EQUAL(String(""), testling->getAvatarHash(user1.toBare())); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling->getAvatarHash(user1.toBare())); } void testStanzaChannelReset_ReceiveHashAfterResetUpdatesHash() { @@ -154,7 +154,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { return result; } - boost::shared_ptr createPresenceWithPhotoHash(const JID& jid, const String& hash) { + boost::shared_ptr createPresenceWithPhotoHash(const JID& jid, const std::string& hash) { boost::shared_ptr presence(new Presence()); presence->setFrom(jid); presence->addPayload(boost::shared_ptr(new VCardUpdate(hash))); @@ -187,7 +187,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { VCardManager* vcardManager; VCardMemoryStorage* vcardStorage; ByteArray avatar1; - String avatar1Hash; + std::string avatar1Hash; std::vector changes; JID user1; JID user2; diff --git a/Swiften/Avatars/VCardAvatarManager.cpp b/Swiften/Avatars/VCardAvatarManager.cpp index 244a73e..ce732db 100644 --- a/Swiften/Avatars/VCardAvatarManager.cpp +++ b/Swiften/Avatars/VCardAvatarManager.cpp @@ -28,10 +28,10 @@ void VCardAvatarManager::handleVCardChanged(const JID& from) { onAvatarChanged(from); } -String VCardAvatarManager::getAvatarHash(const JID& jid) const { +std::string VCardAvatarManager::getAvatarHash(const JID& jid) const { VCard::ref vCard = vcardManager_->getVCard(getAvatarJID(jid)); if (vCard && !vCard->getPhoto().isEmpty()) { - String hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); + std::string hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); if (!avatarStorage_->hasAvatar(hash)) { avatarStorage_->addAvatar(hash, vCard->getPhoto()); } diff --git a/Swiften/Avatars/VCardAvatarManager.h b/Swiften/Avatars/VCardAvatarManager.h index 069f938..3f99dad 100644 --- a/Swiften/Avatars/VCardAvatarManager.h +++ b/Swiften/Avatars/VCardAvatarManager.h @@ -21,7 +21,7 @@ namespace Swift { public: VCardAvatarManager(VCardManager*, AvatarStorage*, MUCRegistry* = NULL); - String getAvatarHash(const JID&) const; + std::string getAvatarHash(const JID&) const; private: void handleVCardChanged(const JID& from); diff --git a/Swiften/Avatars/VCardUpdateAvatarManager.cpp b/Swiften/Avatars/VCardUpdateAvatarManager.cpp index 879846e..08d026b 100644 --- a/Swiften/Avatars/VCardUpdateAvatarManager.cpp +++ b/Swiften/Avatars/VCardUpdateAvatarManager.cpp @@ -52,7 +52,7 @@ void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vC setAvatarHash(from, ""); } else { - String hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); + std::string hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); if (!avatarStorage_->hasAvatar(hash)) { avatarStorage_->addAvatar(hash, vCard->getPhoto()); } @@ -60,21 +60,21 @@ void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vC } } -void VCardUpdateAvatarManager::setAvatarHash(const JID& from, const String& hash) { +void VCardUpdateAvatarManager::setAvatarHash(const JID& from, const std::string& hash) { avatarHashes_[from] = hash; onAvatarChanged(from); } /* void VCardUpdateAvatarManager::setAvatar(const JID& jid, const ByteArray& avatar) { - String hash = Hexify::hexify(SHA1::getHash(avatar)); + std::string hash = Hexify::hexify(SHA1::getHash(avatar)); avatarStorage_->addAvatar(hash, avatar); setAvatarHash(getAvatarJID(jid), hash); } */ -String VCardUpdateAvatarManager::getAvatarHash(const JID& jid) const { - std::map::const_iterator i = avatarHashes_.find(getAvatarJID(jid)); +std::string VCardUpdateAvatarManager::getAvatarHash(const JID& jid) const { + std::map::const_iterator i = avatarHashes_.find(getAvatarJID(jid)); if (i != avatarHashes_.end()) { return i->second; } @@ -90,9 +90,9 @@ JID VCardUpdateAvatarManager::getAvatarJID(const JID& jid) const { void VCardUpdateAvatarManager::handleStanzaChannelAvailableChanged(bool available) { if (available) { - std::map oldAvatarHashes; + std::map oldAvatarHashes; avatarHashes_.swap(oldAvatarHashes); - for(std::map::const_iterator i = oldAvatarHashes.begin(); i != oldAvatarHashes.end(); ++i) { + for(std::map::const_iterator i = oldAvatarHashes.begin(); i != oldAvatarHashes.end(); ++i) { onAvatarChanged(i->first); } } diff --git a/Swiften/Avatars/VCardUpdateAvatarManager.h b/Swiften/Avatars/VCardUpdateAvatarManager.h index 8827ab7..1f03898 100644 --- a/Swiften/Avatars/VCardUpdateAvatarManager.h +++ b/Swiften/Avatars/VCardUpdateAvatarManager.h @@ -25,13 +25,13 @@ namespace Swift { public: VCardUpdateAvatarManager(VCardManager*, StanzaChannel*, AvatarStorage*, MUCRegistry* = NULL); - String getAvatarHash(const JID&) const; + std::string getAvatarHash(const JID&) const; private: void handlePresenceReceived(boost::shared_ptr); void handleStanzaChannelAvailableChanged(bool); void handleVCardChanged(const JID& from, VCard::ref); - void setAvatarHash(const JID& from, const String& hash); + void setAvatarHash(const JID& from, const std::string& hash); JID getAvatarJID(const JID& o) const; private: @@ -39,6 +39,6 @@ namespace Swift { StanzaChannel* stanzaChannel_; AvatarStorage* avatarStorage_; MUCRegistry* mucRegistry_; - std::map avatarHashes_; + std::map avatarHashes_; }; } diff --git a/Swiften/Base/ByteArray.cpp b/Swiften/Base/ByteArray.cpp index 36cc19c..7701268 100644 --- a/Swiften/Base/ByteArray.cpp +++ b/Swiften/Base/ByteArray.cpp @@ -26,8 +26,8 @@ namespace Swift { static const int BUFFER_SIZE = 4096; -void ByteArray::readFromFile(const String& file) { - std::ifstream input(file.getUTF8Data(), std::ios_base::in|std::ios_base::binary); +void ByteArray::readFromFile(const std::string& file) { + std::ifstream input(file.c_str(), std::ios_base::in|std::ios_base::binary); while (input.good()) { size_t oldSize = data_.size(); data_.resize(oldSize + BUFFER_SIZE); diff --git a/Swiften/Base/ByteArray.h b/Swiften/Base/ByteArray.h index b5cbfb0..90a4907 100644 --- a/Swiften/Base/ByteArray.h +++ b/Swiften/Base/ByteArray.h @@ -10,7 +10,7 @@ #include #include -#include "Swiften/Base/String.h" +#include namespace Swift { class ByteArray @@ -20,7 +20,7 @@ namespace Swift { ByteArray() : data_() {} - ByteArray(const String& s) : data_(s.getUTF8String().begin(), s.getUTF8String().end()) {} + ByteArray(const std::string& s) : data_(s.begin(), s.end()) {} ByteArray(const char* c) { while (*c) { @@ -107,11 +107,11 @@ namespace Swift { return data_.end(); } - String toString() const { - return String(getData(), getSize()); + std::string toString() const { + return std::string(getData(), getSize()); } - void readFromFile(const String& file); + void readFromFile(const std::string& file); void clear() { data_.clear(); diff --git a/Swiften/Base/IDGenerator.cpp b/Swiften/Base/IDGenerator.cpp index b620de7..74a0f65 100644 --- a/Swiften/Base/IDGenerator.cpp +++ b/Swiften/Base/IDGenerator.cpp @@ -11,16 +11,16 @@ namespace Swift { IDGenerator::IDGenerator() { } -String IDGenerator::generateID() { +std::string IDGenerator::generateID() { bool carry = true; size_t i = 0; - while (carry && i < currentID_.getUTF8Size()) { - char c = currentID_.getUTF8String()[i]; + while (carry && i < currentID_.size()) { + char c = currentID_[i]; if (c >= 'z') { - currentID_.getUTF8String()[i] = 'a'; + currentID_[i] = 'a'; } else { - currentID_.getUTF8String()[i] = c+1; + currentID_[i] = c+1; carry = false; } ++i; diff --git a/Swiften/Base/IDGenerator.h b/Swiften/Base/IDGenerator.h index 2089658..4b6289b 100644 --- a/Swiften/Base/IDGenerator.h +++ b/Swiften/Base/IDGenerator.h @@ -7,17 +7,17 @@ #ifndef SWIFTEN_IDGenerator_H #define SWIFTEN_IDGenerator_H -#include "Swiften/Base/String.h" +#include namespace Swift { class IDGenerator { public: IDGenerator(); - String generateID(); + std::string generateID(); private: - String currentID_; + std::string currentID_; }; } diff --git a/Swiften/Base/Paths.cpp b/Swiften/Base/Paths.cpp index c1dbef2..0e69b61 100644 --- a/Swiften/Base/Paths.cpp +++ b/Swiften/Base/Paths.cpp @@ -25,7 +25,7 @@ boost::filesystem::path Paths::getExecutablePath() { uint32_t size = 4096; path.resize(size); if (_NSGetExecutablePath(path.getData(), &size) == 0) { - return boost::filesystem::path(path.toString().getUTF8Data()).parent_path(); + return boost::filesystem::path(path.toString().c_str()).parent_path(); } #elif defined(SWIFTEN_PLATFORM_LINUX) ByteArray path; @@ -33,13 +33,13 @@ boost::filesystem::path Paths::getExecutablePath() { size_t size = readlink("/proc/self/exe", path.getData(), path.getSize()); if (size > 0) { path.resize(size); - return boost::filesystem::path(path.toString().getUTF8Data()).parent_path(); + return boost::filesystem::path(path.toString().c_str()).parent_path(); } #elif defined(SWIFTEN_PLATFORM_WINDOWS) ByteArray data; data.resize(2048); GetModuleFileName(NULL, data.getData(), data.getSize()); - return boost::filesystem::path(data.toString().getUTF8Data()).parent_path(); + return boost::filesystem::path(data.toString().c_str()).parent_path(); #endif return boost::filesystem::path(); } diff --git a/Swiften/Base/SConscript b/Swiften/Base/SConscript index 9c7b8dc..ca22044 100644 --- a/Swiften/Base/SConscript +++ b/Swiften/Base/SConscript @@ -5,8 +5,8 @@ objects = swiften_env.StaticObject([ "Error.cpp", "Log.cpp", "Paths.cpp", - "IDGenerator.cpp", "String.cpp", + "IDGenerator.cpp", "sleep.cpp", ]) swiften_env.Append(SWIFTEN_OBJECTS = [objects]) diff --git a/Swiften/Base/String.cpp b/Swiften/Base/String.cpp index 460df36..7ddf614 100644 --- a/Swiften/Base/String.cpp +++ b/Swiften/Base/String.cpp @@ -7,7 +7,7 @@ #include #include -#include "Swiften/Base/String.h" +#include namespace Swift { @@ -34,11 +34,11 @@ static inline size_t sequenceLength(char firstByte) { return 1; } -std::vector String::getUnicodeCodePoints() const { +std::vector String::getUnicodeCodePoints(const std::string& s) { std::vector result; - for (size_t i = 0; i < data_.size();) { + for (size_t i = 0; i < s.size();) { unsigned int codePoint = 0; - char firstChar = data_[i]; + char firstChar = s[i]; size_t length = sequenceLength(firstChar); // First character is special @@ -49,7 +49,7 @@ std::vector String::getUnicodeCodePoints() const { codePoint = firstChar & ((1<<(firstCharBitSize+1)) - 1); for (size_t j = 1; j < length; ++j) { - codePoint = (codePoint<<6) | (data_[i+j] & 0x3F); + codePoint = (codePoint<<6) | (s[i+j] & 0x3F); } result.push_back(codePoint); i += length; @@ -58,37 +58,37 @@ std::vector String::getUnicodeCodePoints() const { } -std::pair String::getSplittedAtFirst(char c) const { +std::pair String::getSplittedAtFirst(const std::string& s, char c) { assert((c & 0x80) == 0); - size_t firstMatch = data_.find(c); - if (firstMatch != data_.npos) { - return std::make_pair(data_.substr(0,firstMatch),data_.substr(firstMatch+1,data_.npos)); + size_t firstMatch = s.find(c); + if (firstMatch != s.npos) { + return std::make_pair(s.substr(0,firstMatch),s.substr(firstMatch+1,s.npos)); } else { - return std::make_pair(*this, ""); + return std::make_pair(s, ""); } } -void String::replaceAll(char c, const String& s) { +void String::replaceAll(std::string& src, char c, const std::string& s) { size_t lastPos = 0; size_t matchingIndex = 0; - while ((matchingIndex = data_.find(c, lastPos)) != data_.npos) { - data_.replace(matchingIndex, 1, s.data_); - lastPos = matchingIndex + s.data_.size(); + while ((matchingIndex = src.find(c, lastPos)) != src.npos) { + src.replace(matchingIndex, 1, s); + lastPos = matchingIndex + s.size(); } } -std::vector String::split(char c) const { +std::vector String::split(const std::string& s, char c) { assert((c & 0x80) == 0); - std::vector result; - String accumulator; - for (size_t i = 0; i < data_.size(); ++i) { - if (data_[i] == c) { + std::vector result; + std::string accumulator; + for (size_t i = 0; i < s.size(); ++i) { + if (s[i] == c) { result.push_back(accumulator); accumulator = ""; } else { - accumulator += data_[i]; + accumulator += s[i]; } } result.push_back(accumulator); diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h index 7d2f928..192d53b 100644 --- a/Swiften/Base/String.h +++ b/Swiften/Base/String.h @@ -6,141 +6,24 @@ #pragma once -#include - -#include +#include #include -#include #include -#include -#include #define SWIFTEN_STRING_TO_CFSTRING(a) \ - CFStringCreateWithBytes(NULL, reinterpret_cast(a.getUTF8Data()), a.getUTF8Size(), kCFStringEncodingUTF8, false) + CFStringCreateWithBytes(NULL, reinterpret_cast(a.c_str()), a.size(), kCFStringEncodingUTF8, false) namespace Swift { - class ByteArray; - - class String { - friend class ByteArray; - - public: - String() {} - String(const char* data) : data_(data) {} - String(const char* data, size_t len) : data_(data, len) {} - String(const std::string& data) : data_(data) {} - - bool isEmpty() const { return data_.empty(); } - - const char* getUTF8Data() const { return data_.c_str(); } - const std::string& getUTF8String() const { return data_; } - std::string& getUTF8String() { return data_; } - size_t getUTF8Size() const { return data_.size(); } - std::vector getUnicodeCodePoints() const; - - void clear() { data_.clear(); } - - /** - * Returns the part before and after 'c'. - * If the given splitter does not occur in the string, the second - * component is the empty string. - */ - std::pair getSplittedAtFirst(char c) const; - - std::vector split(char c) const; - - String getLowerCase() const { - return boost::to_lower_copy(data_); - } - - void removeAll(char c) { - data_.erase(std::remove(data_.begin(), data_.end(), c), data_.end()); - } - - void replaceAll(char c, const String& s); - - bool beginsWith(char c) const { - return data_.size() > 0 && data_[0] == c; - } - - bool beginsWith(const String& s) const { - return boost::starts_with(data_, s.data_); - } - - bool endsWith(char c) const { - return data_.size() > 0 && data_[data_.size()-1] == c; - } - - bool endsWith(const String& s) const { - return boost::ends_with(data_, s.data_); - } - - String getSubstring(size_t begin, size_t end) const { - return String(data_.substr(begin, end)); - } - - size_t find(char c) const { - assert((c & 0x80) == 0); - return data_.find(c); - } - - size_t npos() const { - return data_.npos; - } - - friend String operator+(const String& a, const String& b) { - return String(a.data_ + b.data_); + namespace String { + std::vector getUnicodeCodePoints(const std::string&); + std::pair getSplittedAtFirst(const std::string&, char c); + std::vector split(const std::string&, char c); + void replaceAll(std::string&, char c, const std::string& s); + inline bool beginsWith(const std::string& s, char c) { + return s.size() > 0 && s[0] == c; } - - friend String operator+(const String& a, char b) { - return String(a.data_ + b); + inline bool endsWith(const std::string& s, char c) { + return s.size() > 0 && s[s.size()-1] == c; } - - String& operator+=(const String& o) { - data_ += o.data_; - return *this; - } - - String& operator+=(char c) { - data_ += c; - return *this; - } - - String& operator=(const String& o) { - data_ = o.data_; - return *this; - } - - bool contains(const String& o) { - return data_.find(o.data_) != std::string::npos; - } - - char operator[](size_t i) const { - return data_[i]; - } - - friend bool operator>(const String& a, const String& b) { - return a.data_ > b.data_; - } - - friend bool operator<(const String& a, const String& b) { - return a.data_ < b.data_; - } - - friend bool operator!=(const String& a, const String& b) { - return a.data_ != b.data_; - } - - friend bool operator==(const String& a, const String& b) { - return a.data_ == b.data_; - } - - friend std::ostream& operator<<(std::ostream& os, const String& s) { - os << s.data_; - return os; - } - - private: - std::string data_; }; } diff --git a/Swiften/Base/UnitTest/IDGeneratorTest.cpp b/Swiften/Base/UnitTest/IDGeneratorTest.cpp index 4a6b29c..4874684 100644 --- a/Swiften/Base/UnitTest/IDGeneratorTest.cpp +++ b/Swiften/Base/UnitTest/IDGeneratorTest.cpp @@ -28,13 +28,13 @@ class IDGeneratorTest : public CppUnit::TestFixture void testGenerate() { IDGenerator testling; for (unsigned int i = 0; i < 26*4; ++i) { - String id = testling.generateID(); + std::string id = testling.generateID(); CPPUNIT_ASSERT(generatedIDs_.insert(id).second); } } private: - std::set generatedIDs_; + std::set generatedIDs_; }; CPPUNIT_TEST_SUITE_REGISTRATION(IDGeneratorTest); diff --git a/Swiften/Base/UnitTest/StringTest.cpp b/Swiften/Base/UnitTest/StringTest.cpp index 161b4f1..884bbee 100644 --- a/Swiften/Base/UnitTest/StringTest.cpp +++ b/Swiften/Base/UnitTest/StringTest.cpp @@ -6,38 +6,29 @@ #include #include +#include -#include "Swiften/Base/String.h" +#include using namespace Swift; -class StringTest : public CppUnit::TestFixture -{ +class StringTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(StringTest); CPPUNIT_TEST(testGetUnicodeCodePoints); CPPUNIT_TEST(testGetSplittedAtFirst); CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtEnd); CPPUNIT_TEST(testGetSplittedAtFirst_NoSuchCharacter); - CPPUNIT_TEST(testRemoveAll); - CPPUNIT_TEST(testRemoveAll_LastChar); - CPPUNIT_TEST(testRemoveAll_ConsecutiveChars); CPPUNIT_TEST(testReplaceAll); CPPUNIT_TEST(testReplaceAll_LastChar); CPPUNIT_TEST(testReplaceAll_ConsecutiveChars); CPPUNIT_TEST(testReplaceAll_MatchingReplace); - CPPUNIT_TEST(testGetLowerCase); CPPUNIT_TEST(testSplit); - CPPUNIT_TEST(testContains); - CPPUNIT_TEST(testContainsFalse); - CPPUNIT_TEST(testContainsExact); - CPPUNIT_TEST(testEndsWith); - CPPUNIT_TEST(testEndsWith_DoesNotEndWith); CPPUNIT_TEST_SUITE_END(); public: void testGetUnicodeCodePoints() { - String testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d"); - std::vector points = testling.getUnicodeCodePoints(); + std::string testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d"); + std::vector points = String::getUnicodeCodePoints(testling); CPPUNIT_ASSERT_EQUAL(0x24U, points[0]); CPPUNIT_ASSERT_EQUAL(0xA2U, points[1]); @@ -46,120 +37,69 @@ class StringTest : public CppUnit::TestFixture } void testGetSplittedAtFirst() { - String testling("ab@cd@ef"); + std::string testling("ab@cd@ef"); - std::pair result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT_EQUAL(String("cd@ef"), result.second); + std::pair result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT_EQUAL(std::string("cd@ef"), result.second); } void testGetSplittedAtFirst_CharacterAtEnd() { - String testling("ab@"); + std::string testling("ab@"); - std::pair result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT(result.second.isEmpty()); + std::pair result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT(result.second.empty()); } void testGetSplittedAtFirst_NoSuchCharacter() { - String testling("ab"); + std::string testling("ab"); - std::pair result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT(result.second.isEmpty()); - } - - void testRemoveAll() { - String testling("ab c de"); - - testling.removeAll(' '); - - CPPUNIT_ASSERT_EQUAL(String("abcde"), testling); - } - - void testRemoveAll_LastChar() { - String testling("abcde "); - - testling.removeAll(' '); - - CPPUNIT_ASSERT_EQUAL(String("abcde"), testling); - } - - void testRemoveAll_ConsecutiveChars() { - String testling("ab cde"); - - testling.removeAll(' '); - - CPPUNIT_ASSERT_EQUAL(String("abcde"), testling); + std::pair result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT(result.second.empty()); } void testReplaceAll() { - String testling("abcbd"); + std::string testling("abcbd"); - testling.replaceAll('b', "xyz"); + String::replaceAll(testling, 'b', "xyz"); - CPPUNIT_ASSERT_EQUAL(String("axyzcxyzd"), testling); + CPPUNIT_ASSERT_EQUAL(std::string("axyzcxyzd"), testling); } void testReplaceAll_LastChar() { - String testling("abc"); + std::string testling("abc"); - testling.replaceAll('c', "xyz"); + String::replaceAll(testling, 'c', "xyz"); - CPPUNIT_ASSERT_EQUAL(String("abxyz"), testling); + CPPUNIT_ASSERT_EQUAL(std::string("abxyz"), testling); } void testReplaceAll_ConsecutiveChars() { - String testling("abbc"); + std::string testling("abbc"); - testling.replaceAll('b',"xyz"); + String::replaceAll(testling, 'b',"xyz"); - CPPUNIT_ASSERT_EQUAL(String("axyzxyzc"), testling); + CPPUNIT_ASSERT_EQUAL(std::string("axyzxyzc"), testling); } void testReplaceAll_MatchingReplace() { - String testling("abc"); + std::string testling("abc"); - testling.replaceAll('b',"bbb"); + String::replaceAll(testling, 'b',"bbb"); - CPPUNIT_ASSERT_EQUAL(String("abbbc"), testling); - } - - void testGetLowerCase() { - String testling("aBcD e"); - - CPPUNIT_ASSERT_EQUAL(String("abcd e"), testling.getLowerCase()); + CPPUNIT_ASSERT_EQUAL(std::string("abbbc"), testling); } void testSplit() { - std::vector result = String("abc def ghi").split(' '); + std::vector result = String::split("abc def ghi", ' '); CPPUNIT_ASSERT_EQUAL(3, static_cast(result.size())); - CPPUNIT_ASSERT_EQUAL(String("abc"), result[0]); - CPPUNIT_ASSERT_EQUAL(String("def"), result[1]); - CPPUNIT_ASSERT_EQUAL(String("ghi"), result[2]); - } - - void testContains() { - CPPUNIT_ASSERT(String("abcde").contains(String("bcd"))); + CPPUNIT_ASSERT_EQUAL(std::string("abc"), result[0]); + CPPUNIT_ASSERT_EQUAL(std::string("def"), result[1]); + CPPUNIT_ASSERT_EQUAL(std::string("ghi"), result[2]); } - - void testContainsFalse() { - CPPUNIT_ASSERT(!String("abcde").contains(String("abcdef"))); - } - - void testContainsExact() { - CPPUNIT_ASSERT(String("abcde").contains(String("abcde"))); - } - - void testEndsWith() { - CPPUNIT_ASSERT(String("abcdef").endsWith("cdef")); - } - - void testEndsWith_DoesNotEndWith() { - CPPUNIT_ASSERT(!String("abcdef").endsWith("ddef")); - } - }; CPPUNIT_TEST_SUITE_REGISTRATION(StringTest); diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp index 168c357..904f722 100644 --- a/Swiften/Client/Client.cpp +++ b/Swiften/Client/Client.cpp @@ -28,7 +28,7 @@ namespace Swift { -Client::Client(const JID& jid, const String& password, NetworkFactories* networkFactories, Storages* storages) : CoreClient(jid, password, networkFactories), storages(storages) { +Client::Client(const JID& jid, const std::string& password, NetworkFactories* networkFactories, Storages* storages) : CoreClient(jid, password, networkFactories), storages(storages) { memoryStorages = new MemoryStorages(); softwareVersionResponder = new SoftwareVersionResponder(getIQRouter()); @@ -93,7 +93,7 @@ XMPPRoster* Client::getRoster() const { return roster; } -void Client::setSoftwareVersion(const String& name, const String& version) { +void Client::setSoftwareVersion(const std::string& name, const std::string& version) { softwareVersionResponder->setVersion(name, version); } diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h index 4725d50..868c9c4 100644 --- a/Swiften/Client/Client.h +++ b/Swiften/Client/Client.h @@ -47,7 +47,7 @@ namespace Swift { * this is NULL, * all data will be stored in memory (and be lost on shutdown) */ - Client(const JID& jid, const String& password, NetworkFactories* networkFactories, Storages* storages = NULL); + Client(const JID& jid, const std::string& password, NetworkFactories* networkFactories, Storages* storages = NULL); ~Client(); @@ -56,7 +56,7 @@ namespace Swift { * * This will be used to respond to version queries from other entities. */ - void setSoftwareVersion(const String& name, const String& version); + void setSoftwareVersion(const std::string& name, const std::string& version); /** * Returns a representation of the roster. diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index 49334a3..98e3065 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -304,7 +304,7 @@ void ClientSession::continueSessionInitialization() { if (needResourceBind) { state = BindingResource; boost::shared_ptr resourceBind(new ResourceBind()); - if (!localJID.getResource().isEmpty()) { + if (!localJID.getResource().empty()) { resourceBind->setResource(localJID.getResource()); } sendStanza(IQ::createRequest(IQ::Set, JID(), "session-bind", resourceBind)); @@ -331,7 +331,7 @@ bool ClientSession::checkState(State state) { return true; } -void ClientSession::sendCredentials(const String& password) { +void ClientSession::sendCredentials(const std::string& password) { assert(WaitingForCredentials); state = Authenticating; authenticator->setCredentials(localJID.getNode(), password); diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index be0f89e..e15a707 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h @@ -12,7 +12,7 @@ #include "Swiften/Base/Error.h" #include "Swiften/Session/SessionStream.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swiften/Elements/Element.h" #include "Swiften/StreamManagement/StanzaAckRequester.h" @@ -86,7 +86,7 @@ namespace Swift { return getState() == Finished; } - void sendCredentials(const String& password); + void sendCredentials(const std::string& password); void sendStanza(boost::shared_ptr); void setCertificateTrustChecker(CertificateTrustChecker* checker) { diff --git a/Swiften/Client/ClientSessionStanzaChannel.cpp b/Swiften/Client/ClientSessionStanzaChannel.cpp index 996196b..6b32b3d 100644 --- a/Swiften/Client/ClientSessionStanzaChannel.cpp +++ b/Swiften/Client/ClientSessionStanzaChannel.cpp @@ -31,7 +31,7 @@ void ClientSessionStanzaChannel::sendPresence(boost::shared_ptr presen send(presence); } -String ClientSessionStanzaChannel::getNewIQID() { +std::string ClientSessionStanzaChannel::getNewIQID() { return idGenerator.generateID(); } diff --git a/Swiften/Client/ClientSessionStanzaChannel.h b/Swiften/Client/ClientSessionStanzaChannel.h index d3fd093..8a56301 100644 --- a/Swiften/Client/ClientSessionStanzaChannel.h +++ b/Swiften/Client/ClientSessionStanzaChannel.h @@ -33,7 +33,7 @@ namespace Swift { } private: - String getNewIQID(); + std::string getNewIQID(); void send(boost::shared_ptr stanza); void handleSessionFinished(boost::shared_ptr error); void handleStanza(boost::shared_ptr stanza); diff --git a/Swiften/Client/ClientXMLTracer.h b/Swiften/Client/ClientXMLTracer.h index 43fdda3..bca2a54 100644 --- a/Swiften/Client/ClientXMLTracer.h +++ b/Swiften/Client/ClientXMLTracer.h @@ -19,7 +19,7 @@ namespace Swift { } private: - static void printData(char direction, const String& data) { + static void printData(char direction, const std::string& data) { printLine(direction); std::cerr << data << std::endl; } diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index 2bd22c8..edb7643 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp @@ -22,7 +22,7 @@ namespace Swift { -CoreClient::CoreClient(const JID& jid, const String& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) { +CoreClient::CoreClient(const JID& jid, const std::string& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) { stanzaChannel_ = new ClientSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::bind(&CoreClient::handleMessageReceived, this, _1)); stanzaChannel_->onPresenceReceived.connect(boost::bind(&CoreClient::handlePresenceReceived, this, _1)); @@ -52,7 +52,7 @@ void CoreClient::connect() { connect(jid_.getDomain()); } -void CoreClient::connect(const String& host) { +void CoreClient::connect(const std::string& host) { SWIFT_LOG(debug) << "Connecting to host " << host << std::endl; disconnectRequested_ = false; assert(!connector_); @@ -74,7 +74,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr connectio assert(!sessionStream_); sessionStream_ = boost::shared_ptr(new BasicSessionStream(ClientStreamType, connection_, getPayloadParserFactories(), getPayloadSerializers(), tlsFactories->getTLSContextFactory(), networkFactories->getTimerFactory())); - if (!certificate_.isEmpty()) { + if (!certificate_.empty()) { sessionStream_->setTLSCertificate(PKCS12Certificate(certificate_, password_)); } sessionStream_->onDataRead.connect(boost::bind(&CoreClient::handleDataRead, this, _1)); @@ -101,7 +101,7 @@ void CoreClient::disconnect() { } } -void CoreClient::setCertificate(const String& certificate) { +void CoreClient::setCertificate(const std::string& certificate) { certificate_ = certificate; } @@ -219,11 +219,11 @@ void CoreClient::handleNeedCredentials() { session_->sendCredentials(password_); } -void CoreClient::handleDataRead(const String& data) { +void CoreClient::handleDataRead(const std::string& data) { onDataRead(data); } -void CoreClient::handleDataWritten(const String& data) { +void CoreClient::handleDataWritten(const std::string& data) { onDataWritten(data); } diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h index 5ecf2c9..92cd197 100644 --- a/Swiften/Client/CoreClient.h +++ b/Swiften/Client/CoreClient.h @@ -17,7 +17,7 @@ #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/Message.h" #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" #include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" @@ -52,10 +52,10 @@ namespace Swift { * Constructs a client for the given JID with the given password. * The given eventLoop will be used to post events to. */ - CoreClient(const JID& jid, const String& password, NetworkFactories* networkFactories); + CoreClient(const JID& jid, const std::string& password, NetworkFactories* networkFactories); ~CoreClient(); - void setCertificate(const String& certificate); + void setCertificate(const std::string& certificate); /** * Connects the client to the server. @@ -70,7 +70,7 @@ namespace Swift { */ void disconnect(); - void connect(const String& host); + void connect(const std::string& host); /** * Sends a message. @@ -164,7 +164,7 @@ namespace Swift { * This signal is emitted before the XML data is parsed, * so this data is unformatted. */ - boost::signal onDataRead; + boost::signal onDataRead; /** * Emitted when the client sends data. @@ -172,7 +172,7 @@ namespace Swift { * This signal is emitted after the XML was serialized, and * is unformatted. */ - boost::signal onDataWritten; + boost::signal onDataWritten; /** * Emitted when a message is received. @@ -197,15 +197,15 @@ namespace Swift { void handleStanzaChannelAvailableChanged(bool available); void handleSessionFinished(boost::shared_ptr); void handleNeedCredentials(); - void handleDataRead(const String&); - void handleDataWritten(const String&); + void handleDataRead(const std::string&); + void handleDataWritten(const std::string&); void handlePresenceReceived(Presence::ref); void handleMessageReceived(Message::ref); void handleStanzaAcked(Stanza::ref); private: JID jid_; - String password_; + std::string password_; NetworkFactories* networkFactories; ClientSessionStanzaChannel* stanzaChannel_; IQRouter* iqRouter_; @@ -214,7 +214,7 @@ namespace Swift { boost::shared_ptr connection_; boost::shared_ptr sessionStream_; boost::shared_ptr session_; - String certificate_; + std::string certificate_; bool disconnectRequested_; CertificateTrustChecker* certificateTrustChecker; }; diff --git a/Swiften/Client/DummyNickManager.h b/Swiften/Client/DummyNickManager.h index b746f88..0e3ff50 100644 --- a/Swiften/Client/DummyNickManager.h +++ b/Swiften/Client/DummyNickManager.h @@ -13,11 +13,11 @@ namespace Swift { class DummyNickManager : public NickManager { public: - String getOwnNick() const { + std::string getOwnNick() const { return ""; } - void setOwnNick(const String&) { + void setOwnNick(const std::string&) { } }; } diff --git a/Swiften/Client/DummyStanzaChannel.h b/Swiften/Client/DummyStanzaChannel.h index 5784788..b9f05c3 100644 --- a/Swiften/Client/DummyStanzaChannel.h +++ b/Swiften/Client/DummyStanzaChannel.h @@ -36,7 +36,7 @@ namespace Swift { sentStanzas.push_back(presence); } - virtual String getNewIQID() { + virtual std::string getNewIQID() { return "test-id"; } diff --git a/Swiften/Client/FileStorages.cpp b/Swiften/Client/FileStorages.cpp index 9f2dda0..ad8b130 100644 --- a/Swiften/Client/FileStorages.cpp +++ b/Swiften/Client/FileStorages.cpp @@ -12,8 +12,8 @@ namespace Swift { FileStorages::FileStorages(const boost::filesystem::path& baseDir, const JID& jid) { - String profile = jid.toBare(); - vcardStorage = new VCardFileStorage(baseDir / profile.getUTF8String() / "vcards"); + std::string profile = jid.toBare(); + vcardStorage = new VCardFileStorage(baseDir / profile / "vcards"); capsStorage = new CapsFileStorage(baseDir / "caps"); avatarStorage = new AvatarFileStorage(baseDir / "avatars"); } diff --git a/Swiften/Client/NickManager.h b/Swiften/Client/NickManager.h index e918b07..288aa7b 100644 --- a/Swiften/Client/NickManager.h +++ b/Swiften/Client/NickManager.h @@ -7,16 +7,16 @@ #pragma once #include -#include +#include namespace Swift { class NickManager { public: virtual ~NickManager(); - virtual String getOwnNick() const = 0; - virtual void setOwnNick(const String& nick) = 0; + virtual std::string getOwnNick() const = 0; + virtual void setOwnNick(const std::string& nick) = 0; - boost::signal onOwnNickChanged; + boost::signal onOwnNickChanged; }; } diff --git a/Swiften/Client/NickManagerImpl.cpp b/Swiften/Client/NickManagerImpl.cpp index fd37222..b9ebcde 100644 --- a/Swiften/Client/NickManagerImpl.cpp +++ b/Swiften/Client/NickManagerImpl.cpp @@ -22,11 +22,11 @@ NickManagerImpl::~NickManagerImpl() { vcardManager->onVCardChanged.disconnect(boost::bind(&NickManagerImpl::handleVCardReceived, this, _1, _2)); } -String NickManagerImpl::getOwnNick() const { +std::string NickManagerImpl::getOwnNick() const { return ownNick; } -void NickManagerImpl::setOwnNick(const String&) { +void NickManagerImpl::setOwnNick(const std::string&) { } void NickManagerImpl::handleVCardReceived(const JID& jid, VCard::ref vcard) { @@ -37,8 +37,8 @@ void NickManagerImpl::handleVCardReceived(const JID& jid, VCard::ref vcard) { } void NickManagerImpl::updateOwnNickFromVCard(VCard::ref vcard) { - String nick; - if (vcard && !vcard->getNickname().isEmpty()) { + std::string nick; + if (vcard && !vcard->getNickname().empty()) { nick = vcard->getNickname(); } if (ownNick != nick) { diff --git a/Swiften/Client/NickManagerImpl.h b/Swiften/Client/NickManagerImpl.h index 8796dbe..d732987 100644 --- a/Swiften/Client/NickManagerImpl.h +++ b/Swiften/Client/NickManagerImpl.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace Swift { class VCardManager; @@ -19,8 +19,8 @@ namespace Swift { NickManagerImpl(const JID& ownJID, VCardManager* vcardManager); ~NickManagerImpl(); - String getOwnNick() const; - void setOwnNick(const String& nick); + std::string getOwnNick() const; + void setOwnNick(const std::string& nick); private: void handleVCardReceived(const JID& jid, VCard::ref vCard); @@ -29,6 +29,6 @@ namespace Swift { private: JID ownJID; VCardManager* vcardManager; - String ownNick; + std::string ownNick; }; } diff --git a/Swiften/Client/NickResolver.cpp b/Swiften/Client/NickResolver.cpp index 3e1ae8e..6d5e742 100644 --- a/Swiften/Client/NickResolver.cpp +++ b/Swiften/Client/NickResolver.cpp @@ -31,28 +31,28 @@ NickResolver::NickResolver(const JID& ownJID, XMPPRoster* xmppRoster, VCardManag xmppRoster_->onJIDAdded.connect(boost::bind(&NickResolver::handleJIDAdded, this, _1)); } -void NickResolver::handleJIDUpdated(const JID& jid, const String& previousNick, const std::vector& /*groups*/) { +void NickResolver::handleJIDUpdated(const JID& jid, const std::string& previousNick, const std::vector& /*groups*/) { onNickChanged(jid, previousNick); } void NickResolver::handleJIDAdded(const JID& jid) { - String oldNick(jidToNick(jid)); + std::string oldNick(jidToNick(jid)); onNickChanged(jid, oldNick); } -String NickResolver::jidToNick(const JID& jid) { +std::string NickResolver::jidToNick(const JID& jid) { if (jid.toBare() == ownJID_) { - if (!ownNick_.isEmpty()) { + if (!ownNick_.empty()) { return ownNick_; } } - String nick; + std::string nick; if (mucRegistry_ && mucRegistry_->isMUC(jid.toBare()) ) { - return jid.getResource().isEmpty() ? jid.toBare().toString() : jid.getResource(); + return jid.getResource().empty() ? jid.toBare().toString() : jid.getResource(); } - if (xmppRoster_->containsJID(jid) && !xmppRoster_->getNameForJID(jid).isEmpty()) { + if (xmppRoster_->containsJID(jid) && !xmppRoster_->getNameForJID(jid).empty()) { return xmppRoster_->getNameForJID(jid); } @@ -63,14 +63,14 @@ void NickResolver::handleVCardReceived(const JID& jid, VCard::ref ownVCard) { if (!jid.equals(ownJID_, JID::WithoutResource)) { return; } - String initialNick = ownNick_; + std::string initialNick = ownNick_; ownNick_ = ownJID_.toString(); if (ownVCard) { - if (!ownVCard->getNickname().isEmpty()) { + if (!ownVCard->getNickname().empty()) { ownNick_ = ownVCard->getNickname(); - } else if (!ownVCard->getGivenName().isEmpty()) { + } else if (!ownVCard->getGivenName().empty()) { ownNick_ = ownVCard->getGivenName(); - } else if (!ownVCard->getFullName().isEmpty()) { + } else if (!ownVCard->getFullName().empty()) { ownNick_ = ownVCard->getFullName(); } } diff --git a/Swiften/Client/NickResolver.h b/Swiften/Client/NickResolver.h index 697409f..881362a 100644 --- a/Swiften/Client/NickResolver.h +++ b/Swiften/Client/NickResolver.h @@ -8,7 +8,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swiften/Elements/VCard.h" @@ -20,18 +20,18 @@ namespace Swift { public: NickResolver(const JID& ownJID, XMPPRoster* xmppRoster, VCardManager* vcardManager, MUCRegistry* mucRegistry); - String jidToNick(const JID& jid); + std::string jidToNick(const JID& jid); - boost::signal onNickChanged; + boost::signal onNickChanged; private: void handleVCardReceived(const JID& jid, VCard::ref vCard); - void handleJIDUpdated(const JID& jid, const String& previousNick, const std::vector& groups); + void handleJIDUpdated(const JID& jid, const std::string& previousNick, const std::vector& groups); void handleJIDAdded(const JID& jid); private: JID ownJID_; - String ownNick_; + std::string ownNick_; XMPPRoster* xmppRoster_; MUCRegistry* mucRegistry_; VCardManager* vcardManager_; diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp index af8a4c3..21c0ffb 100644 --- a/Swiften/Client/UnitTest/ClientSessionTest.cpp +++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp @@ -455,7 +455,7 @@ class ClientSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(boost::dynamic_pointer_cast(event.element)); } - void receiveAuthRequest(const String& mech) { + void receiveAuthRequest(const std::string& mech) { Event event = popEvent(); CPPUNIT_ASSERT(event.element); boost::shared_ptr request(boost::dynamic_pointer_cast(event.element)); @@ -490,7 +490,7 @@ class ClientSessionTest : public CppUnit::TestFixture { bool tlsEncrypted; bool compressed; bool whitespacePingEnabled; - String bindID; + std::string bindID; int resetCount; std::deque receivedEvents; }; diff --git a/Swiften/Client/UnitTest/NickResolverTest.cpp b/Swiften/Client/UnitTest/NickResolverTest.cpp index 0c5c91b..bd778d4 100644 --- a/Swiften/Client/UnitTest/NickResolverTest.cpp +++ b/Swiften/Client/UnitTest/NickResolverTest.cpp @@ -58,34 +58,34 @@ class NickResolverTest : public CppUnit::TestFixture { registry_->addMUC(JID("foo@bar")); JID testJID("foo@bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("baz"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("baz"), resolver_->jidToNick(testJID)); } void testMUCNoNick() { registry_->addMUC(JID("foo@bar")); JID testJID("foo@bar"); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testNoMatch() { JID testJID("foo@bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testZeroLengthMatch() { JID testJID("foo@bar/baz"); xmppRoster_->addContact(testJID, "", groups_, RosterItemPayload::Both); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testMatch() { JID testJID("foo@bar/baz"); xmppRoster_->addContact(testJID, "Test", groups_, RosterItemPayload::Both); - CPPUNIT_ASSERT_EQUAL(String("Test"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("Test"), resolver_->jidToNick(testJID)); } void testOverwrittenMatch() { @@ -93,40 +93,40 @@ class NickResolverTest : public CppUnit::TestFixture { xmppRoster_->addContact(testJID, "FailTest", groups_, RosterItemPayload::Both); xmppRoster_->addContact(testJID, "Test", groups_, RosterItemPayload::Both); - CPPUNIT_ASSERT_EQUAL(String("Test"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("Test"), resolver_->jidToNick(testJID)); } void testRemovedMatch() { JID testJID("foo@bar/baz"); xmppRoster_->addContact(testJID, "FailTest", groups_, RosterItemPayload::Both); xmppRoster_->removeContact(testJID); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testOwnNickFullOnly() { populateOwnVCard("", "", "Kevin Smith"); - CPPUNIT_ASSERT_EQUAL(String("Kevin Smith"), resolver_->jidToNick(ownJID_)); + CPPUNIT_ASSERT_EQUAL(std::string("Kevin Smith"), resolver_->jidToNick(ownJID_)); } void testOwnNickGivenAndFull() { populateOwnVCard("", "Kevin", "Kevin Smith"); - CPPUNIT_ASSERT_EQUAL(String("Kevin"), resolver_->jidToNick(ownJID_)); + CPPUNIT_ASSERT_EQUAL(std::string("Kevin"), resolver_->jidToNick(ownJID_)); } void testOwnNickNickEtAl() { populateOwnVCard("Kev", "Kevin", "Kevin Smith"); - CPPUNIT_ASSERT_EQUAL(String("Kev"), resolver_->jidToNick(ownJID_)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev"), resolver_->jidToNick(ownJID_)); } - void populateOwnVCard(const String& nick, const String& given, const String& full) { + void populateOwnVCard(const std::string& nick, const std::string& given, const std::string& full) { VCard::ref vcard(new VCard()); - if (!nick.isEmpty()) { + if (!nick.empty()) { vcard->setNickname(nick); } - if (!given.isEmpty()) { + if (!given.empty()) { vcard->setGivenName(given); } - if (!full.isEmpty()) { + if (!full.empty()) { vcard->setFullName(full); } vCardManager_->requestVCard(ownJID_); @@ -135,7 +135,7 @@ class NickResolverTest : public CppUnit::TestFixture { } private: - std::vector groups_; + std::vector groups_; XMPPRosterImpl* xmppRoster_; VCardStorage* vCardStorage_; IQRouter* iqRouter_; diff --git a/Swiften/Component/Component.cpp b/Swiften/Component/Component.cpp index f3e2b81..fb4ba4c 100644 --- a/Swiften/Component/Component.cpp +++ b/Swiften/Component/Component.cpp @@ -10,7 +10,7 @@ namespace Swift { -Component::Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret) : CoreComponent(eventLoop, networkFactories, jid, secret) { +Component::Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret) : CoreComponent(eventLoop, networkFactories, jid, secret) { softwareVersionResponder = new SoftwareVersionResponder(getIQRouter()); softwareVersionResponder->start(); } @@ -20,7 +20,7 @@ Component::~Component() { delete softwareVersionResponder; } -void Component::setSoftwareVersion(const String& name, const String& version) { +void Component::setSoftwareVersion(const std::string& name, const std::string& version) { softwareVersionResponder->setVersion(name, version); } diff --git a/Swiften/Component/Component.h b/Swiften/Component/Component.h index 1a04272..0119db0 100644 --- a/Swiften/Component/Component.h +++ b/Swiften/Component/Component.h @@ -19,7 +19,7 @@ namespace Swift { */ class Component : public CoreComponent { public: - Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret); + Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret); ~Component(); /** @@ -27,7 +27,7 @@ namespace Swift { * * This will be used to respond to version queries from other entities. */ - void setSoftwareVersion(const String& name, const String& version); + void setSoftwareVersion(const std::string& name, const std::string& version); private: SoftwareVersionResponder* softwareVersionResponder; diff --git a/Swiften/Component/ComponentConnector.cpp b/Swiften/Component/ComponentConnector.cpp index e764138..2af45f6 100644 --- a/Swiften/Component/ComponentConnector.cpp +++ b/Swiften/Component/ComponentConnector.cpp @@ -16,7 +16,7 @@ namespace Swift { -ComponentConnector::ComponentConnector(const String& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0) { +ComponentConnector::ComponentConnector(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0) { } void ComponentConnector::setTimeoutMilliseconds(int milliseconds) { diff --git a/Swiften/Component/ComponentConnector.h b/Swiften/Component/ComponentConnector.h index a84d8ba..c5e8f80 100644 --- a/Swiften/Component/ComponentConnector.h +++ b/Swiften/Component/ComponentConnector.h @@ -13,7 +13,7 @@ #include "Swiften/Network/Connection.h" #include "Swiften/Network/Timer.h" #include "Swiften/Network/HostAddressPort.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Network/DomainNameResolveError.h" namespace Swift { @@ -26,7 +26,7 @@ namespace Swift { public: typedef boost::shared_ptr ref; - static ComponentConnector::ref create(const String& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { + static ComponentConnector::ref create(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { return ComponentConnector::ref(new ComponentConnector(hostname, port, resolver, connectionFactory, timerFactory)); } @@ -38,7 +38,7 @@ namespace Swift { boost::signal)> onConnectFinished; private: - ComponentConnector(const String& hostname, int port, DomainNameResolver*, ConnectionFactory*, TimerFactory*); + ComponentConnector(const std::string& hostname, int port, DomainNameResolver*, ConnectionFactory*, TimerFactory*); void handleAddressQueryResult(const std::vector& address, boost::optional error); void tryNextAddress(); @@ -50,7 +50,7 @@ namespace Swift { private: - String hostname; + std::string hostname; int port; DomainNameResolver* resolver; ConnectionFactory* connectionFactory; diff --git a/Swiften/Component/ComponentHandshakeGenerator.cpp b/Swiften/Component/ComponentHandshakeGenerator.cpp index 422f986..4081420 100644 --- a/Swiften/Component/ComponentHandshakeGenerator.cpp +++ b/Swiften/Component/ComponentHandshakeGenerator.cpp @@ -7,16 +7,17 @@ #include "Swiften/Component/ComponentHandshakeGenerator.h" #include "Swiften/StringCodecs/Hexify.h" #include "Swiften/StringCodecs/SHA1.h" +#include namespace Swift { -String ComponentHandshakeGenerator::getHandshake(const String& streamID, const String& secret) { - String concatenatedString = streamID + secret; - concatenatedString.replaceAll('&', "&"); - concatenatedString.replaceAll('<', "<"); - concatenatedString.replaceAll('>', ">"); - concatenatedString.replaceAll('\'', "'"); - concatenatedString.replaceAll('"', """); +std::string ComponentHandshakeGenerator::getHandshake(const std::string& streamID, const std::string& secret) { + std::string concatenatedString = streamID + secret; + String::replaceAll(concatenatedString, '&', "&"); + String::replaceAll(concatenatedString, '<', "<"); + String::replaceAll(concatenatedString, '>', ">"); + String::replaceAll(concatenatedString, '\'', "'"); + String::replaceAll(concatenatedString, '"', """); return Hexify::hexify(SHA1::getHash(ByteArray(concatenatedString))); } diff --git a/Swiften/Component/ComponentHandshakeGenerator.h b/Swiften/Component/ComponentHandshakeGenerator.h index d71a664..4181d3c 100644 --- a/Swiften/Component/ComponentHandshakeGenerator.h +++ b/Swiften/Component/ComponentHandshakeGenerator.h @@ -6,12 +6,12 @@ #pragma once -#include "Swiften/Base/String.h" +#include namespace Swift { class ComponentHandshakeGenerator { public: - static String getHandshake(const String& streamID, const String& secret); + static std::string getHandshake(const std::string& streamID, const std::string& secret); }; } diff --git a/Swiften/Component/ComponentSession.cpp b/Swiften/Component/ComponentSession.cpp index c45f663..17e0dfd 100644 --- a/Swiften/Component/ComponentSession.cpp +++ b/Swiften/Component/ComponentSession.cpp @@ -15,7 +15,7 @@ namespace Swift { -ComponentSession::ComponentSession(const JID& jid, const String& secret, boost::shared_ptr stream) : jid(jid), secret(secret), stream(stream), state(Initial) { +ComponentSession::ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr stream) : jid(jid), secret(secret), stream(stream), state(Initial) { } ComponentSession::~ComponentSession() { diff --git a/Swiften/Component/ComponentSession.h b/Swiften/Component/ComponentSession.h index dbe6e27..168e618 100644 --- a/Swiften/Component/ComponentSession.h +++ b/Swiften/Component/ComponentSession.h @@ -12,7 +12,7 @@ #include "Swiften/JID/JID.h" #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Base/Error.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Element.h" #include "Swiften/Elements/Stanza.h" #include "Swiften/Session/SessionStream.h" @@ -41,7 +41,7 @@ namespace Swift { ~ComponentSession(); - static boost::shared_ptr create(const JID& jid, const String& secret, boost::shared_ptr stream) { + static boost::shared_ptr create(const JID& jid, const std::string& secret, boost::shared_ptr stream) { return boost::shared_ptr(new ComponentSession(jid, secret, stream)); } @@ -60,7 +60,7 @@ namespace Swift { boost::signal)> onStanzaReceived; private: - ComponentSession(const JID& jid, const String& secret, boost::shared_ptr); + ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr); void finishSession(Error::Type error); void finishSession(boost::shared_ptr error); @@ -75,7 +75,7 @@ namespace Swift { private: JID jid; - String secret; + std::string secret; boost::shared_ptr stream; boost::shared_ptr error; State state; diff --git a/Swiften/Component/ComponentSessionStanzaChannel.cpp b/Swiften/Component/ComponentSessionStanzaChannel.cpp index 9f4dc2e..b9fecb2 100644 --- a/Swiften/Component/ComponentSessionStanzaChannel.cpp +++ b/Swiften/Component/ComponentSessionStanzaChannel.cpp @@ -30,7 +30,7 @@ void ComponentSessionStanzaChannel::sendPresence(boost::shared_ptr pre send(presence); } -String ComponentSessionStanzaChannel::getNewIQID() { +std::string ComponentSessionStanzaChannel::getNewIQID() { return idGenerator.generateID(); } diff --git a/Swiften/Component/ComponentSessionStanzaChannel.h b/Swiften/Component/ComponentSessionStanzaChannel.h index 856031f..605c8dc 100644 --- a/Swiften/Component/ComponentSessionStanzaChannel.h +++ b/Swiften/Component/ComponentSessionStanzaChannel.h @@ -36,7 +36,7 @@ namespace Swift { } private: - String getNewIQID(); + std::string getNewIQID(); void send(boost::shared_ptr stanza); void handleSessionFinished(boost::shared_ptr error); void handleStanza(boost::shared_ptr stanza); diff --git a/Swiften/Component/ComponentXMLTracer.h b/Swiften/Component/ComponentXMLTracer.h index 512e69c..70a617b 100644 --- a/Swiften/Component/ComponentXMLTracer.h +++ b/Swiften/Component/ComponentXMLTracer.h @@ -19,7 +19,7 @@ namespace Swift { } private: - static void printData(char direction, const String& data) { + static void printData(char direction, const std::string& data) { printLine(direction); std::cerr << data << std::endl; } diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp index eabe62d..e79d735 100644 --- a/Swiften/Component/CoreComponent.cpp +++ b/Swiften/Component/CoreComponent.cpp @@ -19,7 +19,7 @@ namespace Swift { -CoreComponent::CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret) : eventLoop(eventLoop), networkFactories(networkFactories), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { +CoreComponent::CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret) : eventLoop(eventLoop), networkFactories(networkFactories), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { stanzaChannel_ = new ComponentSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::ref(onMessageReceived)); stanzaChannel_->onPresenceReceived.connect(boost::ref(onPresenceReceived)); @@ -41,7 +41,7 @@ CoreComponent::~CoreComponent() { delete stanzaChannel_; } -void CoreComponent::connect(const String& host, int port) { +void CoreComponent::connect(const std::string& host, int port) { assert(!connector_); connector_ = ComponentConnector::create(host, port, &resolver_, networkFactories->getConnectionFactory(), networkFactories->getTimerFactory()); connector_->onConnectFinished.connect(boost::bind(&CoreComponent::handleConnectorFinished, this, _1)); @@ -138,11 +138,11 @@ void CoreComponent::handleSessionFinished(boost::shared_ptr error) { } } -void CoreComponent::handleDataRead(const String& data) { +void CoreComponent::handleDataRead(const std::string& data) { onDataRead(data); } -void CoreComponent::handleDataWritten(const String& data) { +void CoreComponent::handleDataWritten(const std::string& data) { onDataWritten(data); } diff --git a/Swiften/Component/CoreComponent.h b/Swiften/Component/CoreComponent.h index 8ebf80f..64c9071 100644 --- a/Swiften/Component/CoreComponent.h +++ b/Swiften/Component/CoreComponent.h @@ -17,7 +17,7 @@ #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/Message.h" #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" #include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" #include "Swiften/Component/ComponentSessionStanzaChannel.h" @@ -41,10 +41,10 @@ namespace Swift { */ class CoreComponent : public Entity { public: - CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret); + CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret); ~CoreComponent(); - void connect(const String& host, int port); + void connect(const std::string& host, int port); void disconnect(); void sendMessage(boost::shared_ptr); @@ -72,8 +72,8 @@ namespace Swift { public: boost::signal onError; boost::signal onConnected; - boost::signal onDataRead; - boost::signal onDataWritten; + boost::signal onDataRead; + boost::signal onDataWritten; boost::signal)> onMessageReceived; boost::signal) > onPresenceReceived; @@ -82,15 +82,15 @@ namespace Swift { void handleConnectorFinished(boost::shared_ptr); void handleStanzaChannelAvailableChanged(bool available); void handleSessionFinished(boost::shared_ptr); - void handleDataRead(const String&); - void handleDataWritten(const String&); + void handleDataRead(const std::string&); + void handleDataWritten(const std::string&); private: EventLoop* eventLoop; NetworkFactories* networkFactories; PlatformDomainNameResolver resolver_; JID jid_; - String secret_; + std::string secret_; ComponentSessionStanzaChannel* stanzaChannel_; IQRouter* iqRouter_; ComponentConnector::ref connector_; diff --git a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp index bfa2cb2..052b5de 100644 --- a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp +++ b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp @@ -146,7 +146,7 @@ class ComponentConnectorTest : public CppUnit::TestFixture { } private: - ComponentConnector::ref createConnector(const String& hostname, int port) { + ComponentConnector::ref createConnector(const std::string& hostname, int port) { ComponentConnector::ref connector = ComponentConnector::create(hostname, port, resolver, connectionFactory, timerFactory); connector->onConnectFinished.connect(boost::bind(&ComponentConnectorTest::handleConnectorFinished, this, _1)); return connector; diff --git a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp index e72dbea..5366478 100644 --- a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp +++ b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp @@ -19,13 +19,13 @@ class ComponentHandshakeGeneratorTest : public CppUnit::TestFixture { public: void testGetHandshake() { - String result = ComponentHandshakeGenerator::getHandshake("myid", "mysecret"); - CPPUNIT_ASSERT_EQUAL(String("4011cd31f9b99ac089a0cd7ce297da7323fa2525"), result); + std::string result = ComponentHandshakeGenerator::getHandshake("myid", "mysecret"); + CPPUNIT_ASSERT_EQUAL(std::string("4011cd31f9b99ac089a0cd7ce297da7323fa2525"), result); } void testGetHandshake_SpecialChars() { - String result = ComponentHandshakeGenerator::getHandshake("&<", ">'\""); - CPPUNIT_ASSERT_EQUAL(String("33631b3e0aaeb2a11c4994c917919324028873fe"), result); + std::string result = ComponentHandshakeGenerator::getHandshake("&<", ">'\""); + CPPUNIT_ASSERT_EQUAL(std::string("33631b3e0aaeb2a11c4994c917919324028873fe"), result); } }; diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp index 86776e8..af8962a 100644 --- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp +++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp @@ -180,7 +180,7 @@ class ComponentSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(event.element); ComponentHandshake::ref handshake(boost::dynamic_pointer_cast(event.element)); CPPUNIT_ASSERT(handshake); - CPPUNIT_ASSERT_EQUAL(String("4c4f8a41141722c8bbfbdd92d827f7b2fc0a542b"), handshake->getData()); + CPPUNIT_ASSERT_EQUAL(std::string("4c4f8a41141722c8bbfbdd92d827f7b2fc0a542b"), handshake->getData()); } Event popEvent() { @@ -192,7 +192,7 @@ class ComponentSessionTest : public CppUnit::TestFixture { bool available; bool whitespacePingEnabled; - String bindID; + std::string bindID; int resetCount; std::deque receivedEvents; }; diff --git a/Swiften/Config/swiften-config.cpp b/Swiften/Config/swiften-config.cpp index 4f4016e..d381faa 100644 --- a/Swiften/Config/swiften-config.cpp +++ b/Swiften/Config/swiften-config.cpp @@ -10,17 +10,18 @@ #include #include #include +#include -#include #include #include #include +#include #include "swiften-config.h" using namespace Swift; -void printFlags(const std::vector& flags) { +void printFlags(const std::vector& flags) { for (size_t i = 0; i < flags.size(); ++i) { if (i > 0) { std::cout << " "; @@ -60,11 +61,11 @@ int main(int argc, char* argv[]) { } // Read in all variables - std::vector libs; + std::vector libs; for (size_t i = 0; LIBFLAGS[i]; ++i) { libs.push_back(LIBFLAGS[i]); } - std::vector cflags; + std::vector cflags; for (size_t i = 0; CPPFLAGS[i]; ++i) { cflags.push_back(CPPFLAGS[i]); } @@ -77,8 +78,8 @@ int main(int argc, char* argv[]) { // Replace "#" variables with the correct path for(size_t i = 0; i < libs.size(); ++i) { if (inPlace) { - String lib = libs[i]; - lib.replaceAll('#', topPath.string()); + std::string lib = libs[i]; + String::replaceAll(lib, '#', topPath.string()); libs[i] = lib; } else { @@ -87,8 +88,8 @@ int main(int argc, char* argv[]) { } for(size_t i = 0; i < cflags.size(); ++i) { if (inPlace) { - String cflag = cflags[i]; - cflag.replaceAll('#', topPath.string()); + std::string cflag = cflags[i]; + String::replaceAll(cflag, '#', topPath.string()); cflags[i] = cflag; } else { diff --git a/Swiften/Disco/CapsFileStorage.cpp b/Swiften/Disco/CapsFileStorage.cpp index 107cf28..2334acf 100644 --- a/Swiften/Disco/CapsFileStorage.cpp +++ b/Swiften/Disco/CapsFileStorage.cpp @@ -21,7 +21,7 @@ namespace Swift { CapsFileStorage::CapsFileStorage(const boost::filesystem::path& path) : path(path) { } -DiscoInfo::ref CapsFileStorage::getDiscoInfo(const String& hash) const { +DiscoInfo::ref CapsFileStorage::getDiscoInfo(const std::string& hash) const { boost::filesystem::path capsPath(getCapsPath(hash)); if (boost::filesystem::exists(capsPath)) { ByteArray data; @@ -29,7 +29,7 @@ DiscoInfo::ref CapsFileStorage::getDiscoInfo(const String& hash) const { DiscoInfoParser parser; PayloadParserTester tester(&parser); - tester.parse(String(data.getData(), data.getSize())); + tester.parse(std::string(data.getData(), data.getSize())); return boost::dynamic_pointer_cast(parser.getPayload()); } else { @@ -37,7 +37,7 @@ DiscoInfo::ref CapsFileStorage::getDiscoInfo(const String& hash) const { } } -void CapsFileStorage::setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo) { +void CapsFileStorage::setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo) { boost::filesystem::path capsPath(getCapsPath(hash)); if (!boost::filesystem::exists(capsPath.parent_path())) { try { @@ -54,8 +54,8 @@ void CapsFileStorage::setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo) file.close(); } -boost::filesystem::path CapsFileStorage::getCapsPath(const String& hash) const { - return path / (Hexify::hexify(Base64::decode(hash)) + ".xml").getUTF8String(); +boost::filesystem::path CapsFileStorage::getCapsPath(const std::string& hash) const { + return path / (Hexify::hexify(Base64::decode(hash)) + ".xml"); } } diff --git a/Swiften/Disco/CapsFileStorage.h b/Swiften/Disco/CapsFileStorage.h index ea1b1a2..5faf08b 100644 --- a/Swiften/Disco/CapsFileStorage.h +++ b/Swiften/Disco/CapsFileStorage.h @@ -9,18 +9,18 @@ #include #include "Swiften/Disco/CapsStorage.h" -#include "Swiften/Base/String.h" +#include namespace Swift { class CapsFileStorage : public CapsStorage { public: CapsFileStorage(const boost::filesystem::path& path); - virtual DiscoInfo::ref getDiscoInfo(const String& hash) const; - virtual void setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo); + virtual DiscoInfo::ref getDiscoInfo(const std::string& hash) const; + virtual void setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo); private: - boost::filesystem::path getCapsPath(const String& hash) const; + boost::filesystem::path getCapsPath(const std::string& hash) const; private: boost::filesystem::path path; diff --git a/Swiften/Disco/CapsInfoGenerator.cpp b/Swiften/Disco/CapsInfoGenerator.cpp index 94f2a7a..5c0e9a7 100644 --- a/Swiften/Disco/CapsInfoGenerator.cpp +++ b/Swiften/Disco/CapsInfoGenerator.cpp @@ -22,11 +22,11 @@ namespace { namespace Swift { -CapsInfoGenerator::CapsInfoGenerator(const String& node) : node_(node) { +CapsInfoGenerator::CapsInfoGenerator(const std::string& node) : node_(node) { } CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const { - String serializedCaps; + std::string serializedCaps; std::vector identities(discoInfo.getIdentities()); std::sort(identities.begin(), identities.end()); @@ -34,9 +34,9 @@ CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const { serializedCaps += identity.getCategory() + "/" + identity.getType() + "/" + identity.getLanguage() + "/" + identity.getName() + "<"; } - std::vector features(discoInfo.getFeatures()); + std::vector features(discoInfo.getFeatures()); std::sort(features.begin(), features.end()); - foreach (const String& feature, features) { + foreach (const std::string& feature, features) { serializedCaps += feature + "<"; } @@ -49,15 +49,15 @@ CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const { continue; } serializedCaps += field->getName() + "<"; - std::vector values(field->getRawValues()); + std::vector values(field->getRawValues()); std::sort(values.begin(), values.end()); - foreach(const String& value, values) { + foreach(const std::string& value, values) { serializedCaps += value + "<"; } } } - String version(Base64::encode(SHA1::getHash(serializedCaps))); + std::string version(Base64::encode(SHA1::getHash(serializedCaps))); return CapsInfo(node_, version, "sha-1"); } diff --git a/Swiften/Disco/CapsInfoGenerator.h b/Swiften/Disco/CapsInfoGenerator.h index cc32bbd..41a1d94 100644 --- a/Swiften/Disco/CapsInfoGenerator.h +++ b/Swiften/Disco/CapsInfoGenerator.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/CapsInfo.h" namespace Swift { @@ -14,11 +14,11 @@ namespace Swift { class CapsInfoGenerator { public: - CapsInfoGenerator(const String& node); + CapsInfoGenerator(const std::string& node); CapsInfo generateCapsInfo(const DiscoInfo& discoInfo) const; private: - String node_; + std::string node_; }; } diff --git a/Swiften/Disco/CapsManager.cpp b/Swiften/Disco/CapsManager.cpp index 1c785e5..63166e6 100644 --- a/Swiften/Disco/CapsManager.cpp +++ b/Swiften/Disco/CapsManager.cpp @@ -26,7 +26,7 @@ void CapsManager::handlePresenceReceived(boost::shared_ptr presence) { if (!capsInfo || capsInfo->getHash() != "sha-1" || presence->getPayload()) { return; } - String hash = capsInfo->getVersion(); + std::string hash = capsInfo->getVersion(); if (capsStorage->getDiscoInfo(hash)) { return; } @@ -48,16 +48,16 @@ void CapsManager::handleStanzaChannelAvailableChanged(bool available) { } } -void CapsManager::handleDiscoInfoReceived(const JID& from, const String& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) { +void CapsManager::handleDiscoInfoReceived(const JID& from, const std::string& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) { requestedDiscoInfos.erase(hash); if (error || CapsInfoGenerator("").generateCapsInfo(*discoInfo.get()).getVersion() != hash) { if (warnOnInvalidHash && !error) { std::cerr << "Warning: Caps from " << from.toString() << " do not verify" << std::endl; } failingCaps.insert(std::make_pair(from, hash)); - std::map > >::iterator i = fallbacks.find(hash); + std::map > >::iterator i = fallbacks.find(hash); if (i != fallbacks.end() && !i->second.empty()) { - std::pair fallbackAndNode = *i->second.begin(); + std::pair fallbackAndNode = *i->second.begin(); i->second.erase(i->second.begin()); requestDiscoInfo(fallbackAndNode.first, fallbackAndNode.second, hash); } @@ -68,14 +68,14 @@ void CapsManager::handleDiscoInfoReceived(const JID& from, const String& hash, D onCapsAvailable(hash); } -void CapsManager::requestDiscoInfo(const JID& jid, const String& node, const String& hash) { +void CapsManager::requestDiscoInfo(const JID& jid, const std::string& node, const std::string& hash) { GetDiscoInfoRequest::ref request = GetDiscoInfoRequest::create(jid, node + "#" + hash, iqRouter); request->onResponse.connect(boost::bind(&CapsManager::handleDiscoInfoReceived, this, jid, hash, _1, _2)); requestedDiscoInfos.insert(hash); request->send(); } -DiscoInfo::ref CapsManager::getCaps(const String& hash) const { +DiscoInfo::ref CapsManager::getCaps(const std::string& hash) const { return capsStorage->getDiscoInfo(hash); } diff --git a/Swiften/Disco/CapsManager.h b/Swiften/Disco/CapsManager.h index 842f2be..961dae8 100644 --- a/Swiften/Disco/CapsManager.h +++ b/Swiften/Disco/CapsManager.h @@ -26,7 +26,7 @@ namespace Swift { public: CapsManager(CapsStorage*, StanzaChannel*, IQRouter*); - DiscoInfo::ref getCaps(const String&) const; + DiscoInfo::ref getCaps(const std::string&) const; // Mainly for testing purposes void setWarnOnInvalidHash(bool b) { @@ -36,15 +36,15 @@ namespace Swift { private: void handlePresenceReceived(boost::shared_ptr); void handleStanzaChannelAvailableChanged(bool); - void handleDiscoInfoReceived(const JID&, const String& hash, DiscoInfo::ref, ErrorPayload::ref); - void requestDiscoInfo(const JID& jid, const String& node, const String& hash); + void handleDiscoInfoReceived(const JID&, const std::string& hash, DiscoInfo::ref, ErrorPayload::ref); + void requestDiscoInfo(const JID& jid, const std::string& node, const std::string& hash); private: IQRouter* iqRouter; CapsStorage* capsStorage; bool warnOnInvalidHash; - std::set requestedDiscoInfos; - std::set< std::pair > failingCaps; - std::map > > fallbacks; + std::set requestedDiscoInfos; + std::set< std::pair > failingCaps; + std::map > > fallbacks; }; } diff --git a/Swiften/Disco/CapsMemoryStorage.h b/Swiften/Disco/CapsMemoryStorage.h index 71bd5d5..1e2d7be 100644 --- a/Swiften/Disco/CapsMemoryStorage.h +++ b/Swiften/Disco/CapsMemoryStorage.h @@ -9,7 +9,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Disco/CapsStorage.h" namespace Swift { @@ -17,7 +17,7 @@ namespace Swift { public: CapsMemoryStorage() {} - virtual DiscoInfo::ref getDiscoInfo(const String& hash) const { + virtual DiscoInfo::ref getDiscoInfo(const std::string& hash) const { CapsMap::const_iterator i = caps.find(hash); if (i != caps.end()) { return i->second; @@ -27,12 +27,12 @@ namespace Swift { } } - virtual void setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo) { + virtual void setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo) { caps[hash] = discoInfo; } private: - typedef std::map CapsMap; + typedef std::map CapsMap; CapsMap caps; }; } diff --git a/Swiften/Disco/CapsProvider.h b/Swiften/Disco/CapsProvider.h index 815391a..71e2741 100644 --- a/Swiften/Disco/CapsProvider.h +++ b/Swiften/Disco/CapsProvider.h @@ -11,14 +11,14 @@ #include "Swiften/Elements/CapsInfo.h" namespace Swift { - class String; + class CapsProvider { public: virtual ~CapsProvider() {} - virtual DiscoInfo::ref getCaps(const String&) const = 0; + virtual DiscoInfo::ref getCaps(const std::string&) const = 0; - boost::signal onCapsAvailable; + boost::signal onCapsAvailable; }; } diff --git a/Swiften/Disco/CapsStorage.h b/Swiften/Disco/CapsStorage.h index e4ff945..f0a71a3 100644 --- a/Swiften/Disco/CapsStorage.h +++ b/Swiften/Disco/CapsStorage.h @@ -11,13 +11,13 @@ #include "Swiften/Elements/DiscoInfo.h" namespace Swift { - class String; + class CapsStorage { public: virtual ~CapsStorage(); - virtual DiscoInfo::ref getDiscoInfo(const String&) const = 0; - virtual void setDiscoInfo(const String&, DiscoInfo::ref) = 0; + virtual DiscoInfo::ref getDiscoInfo(const std::string&) const = 0; + virtual void setDiscoInfo(const std::string&, DiscoInfo::ref) = 0; }; } diff --git a/Swiften/Disco/ClientDiscoManager.cpp b/Swiften/Disco/ClientDiscoManager.cpp index 6753df2..fb7cce9 100644 --- a/Swiften/Disco/ClientDiscoManager.cpp +++ b/Swiften/Disco/ClientDiscoManager.cpp @@ -24,7 +24,7 @@ ClientDiscoManager::~ClientDiscoManager() { delete discoInfoResponder; } -void ClientDiscoManager::setCapsNode(const String& node) { +void ClientDiscoManager::setCapsNode(const std::string& node) { capsNode = node; } diff --git a/Swiften/Disco/ClientDiscoManager.h b/Swiften/Disco/ClientDiscoManager.h index b997374..3771044 100644 --- a/Swiften/Disco/ClientDiscoManager.h +++ b/Swiften/Disco/ClientDiscoManager.h @@ -41,7 +41,7 @@ namespace Swift { /** * Needs to be called before calling setDiscoInfo(). */ - void setCapsNode(const String& node); + void setCapsNode(const std::string& node); /** * Sets the capabilities of the client. @@ -61,7 +61,7 @@ namespace Swift { private: PayloadAddingPresenceSender* presenceSender; DiscoInfoResponder* discoInfoResponder; - String capsNode; + std::string capsNode; CapsInfo::ref capsInfo; }; } diff --git a/Swiften/Disco/DiscoInfoResponder.cpp b/Swiften/Disco/DiscoInfoResponder.cpp index 0254ad9..7ba044e 100644 --- a/Swiften/Disco/DiscoInfoResponder.cpp +++ b/Swiften/Disco/DiscoInfoResponder.cpp @@ -22,18 +22,18 @@ void DiscoInfoResponder::setDiscoInfo(const DiscoInfo& info) { info_ = info; } -void DiscoInfoResponder::setDiscoInfo(const String& node, const DiscoInfo& info) { +void DiscoInfoResponder::setDiscoInfo(const std::string& node, const DiscoInfo& info) { DiscoInfo newInfo(info); newInfo.setNode(node); nodeInfo_[node] = newInfo; } -bool DiscoInfoResponder::handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr info) { - if (info->getNode().isEmpty()) { +bool DiscoInfoResponder::handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr info) { + if (info->getNode().empty()) { sendResponse(from, id, boost::shared_ptr(new DiscoInfo(info_))); } else { - std::map::const_iterator i = nodeInfo_.find(info->getNode()); + std::map::const_iterator i = nodeInfo_.find(info->getNode()); if (i != nodeInfo_.end()) { sendResponse(from, id, boost::shared_ptr(new DiscoInfo((*i).second))); } diff --git a/Swiften/Disco/DiscoInfoResponder.h b/Swiften/Disco/DiscoInfoResponder.h index 3861ffd..f114a21 100644 --- a/Swiften/Disco/DiscoInfoResponder.h +++ b/Swiften/Disco/DiscoInfoResponder.h @@ -20,13 +20,13 @@ namespace Swift { void clearDiscoInfo(); void setDiscoInfo(const DiscoInfo& info); - void setDiscoInfo(const String& node, const DiscoInfo& info); + void setDiscoInfo(const std::string& node, const DiscoInfo& info); private: - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr payload); private: DiscoInfo info_; - std::map nodeInfo_; + std::map nodeInfo_; }; } diff --git a/Swiften/Disco/EntityCapsManager.cpp b/Swiften/Disco/EntityCapsManager.cpp index 26e0594..3f2e3d7 100644 --- a/Swiften/Disco/EntityCapsManager.cpp +++ b/Swiften/Disco/EntityCapsManager.cpp @@ -26,8 +26,8 @@ void EntityCapsManager::handlePresenceReceived(boost::shared_ptr prese if (!capsInfo || capsInfo->getHash() != "sha-1" || presence->getPayload()) { return; } - String hash = capsInfo->getVersion(); - std::map::iterator i = caps.find(from); + std::string hash = capsInfo->getVersion(); + std::map::iterator i = caps.find(from); if (i == caps.end() || i->second != hash) { caps.insert(std::make_pair(from, hash)); DiscoInfo::ref disco = capsProvider->getCaps(hash); @@ -41,7 +41,7 @@ void EntityCapsManager::handlePresenceReceived(boost::shared_ptr prese } } else { - std::map::iterator i = caps.find(from); + std::map::iterator i = caps.find(from); if (i != caps.end()) { caps.erase(i); onCapsChanged(from); @@ -51,17 +51,17 @@ void EntityCapsManager::handlePresenceReceived(boost::shared_ptr prese void EntityCapsManager::handleStanzaChannelAvailableChanged(bool available) { if (available) { - std::map capsCopy; + std::map capsCopy; capsCopy.swap(caps); - for (std::map::const_iterator i = capsCopy.begin(); i != capsCopy.end(); ++i) { + for (std::map::const_iterator i = capsCopy.begin(); i != capsCopy.end(); ++i) { onCapsChanged(i->first); } } } -void EntityCapsManager::handleCapsAvailable(const String& hash) { +void EntityCapsManager::handleCapsAvailable(const std::string& hash) { // TODO: Use Boost.Bimap ? - for (std::map::const_iterator i = caps.begin(); i != caps.end(); ++i) { + for (std::map::const_iterator i = caps.begin(); i != caps.end(); ++i) { if (i->second == hash) { onCapsChanged(i->first); } @@ -69,7 +69,7 @@ void EntityCapsManager::handleCapsAvailable(const String& hash) { } DiscoInfo::ref EntityCapsManager::getCaps(const JID& jid) const { - std::map::const_iterator i = caps.find(jid); + std::map::const_iterator i = caps.find(jid); if (i != caps.end()) { return capsProvider->getCaps(i->second); } diff --git a/Swiften/Disco/EntityCapsManager.h b/Swiften/Disco/EntityCapsManager.h index f507a1d..190f876 100644 --- a/Swiften/Disco/EntityCapsManager.h +++ b/Swiften/Disco/EntityCapsManager.h @@ -36,10 +36,10 @@ namespace Swift { private: void handlePresenceReceived(boost::shared_ptr); void handleStanzaChannelAvailableChanged(bool); - void handleCapsAvailable(const String&); + void handleCapsAvailable(const std::string&); private: CapsProvider* capsProvider; - std::map caps; + std::map caps; }; } diff --git a/Swiften/Disco/GetDiscoInfoRequest.h b/Swiften/Disco/GetDiscoInfoRequest.h index 2298b5c..5cec530 100644 --- a/Swiften/Disco/GetDiscoInfoRequest.h +++ b/Swiften/Disco/GetDiscoInfoRequest.h @@ -18,7 +18,7 @@ namespace Swift { return ref(new GetDiscoInfoRequest(jid, router)); } - static ref create(const JID& jid, const String& node, IQRouter* router) { + static ref create(const JID& jid, const std::string& node, IQRouter* router) { return ref(new GetDiscoInfoRequest(jid, node, router)); } @@ -27,7 +27,7 @@ namespace Swift { GenericRequest(IQ::Get, jid, boost::shared_ptr(new DiscoInfo()), router) { } - GetDiscoInfoRequest(const JID& jid, const String& node, IQRouter* router) : + GetDiscoInfoRequest(const JID& jid, const std::string& node, IQRouter* router) : GenericRequest(IQ::Get, jid, boost::shared_ptr(new DiscoInfo()), router) { getPayloadGeneric()->setNode(node); } diff --git a/Swiften/Disco/JIDDiscoInfoResponder.cpp b/Swiften/Disco/JIDDiscoInfoResponder.cpp index 311447f..1298e5a 100644 --- a/Swiften/Disco/JIDDiscoInfoResponder.cpp +++ b/Swiften/Disco/JIDDiscoInfoResponder.cpp @@ -22,21 +22,21 @@ void JIDDiscoInfoResponder::setDiscoInfo(const JID& jid, const DiscoInfo& discoI i->second.discoInfo = discoInfo; } -void JIDDiscoInfoResponder::setDiscoInfo(const JID& jid, const String& node, const DiscoInfo& discoInfo) { +void JIDDiscoInfoResponder::setDiscoInfo(const JID& jid, const std::string& node, const DiscoInfo& discoInfo) { JIDDiscoInfoMap::iterator i = info.insert(std::make_pair(jid, JIDDiscoInfo())).first; DiscoInfo newInfo(discoInfo); newInfo.setNode(node); i->second.nodeDiscoInfo[node] = newInfo; } -bool JIDDiscoInfoResponder::handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr discoInfo) { +bool JIDDiscoInfoResponder::handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr discoInfo) { JIDDiscoInfoMap::const_iterator i = info.find(to); if (i != info.end()) { - if (discoInfo->getNode().isEmpty()) { + if (discoInfo->getNode().empty()) { sendResponse(from, to, id, boost::shared_ptr(new DiscoInfo(i->second.discoInfo))); } else { - std::map::const_iterator j = i->second.nodeDiscoInfo.find(discoInfo->getNode()); + std::map::const_iterator j = i->second.nodeDiscoInfo.find(discoInfo->getNode()); if (j != i->second.nodeDiscoInfo.end()) { sendResponse(from, to, id, boost::shared_ptr(new DiscoInfo(j->second))); } diff --git a/Swiften/Disco/JIDDiscoInfoResponder.h b/Swiften/Disco/JIDDiscoInfoResponder.h index aac43de..d532d0f 100644 --- a/Swiften/Disco/JIDDiscoInfoResponder.h +++ b/Swiften/Disco/JIDDiscoInfoResponder.h @@ -21,15 +21,15 @@ namespace Swift { void clearDiscoInfo(const JID& jid); void setDiscoInfo(const JID& jid, const DiscoInfo& info); - void setDiscoInfo(const JID& jid, const String& node, const DiscoInfo& info); + void setDiscoInfo(const JID& jid, const std::string& node, const DiscoInfo& info); private: - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr payload); private: struct JIDDiscoInfo { DiscoInfo discoInfo; - std::map nodeDiscoInfo; + std::map nodeDiscoInfo; }; typedef std::map JIDDiscoInfoMap; JIDDiscoInfoMap info; diff --git a/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp b/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp index aec3a92..d4cb331 100644 --- a/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp +++ b/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp @@ -30,9 +30,9 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture { CapsInfoGenerator testling("http://code.google.com/p/exodus"); CapsInfo result = testling.generateCapsInfo(discoInfo); - CPPUNIT_ASSERT_EQUAL(String("http://code.google.com/p/exodus"), result.getNode()); - CPPUNIT_ASSERT_EQUAL(String("sha-1"), result.getHash()); - CPPUNIT_ASSERT_EQUAL(String("QgayPKawpkPSDYmwT/WM94uAlu0="), result.getVersion()); + CPPUNIT_ASSERT_EQUAL(std::string("http://code.google.com/p/exodus"), result.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), result.getHash()); + CPPUNIT_ASSERT_EQUAL(std::string("QgayPKawpkPSDYmwT/WM94uAlu0="), result.getVersion()); } void testGenerate_XEP0115ComplexExample() { @@ -48,7 +48,7 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture { FormField::ref field = HiddenFormField::create("urn:xmpp:dataforms:softwareinfo"); field->setName("FORM_TYPE"); extension->addField(field); - std::vector ipVersions; + std::vector ipVersions; ipVersions.push_back("ipv6"); ipVersions.push_back("ipv4"); field = ListMultiFormField::create(ipVersions); @@ -77,7 +77,7 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture { CapsInfoGenerator testling("http://psi-im.org"); CapsInfo result = testling.generateCapsInfo(discoInfo); - CPPUNIT_ASSERT_EQUAL(String("q07IKJEyjvHSyhy//CH0CxmKi8w="), result.getVersion()); + CPPUNIT_ASSERT_EQUAL(std::string("q07IKJEyjvHSyhy//CH0CxmKi8w="), result.getVersion()); } }; diff --git a/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp b/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp index 988065f..bccf0d4 100644 --- a/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp +++ b/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp @@ -45,7 +45,7 @@ class DiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(channel_->iqs_.size())); boost::shared_ptr payload(channel_->iqs_[0]->getPayload()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string(""), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("foo")); testling.stop(); @@ -68,7 +68,7 @@ class DiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(channel_->iqs_.size())); boost::shared_ptr payload(channel_->iqs_[0]->getPayload()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar-node"), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("bar")); testling.stop(); diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp index 0a498cf..544bdad 100644 --- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp @@ -159,15 +159,15 @@ class EntityCapsManagerTest : public CppUnit::TestFixture { private: struct DummyCapsProvider : public CapsProvider { - virtual DiscoInfo::ref getCaps(const String& hash) const { - std::map::const_iterator i = caps.find(hash); + virtual DiscoInfo::ref getCaps(const std::string& hash) const { + std::map::const_iterator i = caps.find(hash); if (i != caps.end()) { return i->second; } return DiscoInfo::ref(); } - std::map caps; + std::map caps; }; private: diff --git a/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp b/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp index 03a3ee8..ef61afa 100644 --- a/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp +++ b/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp @@ -46,7 +46,7 @@ class JIDDiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(channel_->iqs_.size())); boost::shared_ptr payload(channel_->iqs_[0]->getPayload()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string(""), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("foo")); testling.stop(); @@ -69,7 +69,7 @@ class JIDDiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(channel_->iqs_.size())); boost::shared_ptr payload(channel_->iqs_[0]->getPayload()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar-node"), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("bar")); testling.stop(); diff --git a/Swiften/Elements/AuthRequest.h b/Swiften/Elements/AuthRequest.h index a1aac31..ba86900 100644 --- a/Swiften/Elements/AuthRequest.h +++ b/Swiften/Elements/AuthRequest.h @@ -14,14 +14,14 @@ namespace Swift { class AuthRequest : public Element { public: - AuthRequest(const String& mechanism = "") : mechanism_(mechanism) { + AuthRequest(const std::string& mechanism = "") : mechanism_(mechanism) { } - AuthRequest(const String& mechanism, const ByteArray& message) : + AuthRequest(const std::string& mechanism, const ByteArray& message) : mechanism_(mechanism), message_(message) { } - AuthRequest(const String& mechanism, const boost::optional& message) : + AuthRequest(const std::string& mechanism, const boost::optional& message) : mechanism_(mechanism), message_(message) { } @@ -33,16 +33,16 @@ namespace Swift { message_ = boost::optional(message); } - const String& getMechanism() const { + const std::string& getMechanism() const { return mechanism_; } - void setMechanism(const String& mechanism) { + void setMechanism(const std::string& mechanism) { mechanism_ = mechanism; } private: - String mechanism_; + std::string mechanism_; boost::optional message_; }; } diff --git a/Swiften/Elements/Body.h b/Swiften/Elements/Body.h index 8262e09..2887390 100644 --- a/Swiften/Elements/Body.h +++ b/Swiften/Elements/Body.h @@ -7,25 +7,25 @@ #pragma once #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include namespace Swift { class Body : public Payload { public: typedef boost::shared_ptr ref; - Body(const String& text = "") : text_(text) { + Body(const std::string& text = "") : text_(text) { } - void setText(const String& text) { + void setText(const std::string& text) { text_ = text; } - const String& getText() const { + const std::string& getText() const { return text_; } private: - String text_; + std::string text_; }; } diff --git a/Swiften/Elements/Bytestreams.h b/Swiften/Elements/Bytestreams.h index 9d45c8a..b493375 100644 --- a/Swiften/Elements/Bytestreams.h +++ b/Swiften/Elements/Bytestreams.h @@ -11,7 +11,7 @@ #include #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Payload.h" namespace Swift { @@ -20,20 +20,20 @@ namespace Swift { typedef boost::shared_ptr ref; struct StreamHost { - StreamHost(const String& host = "", const JID& jid = JID(), int port = -1) : host(host), jid(jid), port(port) {} + StreamHost(const std::string& host = "", const JID& jid = JID(), int port = -1) : host(host), jid(jid), port(port) {} - String host; + std::string host; JID jid; int port; }; Bytestreams() {} - const String& getStreamID() const { + const std::string& getStreamID() const { return id; } - void setStreamID(const String& id) { + void setStreamID(const std::string& id) { this->id = id; } @@ -54,7 +54,7 @@ namespace Swift { } private: - String id; + std::string id; boost::optional usedStreamHost; std::vector streamHosts; }; diff --git a/Swiften/Elements/CapsInfo.h b/Swiften/Elements/CapsInfo.h index dc3cc2e..ccad278 100644 --- a/Swiften/Elements/CapsInfo.h +++ b/Swiften/Elements/CapsInfo.h @@ -8,7 +8,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Payload.h" namespace Swift { @@ -16,7 +16,7 @@ namespace Swift { public: typedef boost::shared_ptr ref; - CapsInfo(const String& node = "", const String& version = "", const String& hash = "sha-1") : node_(node), version_(version), hash_(hash) {} + CapsInfo(const std::string& node = "", const std::string& version = "", const std::string& hash = "sha-1") : node_(node), version_(version), hash_(hash) {} bool operator==(const CapsInfo& o) const { return o.node_ == node_ && o.version_ == version_ && o.hash_ == hash_; @@ -36,24 +36,24 @@ namespace Swift { } } - const String& getNode() const { return node_; } - void setNode(const String& node) { + const std::string& getNode() const { return node_; } + void setNode(const std::string& node) { node_ = node; } - const String& getVersion() const { return version_; } - void setVersion(const String& version) { + const std::string& getVersion() const { return version_; } + void setVersion(const std::string& version) { version_ = version; } - const String& getHash() const { return hash_; } - void setHash(const String& hash) { + const std::string& getHash() const { return hash_; } + void setHash(const std::string& hash) { hash_ = hash; } private: - String node_; - String version_; - String hash_; + std::string node_; + std::string version_; + std::string hash_; }; } diff --git a/Swiften/Elements/ChatState.h b/Swiften/Elements/ChatState.h index 8dcf77c..2896877 100644 --- a/Swiften/Elements/ChatState.h +++ b/Swiften/Elements/ChatState.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Payload.h" namespace Swift { diff --git a/Swiften/Elements/Command.h b/Swiften/Elements/Command.h index 73d359f..f4059a8 100644 --- a/Swiften/Elements/Command.h +++ b/Swiften/Elements/Command.h @@ -8,7 +8,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/Form.h" @@ -26,21 +26,21 @@ namespace Swift { struct Note { enum Type {Info, Warn, Error}; - Note(String note, Type type) : note(note), type(type) {}; + Note(std::string note, Type type) : note(note), type(type) {}; - String note; + std::string note; Type type; }; public: - Command(const String& node, const String& sessionID, Status status) { constructor(node, sessionID, NoAction, status);} - Command(const String& node = "", const String& sessionID = "", Action action = Execute) { constructor(node, sessionID, action, NoStatus); } + Command(const std::string& node, const std::string& sessionID, Status status) { constructor(node, sessionID, NoAction, status);} + Command(const std::string& node = "", const std::string& sessionID = "", Action action = Execute) { constructor(node, sessionID, action, NoStatus); } - const String& getNode() const { return node_; } - void setNode(const String& node) { node_ = node; } + const std::string& getNode() const { return node_; } + void setNode(const std::string& node) { node_ = node; } - const String& getSessionID() const { return sessionID_; } - void setSessionID(const String& id) { sessionID_ = id; } + const std::string& getSessionID() const { return sessionID_; } + void setSessionID(const std::string& id) { sessionID_ = id; } Action getAction() const { return action_; } void setAction(Action action) { action_ = action; } @@ -60,7 +60,7 @@ namespace Swift { void setForm(Form::ref payload) { form_ = payload; } private: - void constructor(const String& node, const String& sessionID, Action action, Status status) { + void constructor(const std::string& node, const std::string& sessionID, Action action, Status status) { node_ = node; sessionID_ = sessionID; action_ = action; @@ -69,8 +69,8 @@ namespace Swift { } private: - String node_; - String sessionID_; + std::string node_; + std::string sessionID_; Action action_; Status status_; Action executeAction_; diff --git a/Swiften/Elements/ComponentHandshake.h b/Swiften/Elements/ComponentHandshake.h index ca18e73..6047eab 100644 --- a/Swiften/Elements/ComponentHandshake.h +++ b/Swiften/Elements/ComponentHandshake.h @@ -9,25 +9,25 @@ #include #include "Swiften/Elements/Element.h" -#include "Swiften/Base/String.h" +#include namespace Swift { class ComponentHandshake : public Element { public: typedef boost::shared_ptr ref; - ComponentHandshake(const String& data = "") : data(data) { + ComponentHandshake(const std::string& data = "") : data(data) { } - void setData(const String& d) { + void setData(const std::string& d) { data = d; } - const String& getData() const { + const std::string& getData() const { return data; } private: - String data; + std::string data; }; } diff --git a/Swiften/Elements/CompressRequest.h b/Swiften/Elements/CompressRequest.h index b6f01e3..0eb302a 100644 --- a/Swiften/Elements/CompressRequest.h +++ b/Swiften/Elements/CompressRequest.h @@ -13,18 +13,18 @@ namespace Swift { class CompressRequest : public Element { public: - CompressRequest(const String& method = "") : method_(method) {} + CompressRequest(const std::string& method = "") : method_(method) {} - const String& getMethod() const { + const std::string& getMethod() const { return method_; } - void setMethod(const String& method) { + void setMethod(const std::string& method) { method_ = method; } private: - String method_; + std::string method_; }; } diff --git a/Swiften/Elements/DiscoInfo.cpp b/Swiften/Elements/DiscoInfo.cpp index a939d48..9c43ef4 100644 --- a/Swiften/Elements/DiscoInfo.cpp +++ b/Swiften/Elements/DiscoInfo.cpp @@ -8,9 +8,9 @@ namespace Swift { -const String DiscoInfo::ChatStatesFeature = String("http://jabber.org/protocol/chatstates"); -const String DiscoInfo::SecurityLabelsFeature = String("urn:xmpp:sec-label:0"); -const String DiscoInfo::JabberSearchFeature = String("jabber:iq:search"); +const std::string DiscoInfo::ChatStatesFeature = std::string("http://jabber.org/protocol/chatstates"); +const std::string DiscoInfo::SecurityLabelsFeature = std::string("urn:xmpp:sec-label:0"); +const std::string DiscoInfo::JabberSearchFeature = std::string("jabber:iq:search"); bool DiscoInfo::Identity::operator<(const Identity& other) const { diff --git a/Swiften/Elements/DiscoInfo.h b/Swiften/Elements/DiscoInfo.h index 41bf6bf..5101884 100644 --- a/Swiften/Elements/DiscoInfo.h +++ b/Swiften/Elements/DiscoInfo.h @@ -10,7 +10,7 @@ #include #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Form.h" @@ -19,29 +19,29 @@ namespace Swift { public: typedef boost::shared_ptr ref; - static const String ChatStatesFeature; - static const String SecurityLabelsFeature; - static const String JabberSearchFeature; + static const std::string ChatStatesFeature; + static const std::string SecurityLabelsFeature; + static const std::string JabberSearchFeature; const static std::string SecurityLabels; class Identity { public: - Identity(const String& name, const String& category = "client", const String& type = "pc", const String& lang = "") : name_(name), category_(category), type_(type), lang_(lang) { + Identity(const std::string& name, const std::string& category = "client", const std::string& type = "pc", const std::string& lang = "") : name_(name), category_(category), type_(type), lang_(lang) { } - const String& getCategory() const { + const std::string& getCategory() const { return category_; } - const String& getType() const { + const std::string& getType() const { return type_; } - const String& getLanguage() const { + const std::string& getLanguage() const { return lang_; } - const String& getName() const { + const std::string& getName() const { return name_; } @@ -49,20 +49,20 @@ namespace Swift { bool operator<(const Identity& other) const; private: - String name_; - String category_; - String type_; - String lang_; + std::string name_; + std::string category_; + std::string type_; + std::string lang_; }; DiscoInfo() { } - const String& getNode() const { + const std::string& getNode() const { return node_; } - void setNode(const String& node) { + void setNode(const std::string& node) { node_ = node; } @@ -74,15 +74,15 @@ namespace Swift { identities_.push_back(identity); } - const std::vector& getFeatures() const { + const std::vector& getFeatures() const { return features_; } - void addFeature(const String& feature) { + void addFeature(const std::string& feature) { features_.push_back(feature); } - bool hasFeature(const String& feature) const { + bool hasFeature(const std::string& feature) const { return std::find(features_.begin(), features_.end(), feature) != features_.end(); } @@ -95,9 +95,9 @@ namespace Swift { } private: - String node_; + std::string node_; std::vector identities_; - std::vector features_; + std::vector features_; std::vector extensions_; }; } diff --git a/Swiften/Elements/DiscoItems.h b/Swiften/Elements/DiscoItems.h index 400947a..cc5a583 100644 --- a/Swiften/Elements/DiscoItems.h +++ b/Swiften/Elements/DiscoItems.h @@ -10,7 +10,7 @@ #include #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" namespace Swift { @@ -18,14 +18,14 @@ namespace Swift { public: class Item { public: - Item(const String& name, const JID& jid, const String& node="") : name_(name), jid_(jid), node_(node) { + Item(const std::string& name, const JID& jid, const std::string& node="") : name_(name), jid_(jid), node_(node) { } - const String& getName() const { + const std::string& getName() const { return name_; } - const String& getNode() const { + const std::string& getNode() const { return node_; } @@ -34,19 +34,19 @@ namespace Swift { } private: - String name_; + std::string name_; JID jid_; - String node_; + std::string node_; }; DiscoItems() { } - const String& getNode() const { + const std::string& getNode() const { return node_; } - void setNode(const String& node) { + void setNode(const std::string& node) { node_ = node; } @@ -59,7 +59,7 @@ namespace Swift { } private: - String node_; + std::string node_; std::vector items_; }; } diff --git a/Swiften/Elements/ErrorPayload.h b/Swiften/Elements/ErrorPayload.h index 8f849f2..12ad574 100644 --- a/Swiften/Elements/ErrorPayload.h +++ b/Swiften/Elements/ErrorPayload.h @@ -9,7 +9,7 @@ #include #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include namespace Swift { class ErrorPayload : public Payload { @@ -43,7 +43,7 @@ namespace Swift { UnexpectedRequest }; - ErrorPayload(Condition condition = UndefinedCondition, Type type = Cancel, const String& text = String()) : type_(type), condition_(condition), text_(text) { } + ErrorPayload(Condition condition = UndefinedCondition, Type type = Cancel, const std::string& text = std::string()) : type_(type), condition_(condition), text_(text) { } Type getType() const { return type_; @@ -61,17 +61,17 @@ namespace Swift { condition_ = condition; } - void setText(const String& text) { + void setText(const std::string& text) { text_ = text; } - const String& getText() const { + const std::string& getText() const { return text_; } private: Type type_; Condition condition_; - String text_; + std::string text_; }; } diff --git a/Swiften/Elements/Form.cpp b/Swiften/Elements/Form.cpp index 41014ba..03fd1a4 100644 --- a/Swiften/Elements/Form.cpp +++ b/Swiften/Elements/Form.cpp @@ -9,13 +9,13 @@ namespace Swift { -String Form::getFormType() const { +std::string Form::getFormType() const { FormField::ref field = getField("FORM_TYPE"); boost::shared_ptr f = boost::dynamic_pointer_cast(field); return (f ? f->getValue() : ""); } -FormField::ref Form::getField(const String& name) const { +FormField::ref Form::getField(const std::string& name) const { foreach(FormField::ref field, fields_) { if (field->getName() == name) { return field; diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h index 5e8f994..1c50f0c 100644 --- a/Swiften/Elements/Form.h +++ b/Swiften/Elements/Form.h @@ -10,7 +10,7 @@ #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/FormField.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" @@ -31,23 +31,23 @@ namespace Swift { void addField(boost::shared_ptr field) { fields_.push_back(field); } const std::vector >& getFields() const { return fields_; } - void setTitle(const String& title) { title_ = title; } - const String& getTitle() { return title_; } + void setTitle(const std::string& title) { title_ = title; } + const std::string& getTitle() { return title_; } - void setInstructions(const String& instructions) { instructions_ = instructions; } - const String& getInstructions() { return instructions_; } + void setInstructions(const std::string& instructions) { instructions_ = instructions; } + const std::string& getInstructions() { return instructions_; } Type getType() { return type_; } void setType(Type type) { type_ = type; } - String getFormType() const; + std::string getFormType() const; - FormField::ref getField(const String& name) const; + FormField::ref getField(const std::string& name) const; private: std::vector > fields_; - String title_; - String instructions_; + std::string title_; + std::string instructions_; Type type_; }; } diff --git a/Swiften/Elements/FormField.h b/Swiften/Elements/FormField.h index 0221dae..f455303 100644 --- a/Swiften/Elements/FormField.h +++ b/Swiften/Elements/FormField.h @@ -12,7 +12,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" namespace Swift { @@ -23,19 +23,19 @@ namespace Swift { virtual ~FormField() {} struct Option { - Option(const String& label, const String& value) : label(label), value(value) {} - String label; - String value; + Option(const std::string& label, const std::string& value) : label(label), value(value) {} + std::string label; + std::string value; }; - void setName(const String& name) { this->name = name; } - const String& getName() const { return name; } + void setName(const std::string& name) { this->name = name; } + const std::string& getName() const { return name; } - void setLabel(const String& label) { this->label = label; } - const String& getLabel() const { return label; } + void setLabel(const std::string& label) { this->label = label; } + const std::string& getLabel() const { return label; } - void setDescription(const String& description) { this->description = description; } - const String& getDescription() const { return description; } + void setDescription(const std::string& description) { this->description = description; } + const std::string& getDescription() const { return description; } void setRequired(bool required) { this->required = required; } bool getRequired() const { return required; } @@ -48,11 +48,11 @@ namespace Swift { return options; } - const std::vector getRawValues() const { + const std::vector getRawValues() const { return rawValues; } - void addRawValue(const String& value) { + void addRawValue(const std::string& value) { rawValues.push_back(value); } @@ -60,12 +60,12 @@ namespace Swift { FormField() : required(false) {} private: - String name; - String label; - String description; + std::string name; + std::string label; + std::string description; bool required; std::vector
")); boost::shared_ptr payload = boost::dynamic_pointer_cast(parser.getPayload()); - CPPUNIT_ASSERT_EQUAL(String("2.0"), payload->getVersion()); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), payload->getFullName()); - CPPUNIT_ASSERT_EQUAL(String("Alice"), payload->getGivenName()); - CPPUNIT_ASSERT_EQUAL(String("In"), payload->getMiddleName()); - CPPUNIT_ASSERT_EQUAL(String("Wonderland"), payload->getFamilyName()); - CPPUNIT_ASSERT_EQUAL(String("Mrs"), payload->getPrefix()); - CPPUNIT_ASSERT_EQUAL(String("PhD"), payload->getSuffix()); - CPPUNIT_ASSERT_EQUAL(String("DreamGirl"), payload->getNickname()); - CPPUNIT_ASSERT_EQUAL(String("1234mutt"), payload->getUnknownContent()); + CPPUNIT_ASSERT_EQUAL(std::string("2.0"), payload->getVersion()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), payload->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), payload->getGivenName()); + CPPUNIT_ASSERT_EQUAL(std::string("In"), payload->getMiddleName()); + CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), payload->getFamilyName()); + CPPUNIT_ASSERT_EQUAL(std::string("Mrs"), payload->getPrefix()); + CPPUNIT_ASSERT_EQUAL(std::string("PhD"), payload->getSuffix()); + CPPUNIT_ASSERT_EQUAL(std::string("DreamGirl"), payload->getNickname()); + CPPUNIT_ASSERT_EQUAL(std::string("1234mutt"), payload->getUnknownContent()); CPPUNIT_ASSERT_EQUAL(2, static_cast(payload->getEMailAddresses().size())); - CPPUNIT_ASSERT_EQUAL(String("alice@wonderland.lit"), payload->getEMailAddresses()[0].address); + CPPUNIT_ASSERT_EQUAL(std::string("alice@wonderland.lit"), payload->getEMailAddresses()[0].address); CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isHome); CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isInternet); CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isPreferred); CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isWork); CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isX400); - CPPUNIT_ASSERT_EQUAL(String("alice@teaparty.lit"), payload->getEMailAddresses()[1].address); + CPPUNIT_ASSERT_EQUAL(std::string("alice@teaparty.lit"), payload->getEMailAddresses()[1].address); CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isHome); CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isInternet); CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isPreferred); @@ -92,7 +92,7 @@ class VCardParserTest : public CppUnit::TestFixture { "")); VCard* payload = dynamic_cast(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), payload->getPhotoType()); + CPPUNIT_ASSERT_EQUAL(std::string("image/jpeg"), payload->getPhotoType()); CPPUNIT_ASSERT_EQUAL(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), payload->getPhoto()); } @@ -105,7 +105,7 @@ class VCardParserTest : public CppUnit::TestFixture { "")); VCard* payload = dynamic_cast(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("mynick"), payload->getNickname()); + CPPUNIT_ASSERT_EQUAL(std::string("mynick"), payload->getNickname()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp index 79df412..b8ea4fb 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp @@ -30,7 +30,7 @@ class VCardUpdateParserTest : public CppUnit::TestFixture "")); VCardUpdate* payload = dynamic_cast(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("sha1-hash-of-image"), payload->getPhotoHash()); + CPPUNIT_ASSERT_EQUAL(std::string("sha1-hash-of-image"), payload->getPhotoHash()); } }; diff --git a/Swiften/Parser/PayloadParsers/VCardParser.cpp b/Swiften/Parser/PayloadParsers/VCardParser.cpp index 2f1f8dc..61af0ba 100644 --- a/Swiften/Parser/PayloadParsers/VCardParser.cpp +++ b/Swiften/Parser/PayloadParsers/VCardParser.cpp @@ -14,9 +14,9 @@ namespace Swift { VCardParser::VCardParser() : unknownContentParser_(NULL) { } -void VCardParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void VCardParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { elementStack_.push_back(element); - String elementHierarchy = getElementHierarchy(); + std::string elementHierarchy = getElementHierarchy(); if (elementHierarchy == "/vCard/EMAIL") { currentEMailAddress_ = VCard::EMailAddress(); } @@ -32,12 +32,12 @@ void VCardParser::handleStartElement(const String& element, const String& ns, co currentText_ = ""; } -void VCardParser::handleEndElement(const String& element, const String& ns) { +void VCardParser::handleEndElement(const std::string& element, const std::string& ns) { if (unknownContentParser_) { unknownContentParser_->handleEndElement(element, ns); } - String elementHierarchy = getElementHierarchy(); + std::string elementHierarchy = getElementHierarchy(); if (elementHierarchy == "/vCard/VERSION") { getPayloadInternal()->setVersion(currentText_); } @@ -104,16 +104,16 @@ void VCardParser::handleEndElement(const String& element, const String& ns) { elementStack_.pop_back(); } -void VCardParser::handleCharacterData(const String& text) { +void VCardParser::handleCharacterData(const std::string& text) { if (unknownContentParser_) { unknownContentParser_->handleCharacterData(text); } currentText_ += text; } -String VCardParser::getElementHierarchy() const { - String result; - foreach(const String& element, elementStack_) { +std::string VCardParser::getElementHierarchy() const { + std::string result; + foreach(const std::string& element, elementStack_) { result += "/" + element; } return result; diff --git a/Swiften/Parser/PayloadParsers/VCardParser.h b/Swiften/Parser/PayloadParsers/VCardParser.h index f912ff1..c858e61 100644 --- a/Swiften/Parser/PayloadParsers/VCardParser.h +++ b/Swiften/Parser/PayloadParsers/VCardParser.h @@ -16,17 +16,17 @@ namespace Swift { public: VCardParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: - String getElementHierarchy() const; + std::string getElementHierarchy() const; private: - std::vector elementStack_; + std::vector elementStack_; VCard::EMailAddress currentEMailAddress_; SerializingParser* unknownContentParser_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp b/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp index 08d2d35..2218d75 100644 --- a/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp +++ b/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp @@ -11,21 +11,21 @@ namespace Swift { VCardUpdateParser::VCardUpdateParser() : level_(TopLevel) { } -void VCardUpdateParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void VCardUpdateParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { if (level_ == PayloadLevel) { currentText_ = ""; } ++level_; } -void VCardUpdateParser::handleEndElement(const String& element, const String&) { +void VCardUpdateParser::handleEndElement(const std::string& element, const std::string&) { --level_; if (level_ == PayloadLevel && element == "photo") { getPayloadInternal()->setPhotoHash(currentText_); } } -void VCardUpdateParser::handleCharacterData(const String& text) { +void VCardUpdateParser::handleCharacterData(const std::string& text) { currentText_ += text; } diff --git a/Swiften/Parser/PayloadParsers/VCardUpdateParser.h b/Swiften/Parser/PayloadParsers/VCardUpdateParser.h index df86123..b91c17b 100644 --- a/Swiften/Parser/PayloadParsers/VCardUpdateParser.h +++ b/Swiften/Parser/PayloadParsers/VCardUpdateParser.h @@ -16,9 +16,9 @@ namespace Swift { public: VCardUpdateParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -26,6 +26,6 @@ namespace Swift { PayloadLevel = 1 }; int level_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/SerializingParser.cpp b/Swiften/Parser/SerializingParser.cpp index c25b07f..43dfc51 100644 --- a/Swiften/Parser/SerializingParser.cpp +++ b/Swiften/Parser/SerializingParser.cpp @@ -14,7 +14,7 @@ namespace Swift { SerializingParser::SerializingParser() { } -void SerializingParser::handleStartElement(const String& tag, const String& ns, const AttributeMap& attributes) { +void SerializingParser::handleStartElement(const std::string& tag, const std::string& ns, const AttributeMap& attributes) { boost::shared_ptr element(new XMLElement(tag, ns)); for (AttributeMap::const_iterator i = attributes.begin(); i != attributes.end(); ++i) { element->setAttribute((*i).first, (*i).second); @@ -29,18 +29,18 @@ void SerializingParser::handleStartElement(const String& tag, const String& ns, elementStack_.push_back(element); } -void SerializingParser::handleEndElement(const String&, const String&) { +void SerializingParser::handleEndElement(const std::string&, const std::string&) { assert(!elementStack_.empty()); elementStack_.pop_back(); } -void SerializingParser::handleCharacterData(const String& data) { +void SerializingParser::handleCharacterData(const std::string& data) { if (!elementStack_.empty()) { (*(elementStack_.end()-1))->addNode(boost::shared_ptr(new XMLTextNode(data))); } } -String SerializingParser::getResult() const { +std::string SerializingParser::getResult() const { return (rootElement_ ? rootElement_->serialize() : ""); } diff --git a/Swiften/Parser/SerializingParser.h b/Swiften/Parser/SerializingParser.h index 4927677..6276ea0 100644 --- a/Swiften/Parser/SerializingParser.h +++ b/Swiften/Parser/SerializingParser.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_SerializingParser_H #define SWIFTEN_SerializingParser_H -#include "Swiften/Base/String.h" +#include #include "Swiften/Parser/AttributeMap.h" #include "Swiften/Serializer/XML/XMLElement.h" @@ -16,11 +16,11 @@ namespace Swift { public: SerializingParser(); - void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes); - void handleEndElement(const String& element, const String& ns); - void handleCharacterData(const String& data); + void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes); + void handleEndElement(const std::string& element, const std::string& ns); + void handleCharacterData(const std::string& data); - String getResult() const; + std::string getResult() const; private: std::vector< boost::shared_ptr > elementStack_; diff --git a/Swiften/Parser/StanzaAckParser.cpp b/Swiften/Parser/StanzaAckParser.cpp index d85eb9b..9d029cc 100644 --- a/Swiften/Parser/StanzaAckParser.cpp +++ b/Swiften/Parser/StanzaAckParser.cpp @@ -13,11 +13,11 @@ namespace Swift { StanzaAckParser::StanzaAckParser() : GenericElementParser(), depth(0) { } -void StanzaAckParser::handleStartElement(const String&, const String&, const AttributeMap& attributes) { +void StanzaAckParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) { if (depth == 0) { - String handledStanzasString = attributes.getAttribute("h"); + std::string handledStanzasString = attributes.getAttribute("h"); try { - getElementGeneric()->setHandledStanzasCount(boost::lexical_cast(handledStanzasString.getUTF8String())); + getElementGeneric()->setHandledStanzasCount(boost::lexical_cast(handledStanzasString)); } catch (const boost::bad_lexical_cast &) { } @@ -25,7 +25,7 @@ void StanzaAckParser::handleStartElement(const String&, const String&, const Att ++depth; } -void StanzaAckParser::handleEndElement(const String&, const String&) { +void StanzaAckParser::handleEndElement(const std::string&, const std::string&) { --depth; } diff --git a/Swiften/Parser/StanzaAckParser.h b/Swiften/Parser/StanzaAckParser.h index fa9644f..4078dc1 100644 --- a/Swiften/Parser/StanzaAckParser.h +++ b/Swiften/Parser/StanzaAckParser.h @@ -14,8 +14,8 @@ namespace Swift { public: StanzaAckParser(); - virtual void handleStartElement(const String&, const String& ns, const AttributeMap&); - virtual void handleEndElement(const String&, const String& ns); + virtual void handleStartElement(const std::string&, const std::string& ns, const AttributeMap&); + virtual void handleEndElement(const std::string&, const std::string& ns); private: int depth; diff --git a/Swiften/Parser/StanzaParser.cpp b/Swiften/Parser/StanzaParser.cpp index 637b45a..64c4901 100644 --- a/Swiften/Parser/StanzaParser.cpp +++ b/Swiften/Parser/StanzaParser.cpp @@ -23,7 +23,7 @@ StanzaParser::StanzaParser(PayloadParserFactoryCollection* factories) : StanzaParser::~StanzaParser() { } -void StanzaParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void StanzaParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (inStanza()) { if (!inPayload()) { assert(!currentPayloadParser_.get()); @@ -56,7 +56,7 @@ void StanzaParser::handleStartElement(const String& element, const String& ns, c ++currentDepth_; } -void StanzaParser::handleEndElement(const String& element, const String& ns) { +void StanzaParser::handleEndElement(const std::string& element, const std::string& ns) { assert(inStanza()); if (inPayload()) { assert(currentPayloadParser_.get()); @@ -75,7 +75,7 @@ void StanzaParser::handleEndElement(const String& element, const String& ns) { } } -void StanzaParser::handleCharacterData(const String& data) { +void StanzaParser::handleCharacterData(const std::string& data) { if (currentPayloadParser_.get()) { currentPayloadParser_->handleCharacterData(data); } diff --git a/Swiften/Parser/StanzaParser.h b/Swiften/Parser/StanzaParser.h index 60ddafc..df01943 100644 --- a/Swiften/Parser/StanzaParser.h +++ b/Swiften/Parser/StanzaParser.h @@ -9,7 +9,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Stanza.h" #include "Swiften/Parser/ElementParser.h" #include "Swiften/Parser/AttributeMap.h" @@ -23,9 +23,9 @@ namespace Swift { StanzaParser(PayloadParserFactoryCollection* factories); ~StanzaParser(); - void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes); - void handleEndElement(const String& element, const String& ns); - void handleCharacterData(const String& data); + void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes); + void handleEndElement(const std::string& element, const std::string& ns); + void handleCharacterData(const std::string& data); virtual boost::shared_ptr getElement() const = 0; virtual void handleStanzaAttributes(const AttributeMap&) {} diff --git a/Swiften/Parser/StreamErrorParser.cpp b/Swiften/Parser/StreamErrorParser.cpp index d222c40..f4530f9 100644 --- a/Swiften/Parser/StreamErrorParser.cpp +++ b/Swiften/Parser/StreamErrorParser.cpp @@ -11,11 +11,11 @@ namespace Swift { StreamErrorParser::StreamErrorParser() : level(TopLevel) { } -void StreamErrorParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void StreamErrorParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level; } -void StreamErrorParser::handleEndElement(const String& element, const String& ns) { +void StreamErrorParser::handleEndElement(const std::string& element, const std::string& ns) { --level; if (level == ElementLevel && ns == "urn:ietf:params:xml:ns:xmpp-streams") { if (element == "text") { @@ -102,7 +102,7 @@ void StreamErrorParser::handleEndElement(const String& element, const String& ns } } -void StreamErrorParser::handleCharacterData(const String& data) { +void StreamErrorParser::handleCharacterData(const std::string& data) { currentText += data; } diff --git a/Swiften/Parser/StreamErrorParser.h b/Swiften/Parser/StreamErrorParser.h index a2aaa67..61c8c12 100644 --- a/Swiften/Parser/StreamErrorParser.h +++ b/Swiften/Parser/StreamErrorParser.h @@ -14,9 +14,9 @@ namespace Swift { public: StreamErrorParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -24,6 +24,6 @@ namespace Swift { ElementLevel = 1 }; int level; - String currentText; + std::string currentText; }; } diff --git a/Swiften/Parser/StreamFeaturesParser.cpp b/Swiften/Parser/StreamFeaturesParser.cpp index 02e70be..377f215 100644 --- a/Swiften/Parser/StreamFeaturesParser.cpp +++ b/Swiften/Parser/StreamFeaturesParser.cpp @@ -11,7 +11,7 @@ namespace Swift { StreamFeaturesParser::StreamFeaturesParser() : GenericElementParser(), currentDepth_(0), inMechanisms_(false), inMechanism_(false), inCompression_(false), inCompressionMethod_(false) { } -void StreamFeaturesParser::handleStartElement(const String& element, const String& ns, const AttributeMap&) { +void StreamFeaturesParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap&) { if (currentDepth_ == 1) { if (element == "starttls" && ns == "urn:ietf:params:xml:ns:xmpp-tls") { getElementGeneric()->setHasStartTLS(); @@ -45,7 +45,7 @@ void StreamFeaturesParser::handleStartElement(const String& element, const Strin ++currentDepth_; } -void StreamFeaturesParser::handleEndElement(const String&, const String&) { +void StreamFeaturesParser::handleEndElement(const std::string&, const std::string&) { --currentDepth_; if (currentDepth_ == 1) { inCompression_ = false; @@ -63,7 +63,7 @@ void StreamFeaturesParser::handleEndElement(const String&, const String&) { } } -void StreamFeaturesParser::handleCharacterData(const String& data) { +void StreamFeaturesParser::handleCharacterData(const std::string& data) { currentText_ += data; } diff --git a/Swiften/Parser/StreamFeaturesParser.h b/Swiften/Parser/StreamFeaturesParser.h index a12644d..ee65a2a 100644 --- a/Swiften/Parser/StreamFeaturesParser.h +++ b/Swiften/Parser/StreamFeaturesParser.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_STREAMFEATURESPARSER_H #define SWIFTEN_STREAMFEATURESPARSER_H -#include "Swiften/Base/String.h" +#include #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/StreamFeatures.h" @@ -17,13 +17,13 @@ namespace Swift { StreamFeaturesParser(); private: - void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes); - void handleEndElement(const String& element, const String& ns); - void handleCharacterData(const String& data); + void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes); + void handleEndElement(const std::string& element, const std::string& ns); + void handleCharacterData(const std::string& data); private: int currentDepth_; - String currentText_; + std::string currentText_; bool inMechanisms_; bool inMechanism_; bool inCompression_; diff --git a/Swiften/Parser/UnitTest/ParserTester.h b/Swiften/Parser/UnitTest/ParserTester.h index bdb9291..970c1be 100644 --- a/Swiften/Parser/UnitTest/ParserTester.h +++ b/Swiften/Parser/UnitTest/ParserTester.h @@ -25,19 +25,19 @@ namespace Swift { delete xmlParser_; } - bool parse(const String& data) { + bool parse(const std::string& data) { return xmlParser_->parse(data); } - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { parser_->handleStartElement(element, ns, attributes); } - virtual void handleEndElement(const String& element, const String& ns) { + virtual void handleEndElement(const std::string& element, const std::string& ns) { parser_->handleEndElement(element, ns); } - virtual void handleCharacterData(const String& data) { + virtual void handleCharacterData(const std::string& data) { parser_->handleCharacterData(data); } diff --git a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp b/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp index 668846f..8e49764 100644 --- a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp +++ b/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp @@ -91,12 +91,12 @@ class PayloadParserFactoryCollectionTest : public CppUnit::TestFixture private: struct DummyFactory : public PayloadParserFactory { - DummyFactory(const String& element = "") : element(element) {} - virtual bool canParse(const String& e, const String&, const AttributeMap&) const { - return element.isEmpty() ? true : element == e; + DummyFactory(const std::string& element = "") : element(element) {} + virtual bool canParse(const std::string& e, const std::string&, const AttributeMap&) const { + return element.empty() ? true : element == e; } virtual PayloadParser* createPayloadParser() { return NULL; } - String element; + std::string element; }; }; diff --git a/Swiften/Parser/UnitTest/SerializingParserTest.cpp b/Swiften/Parser/UnitTest/SerializingParserTest.cpp index e7018a2..c0af493 100644 --- a/Swiften/Parser/UnitTest/SerializingParserTest.cpp +++ b/Swiften/Parser/UnitTest/SerializingParserTest.cpp @@ -35,7 +35,7 @@ class SerializingParserTest : public CppUnit::TestFixture "" "")); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "Hello<&World" "foobarbaz" @@ -45,7 +45,7 @@ class SerializingParserTest : public CppUnit::TestFixture void testParse_Empty() { SerializingParser testling; - CPPUNIT_ASSERT_EQUAL(String(""), testling.getResult()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResult()); } void testParse_ToplevelCharacterData() { @@ -57,7 +57,7 @@ class SerializingParserTest : public CppUnit::TestFixture testling.handleEndElement("message", ""); testling.handleCharacterData("bar"); - CPPUNIT_ASSERT_EQUAL(String(""), testling.getResult()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResult()); } }; diff --git a/Swiften/Parser/UnitTest/StanzaParserTest.cpp b/Swiften/Parser/UnitTest/StanzaParserTest.cpp index 48d24da..d57f798 100644 --- a/Swiften/Parser/UnitTest/StanzaParserTest.cpp +++ b/Swiften/Parser/UnitTest/StanzaParserTest.cpp @@ -115,7 +115,7 @@ class StanzaParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(JID("foo@example.com/blo"), testling.getStanza()->getTo()); CPPUNIT_ASSERT_EQUAL(JID("bar@example.com/baz"), testling.getStanza()->getFrom()); - CPPUNIT_ASSERT_EQUAL(String("id-123"), testling.getStanza()->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("id-123"), testling.getStanza()->getID()); } private: @@ -132,14 +132,14 @@ class StanzaParserTest : public CppUnit::TestFixture { public: MyPayload1Parser() {} - virtual void handleStartElement(const String& element, const String&, const AttributeMap&) { + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap&) { if (element != "mypayload1") { getPayloadInternal()->hasChild = true; } } - virtual void handleEndElement(const String&, const String&) {} - virtual void handleCharacterData(const String&) {} + virtual void handleEndElement(const std::string&, const std::string&) {} + virtual void handleCharacterData(const std::string&) {} }; class MyPayload1ParserFactory : public PayloadParserFactory @@ -149,7 +149,7 @@ class StanzaParserTest : public CppUnit::TestFixture { PayloadParser* createPayloadParser() { return new MyPayload1Parser(); } - bool canParse(const String& element, const String&, const AttributeMap&) const { + bool canParse(const std::string& element, const std::string&, const AttributeMap&) const { return element == "mypayload1"; } }; @@ -165,9 +165,9 @@ class StanzaParserTest : public CppUnit::TestFixture { public: MyPayload2Parser() {} - virtual void handleStartElement(const String&, const String&, const AttributeMap&) {} - virtual void handleEndElement(const String&, const String&) {} - virtual void handleCharacterData(const String&) {} + virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) {} + virtual void handleEndElement(const std::string&, const std::string&) {} + virtual void handleCharacterData(const std::string&) {} }; @@ -177,7 +177,7 @@ class StanzaParserTest : public CppUnit::TestFixture { MyPayload2ParserFactory() {} PayloadParser* createPayloadParser() { return new MyPayload2Parser(); } - bool canParse(const String& element, const String&, const AttributeMap&) const { + bool canParse(const std::string& element, const std::string&, const AttributeMap&) const { return element == "mypayload2"; } }; diff --git a/Swiften/Parser/UnitTest/XMLParserTest.cpp b/Swiften/Parser/UnitTest/XMLParserTest.cpp index 2aae4cd..426b7a0 100644 --- a/Swiften/Parser/UnitTest/XMLParserTest.cpp +++ b/Swiften/Parser/UnitTest/XMLParserTest.cpp @@ -8,7 +8,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Parser/XMLParserClient.h" #ifdef HAVE_EXPAT #include "Swiften/Parser/ExpatParser.h" @@ -45,23 +45,23 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast(4), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(static_cast(1), client_.events[0].attributes.size()); - CPPUNIT_ASSERT_EQUAL(String("get"), client_.events[0].attributes["type"]); - CPPUNIT_ASSERT_EQUAL(String(), client_.events[0].ns); + CPPUNIT_ASSERT_EQUAL(std::string("get"), client_.events[0].attributes["type"]); + CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[0].ns); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[1].data); CPPUNIT_ASSERT_EQUAL(static_cast(0), client_.events[1].attributes.size()); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[1].ns); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[2].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[2].ns); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[2].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[3].data); - CPPUNIT_ASSERT_EQUAL(String(), client_.events[3].ns); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[3].ns); } void testParse_ElementInNamespacedElement() { @@ -75,24 +75,24 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast(5), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(static_cast(0), client_.events[0].attributes.size()); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[0].ns); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[0].ns); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("name"), client_.events[1].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[1].ns); + CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("Swift"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("Swift"), client_.events[2].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("name"), client_.events[3].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[3].ns); + CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[3].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[4].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[4].ns); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[4].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[4].ns); } void testParse_CharacterData() { @@ -103,25 +103,25 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast(7), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("html"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].data); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("i"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[2].data); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("bli"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string("bli"), client_.events[3].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type); - CPPUNIT_ASSERT_EQUAL(String("i"), client_.events[4].data); + CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[4].data); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[5].type); - CPPUNIT_ASSERT_EQUAL(String("blo"), client_.events[5].data); + CPPUNIT_ASSERT_EQUAL(std::string("blo"), client_.events[5].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[6].type); - CPPUNIT_ASSERT_EQUAL(String("html"), client_.events[6].data); + CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[6].data); } void testParse_NamespacePrefix() { @@ -132,20 +132,20 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast(4), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("x"), client_.events[0].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[0].ns); + CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[0].ns); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("y"), client_.events[1].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[1].ns); + CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("y"), client_.events[2].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[2].ns); + CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[2].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("x"), client_.events[3].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[3].ns); + CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[3].ns); } void testParse_UnhandledXML() { @@ -156,10 +156,10 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast(2), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data); } void testParse_InvalidXML() { @@ -184,10 +184,10 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast(2), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data); } void testParse_WhitespaceInAttribute() { @@ -199,11 +199,11 @@ class XMLParserTest : public CppUnit::TestFixture { "")); CPPUNIT_ASSERT_EQUAL(static_cast(3), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("presence"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[1].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("presence"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[2].data); } private: @@ -213,30 +213,30 @@ class XMLParserTest : public CppUnit::TestFixture { struct Event { Event( Type type, - const String& data, - const String& ns, + const std::string& data, + const std::string& ns, const AttributeMap& attributes) : type(type), data(data), ns(ns), attributes(attributes) {} - Event(Type type, const String& data, const String& ns = String()) + Event(Type type, const std::string& data, const std::string& ns = std::string()) : type(type), data(data), ns(ns) {} Type type; - String data; - String ns; + std::string data; + std::string ns; AttributeMap attributes; }; Client() {} - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { events.push_back(Event(StartElement, element, ns, attributes)); } - virtual void handleEndElement(const String& element, const String& ns) { + virtual void handleEndElement(const std::string& element, const std::string& ns) { events.push_back(Event(EndElement, element, ns)); } - virtual void handleCharacterData(const String& data) { + virtual void handleCharacterData(const std::string& data) { events.push_back(Event(CharacterData, data)); } diff --git a/Swiften/Parser/UnitTest/XMPPParserTest.cpp b/Swiften/Parser/UnitTest/XMPPParserTest.cpp index 1eaa798..8ce96d8 100644 --- a/Swiften/Parser/UnitTest/XMPPParserTest.cpp +++ b/Swiften/Parser/UnitTest/XMPPParserTest.cpp @@ -9,7 +9,7 @@ #include #include "Swiften/Elements/ProtocolHeader.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Parser/XMPPParser.h" #include "Swiften/Parser/ElementParser.h" #include "Swiften/Parser/XMPPParserClient.h" @@ -49,7 +49,7 @@ class XMPPParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(5, static_cast(client_.events.size())); CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("example.com"), client_.events[0].header->getTo()); + CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getTo()); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[3].type); @@ -64,8 +64,8 @@ class XMPPParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(client_.events.size())); CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("example.com"), client_.events[0].header->getFrom()); - CPPUNIT_ASSERT_EQUAL(String("aeab"), client_.events[0].header->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getFrom()); + CPPUNIT_ASSERT_EQUAL(std::string("aeab"), client_.events[0].header->getID()); } diff --git a/Swiften/Parser/UnknownPayloadParser.h b/Swiften/Parser/UnknownPayloadParser.h index c652cf1..8750f22 100644 --- a/Swiften/Parser/UnknownPayloadParser.h +++ b/Swiften/Parser/UnknownPayloadParser.h @@ -12,15 +12,15 @@ #include "Swiften/Parser/PayloadParser.h" namespace Swift { - class String; + class UnknownPayloadParser : public PayloadParser { public: UnknownPayloadParser() {} - virtual void handleStartElement(const String&, const String&, const AttributeMap&) {} - virtual void handleEndElement(const String&, const String&) {} - virtual void handleCharacterData(const String&) {} + virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) {} + virtual void handleEndElement(const std::string&, const std::string&) {} + virtual void handleCharacterData(const std::string&) {} virtual boost::shared_ptr getPayload() const { return boost::shared_ptr(); diff --git a/Swiften/Parser/XMLParser.h b/Swiften/Parser/XMLParser.h index 80d23f4..69a6ecf 100644 --- a/Swiften/Parser/XMLParser.h +++ b/Swiften/Parser/XMLParser.h @@ -4,11 +4,12 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#ifndef SWIFTEN_XMLParser_H -#define SWIFTEN_XMLParser_H +#pragma once + +#include namespace Swift { - class String; + class XMLParserClient; class XMLParser { @@ -16,7 +17,7 @@ namespace Swift { XMLParser(XMLParserClient* client); virtual ~XMLParser(); - virtual bool parse(const String& data) = 0; + virtual bool parse(const std::string& data) = 0; protected: XMLParserClient* getClient() const { @@ -27,5 +28,3 @@ namespace Swift { XMLParserClient* client_; }; } - -#endif diff --git a/Swiften/Parser/XMLParserClient.h b/Swiften/Parser/XMLParserClient.h index 9c2df6f..089ef35 100644 --- a/Swiften/Parser/XMLParserClient.h +++ b/Swiften/Parser/XMLParserClient.h @@ -10,15 +10,15 @@ #include "Swiften/Parser/AttributeMap.h" namespace Swift { - class String; + class XMLParserClient { public: virtual ~XMLParserClient(); - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) = 0; - virtual void handleEndElement(const String& element, const String& ns) = 0; - virtual void handleCharacterData(const String& data) = 0; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) = 0; + virtual void handleEndElement(const std::string& element, const std::string& ns) = 0; + virtual void handleCharacterData(const std::string& data) = 0; }; } diff --git a/Swiften/Parser/XMPPParser.cpp b/Swiften/Parser/XMPPParser.cpp index b274c94..1fb7682 100644 --- a/Swiften/Parser/XMPPParser.cpp +++ b/Swiften/Parser/XMPPParser.cpp @@ -10,7 +10,7 @@ #include #include "Swiften/Elements/ProtocolHeader.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Parser/XMLParser.h" #include "Swiften/Parser/PlatformXMLParserFactory.h" #include "Swiften/Parser/XMPPParserClient.h" @@ -62,12 +62,12 @@ XMPPParser::~XMPPParser() { delete xmlParser_; } -bool XMPPParser::parse(const String& data) { +bool XMPPParser::parse(const std::string& data) { bool xmlParseResult = xmlParser_->parse(data); return xmlParseResult && !parseErrorOccurred_; } -void XMPPParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void XMPPParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (!parseErrorOccurred_) { if (level_ == TopLevel) { if (element == "stream" && ns == "http://etherx.jabber.org/streams") { @@ -93,7 +93,7 @@ void XMPPParser::handleStartElement(const String& element, const String& ns, con ++level_; } -void XMPPParser::handleEndElement(const String& element, const String& ns) { +void XMPPParser::handleEndElement(const std::string& element, const std::string& ns) { assert(level_ > TopLevel); --level_; if (!parseErrorOccurred_) { @@ -113,7 +113,7 @@ void XMPPParser::handleEndElement(const String& element, const String& ns) { } } -void XMPPParser::handleCharacterData(const String& data) { +void XMPPParser::handleCharacterData(const std::string& data) { if (!parseErrorOccurred_) { if (currentElementParser_) { currentElementParser_->handleCharacterData(data); @@ -124,7 +124,7 @@ void XMPPParser::handleCharacterData(const String& data) { } } -ElementParser* XMPPParser::createElementParser(const String& element, const String& ns) { +ElementParser* XMPPParser::createElementParser(const std::string& element, const std::string& ns) { if (element == "presence") { return new PresenceParser(payloadParserFactories_); } diff --git a/Swiften/Parser/XMPPParser.h b/Swiften/Parser/XMPPParser.h index c1a9323..8a00995 100644 --- a/Swiften/Parser/XMPPParser.h +++ b/Swiften/Parser/XMPPParser.h @@ -16,7 +16,7 @@ namespace Swift { class XMLParser; class XMPPParserClient; - class String; + class ElementParser; class PayloadParserFactoryCollection; @@ -27,17 +27,17 @@ namespace Swift { PayloadParserFactoryCollection* payloadParserFactories); ~XMPPParser(); - bool parse(const String&); + bool parse(const std::string&); private: virtual void handleStartElement( - const String& element, - const String& ns, + const std::string& element, + const std::string& ns, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String& ns); - virtual void handleCharacterData(const String& data); + virtual void handleEndElement(const std::string& element, const std::string& ns); + virtual void handleCharacterData(const std::string& data); - ElementParser* createElementParser(const String& element, const String& xmlns); + ElementParser* createElementParser(const std::string& element, const std::string& xmlns); private: XMLParser* xmlParser_; diff --git a/Swiften/Parser/XMPPParserClient.h b/Swiften/Parser/XMPPParserClient.h index 24b78e2..1ddb86d 100644 --- a/Swiften/Parser/XMPPParserClient.h +++ b/Swiften/Parser/XMPPParserClient.h @@ -11,7 +11,7 @@ #include "Swiften/Elements/Element.h" namespace Swift { - class String; + class ProtocolHeader; class XMPPParserClient { diff --git a/Swiften/Presence/PresenceOracle.h b/Swiften/Presence/PresenceOracle.h index 4e16e41..f98e1cd 100644 --- a/Swiften/Presence/PresenceOracle.h +++ b/Swiften/Presence/PresenceOracle.h @@ -8,7 +8,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Presence.h" #include "Swiften/Base/boost_bsignals.h" diff --git a/Swiften/Presence/SubscriptionManager.h b/Swiften/Presence/SubscriptionManager.h index fdf3c04..ad55f9d 100644 --- a/Swiften/Presence/SubscriptionManager.h +++ b/Swiften/Presence/SubscriptionManager.h @@ -8,7 +8,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Elements/Presence.h" @@ -33,9 +33,9 @@ namespace Swift { * received. This is useful when the subscriber adds extensions to * the request. */ - boost::signal onPresenceSubscriptionRequest; + boost::signal onPresenceSubscriptionRequest; - boost::signal onPresenceSubscriptionRevoked; + boost::signal onPresenceSubscriptionRevoked; private: void handleIncomingPresence(Presence::ref presence); diff --git a/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp index 3a6487a..132c865 100644 --- a/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp +++ b/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp @@ -44,7 +44,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->sendPresence(Presence::create("bar")); CPPUNIT_ASSERT_EQUAL(1, static_cast(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex(0)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex(0)->getStatus()); CPPUNIT_ASSERT(stanzaChannel->getStanzaAtIndex(0)->getPayload()); } @@ -55,7 +55,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->sendPresence(Presence::create("bar")); CPPUNIT_ASSERT_EQUAL(1, static_cast(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex(0)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex(0)->getStatus()); CPPUNIT_ASSERT(!stanzaChannel->getStanzaAtIndex(0)->getPayload()); } @@ -76,7 +76,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->setPayload(MyPayload::create("foo")); CPPUNIT_ASSERT_EQUAL(2, static_cast(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex(1)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex(1)->getStatus()); CPPUNIT_ASSERT(stanzaChannel->getStanzaAtIndex(1)->getPayload()); } @@ -102,7 +102,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->setPayload(MyPayload::create("foo")); CPPUNIT_ASSERT_EQUAL(3, static_cast(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex(2)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex(2)->getStatus()); } private: @@ -114,13 +114,13 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { struct MyPayload : public Payload { typedef boost::shared_ptr ref; - MyPayload(const String& body) : body(body) {} + MyPayload(const std::string& body) : body(body) {} - static ref create(const String& body) { + static ref create(const std::string& body) { return ref(new MyPayload(body)); } - String body; + std::string body; }; private: diff --git a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp index aa450a2..24cc62c 100644 --- a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp +++ b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp @@ -122,7 +122,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { } void testSubscriptionRequest() { - String reasonText = "Because I want to"; + std::string reasonText = "Because I want to"; JID sentJID = JID("me@example.com"); boost::shared_ptr sentPresence(new Presence()); @@ -147,14 +147,14 @@ class PresenceOracleTest : public CppUnit::TestFixture { } private: - Presence::ref makeOnline(const String& resource, int priority) { + Presence::ref makeOnline(const std::string& resource, int priority) { Presence::ref presence(new Presence()); presence->setPriority(priority); presence->setFrom(JID("alice@wonderland.lit/" + resource)); return presence; } - Presence::ref makeOffline(const String& resource) { + Presence::ref makeOffline(const std::string& resource) { Presence::ref presence(new Presence()); presence->setFrom(JID("alice@wonderland.lit" + resource)); presence->setType(Presence::Unavailable); @@ -165,7 +165,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { changes.push_back(newPresence); } - void handlePresenceSubscriptionRequest(const JID& jid, const String& reason) { + void handlePresenceSubscriptionRequest(const JID& jid, const std::string& reason) { SubscriptionRequestInfo subscriptionRequest; subscriptionRequest.jid = jid; subscriptionRequest.reason = reason; @@ -181,7 +181,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { private: struct SubscriptionRequestInfo { JID jid; - String reason; + std::string reason; }; PresenceOracle* oracle_; SubscriptionManager* subscriptionManager_; diff --git a/Swiften/QA/ClientTest/ClientTest.cpp b/Swiften/QA/ClientTest/ClientTest.cpp index 0fb02ad..35bb096 100644 --- a/Swiften/QA/ClientTest/ClientTest.cpp +++ b/Swiften/QA/ClientTest/ClientTest.cpp @@ -59,7 +59,7 @@ int main(int, char**) { return -1; } - client = new Swift::Client(JID(jid), String(pass), &networkFactories); + client = new Swift::Client(JID(jid), std::string(pass), &networkFactories); ClientXMLTracer* tracer = new ClientXMLTracer(client); client->onConnected.connect(&handleConnected); client->setAlwaysTrustCertificates(); diff --git a/Swiften/QA/DNSSDTest/DNSSDTest.cpp b/Swiften/QA/DNSSDTest/DNSSDTest.cpp index 7aa7b5e..1bf0965 100644 --- a/Swiften/QA/DNSSDTest/DNSSDTest.cpp +++ b/Swiften/QA/DNSSDTest/DNSSDTest.cpp @@ -65,18 +65,18 @@ class DNSSDTest : public CppUnit::TestFixture { // Check that our registered queries are correct CPPUNIT_ASSERT_EQUAL(1, static_cast((registered.size()))); - CPPUNIT_ASSERT_EQUAL(String("DNSSDTest"), registered[0].getName()); - CPPUNIT_ASSERT_EQUAL(String("local"), registered[0].getDomain()); - CPPUNIT_ASSERT_EQUAL(String("_presence._tcp"), registered[0].getType()); + CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), registered[0].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("local"), registered[0].getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), registered[0].getType()); // Check that our browse query discovered us std::sort(added.begin(), added.end()); CPPUNIT_ASSERT(added.size() >= 1); //for (size_t i = 0; i < added.size(); ++i) { for (size_t i = 0; i < added.size(); ++i) { - CPPUNIT_ASSERT_EQUAL(String("DNSSDTest"), added[i].getName()); - CPPUNIT_ASSERT_EQUAL(String("local"), added[i].getDomain()); - CPPUNIT_ASSERT_EQUAL(String("_presence._tcp"), added[i].getType()); + CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), added[i].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("local"), added[i].getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), added[i].getType()); CPPUNIT_ASSERT(added[i].getNetworkInterfaceID() != 0); } diff --git a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp index 57e7a5a..82a8be2 100644 --- a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp +++ b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp @@ -8,7 +8,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Network/BoostConnectionServer.h" #include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/EventLoop/DummyEventLoop.h" diff --git a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp index 61572a0..928e3db 100644 --- a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp +++ b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp @@ -9,7 +9,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/sleep.h" #include "Swiften/Network/BoostConnection.h" #include "Swiften/Network/HostAddress.h" diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp index b0316fe..a0a7e7b 100644 --- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp +++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp @@ -11,7 +11,7 @@ #include #include "Swiften/Base/sleep.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" #include "Swiften/Network/PlatformDomainNameResolver.h" #include "Swiften/Network/DomainNameAddressQuery.h" @@ -147,19 +147,19 @@ class DomainNameResolverTest : public CppUnit::TestFixture { waitForResults(); CPPUNIT_ASSERT_EQUAL(4, static_cast(serviceQueryResult.size())); - CPPUNIT_ASSERT_EQUAL(String("xmpp1.test.swift.im"), serviceQueryResult[0].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp1.test.swift.im"), serviceQueryResult[0].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[0].port); CPPUNIT_ASSERT_EQUAL(0, serviceQueryResult[0].priority); CPPUNIT_ASSERT_EQUAL(1, serviceQueryResult[0].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp-invalid.test.swift.im"), serviceQueryResult[1].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp-invalid.test.swift.im"), serviceQueryResult[1].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[1].port); CPPUNIT_ASSERT_EQUAL(1, serviceQueryResult[1].priority); CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[1].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp3.test.swift.im"), serviceQueryResult[2].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp3.test.swift.im"), serviceQueryResult[2].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[2].port); CPPUNIT_ASSERT_EQUAL(3, serviceQueryResult[2].priority); CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[2].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp2.test.swift.im"), serviceQueryResult[3].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp2.test.swift.im"), serviceQueryResult[3].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[3].port); CPPUNIT_ASSERT_EQUAL(5, serviceQueryResult[3].priority); CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[3].weight); @@ -169,7 +169,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture { } private: - boost::shared_ptr createAddressQuery(const String& domain) { + boost::shared_ptr createAddressQuery(const std::string& domain) { boost::shared_ptr result = resolver->createAddressQuery(domain); result->onResult.connect(boost::bind(&DomainNameResolverTest::handleAddressQueryResult, this, _1, _2)); return result; @@ -183,7 +183,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture { resultsAvailable = true; } - boost::shared_ptr createServiceQuery(const String& domain) { + boost::shared_ptr createServiceQuery(const std::string& domain) { boost::shared_ptr result = resolver->createServiceQuery(domain); result->onResult.connect(boost::bind(&DomainNameResolverTest::handleServiceQueryResult, this, _1)); return result; diff --git a/Swiften/QA/ReconnectTest/ReconnectTest.cpp b/Swiften/QA/ReconnectTest/ReconnectTest.cpp index e74ae27..117cfa3 100644 --- a/Swiften/QA/ReconnectTest/ReconnectTest.cpp +++ b/Swiften/QA/ReconnectTest/ReconnectTest.cpp @@ -61,7 +61,7 @@ int main(int, char**) { } JID jid(jidChars); - String pass(passChars); + std::string pass(passChars); client_ = new Swift::Client(jid, pass); handleTick(boost::shared_ptr()); diff --git a/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp b/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp index b8e9fd4..925c775 100644 --- a/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp +++ b/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp @@ -34,7 +34,7 @@ class FileReadBytestreamTest : public CppUnit::TestFixture { ByteArray result = testling->read(10); - CPPUNIT_ASSERT_EQUAL(String("/*\n * Copy"), result.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("/*\n * Copy"), result.toString()); } void testRead_Twice() { @@ -43,7 +43,7 @@ class FileReadBytestreamTest : public CppUnit::TestFixture { testling->read(10); ByteArray result = testling->read(10); - CPPUNIT_ASSERT_EQUAL(String("right (c) "), result.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("right (c) "), result.toString()); } void testIsFinished_NotFinished() { diff --git a/Swiften/QA/StorageTest/VCardFileStorageTest.cpp b/Swiften/QA/StorageTest/VCardFileStorageTest.cpp index 7ef1fd5..992ee50 100644 --- a/Swiften/QA/StorageTest/VCardFileStorageTest.cpp +++ b/Swiften/QA/StorageTest/VCardFileStorageTest.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "Swiften/VCards/VCardFileStorage.h" #include "Swiften/JID/JID.h" @@ -44,7 +45,7 @@ class VCardFileStorageTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(boost::filesystem::exists(vcardFile)); ByteArray data; data.readFromFile(vcardFile.string()); - CPPUNIT_ASSERT(data.toString().beginsWith("")); + CPPUNIT_ASSERT(boost::starts_with(data.toString(), "")); } void testGetVCard() { @@ -54,7 +55,7 @@ class VCardFileStorageTest : public CppUnit::TestFixture { testling->setVCard(JID("alice@wonderland.lit"), vcard); VCard::ref result = testling->getVCard(JID("alice@wonderland.lit")); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), result->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), result->getFullName()); } void testGetVCard_FileDoesNotExist() { diff --git a/Swiften/QA/TLSTest/CertificateTest.cpp b/Swiften/QA/TLSTest/CertificateTest.cpp index 769272b..0f37fde 100644 --- a/Swiften/QA/TLSTest/CertificateTest.cpp +++ b/Swiften/QA/TLSTest/CertificateTest.cpp @@ -42,7 +42,7 @@ class CertificateTest : public CppUnit::TestFixture { void testConstructFromDER() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getCommonNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getCommonNames()[0]); } void testToDER() { @@ -55,7 +55,7 @@ class CertificateTest : public CppUnit::TestFixture { void testGetSubjectName() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); - CPPUNIT_ASSERT_EQUAL(String("/description=114072-VMk8pdi1aj5kTXxO/C=US/ST=Colorado/L=Denver/O=Peter Saint-Andre/OU=StartCom Trusted Certificate Member/CN=*.jabber.org/emailAddress=hostmaster@jabber.org"), testling->getSubjectName()); + CPPUNIT_ASSERT_EQUAL(std::string("/description=114072-VMk8pdi1aj5kTXxO/C=US/ST=Colorado/L=Denver/O=Peter Saint-Andre/OU=StartCom Trusted Certificate Member/CN=*.jabber.org/emailAddress=hostmaster@jabber.org"), testling->getSubjectName()); } */ @@ -63,29 +63,29 @@ class CertificateTest : public CppUnit::TestFixture { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(1, static_cast(testling->getCommonNames().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getCommonNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getCommonNames()[0]); } void testGetSRVNames() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(1, static_cast(testling->getSRVNames().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getSRVNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getSRVNames()[0]); } void testGetDNSNames() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(2, static_cast(testling->getDNSNames().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getDNSNames()[0]); - CPPUNIT_ASSERT_EQUAL(String("jabber.org"), testling->getDNSNames()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getDNSNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("jabber.org"), testling->getDNSNames()[1]); } void testGetXMPPAddresses() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(1, static_cast(testling->getXMPPAddresses().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getXMPPAddresses()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getXMPPAddresses()[0]); } private: diff --git a/Swiften/Queries/DummyIQChannel.h b/Swiften/Queries/DummyIQChannel.h index 92b7f2b..f740b5c 100644 --- a/Swiften/Queries/DummyIQChannel.h +++ b/Swiften/Queries/DummyIQChannel.h @@ -19,7 +19,7 @@ namespace Swift { iqs_.push_back(iq); } - virtual String getNewIQID() { + virtual std::string getNewIQID() { return "test-id"; } diff --git a/Swiften/Queries/GetResponder.h b/Swiften/Queries/GetResponder.h index 2201b95..ca3b677 100644 --- a/Swiften/Queries/GetResponder.h +++ b/Swiften/Queries/GetResponder.h @@ -15,6 +15,6 @@ namespace Swift { GetResponder(IQRouter* router) : Responder(router) {} private: - virtual bool handleSetRequest(const JID&, const JID&, const String&, boost::shared_ptr) { return false; } + virtual bool handleSetRequest(const JID&, const JID&, const std::string&, boost::shared_ptr) { return false; } }; } diff --git a/Swiften/Queries/IQChannel.h b/Swiften/Queries/IQChannel.h index e700b51..22b7572 100644 --- a/Swiften/Queries/IQChannel.h +++ b/Swiften/Queries/IQChannel.h @@ -10,7 +10,7 @@ #include "Swiften/Base/boost_bsignals.h" #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/IQ.h" namespace Swift { @@ -19,7 +19,7 @@ namespace Swift { virtual ~IQChannel(); virtual void sendIQ(boost::shared_ptr) = 0; - virtual String getNewIQID() = 0; + virtual std::string getNewIQID() = 0; virtual bool isAvailable() const = 0; diff --git a/Swiften/Queries/IQRouter.cpp b/Swiften/Queries/IQRouter.cpp index a08668a..1bfff70 100644 --- a/Swiften/Queries/IQRouter.cpp +++ b/Swiften/Queries/IQRouter.cpp @@ -87,7 +87,7 @@ void IQRouter::sendIQ(boost::shared_ptr iq) { channel_->sendIQ(iq); } -String IQRouter::getNewIQID() { +std::string IQRouter::getNewIQID() { return channel_->getNewIQID(); } diff --git a/Swiften/Queries/IQRouter.h b/Swiften/Queries/IQRouter.h index 42fa6e9..312dca8 100644 --- a/Swiften/Queries/IQRouter.h +++ b/Swiften/Queries/IQRouter.h @@ -9,7 +9,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/IQ.h" namespace Swift { @@ -45,7 +45,7 @@ namespace Swift { * it. */ void sendIQ(boost::shared_ptr iq); - String getNewIQID(); + std::string getNewIQID(); bool isAvailable(); diff --git a/Swiften/Queries/Request.h b/Swiften/Queries/Request.h index 4ed8dc2..eee89e9 100644 --- a/Swiften/Queries/Request.h +++ b/Swiften/Queries/Request.h @@ -11,7 +11,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Queries/IQHandler.h" #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/Payload.h" @@ -66,7 +66,7 @@ namespace Swift { IQ::Type type_; JID receiver_; boost::shared_ptr payload_; - String id_; + std::string id_; bool sent_; }; } diff --git a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp index 71c6cf0..b7c36cb 100644 --- a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp +++ b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp @@ -26,8 +26,8 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { public: class MyPayload : public Payload { public: - MyPayload(const String& text = "") : text(text) {} - String text; + MyPayload(const std::string& text = "") : text(text) {} + std::string text; }; public: @@ -61,7 +61,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { channel->onIQReceived(createResponse("test-id", "foo")); CPPUNIT_ASSERT_EQUAL(1, static_cast(responses.size())); - CPPUNIT_ASSERT_EQUAL(String("foo"), boost::dynamic_pointer_cast(responses[0])->text); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), boost::dynamic_pointer_cast(responses[0])->text); } void testHandleResponse_Error() { @@ -84,7 +84,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { } } - boost::shared_ptr createResponse(const String& id, const String& text) { + boost::shared_ptr createResponse(const std::string& id, const std::string& text) { boost::shared_ptr iq(new IQ(IQ::Result)); boost::shared_ptr storage(new PrivateStorage()); storage->setPayload(boost::shared_ptr(new MyPayload(text))); @@ -93,7 +93,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { return iq; } - boost::shared_ptr createError(const String& id) { + boost::shared_ptr createError(const std::string& id) { boost::shared_ptr iq(new IQ(IQ::Error)); iq->setID(id); return iq; diff --git a/Swiften/Queries/Responder.h b/Swiften/Queries/Responder.h index 322ba60..2ce8f10 100644 --- a/Swiften/Queries/Responder.h +++ b/Swiften/Queries/Responder.h @@ -57,40 +57,40 @@ namespace Swift { * * This method is implemented in the concrete subclasses. */ - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr payload) = 0; + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr payload) = 0; /** * Handle an incoming IQ-Set request containing a payload of class PAYLOAD_TYPE. * * This method is implemented in the concrete subclasses. */ - virtual bool handleSetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr payload) = 0; + virtual bool handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr payload) = 0; /** * Convenience function for sending an IQ response. */ - void sendResponse(const JID& to, const String& id, boost::shared_ptr payload) { + void sendResponse(const JID& to, const std::string& id, boost::shared_ptr payload) { router_->sendIQ(IQ::createResult(to, id, payload)); } /** * Convenience function for sending an IQ response, with a specific from address. */ - void sendResponse(const JID& to, const JID& from, const String& id, boost::shared_ptr payload) { + void sendResponse(const JID& to, const JID& from, const std::string& id, boost::shared_ptr payload) { router_->sendIQ(IQ::createResult(to, from, id, payload)); } /** * Convenience function for responding with an error. */ - void sendError(const JID& to, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { + void sendError(const JID& to, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { router_->sendIQ(IQ::createError(to, id, condition, type)); } /** * Convenience function for responding with an error from a specific from address. */ - void sendError(const JID& to, const JID& from, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { + void sendError(const JID& to, const JID& from, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { router_->sendIQ(IQ::createError(to, from, id, condition, type)); } diff --git a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp index cc58114..0b8362c 100644 --- a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp +++ b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp @@ -12,12 +12,12 @@ namespace Swift { SoftwareVersionResponder::SoftwareVersionResponder(IQRouter* router) : GetResponder(router) { } -void SoftwareVersionResponder::setVersion(const String& client, const String& version) { +void SoftwareVersionResponder::setVersion(const std::string& client, const std::string& version) { this->client = client; this->version = version; } -bool SoftwareVersionResponder::handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr) { +bool SoftwareVersionResponder::handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr) { sendResponse(from, id, boost::shared_ptr(new SoftwareVersion(client, version))); return true; } diff --git a/Swiften/Queries/Responders/SoftwareVersionResponder.h b/Swiften/Queries/Responders/SoftwareVersionResponder.h index 9da82b0..f6a3d52 100644 --- a/Swiften/Queries/Responders/SoftwareVersionResponder.h +++ b/Swiften/Queries/Responders/SoftwareVersionResponder.h @@ -16,13 +16,13 @@ namespace Swift { public: SoftwareVersionResponder(IQRouter* router); - void setVersion(const String& client, const String& version); + void setVersion(const std::string& client, const std::string& version); private: - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr payload); private: - String client; - String version; + std::string client; + std::string version; }; } diff --git a/Swiften/Queries/SetResponder.h b/Swiften/Queries/SetResponder.h index a04be64..ec3460c 100644 --- a/Swiften/Queries/SetResponder.h +++ b/Swiften/Queries/SetResponder.h @@ -15,6 +15,6 @@ namespace Swift { SetResponder(IQRouter* router) : Responder(router) {} private: - virtual bool handleGetRequest(const JID&, const JID&, const String&, boost::shared_ptr) { return false; } + virtual bool handleGetRequest(const JID&, const JID&, const std::string&, boost::shared_ptr) { return false; } }; } diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp index 5013053..e99149e 100644 --- a/Swiften/Queries/UnitTest/RequestTest.cpp +++ b/Swiften/Queries/UnitTest/RequestTest.cpp @@ -30,8 +30,8 @@ class RequestTest : public CppUnit::TestFixture { public: class MyPayload : public Payload { public: - MyPayload(const String& s = "") : text_(s) {} - String text_; + MyPayload(const std::string& s = "") : text_(s) {} + std::string text_; }; typedef GenericRequest MyRequest; @@ -57,7 +57,7 @@ class RequestTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast(channel_->iqs_.size())); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getTo()); CPPUNIT_ASSERT_EQUAL(IQ::Set, channel_->iqs_[0]->getType()); - CPPUNIT_ASSERT_EQUAL(String("test-id"), channel_->iqs_[0]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("test-id"), channel_->iqs_[0]->getID()); } void testSendGet() { @@ -140,19 +140,19 @@ class RequestTest : public CppUnit::TestFixture { else { boost::shared_ptr payload(boost::dynamic_pointer_cast(p)); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("bar"), payload->text_); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), payload->text_); ++responsesReceived_; } } - boost::shared_ptr createResponse(const String& id) { + boost::shared_ptr createResponse(const std::string& id) { boost::shared_ptr iq(new IQ(IQ::Result)); iq->addPayload(responsePayload_); iq->setID(id); return iq; } - boost::shared_ptr createError(const String& id) { + boost::shared_ptr createError(const std::string& id) { boost::shared_ptr iq(new IQ(IQ::Error)); iq->setID(id); return iq; diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp index 97eb0c6..c087827 100644 --- a/Swiften/Queries/UnitTest/ResponderTest.cpp +++ b/Swiften/Queries/UnitTest/ResponderTest.cpp @@ -128,15 +128,15 @@ class ResponderTest : public CppUnit::TestFixture { public: MyResponder(IQRouter* router) : Responder(router), getRequestResponse_(true), setRequestResponse_(true) {} - virtual bool handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr payload) { + virtual bool handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); - CPPUNIT_ASSERT_EQUAL(String("myid"), id); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), id); getPayloads_.push_back(payload); return getRequestResponse_; } - virtual bool handleSetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr payload) { + virtual bool handleSetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); - CPPUNIT_ASSERT_EQUAL(String("myid"), id); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), id); setPayloads_.push_back(payload); return setRequestResponse_; } diff --git a/Swiften/Roster/RosterPushResponder.h b/Swiften/Roster/RosterPushResponder.h index ea7cff5..b38914b 100644 --- a/Swiften/Roster/RosterPushResponder.h +++ b/Swiften/Roster/RosterPushResponder.h @@ -20,7 +20,7 @@ namespace Swift { boost::signal)> onRosterReceived; private: - virtual bool handleSetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr payload) { + virtual bool handleSetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr payload) { onRosterReceived(payload); sendResponse(from, id, boost::shared_ptr()); return true; diff --git a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp index cabf2bf..4ef1cc1 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp @@ -65,7 +65,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(static_cast(0), xmppRoster_->getGroupsForJID(jid1_).size()); CPPUNIT_ASSERT(xmppRoster_->containsJID(jid1_)); - CPPUNIT_ASSERT_EQUAL(String("Bob"), xmppRoster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("Bob"), xmppRoster_->getNameForJID(jid1_)); } void testModify() { @@ -85,7 +85,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("Bob2"), xmppRoster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("Bob2"), xmppRoster_->getNameForJID(jid1_)); } void testRemove() { @@ -135,7 +135,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { boost::shared_ptr payload4(new RosterPayload()); RosterItemPayload item(jid3_, "Jane", RosterItemPayload::Both); - String janesGroup("Jane's Group"); + std::string janesGroup("Jane's Group"); item.addGroup(janesGroup); payload4->addItem(item); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id4", payload4)); @@ -156,14 +156,14 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { boost::shared_ptr payload6(new RosterPayload()); RosterItemPayload item2(jid2_, "Little Alice", RosterItemPayload::Both); - String alicesGroup("Alice's Group"); + std::string alicesGroup("Alice's Group"); item2.addGroup(alicesGroup); payload6->addItem(item2); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id6", payload6)); CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("Little Alice"), xmppRoster_->getNameForJID(jid2_)); - CPPUNIT_ASSERT_EQUAL(String("Jane"), xmppRoster_->getNameForJID(jid3_)); + CPPUNIT_ASSERT_EQUAL(std::string("Little Alice"), xmppRoster_->getNameForJID(jid2_)); + CPPUNIT_ASSERT_EQUAL(std::string("Jane"), xmppRoster_->getNameForJID(jid3_)); CPPUNIT_ASSERT_EQUAL(static_cast(1), xmppRoster_->getGroupsForJID(jid2_).size()); CPPUNIT_ASSERT_EQUAL(alicesGroup, xmppRoster_->getGroupsForJID(jid2_)[0]); CPPUNIT_ASSERT_EQUAL(static_cast(1), xmppRoster_->getGroupsForJID(jid3_).size()); diff --git a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp index 77993ea..edb8271 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp @@ -45,21 +45,21 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { 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_EQUAL(std::string("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); 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_)); - CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("NameTwo"), roster_->getNameForJID(jid2_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid2_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); 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_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), roster_->getNameForJID(jid3_)); CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid3_)); } @@ -73,7 +73,7 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { 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_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName2"), roster_->getNameForJID(jid1_)); roster_->addContact(jid2_, "NewName3", groups1_, RosterItemPayload::Both); handler_->reset(); roster_->removeContact(jid2_); @@ -89,13 +89,13 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { 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_EQUAL(std::string("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); 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_)); + CPPUNIT_ASSERT_EQUAL(std::string("NameTwo"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid1_)); } @@ -105,8 +105,8 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { JID jid1_; JID jid2_; JID jid3_; - std::vector groups1_; - std::vector groups2_; + std::vector groups1_; + std::vector groups2_; }; CPPUNIT_TEST_SUITE_REGISTRATION(XMPPRosterImplTest); diff --git a/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h b/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h index 5e15e9f..1bbd8e9 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h +++ b/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h @@ -34,11 +34,11 @@ public: return lastJID_; } - String getLastOldName() { + std::string getLastOldName() { return lastOldName_; } - std::vector getLastOldGroups() { + std::vector getLastOldGroups() { return lastOldGroups_; } @@ -57,7 +57,7 @@ private: lastEvent_ = Remove; } - void handleJIDUpdated(const JID& jid, const String& oldName, const std::vector& oldGroups) { + void handleJIDUpdated(const JID& jid, const std::string& oldName, const std::vector& oldGroups) { CPPUNIT_ASSERT_EQUAL(None, lastEvent_); lastJID_ = jid; lastOldName_ = oldName; @@ -67,7 +67,7 @@ private: XMPPRosterEvents lastEvent_; JID lastJID_; - String lastOldName_; - std::vector lastOldGroups_; + std::string lastOldName_; + std::vector lastOldGroups_; }; diff --git a/Swiften/Roster/XMPPRoster.h b/Swiften/Roster/XMPPRoster.h index 676e8f9..958c1f6 100644 --- a/Swiften/Roster/XMPPRoster.h +++ b/Swiften/Roster/XMPPRoster.h @@ -11,7 +11,7 @@ #include #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/JID/JID.h" #include "Swiften/Elements/RosterItemPayload.h" #include @@ -41,12 +41,12 @@ namespace Swift { /** * Retrieves the stored roster name for the given jid. */ - virtual String getNameForJID(const JID& jid) const = 0; + virtual std::string getNameForJID(const JID& jid) const = 0; /** * Returns the list of groups for the given JID. */ - virtual std::vector getGroupsForJID(const JID& jid) = 0; + virtual std::vector getGroupsForJID(const JID& jid) = 0; /** * Retrieve the items in the roster. @@ -61,7 +61,7 @@ namespace Swift { /** * Retrieve the list of (existing) groups. */ - virtual std::set getGroups() const = 0; + virtual std::set getGroups() const = 0; public: /** @@ -78,7 +78,7 @@ namespace Swift { * Emitted when the name or the groups of the roster item with the * given JID changes. */ - boost::signal&)> onJIDUpdated; + boost::signal&)> onJIDUpdated; /** * Emitted when the roster is reset (e.g. due to logging in/logging out). diff --git a/Swiften/Roster/XMPPRosterController.h b/Swiften/Roster/XMPPRosterController.h index 073a233..28c2541 100644 --- a/Swiften/Roster/XMPPRosterController.h +++ b/Swiften/Roster/XMPPRosterController.h @@ -9,7 +9,7 @@ #include #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/RosterPayload.h" #include "Swiften/Roster/RosterPushResponder.h" diff --git a/Swiften/Roster/XMPPRosterImpl.cpp b/Swiften/Roster/XMPPRosterImpl.cpp index 3e9e312..8086806 100644 --- a/Swiften/Roster/XMPPRosterImpl.cpp +++ b/Swiften/Roster/XMPPRosterImpl.cpp @@ -12,12 +12,12 @@ namespace Swift { XMPPRosterImpl::XMPPRosterImpl() { } -void XMPPRosterImpl::addContact(const JID& jid, const String& name, const std::vector& groups, RosterItemPayload::Subscription subscription) { +void XMPPRosterImpl::addContact(const JID& jid, const std::string& name, const std::vector& groups, RosterItemPayload::Subscription subscription) { JID bareJID(jid.toBare()); std::map::iterator i = entries_.find(bareJID); if (i != entries_.end()) { - String oldName = i->second.getName(); - std::vector oldGroups = i->second.getGroups(); + std::string oldName = i->second.getName(); + std::vector oldGroups = i->second.getGroups(); i->second = XMPPRosterItem(jid, name, groups, subscription); onJIDUpdated(bareJID, oldName, oldGroups); } @@ -41,7 +41,7 @@ bool XMPPRosterImpl::containsJID(const JID& jid) { return entries_.find(JID(jid.toBare())) != entries_.end(); } -String XMPPRosterImpl::getNameForJID(const JID& jid) const { +std::string XMPPRosterImpl::getNameForJID(const JID& jid) const { std::map::const_iterator i = entries_.find(jid.toBare()); if (i != entries_.end()) { return i->second.getName(); @@ -51,13 +51,13 @@ String XMPPRosterImpl::getNameForJID(const JID& jid) const { } } -std::vector XMPPRosterImpl::getGroupsForJID(const JID& jid) { +std::vector XMPPRosterImpl::getGroupsForJID(const JID& jid) { std::map::iterator i = entries_.find(jid.toBare()); if (i != entries_.end()) { return i->second.getGroups(); } else { - return std::vector(); + return std::vector(); } } @@ -89,10 +89,10 @@ boost::optional XMPPRosterImpl::getItem(const JID& jid) const { } } -std::set XMPPRosterImpl::getGroups() const { - std::set result; +std::set XMPPRosterImpl::getGroups() const { + std::set result; foreach(const RosterMap::value_type& entry, entries_) { - std::vector groups = entry.second.getGroups(); + std::vector groups = entry.second.getGroups(); result.insert(groups.begin(), groups.end()); } return result; diff --git a/Swiften/Roster/XMPPRosterImpl.h b/Swiften/Roster/XMPPRosterImpl.h index f65683f..a44a1ce 100644 --- a/Swiften/Roster/XMPPRosterImpl.h +++ b/Swiften/Roster/XMPPRosterImpl.h @@ -16,18 +16,18 @@ namespace Swift { public: XMPPRosterImpl(); - void addContact(const JID& jid, const String& name, const std::vector& groups, const RosterItemPayload::Subscription subscription); + void addContact(const JID& jid, const std::string& name, const std::vector& groups, const RosterItemPayload::Subscription subscription); void removeContact(const JID& jid); void clear(); bool containsJID(const JID& jid); RosterItemPayload::Subscription getSubscriptionStateForJID(const JID& jid); - String getNameForJID(const JID& jid) const; - std::vector getGroupsForJID(const JID& jid); + std::string getNameForJID(const JID& jid) const; + std::vector getGroupsForJID(const JID& jid); virtual std::vector getItems() const; virtual boost::optional getItem(const JID&) const; - virtual std::set getGroups() const; + virtual std::set getGroups() const; private: typedef std::map RosterMap; diff --git a/Swiften/Roster/XMPPRosterItem.h b/Swiften/Roster/XMPPRosterItem.h index ceb7763..c821cbf 100644 --- a/Swiften/Roster/XMPPRosterItem.h +++ b/Swiften/Roster/XMPPRosterItem.h @@ -9,33 +9,33 @@ #include -#include +#include #include #include namespace Swift { class XMPPRosterItem { public: - XMPPRosterItem(const JID& jid, const String& name, const std::vector& groups, RosterItemPayload::Subscription subscription) : jid(jid), name(name), groups(groups), subscription(subscription) { + XMPPRosterItem(const JID& jid, const std::string& name, const std::vector& groups, RosterItemPayload::Subscription subscription) : jid(jid), name(name), groups(groups), subscription(subscription) { } const JID& getJID() const { return jid; } - const String& getName() const { + const std::string& getName() const { return name; } - void setName(const String& name) { + void setName(const std::string& name) { this->name = name; } - const std::vector& getGroups() const { + const std::vector& getGroups() const { return groups; } - void setGroups(const std::vector& groups) { + void setGroups(const std::vector& groups) { this->groups = groups; } @@ -45,8 +45,8 @@ namespace Swift { private: JID jid; - String name; - std::vector groups; + std::string name; + std::vector groups; RosterItemPayload::Subscription subscription; }; } diff --git a/Swiften/SASL/ClientAuthenticator.cpp b/Swiften/SASL/ClientAuthenticator.cpp index 4eae2b4..533f172 100644 --- a/Swiften/SASL/ClientAuthenticator.cpp +++ b/Swiften/SASL/ClientAuthenticator.cpp @@ -8,7 +8,7 @@ namespace Swift { -ClientAuthenticator::ClientAuthenticator(const String& name) : name(name) { +ClientAuthenticator::ClientAuthenticator(const std::string& name) : name(name) { } ClientAuthenticator::~ClientAuthenticator() { diff --git a/Swiften/SASL/ClientAuthenticator.h b/Swiften/SASL/ClientAuthenticator.h index 718ccdc..33db75f 100644 --- a/Swiften/SASL/ClientAuthenticator.h +++ b/Swiften/SASL/ClientAuthenticator.h @@ -8,20 +8,20 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" namespace Swift { class ClientAuthenticator { public: - ClientAuthenticator(const String& name); + ClientAuthenticator(const std::string& name); virtual ~ClientAuthenticator(); - const String& getName() const { + const std::string& getName() const { return name; } - void setCredentials(const String& authcid, const String& password, const String& authzid = String()) { + void setCredentials(const std::string& authcid, const std::string& password, const std::string& authzid = std::string()) { this->authcid = authcid; this->password = password; this->authzid = authzid; @@ -30,22 +30,22 @@ namespace Swift { virtual boost::optional getResponse() const = 0; virtual bool setChallenge(const boost::optional&) = 0; - const String& getAuthenticationID() const { + const std::string& getAuthenticationID() const { return authcid; } - const String& getAuthorizationID() const { + const std::string& getAuthorizationID() const { return authzid; } - const String& getPassword() const { + const std::string& getPassword() const { return password; } private: - String name; - String authcid; - String password; - String authzid; + std::string name; + std::string authcid; + std::string password; + std::string authzid; }; } diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp index 050b73b..6892948 100644 --- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp +++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp @@ -13,7 +13,7 @@ namespace Swift { -DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const String& host, const String& nonce) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce) { +DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce) { } boost::optional DIGESTMD5ClientAuthenticator::getResponse() const { @@ -21,29 +21,29 @@ boost::optional DIGESTMD5ClientAuthenticator::getResponse() const { return boost::optional(); } else if (step == Response) { - String realm; + std::string realm; if (challenge.getValue("realm")) { realm = *challenge.getValue("realm"); } - String qop = "auth"; - String digestURI = "xmpp/" + host; - String nc = "00000001"; + std::string qop = "auth"; + std::string digestURI = "xmpp/" + host; + std::string nc = "00000001"; // Compute the response value ByteArray A1 = MD5::getHash(getAuthenticationID() + ":" + realm + ":" + getPassword()) + ":" + *challenge.getValue("nonce") + ":" + cnonce; - if (!getAuthorizationID().isEmpty()) { + if (!getAuthorizationID().empty()) { A1 += ":" + getAuthenticationID(); } - String A2 = "AUTHENTICATE:" + digestURI; + std::string A2 = "AUTHENTICATE:" + digestURI; - String responseValue = Hexify::hexify(MD5::getHash( + std::string responseValue = Hexify::hexify(MD5::getHash( Hexify::hexify(MD5::getHash(A1)) + ":" + *challenge.getValue("nonce") + ":" + nc + ":" + cnonce + ":" + qop + ":" + Hexify::hexify(MD5::getHash(A2)))); DIGESTMD5Properties response; response.setValue("username", getAuthenticationID()); - if (!realm.isEmpty()) { + if (!realm.empty()) { response.setValue("realm", realm); } response.setValue("nonce", *challenge.getValue("nonce")); @@ -53,7 +53,7 @@ boost::optional DIGESTMD5ClientAuthenticator::getResponse() const { response.setValue("digest-uri", digestURI); response.setValue("charset", "utf-8"); response.setValue("response", responseValue); - if (!getAuthorizationID().isEmpty()) { + if (!getAuthorizationID().empty()) { response.setValue("authzid", getAuthorizationID()); } return response.serialize(); diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.h b/Swiften/SASL/DIGESTMD5ClientAuthenticator.h index 457bde9..50dd9aa 100644 --- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.h +++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.h @@ -8,7 +8,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" #include "Swiften/SASL/ClientAuthenticator.h" #include "Swiften/SASL/DIGESTMD5Properties.h" @@ -16,7 +16,7 @@ namespace Swift { class DIGESTMD5ClientAuthenticator : public ClientAuthenticator { public: - DIGESTMD5ClientAuthenticator(const String& host, const String& nonce); + DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce); virtual boost::optional getResponse() const; virtual bool setChallenge(const boost::optional&); @@ -27,8 +27,8 @@ namespace Swift { Response, Final, } step; - String host; - String cnonce; + std::string host; + std::string cnonce; DIGESTMD5Properties challenge; }; } diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp index 571602b..c7a2474 100644 --- a/Swiften/SASL/DIGESTMD5Properties.cpp +++ b/Swiften/SASL/DIGESTMD5Properties.cpp @@ -58,7 +58,7 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) { } else { if (c == ',' && !insideQuotes(currentValue)) { - String key = currentKey.toString(); + std::string key = currentKey.toString(); if (isQuoted(key)) { result.setValue(key, stripQuotes(currentValue).toString()); } @@ -76,7 +76,7 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) { } if (!currentKey.isEmpty()) { - String key = currentKey.toString(); + std::string key = currentKey.toString(); if (isQuoted(key)) { result.setValue(key, stripQuotes(currentValue).toString()); } @@ -106,21 +106,21 @@ ByteArray DIGESTMD5Properties::serialize() const { return result; } -boost::optional DIGESTMD5Properties::getValue(const String& key) const { +boost::optional DIGESTMD5Properties::getValue(const std::string& key) const { DIGESTMD5PropertiesMap::const_iterator i = properties.find(key); if (i != properties.end()) { return i->second.toString(); } else { - return boost::optional(); + return boost::optional(); } } -void DIGESTMD5Properties::setValue(const String& key, const String& value) { +void DIGESTMD5Properties::setValue(const std::string& key, const std::string& value) { properties.insert(DIGESTMD5PropertiesMap::value_type(key, ByteArray(value))); } -bool DIGESTMD5Properties::isQuoted(const String& p) { +bool DIGESTMD5Properties::isQuoted(const std::string& p) { return p == "authzid" || p == "cnonce" || p == "digest-uri" || p == "nonce" || p == "realm" || p == "username"; } diff --git a/Swiften/SASL/DIGESTMD5Properties.h b/Swiften/SASL/DIGESTMD5Properties.h index 3afd369..6e2e592 100644 --- a/Swiften/SASL/DIGESTMD5Properties.h +++ b/Swiften/SASL/DIGESTMD5Properties.h @@ -9,7 +9,7 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" namespace Swift { @@ -17,19 +17,19 @@ namespace Swift { public: DIGESTMD5Properties(); - boost::optional getValue(const String& key) const; + boost::optional getValue(const std::string& key) const; - void setValue(const String& key, const String& value); + void setValue(const std::string& key, const std::string& value); ByteArray serialize() const; static DIGESTMD5Properties parse(const ByteArray&); private: - static bool isQuoted(const String& property); + static bool isQuoted(const std::string& property); private: - typedef std::multimap DIGESTMD5PropertiesMap; + typedef std::multimap DIGESTMD5PropertiesMap; DIGESTMD5PropertiesMap properties; }; } diff --git a/Swiften/SASL/PLAINMessage.cpp b/Swiften/SASL/PLAINMessage.cpp index c2621a3..3728b39 100644 --- a/Swiften/SASL/PLAINMessage.cpp +++ b/Swiften/SASL/PLAINMessage.cpp @@ -8,7 +8,7 @@ namespace Swift { -PLAINMessage::PLAINMessage(const String& authcid, const String& password, const String& authzid) : authcid(authcid), authzid(authzid), password(password) { +PLAINMessage::PLAINMessage(const std::string& authcid, const std::string& password, const std::string& authzid) : authcid(authcid), authzid(authzid), password(password) { } PLAINMessage::PLAINMessage(const ByteArray& value) { @@ -37,8 +37,8 @@ PLAINMessage::PLAINMessage(const ByteArray& value) { } ByteArray PLAINMessage::getValue() const { - String s = authzid + '\0' + authcid + '\0' + password; - return ByteArray(s.getUTF8Data(), s.getUTF8Size()); + std::string s = authzid + '\0' + authcid + '\0' + password; + return ByteArray(s.c_str(), s.size()); } } diff --git a/Swiften/SASL/PLAINMessage.h b/Swiften/SASL/PLAINMessage.h index 3624c6e..d08d70d 100644 --- a/Swiften/SASL/PLAINMessage.h +++ b/Swiften/SASL/PLAINMessage.h @@ -8,32 +8,32 @@ // #pragma once -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" namespace Swift { class PLAINMessage { public: - PLAINMessage(const String& authcid, const String& password, const String& authzid = ""); + PLAINMessage(const std::string& authcid, const std::string& password, const std::string& authzid = ""); PLAINMessage(const ByteArray& value); ByteArray getValue() const; - const String& getAuthenticationID() const { + const std::string& getAuthenticationID() const { return authcid; } - const String& getPassword() const { + const std::string& getPassword() const { return password; } - const String& getAuthorizationID() const { + const std::string& getAuthorizationID() const { return authzid; } private: - String authcid; - String authzid; - String password; + std::string authcid; + std::string authzid; + std::string password; }; } diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp index b8c89c6..72d535a 100644 --- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp +++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp @@ -18,9 +18,9 @@ namespace Swift { -static String escape(const String& s) { - String result; - for (size_t i = 0; i < s.getUTF8Size(); ++i) { +static std::string escape(const std::string& s) { + std::string result; + for (size_t i = 0; i < s.size(); ++i) { if (s[i] == ',') { result += "=2C"; } @@ -35,7 +35,7 @@ static String escape(const String& s) { } -SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const String& nonce, bool useChannelBinding) : ClientAuthenticator(useChannelBinding ? "SCRAM-SHA-1-PLUS" : "SCRAM-SHA-1"), step(Initial), clientnonce(nonce), useChannelBinding(useChannelBinding) { +SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding) : ClientAuthenticator(useChannelBinding ? "SCRAM-SHA-1-PLUS" : "SCRAM-SHA-1"), step(Initial), clientnonce(nonce), useChannelBinding(useChannelBinding) { } boost::optional SCRAMSHA1ClientAuthenticator::getResponse() const { @@ -65,26 +65,26 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional } initialServerMessage = *challenge; - std::map keys = parseMap(String(initialServerMessage.getData(), initialServerMessage.getSize())); + std::map keys = parseMap(std::string(initialServerMessage.getData(), initialServerMessage.getSize())); // Extract the salt ByteArray salt = Base64::decode(keys['s']); // Extract the server nonce - String clientServerNonce = keys['r']; - if (clientServerNonce.getUTF8Size() <= clientnonce.getUTF8Size()) { + std::string clientServerNonce = keys['r']; + if (clientServerNonce.size() <= clientnonce.size()) { return false; } - String receivedClientNonce = clientServerNonce.getSubstring(0, clientnonce.getUTF8Size()); + std::string receivedClientNonce = clientServerNonce.substr(0, clientnonce.size()); if (receivedClientNonce != clientnonce) { return false; } - serverNonce = clientServerNonce.getSubstring(clientnonce.getUTF8Size(), clientServerNonce.npos()); + serverNonce = clientServerNonce.substr(clientnonce.size(), clientServerNonce.npos); // Extract the number of iterations int iterations = 0; try { - iterations = boost::lexical_cast(keys['i'].getUTF8String()); + iterations = boost::lexical_cast(keys['i']); } catch (const boost::bad_lexical_cast&) { return false; @@ -117,14 +117,14 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional } } -std::map SCRAMSHA1ClientAuthenticator::parseMap(const String& s) { - std::map result; - if (s.getUTF8Size() > 0) { +std::map SCRAMSHA1ClientAuthenticator::parseMap(const std::string& s) { + std::map result; + if (s.size() > 0) { char key = 0; - String value; + std::string value; size_t i = 0; bool expectKey = true; - while (i < s.getUTF8Size()) { + while (i < s.size()) { if (expectKey) { key = s[i]; expectKey = false; @@ -146,8 +146,8 @@ std::map SCRAMSHA1ClientAuthenticator::parseMap(const String& s) { } ByteArray SCRAMSHA1ClientAuthenticator::getInitialBareClientMessage() const { - String authenticationID = StringPrep::getPrepared(getAuthenticationID(), StringPrep::SASLPrep); - return ByteArray(String("n=" + escape(authenticationID) + ",r=" + clientnonce)); + std::string authenticationID = StringPrep::getPrepared(getAuthenticationID(), StringPrep::SASLPrep); + return ByteArray(std::string("n=" + escape(authenticationID) + ",r=" + clientnonce)); } ByteArray SCRAMSHA1ClientAuthenticator::getGS2Header() const { @@ -160,7 +160,7 @@ ByteArray SCRAMSHA1ClientAuthenticator::getGS2Header() const { channelBindingHeader = ByteArray("y"); } } - return channelBindingHeader + ByteArray(",") + (getAuthorizationID().isEmpty() ? "" : "a=" + escape(getAuthorizationID())) + ","; + return channelBindingHeader + ByteArray(",") + (getAuthorizationID().empty() ? "" : "a=" + escape(getAuthorizationID())) + ","; } void SCRAMSHA1ClientAuthenticator::setTLSChannelBindingData(const ByteArray& channelBindingData) { diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h index 2cf3cc7..602fc94 100644 --- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h +++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h @@ -9,14 +9,14 @@ #include #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Base/ByteArray.h" #include "Swiften/SASL/ClientAuthenticator.h" namespace Swift { class SCRAMSHA1ClientAuthenticator : public ClientAuthenticator { public: - SCRAMSHA1ClientAuthenticator(const String& nonce, bool useChannelBinding = false); + SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding = false); void setTLSChannelBindingData(const ByteArray& channelBindingData); @@ -28,7 +28,7 @@ namespace Swift { ByteArray getGS2Header() const; ByteArray getFinalMessageWithoutProof() const; - static std::map parseMap(const String&); + static std::map parseMap(const std::string&); private: enum Step { @@ -36,7 +36,7 @@ namespace Swift { Proof, Final } step; - String clientnonce; + std::string clientnonce; ByteArray initialServerMessage; ByteArray serverNonce; ByteArray authMessage; diff --git a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp index 72c2b64..54f0571 100644 --- a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp +++ b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp @@ -38,7 +38,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=088891c800ecff1b842159ad6459104a,username=\"user\""), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=088891c800ecff1b842159ad6459104a,username=\"user\""), response.toString()); } void testGetResponse_WithAuthorizationID() { @@ -52,7 +52,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("authzid=\"myauthzid\",charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=4293834432b6e7889a2dee7e8fe7dd06,username=\"user\""), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("authzid=\"myauthzid\",charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=4293834432b6e7889a2dee7e8fe7dd06,username=\"user\""), response.toString()); } }; diff --git a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp index 1b2c121..152a41e 100644 --- a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp +++ b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp @@ -24,13 +24,13 @@ class DIGESTMD5PropertiesTest : public CppUnit::TestFixture { "algorithm=md5-sess,charset=utf-8")); CPPUNIT_ASSERT(properties.getValue("realm")); - CPPUNIT_ASSERT_EQUAL(String("myrealm1"), *properties.getValue("realm")); + CPPUNIT_ASSERT_EQUAL(std::string("myrealm1"), *properties.getValue("realm")); CPPUNIT_ASSERT(properties.getValue("nonce")); - CPPUNIT_ASSERT_EQUAL(String("mynonce"), *properties.getValue("nonce")); + CPPUNIT_ASSERT_EQUAL(std::string("mynonce"), *properties.getValue("nonce")); CPPUNIT_ASSERT(properties.getValue("algorithm")); - CPPUNIT_ASSERT_EQUAL(String("md5-sess"), *properties.getValue("algorithm")); + CPPUNIT_ASSERT_EQUAL(std::string("md5-sess"), *properties.getValue("algorithm")); CPPUNIT_ASSERT(properties.getValue("charset")); - CPPUNIT_ASSERT_EQUAL(String("utf-8"), *properties.getValue("charset")); + CPPUNIT_ASSERT_EQUAL(std::string("utf-8"), *properties.getValue("charset")); } void testSerialize() { diff --git a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp index 142d09e..d517f0d 100644 --- a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp +++ b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp @@ -40,29 +40,29 @@ class PLAINMessageTest : public CppUnit::TestFixture void testConstructor_WithoutAuthzID() { PLAINMessage message(ByteArray("\0user\0pass", 10)); - CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthorizationID()); - CPPUNIT_ASSERT_EQUAL(String("user"), message.getAuthenticationID()); - CPPUNIT_ASSERT_EQUAL(String("pass"), message.getPassword()); + CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthorizationID()); + CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string("pass"), message.getPassword()); } void testConstructor_WithAuthzID() { PLAINMessage message(ByteArray("authz\0user\0pass", 15)); - CPPUNIT_ASSERT_EQUAL(String("authz"), message.getAuthorizationID()); - CPPUNIT_ASSERT_EQUAL(String("user"), message.getAuthenticationID()); - CPPUNIT_ASSERT_EQUAL(String("pass"), message.getPassword()); + CPPUNIT_ASSERT_EQUAL(std::string("authz"), message.getAuthorizationID()); + CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string("pass"), message.getPassword()); } void testConstructor_NoAuthcid() { PLAINMessage message(ByteArray("authzid", 7)); - CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID()); } void testConstructor_NoPassword() { PLAINMessage message(ByteArray("authzid\0authcid", 15)); - CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID()); } }; diff --git a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp index 0e42f38..5d0edbd 100644 --- a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp +++ b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp @@ -45,7 +45,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_UsernameHasSpecialChars() { @@ -54,7 +54,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithAuthorizationID() { @@ -63,7 +63,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,a=auth,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,a=auth,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() { @@ -72,7 +72,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() { @@ -82,7 +82,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("y,,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("y,,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() { @@ -92,7 +92,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetFinalResponse() { @@ -102,7 +102,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response.toString()); } void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() { @@ -113,7 +113,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response.toString()); } void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() { @@ -124,7 +124,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response.toString()); } void testSetFinalChallenge() { diff --git a/Swiften/Serializer/AuthChallengeSerializer.cpp b/Swiften/Serializer/AuthChallengeSerializer.cpp index 883763f..dcded43 100644 --- a/Swiften/Serializer/AuthChallengeSerializer.cpp +++ b/Swiften/Serializer/AuthChallengeSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthChallengeSerializer::AuthChallengeSerializer() { } -String AuthChallengeSerializer::serialize(boost::shared_ptr element) const { +std::string AuthChallengeSerializer::serialize(boost::shared_ptr element) const { boost::shared_ptr authChallenge(boost::dynamic_pointer_cast(element)); - String value; + std::string value; boost::optional message = authChallenge->getValue(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthChallengeSerializer.h b/Swiften/Serializer/AuthChallengeSerializer.h index 336a88c..a62efb3 100644 --- a/Swiften/Serializer/AuthChallengeSerializer.h +++ b/Swiften/Serializer/AuthChallengeSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: AuthChallengeSerializer(); - virtual String serialize(boost::shared_ptr element) const; + virtual std::string serialize(boost::shared_ptr element) const; }; } diff --git a/Swiften/Serializer/AuthFailureSerializer.h b/Swiften/Serializer/AuthFailureSerializer.h index 7869b1f..477d98c 100644 --- a/Swiften/Serializer/AuthFailureSerializer.h +++ b/Swiften/Serializer/AuthFailureSerializer.h @@ -19,7 +19,7 @@ namespace Swift { AuthFailureSerializer() : GenericElementSerializer() { } - virtual String serialize(boost::shared_ptr) const { + virtual std::string serialize(boost::shared_ptr) const { return XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-sasl").serialize(); } }; diff --git a/Swiften/Serializer/AuthRequestSerializer.cpp b/Swiften/Serializer/AuthRequestSerializer.cpp index 45b6503..0bee302 100644 --- a/Swiften/Serializer/AuthRequestSerializer.cpp +++ b/Swiften/Serializer/AuthRequestSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthRequestSerializer::AuthRequestSerializer() { } -String AuthRequestSerializer::serialize(boost::shared_ptr element) const { +std::string AuthRequestSerializer::serialize(boost::shared_ptr element) const { boost::shared_ptr authRequest(boost::dynamic_pointer_cast(element)); - String value; + std::string value; boost::optional message = authRequest->getMessage(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthRequestSerializer.h b/Swiften/Serializer/AuthRequestSerializer.h index 2680d45..18ef5dd 100644 --- a/Swiften/Serializer/AuthRequestSerializer.h +++ b/Swiften/Serializer/AuthRequestSerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: AuthRequestSerializer(); - virtual String serialize(boost::shared_ptr element) const; + virtual std::string serialize(boost::shared_ptr element) const; }; } diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp index d2d5616..a93b4dd 100644 --- a/Swiften/Serializer/AuthResponseSerializer.cpp +++ b/Swiften/Serializer/AuthResponseSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthResponseSerializer::AuthResponseSerializer() { } -String AuthResponseSerializer::serialize(boost::shared_ptr element) const { +std::string AuthResponseSerializer::serialize(boost::shared_ptr element) const { boost::shared_ptr authResponse(boost::dynamic_pointer_cast(element)); - String value; + std::string value; boost::optional message = authResponse->getValue(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthResponseSerializer.h b/Swiften/Serializer/AuthResponseSerializer.h index b2f4739..cee8ff3 100644 --- a/Swiften/Serializer/AuthResponseSerializer.h +++ b/Swiften/Serializer/AuthResponseSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: AuthResponseSerializer(); - virtual String serialize(boost::shared_ptr element) const; + virtual std::string serialize(boost::shared_ptr element) const; }; } diff --git a/Swiften/Serializer/AuthSuccessSerializer.cpp b/Swiften/Serializer/AuthSuccessSerializer.cpp index 6e9103b..443c740 100644 --- a/Swiften/Serializer/AuthSuccessSerializer.cpp +++ b/Swiften/Serializer/AuthSuccessSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthSuccessSerializer::AuthSuccessSerializer() { } -String AuthSuccessSerializer::serialize(boost::shared_ptr element) const { +std::string AuthSuccessSerializer::serialize(boost::shared_ptr element) const { boost::shared_ptr authSuccess(boost::dynamic_pointer_cast(element)); - String value; + std::string value; boost::optional message = authSuccess->getValue(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthSuccessSerializer.h b/Swiften/Serializer/AuthSuccessSerializer.h index 81b0e36..eb3279c 100644 --- a/Swiften/Serializer/AuthSuccessSerializer.h +++ b/Swiften/Serializer/AuthSuccessSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: AuthSuccessSerializer(); - virtual String serialize(boost::shared_ptr element) const; + virtual std::string serialize(boost::shared_ptr element) const; }; } diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.cpp b/Swiften/Serializer/ComponentHandshakeSerializer.cpp index 011d59e..cf44ea4 100644 --- a/Swiften/Serializer/ComponentHandshakeSerializer.cpp +++ b/Swiften/Serializer/ComponentHandshakeSerializer.cpp @@ -13,7 +13,7 @@ namespace Swift { ComponentHandshakeSerializer::ComponentHandshakeSerializer() { } -String ComponentHandshakeSerializer::serialize(boost::shared_ptr element) const { +std::string ComponentHandshakeSerializer::serialize(boost::shared_ptr element) const { boost::shared_ptr handshake(boost::dynamic_pointer_cast(element)); return "" + handshake->getData() + ""; } diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.h b/Swiften/Serializer/ComponentHandshakeSerializer.h index 5423f08..7681e56 100644 --- a/Swiften/Serializer/ComponentHandshakeSerializer.h +++ b/Swiften/Serializer/ComponentHandshakeSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: ComponentHandshakeSerializer(); - virtual String serialize(boost::shared_ptr element) const; + virtual std::string serialize(boost::shared_ptr element) const; }; } diff --git a/Swiften/Serializer/CompressFailureSerializer.h b/Swiften/Serializer/CompressFailureSerializer.h index 608dadb..02a4b46 100644 --- a/Swiften/Serializer/CompressFailureSerializer.h +++ b/Swiften/Serializer/CompressFailureSerializer.h @@ -19,7 +19,7 @@ namespace Swift { CompressFailureSerializer() : GenericElementSerializer() { } - virtual String serialize(boost::shared_ptr) const { + virtual std::string serialize(boost::shared_ptr) const { return XMLElement("failure", "http://jabber.org/protocol/compress").serialize(); } }; diff --git a/Swiften/Serializer/CompressRequestSerializer.cpp b/Swiften/Serializer/CompressRequestSerializer.cpp index 4959665..7733169 100644 --- a/Swiften/Serializer/CompressRequestSerializer.cpp +++ b/Swiften/Serializer/CompressRequestSerializer.cpp @@ -13,7 +13,7 @@ namespace Swift { CompressRequestSerializer::CompressRequestSerializer() { } -String CompressRequestSerializer::serialize(boost::shared_ptr element) const { +std::string CompressRequestSerializer::serialize(boost::shared_ptr element) const { boost::shared_ptr compressRequest(boost::dynamic_pointer_cast(element)); return "" + compressRequest->getMethod() + ""; } diff --git a/Swiften/Serializer/CompressRequestSerializer.h b/Swiften/Serializer/CompressRequestSerializer.h index 49d6c97..0a14fb1 100644 --- a/Swiften/Serializer/CompressRequestSerializer.h +++ b/Swiften/Serializer/CompressRequestSerializer.h @@ -16,7 +16,7 @@ namespace Swift { public: CompressRequestSerializer(); - virtual String serialize(boost::shared_ptr element) const; + virtual std::string serialize(boost::shared_ptr element) const; virtual bool canSerialize(boost::shared_ptr element) const; }; } diff --git a/Swiften/Serializer/ElementSerializer.h b/Swiften/Serializer/ElementSerializer.h index 48d73ee..3abdf08 100644 --- a/Swiften/Serializer/ElementSerializer.h +++ b/Swiften/Serializer/ElementSerializer.h @@ -9,7 +9,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Element.h" namespace Swift { @@ -17,7 +17,7 @@ namespace Swift { public: virtual ~ElementSerializer(); - virtual String serialize(boost::shared_ptr element) const = 0; + virtual std::string serialize(boost::shared_ptr element) const = 0; virtual bool canSerialize(boost::shared_ptr element) const = 0; }; } diff --git a/Swiften/Serializer/EnableStreamManagementSerializer.h b/Swiften/Serializer/EnableStreamManagementSerializer.h index c5a5011..e224a9c 100644 --- a/Swiften/Serializer/EnableStreamManagementSerializer.h +++ b/Swiften/Serializer/EnableStreamManagementSerializer.h @@ -18,7 +18,7 @@ namespace Swift { EnableStreamManagementSerializer() : GenericElementSerializer() { } - virtual String serialize(boost::shared_ptr) const { + virtual std::string serialize(boost::shared_ptr) const { return XMLElement("enable", "urn:xmpp:sm:2").serialize(); } }; diff --git a/Swiften/Serializer/GenericElementSerializer.h b/Swiften/Serializer/GenericElementSerializer.h index 0329411..903c205 100644 --- a/Swiften/Serializer/GenericElementSerializer.h +++ b/Swiften/Serializer/GenericElementSerializer.h @@ -14,7 +14,7 @@ namespace Swift { template class GenericElementSerializer : public ElementSerializer { public: - virtual String serialize(boost::shared_ptr element) const = 0; + virtual std::string serialize(boost::shared_ptr element) const = 0; virtual bool canSerialize(boost::shared_ptr element) const { return boost::dynamic_pointer_cast(element); diff --git a/Swiften/Serializer/GenericPayloadSerializer.h b/Swiften/Serializer/GenericPayloadSerializer.h index 13603e5..b501613 100644 --- a/Swiften/Serializer/GenericPayloadSerializer.h +++ b/Swiften/Serializer/GenericPayloadSerializer.h @@ -14,7 +14,7 @@ namespace Swift { template class GenericPayloadSerializer : public PayloadSerializer { public: - virtual String serialize(boost::shared_ptr element) const { + virtual std::string serialize(boost::shared_ptr element) const { return serializePayload(boost::dynamic_pointer_cast(element)); } @@ -22,6 +22,6 @@ namespace Swift { return boost::dynamic_pointer_cast(element); } - virtual String serializePayload(boost::shared_ptr) const = 0; + virtual std::string serializePayload(boost::shared_ptr) const = 0; }; } diff --git a/Swiften/Serializer/GenericStanzaSerializer.h b/Swiften/Serializer/GenericStanzaSerializer.h index 557fb37..2f0fccf 100644 --- a/Swiften/Serializer/GenericStanzaSerializer.h +++ b/Swiften/Serializer/GenericStanzaSerializer.h @@ -13,7 +13,7 @@ namespace Swift { template class GenericStanzaSerializer : public StanzaSerializer { public: - GenericStanzaSerializer(const String& tag, PayloadSerializerCollection* payloadSerializers) : StanzaSerializer(tag, payloadSerializers) {} + GenericStanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers) : StanzaSerializer(tag, payloadSerializers) {} virtual bool canSerialize(boost::shared_ptr element) const { return dynamic_cast(element.get()) != 0; diff --git a/Swiften/Serializer/PayloadSerializer.h b/Swiften/Serializer/PayloadSerializer.h index dbb984d..34e6679 100644 --- a/Swiften/Serializer/PayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializer.h @@ -9,7 +9,7 @@ #include -#include "Swiften/Base/String.h" +#include #include "Swiften/Elements/Payload.h" namespace Swift { @@ -18,7 +18,7 @@ namespace Swift { virtual ~PayloadSerializer(); virtual bool canSerialize(boost::shared_ptr) const = 0; - virtual String serialize(boost::shared_ptr) const = 0; + virtual std::string serialize(boost::shared_ptr) const = 0; }; } diff --git a/Swiften/Serializer/PayloadSerializerCollection.h b/Swiften/Serializer/PayloadSerializerCollection.h index fdb8657..1b3cbc5 100644 --- a/Swiften/Serializer/PayloadSerializerCollection.h +++ b/Swiften/Serializer/PayloadSerializerCollection.h @@ -13,7 +13,7 @@ namespace Swift { class PayloadSerializer; - class String; + class PayloadSerializerCollection { public: diff --git a/Swiften/Serializer/PayloadSerializers/BodySerializer.h b/Swiften/Serializer/PayloadSerializers/BodySerializer.h index c73f0c4..6fc6e6d 100644 --- a/Swiften/Serializer/PayloadSerializers/BodySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/BodySerializer.h @@ -16,7 +16,7 @@ namespace Swift { public: BodySerializer() : GenericPayloadSerializer() {} - virtual String serializePayload(boost::shared_ptr body) const { + virtual std::string serializePayload(boost::shared_ptr body) const { XMLTextNode textNode(body->getText()); return "" + textNode.serialize() + ""; } diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp index 9acabee..f9b89f3 100644 --- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp @@ -19,7 +19,7 @@ namespace Swift { BytestreamsSerializer::BytestreamsSerializer() { } -String BytestreamsSerializer::serializePayload(boost::shared_ptr bytestreams) const { +std::string BytestreamsSerializer::serializePayload(boost::shared_ptr bytestreams) const { XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams"); queryElement.setAttribute("sid", bytestreams->getStreamID()); foreach(const Bytestreams::StreamHost& streamHost, bytestreams->getStreamHosts()) { diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h index 50d58c2..d9b14db 100644 --- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: BytestreamsSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp index c7b17bd..ced0d62 100644 --- a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp @@ -15,7 +15,7 @@ namespace Swift { CapsInfoSerializer::CapsInfoSerializer() : GenericPayloadSerializer() { } -String CapsInfoSerializer::serializePayload(boost::shared_ptr capsInfo) const { +std::string CapsInfoSerializer::serializePayload(boost::shared_ptr capsInfo) const { XMLElement capsElement("c", "http://jabber.org/protocol/caps"); capsElement.setAttribute("node", capsInfo->getNode()); capsElement.setAttribute("hash", capsInfo->getHash()); diff --git a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h index a94916b..de0a871 100644 --- a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: CapsInfoSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp index 9f0fe0d..3e877eb 100644 --- a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp @@ -11,8 +11,8 @@ namespace Swift { ChatStateSerializer::ChatStateSerializer() : GenericPayloadSerializer() { } -String ChatStateSerializer::serializePayload(boost::shared_ptr chatState) const { - String result("<"); +std::string ChatStateSerializer::serializePayload(boost::shared_ptr chatState) const { + std::string result("<"); switch (chatState->getChatState()) { case ChatState::Active: result += "active"; break; case ChatState::Composing: result += "composing"; break; diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h index 724f4a1..a786901 100644 --- a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h @@ -14,6 +14,6 @@ namespace Swift { public: ChatStateSerializer(); - virtual String serializePayload(boost::shared_ptr error) const; + virtual std::string serializePayload(boost::shared_ptr error) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp index b29a634..0fa45ce 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp @@ -20,34 +20,34 @@ namespace Swift { CommandSerializer::CommandSerializer() { } -String CommandSerializer::serializePayload(boost::shared_ptr command) const { +std::string CommandSerializer::serializePayload(boost::shared_ptr command) const { XMLElement commandElement("command", "http://jabber.org/protocol/comands"); commandElement.setAttribute("node", command->getNode()); - if (!command->getSessionID().isEmpty()) { + if (!command->getSessionID().empty()) { commandElement.setAttribute("sessionid", command->getSessionID()); } - String action = actionToString(command->getAction()); - if (!action.isEmpty()) { + std::string action = actionToString(command->getAction()); + if (!action.empty()) { commandElement.setAttribute("action", action); } - String status; + std::string status; switch (command->getStatus()) { case Command::Executing: status = "executing";break; case Command::Completed: status = "completed";break; case Command::Canceled: status = "canceled";break; case Command::NoStatus: break; } - if (!status.isEmpty()) { + if (!status.empty()) { commandElement.setAttribute("status", status); } if (command->getAvailableActions().size() > 0) { - String actions = "getExecuteAction()); - if (!executeAction.isEmpty()) { + std::string actions = "getExecuteAction()); + if (!executeAction.empty()) { actions += " execute='" + executeAction + "'"; } actions += ">"; @@ -60,13 +60,13 @@ String CommandSerializer::serializePayload(boost::shared_ptr command) c foreach (Command::Note note, command->getNotes()) { boost::shared_ptr noteElement(new XMLElement("note")); - String type; + std::string type; switch (note.type) { case Command::Note::Info: type = "info"; break; case Command::Note::Warn: type = "warn"; break; case Command::Note::Error: type = "error"; break; } - if (!type.isEmpty()) { + if (!type.empty()) { noteElement->setAttribute("type", type); } noteElement->addNode(boost::shared_ptr(new XMLTextNode(note.note))); @@ -80,8 +80,8 @@ String CommandSerializer::serializePayload(boost::shared_ptr command) c return commandElement.serialize(); } -String CommandSerializer::actionToString(Command::Action action) const { - String string; +std::string CommandSerializer::actionToString(Command::Action action) const { + std::string string; switch (action) { case Command::Cancel: string = "cancel"; break; case Command::Execute: string = "execute"; break; diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h index 4b71aea..b1db825 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h @@ -16,9 +16,9 @@ namespace Swift { public: CommandSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; private: - String actionToString(Command::Action action) const; + std::string actionToString(Command::Action action) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp index a54cf9e..4922042 100644 --- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp @@ -8,6 +8,7 @@ #include +#include #include "Swiften/Serializer/XML/XMLElement.h" namespace Swift { @@ -15,19 +16,19 @@ namespace Swift { DelaySerializer::DelaySerializer() : GenericPayloadSerializer() { } -String DelaySerializer::serializePayload(boost::shared_ptr delay) const { +std::string DelaySerializer::serializePayload(boost::shared_ptr delay) const { XMLElement delayElement("delay", "urn:xmpp:delay"); if (delay->getFrom()) { delayElement.setAttribute("from", delay->getFrom()->toString()); } - String stampString = boostPTimeToXEP0082(delay->getStamp()); + std::string stampString = boostPTimeToXEP0082(delay->getStamp()); delayElement.setAttribute("stamp", stampString); return delayElement.serialize(); } -String DelaySerializer::boostPTimeToXEP0082(const boost::posix_time::ptime& time) { - String stampString = String(boost::posix_time::to_iso_extended_string(time)); - stampString.replaceAll(',', "."); +std::string DelaySerializer::boostPTimeToXEP0082(const boost::posix_time::ptime& time) { + std::string stampString = std::string(boost::posix_time::to_iso_extended_string(time)); + String::replaceAll(stampString, ',', "."); stampString += "Z"; return stampString; } diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h index eb33c9f..c37dc02 100644 --- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h @@ -14,8 +14,8 @@ namespace Swift { public: DelaySerializer(); - virtual String serializePayload(boost::shared_ptr) const; - static String boostPTimeToXEP0082(const boost::posix_time::ptime& time); + virtual std::string serializePayload(boost::shared_ptr) const; + static std::string boostPTimeToXEP0082(const boost::posix_time::ptime& time); }; } diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp index f5923dc..65b0a38 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp @@ -18,14 +18,14 @@ namespace Swift { DiscoInfoSerializer::DiscoInfoSerializer() : GenericPayloadSerializer() { } -String DiscoInfoSerializer::serializePayload(boost::shared_ptr discoInfo) const { +std::string DiscoInfoSerializer::serializePayload(boost::shared_ptr discoInfo) const { XMLElement queryElement("query", "http://jabber.org/protocol/disco#info"); - if (!discoInfo->getNode().isEmpty()) { + if (!discoInfo->getNode().empty()) { queryElement.setAttribute("node", discoInfo->getNode()); } foreach(const DiscoInfo::Identity& identity, discoInfo->getIdentities()) { boost::shared_ptr identityElement(new XMLElement("identity")); - if (!identity.getLanguage().isEmpty()) { + if (!identity.getLanguage().empty()) { identityElement->setAttribute("xml:lang", identity.getLanguage()); } identityElement->setAttribute("category", identity.getCategory()); @@ -33,7 +33,7 @@ String DiscoInfoSerializer::serializePayload(boost::shared_ptr discoI identityElement->setAttribute("type", identity.getType()); queryElement.addNode(identityElement); } - foreach(const String& feature, discoInfo->getFeatures()) { + foreach(const std::string& feature, discoInfo->getFeatures()) { boost::shared_ptr featureElement(new XMLElement("feature")); featureElement->setAttribute("var", feature); queryElement.addNode(featureElement); diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h index 63047d1..46e7ce2 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: DiscoInfoSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp index 056c515..cb1b7c1 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp @@ -16,16 +16,16 @@ namespace Swift { DiscoItemsSerializer::DiscoItemsSerializer() : GenericPayloadSerializer() { } -String DiscoItemsSerializer::serializePayload(boost::shared_ptr discoItems) const { +std::string DiscoItemsSerializer::serializePayload(boost::shared_ptr discoItems) const { XMLElement queryElement("query", "http://jabber.org/protocol/disco#items"); - if (!discoItems->getNode().isEmpty()) { + if (!discoItems->getNode().empty()) { queryElement.setAttribute("node", discoItems->getNode()); } foreach(const DiscoItems::Item& item, discoItems->getItems()) { boost::shared_ptr itemElement(new XMLElement("item")); itemElement->setAttribute("name", item.getName()); itemElement->setAttribute("jid", item.getJID()); - if (!item.getNode().isEmpty()) { + if (!item.getNode().empty()) { itemElement->setAttribute("node", item.getNode()); } queryElement.addNode(itemElement); diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h index 8116e9b..3b00a17 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h @@ -14,7 +14,7 @@ namespace Swift { public: DiscoItemsSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp index d041f6e..15d13d7 100644 --- a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp @@ -12,8 +12,8 @@ namespace Swift { ErrorSerializer::ErrorSerializer() : GenericPayloadSerializer() { } -String ErrorSerializer::serializePayload(boost::shared_ptr error) const { - String result(" error) const { + std::string result("getType()) { case ErrorPayload::Continue: result += "continue"; break; case ErrorPayload::Modify: result += "modify"; break; @@ -23,7 +23,7 @@ String ErrorSerializer::serializePayload(boost::shared_ptr error) } result += "\">"; - String conditionElement; + std::string conditionElement; switch (error->getCondition()) { case ErrorPayload::BadRequest: conditionElement = "bad-request"; break; case ErrorPayload::Conflict: conditionElement = "conflict"; break; @@ -50,7 +50,7 @@ String ErrorSerializer::serializePayload(boost::shared_ptr error) } result += "<" + conditionElement + " xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"; - if (!error->getText().isEmpty()) { + if (!error->getText().empty()) { XMLTextNode textNode(error->getText()); result += "" + textNode.serialize() + ""; } diff --git a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h index ee32279..7fc4dad 100644 --- a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: ErrorSerializer(); - virtual String serializePayload(boost::shared_ptr error) const; + virtual std::string serializePayload(boost::shared_ptr error) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp index 77c2fd4..53b4241 100644 --- a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp @@ -8,9 +8,10 @@ #include #include +#include -#include "Swiften/Base/foreach.h" #include "Swiften/Base/String.h" +#include "Swiften/Base/foreach.h" #include "Swiften/Serializer/XML/XMLTextNode.h" #include "Swiften/Serializer/XML/XMLRawTextNode.h" @@ -18,8 +19,8 @@ using namespace Swift; namespace { template void serializeValueAsString(boost::shared_ptr field, boost::shared_ptr parent) { - String value = boost::dynamic_pointer_cast(field)->getValue(); - if (!value.isEmpty()) { + std::string value = boost::dynamic_pointer_cast(field)->getValue(); + if (!value.empty()) { boost::shared_ptr valueElement(new XMLElement("value")); valueElement->addNode(XMLTextNode::create(value)); parent->addNode(valueElement); @@ -33,9 +34,9 @@ namespace Swift { FormSerializer::FormSerializer() : GenericPayloadSerializer
() { } -String FormSerializer::serializePayload(boost::shared_ptr form) const { +std::string FormSerializer::serializePayload(boost::shared_ptr form) const { boost::shared_ptr formElement(new XMLElement("x", "jabber:x:data")); - String type; + std::string type; switch (form->getType()) { case Form::FormType: type = "form"; break; case Form::SubmitType: type = "submit"; break; @@ -43,10 +44,10 @@ String FormSerializer::serializePayload(boost::shared_ptr form) const { case Form::ResultType: type = "result"; break; } formElement->setAttribute("type", type); - if (!form->getTitle().isEmpty()) { + if (!form->getTitle().empty()) { multiLineify(form->getTitle(), "title", formElement); } - if (!form->getInstructions().isEmpty()) { + if (!form->getInstructions().empty()) { multiLineify(form->getInstructions(), "instructions", formElement); } foreach(boost::shared_ptr field, form->getFields()) { @@ -57,23 +58,23 @@ String FormSerializer::serializePayload(boost::shared_ptr form) const { boost::shared_ptr FormSerializer::fieldToXML(boost::shared_ptr field) const { boost::shared_ptr fieldElement(new XMLElement("field")); - if (!field->getName().isEmpty()) { + if (!field->getName().empty()) { fieldElement->setAttribute("var", field->getName()); } - if (!field->getLabel().isEmpty()) { + if (!field->getLabel().empty()) { fieldElement->setAttribute("label", field->getLabel()); } if (field->getRequired()) { fieldElement->addNode(boost::shared_ptr(new XMLElement("required"))); } - if (!field->getDescription().isEmpty()) { + if (!field->getDescription().empty()) { boost::shared_ptr descriptionElement(new XMLElement("desc")); descriptionElement->addNode(boost::shared_ptr(new XMLTextNode(field->getDescription()))); fieldElement->addNode(descriptionElement); } // Set the value and type - String fieldType; + std::string fieldType; if (boost::dynamic_pointer_cast(field)) { fieldType = "boolean"; boost::shared_ptr valueElement(new XMLElement("value")); @@ -117,8 +118,8 @@ boost::shared_ptr FormSerializer::fieldToXML(boost::shared_ptr(field)) { fieldType = "list-multi"; - std::vector lines = boost::dynamic_pointer_cast(field)->getValue(); - foreach(const String& line, lines) { + std::vector lines = boost::dynamic_pointer_cast(field)->getValue(); + foreach(const std::string& line, lines) { boost::shared_ptr valueElement(new XMLElement("value")); valueElement->addNode(XMLTextNode::create(line)); fieldElement->addNode(valueElement); @@ -129,8 +130,8 @@ boost::shared_ptr FormSerializer::fieldToXML(boost::shared_ptr(field)->getValue(), "value", fieldElement); } else if (boost::dynamic_pointer_cast(field)) { - std::vector lines = boost::dynamic_pointer_cast(field)->getValue(); - foreach(const String& line, lines) { + std::vector lines = boost::dynamic_pointer_cast(field)->getValue(); + foreach(const std::string& line, lines) { boost::shared_ptr valueElement(new XMLElement("value")); valueElement->addNode(XMLTextNode::create(line)); fieldElement->addNode(valueElement); @@ -139,13 +140,13 @@ boost::shared_ptr FormSerializer::fieldToXML(boost::shared_ptrsetAttribute("type", fieldType); } foreach (const FormField::Option& option, field->getOptions()) { boost::shared_ptr optionElement(new XMLElement("option")); - if (!option.label.isEmpty()) { + if (!option.label.empty()) { optionElement->setAttribute("label", option.label); } @@ -159,11 +160,11 @@ boost::shared_ptr FormSerializer::fieldToXML(boost::shared_ptr element) const { - String unRdText(text); - unRdText.removeAll('\r'); - std::vector lines = unRdText.split('\n'); - foreach (String line, lines) { +void FormSerializer::multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr element) const { + std::string unRdText(text); + unRdText.erase(std::remove(unRdText.begin(), unRdText.end(), '\r'), unRdText.end()); + std::vector lines = String::split(unRdText, '\n'); + foreach (std::string line, lines) { boost::shared_ptr lineElement(new XMLElement(elementName)); lineElement->addNode(boost::shared_ptr(new XMLTextNode(line))); element->addNode(lineElement); diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.h b/Swiften/Serializer/PayloadSerializers/FormSerializer.h index 1cdc7f2..86c8dee 100644 --- a/Swiften/Serializer/PayloadSerializers/FormSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.h @@ -16,11 +16,11 @@ namespace Swift { public: FormSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; private: boost::shared_ptr fieldToXML(boost::shared_ptr field) const; - void multiLineify(const String& text, const String& elementName, boost::shared_ptr parent) const; + void multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr parent) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp index 5e52145..7ac4103 100644 --- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp @@ -20,7 +20,7 @@ namespace Swift { IBBSerializer::IBBSerializer() { } -String IBBSerializer::serializePayload(boost::shared_ptr ibb) const { +std::string IBBSerializer::serializePayload(boost::shared_ptr ibb) const { switch(ibb->getAction()) { case IBB::Data: { XMLElement ibbElement("data", "http://jabber.org/protocol/ibb"); diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.h b/Swiften/Serializer/PayloadSerializers/IBBSerializer.h index 71b1c80..d750f6f 100644 --- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: IBBSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp index 5729df6..e4ae11f 100644 --- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp @@ -18,7 +18,7 @@ namespace Swift { InBandRegistrationPayloadSerializer::InBandRegistrationPayloadSerializer() { } -String InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr registration) const { +std::string InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr registration) const { XMLElement registerElement("query", "jabber:iq:register"); if (registration->isRegistered()) { diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h index 168aa3a..45d49ea 100644 --- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h @@ -17,6 +17,6 @@ namespace Swift { public: InBandRegistrationPayloadSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp index dbf79d4..db28514 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp @@ -15,7 +15,7 @@ namespace Swift { MUCOwnerPayloadSerializer::MUCOwnerPayloadSerializer(PayloadSerializerCollection* serializers) : GenericPayloadSerializer(), serializers(serializers) { } -String MUCOwnerPayloadSerializer::serializePayload(boost::shared_ptr mucOwner) const { +std::string MUCOwnerPayloadSerializer::serializePayload(boost::shared_ptr mucOwner) const { XMLElement mucElement("query", "http://jabber.org/protocol/muc#owner"); boost::shared_ptr payload = mucOwner->getPayload(); if (payload) { diff --git a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h index 862cfce..4808744 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h @@ -14,7 +14,7 @@ namespace Swift { class MUCOwnerPayloadSerializer : public GenericPayloadSerializer { public: MUCOwnerPayloadSerializer(PayloadSerializerCollection* serializers); - virtual String serializePayload(boost::shared_ptr version) const; + virtual std::string serializePayload(boost::shared_ptr version) const; private: PayloadSerializerCollection* serializers; }; diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp index 087dece..d7e1613 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp @@ -7,13 +7,14 @@ #include "Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h" #include "Swiften/Serializer/XML/XMLElement.h" +#include namespace Swift { MUCPayloadSerializer::MUCPayloadSerializer() : GenericPayloadSerializer() { } -String MUCPayloadSerializer::serializePayload(boost::shared_ptr muc) const { +std::string MUCPayloadSerializer::serializePayload(boost::shared_ptr muc) const { XMLElement mucElement("x", "http://jabber.org/protocol/muc"); boost::shared_ptr historyElement(new XMLElement("history")); bool history = false; @@ -30,8 +31,8 @@ String MUCPayloadSerializer::serializePayload(boost::shared_ptr muc) history = true; } if (muc->getSince() != boost::posix_time::not_a_date_time) { - String sinceString = String(boost::posix_time::to_iso_extended_string(muc->getSince())); - sinceString.replaceAll(',', "."); + std::string sinceString = std::string(boost::posix_time::to_iso_extended_string(muc->getSince())); + String::replaceAll(sinceString, ',', "."); sinceString += "Z"; historyElement->setAttribute("since", sinceString); history = true; diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h index cd7f107..7038e6e 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h @@ -13,7 +13,7 @@ namespace Swift { class MUCPayloadSerializer : public GenericPayloadSerializer { public: MUCPayloadSerializer(); - virtual String serializePayload(boost::shared_ptr version) const; + virtual std::string serializePayload(boost::shared_ptr version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp index f4732ea..50746a9 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp @@ -20,7 +20,7 @@ namespace Swift { MUCUserPayloadSerializer::MUCUserPayloadSerializer() : GenericPayloadSerializer() { } -String MUCUserPayloadSerializer::serializePayload(boost::shared_ptr payload) const { +std::string MUCUserPayloadSerializer::serializePayload(boost::shared_ptr payload) const { XMLElement mucElement("x", "http://jabber.org/protocol/muc"); foreach (const MUCUserPayload::StatusCode statusCode, payload->getStatusCodes()) { boost::shared_ptr statusElement(new XMLElement("status")); @@ -44,8 +44,8 @@ String MUCUserPayloadSerializer::serializePayload(boost::shared_ptr { public: MUCUserPayloadSerializer(); - String affiliationToString(MUCOccupant::Affiliation affiliation) const; - String roleToString(MUCOccupant::Role role) const; + std::string affiliationToString(MUCOccupant::Affiliation affiliation) const; + std::string roleToString(MUCOccupant::Role role) const; - virtual String serializePayload(boost::shared_ptr version) const; + virtual std::string serializePayload(boost::shared_ptr version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp index 55d5bb6..23d2c25 100644 --- a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp @@ -16,7 +16,7 @@ namespace Swift { NicknameSerializer::NicknameSerializer() : GenericPayloadSerializer() { } -String NicknameSerializer::serializePayload(boost::shared_ptr nick) const { +std::string NicknameSerializer::serializePayload(boost::shared_ptr nick) const { XMLElement nickElement("nick", "http://jabber.org/protocol/nick"); nickElement.addNode(boost::shared_ptr(new XMLTextNode(nick->getNickname()))); return nickElement.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h index e296ffd..e07767b 100644 --- a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h @@ -14,7 +14,7 @@ namespace Swift { public: NicknameSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h index a242215..cc96ce7 100644 --- a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: PrioritySerializer() : GenericPayloadSerializer() {} - virtual String serializePayload(boost::shared_ptr priority) const { + virtual std::string serializePayload(boost::shared_ptr priority) const { return "" + boost::lexical_cast(priority->getPriority()) + ""; } }; diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp index 1964d96..6e1d74d 100644 --- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp @@ -19,7 +19,7 @@ namespace Swift { PrivateStorageSerializer::PrivateStorageSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) { } -String PrivateStorageSerializer::serializePayload(boost::shared_ptr storage) const { +std::string PrivateStorageSerializer::serializePayload(boost::shared_ptr storage) const { XMLElement storageElement("query", "jabber:iq:private"); boost::shared_ptr payload = storage->getPayload(); if (payload) { diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h index 03448be..7b46136 100644 --- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h @@ -16,7 +16,7 @@ namespace Swift { public: PrivateStorageSerializer(PayloadSerializerCollection* serializers); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h index 725a5cd..6874569 100644 --- a/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h @@ -14,7 +14,7 @@ namespace Swift { public: RawXMLPayloadSerializer() : GenericPayloadSerializer() {} - virtual String serializePayload(boost::shared_ptr p) const { + virtual std::string serializePayload(boost::shared_ptr p) const { return p->getRawXML(); } }; diff --git a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp index cdc5764..cfb3a90 100644 --- a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp @@ -16,14 +16,14 @@ namespace Swift { ResourceBindSerializer::ResourceBindSerializer() : GenericPayloadSerializer() { } -String ResourceBindSerializer::serializePayload(boost::shared_ptr resourceBind) const { +std::string ResourceBindSerializer::serializePayload(boost::shared_ptr resourceBind) const { XMLElement bindElement("bind", "urn:ietf:params:xml:ns:xmpp-bind"); if (resourceBind->getJID().isValid()) { boost::shared_ptr jidNode(new XMLElement("jid")); jidNode->addNode(boost::shared_ptr(new XMLTextNode(resourceBind->getJID().toString()))); bindElement.addNode(jidNode); } - else if (!resourceBind->getResource().isEmpty()) { + else if (!resourceBind->getResource().empty()) { boost::shared_ptr resourceNode(new XMLElement("resource")); resourceNode->addNode(boost::shared_ptr(new XMLTextNode(resourceBind->getResource()))); bindElement.addNode(resourceNode); diff --git a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h index 7248863..d259555 100644 --- a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: ResourceBindSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp index b56f404..40faf73 100644 --- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp @@ -18,7 +18,7 @@ namespace Swift { RosterSerializer::RosterSerializer() : GenericPayloadSerializer() { } -String RosterSerializer::serializePayload(boost::shared_ptr roster) const { +std::string RosterSerializer::serializePayload(boost::shared_ptr roster) const { XMLElement queryElement("query", "jabber:iq:roster"); foreach(const RosterItemPayload& item, roster->getItems()) { boost::shared_ptr itemElement(new XMLElement("item")); @@ -37,13 +37,13 @@ String RosterSerializer::serializePayload(boost::shared_ptr roste itemElement->setAttribute("ask", "subscribe"); } - foreach(const String& group, item.getGroups()) { + foreach(const std::string& group, item.getGroups()) { boost::shared_ptr groupElement(new XMLElement("group")); groupElement->addNode(boost::shared_ptr(new XMLTextNode(group))); itemElement->addNode(groupElement); } - if (!item.getUnknownContent().isEmpty()) { + if (!item.getUnknownContent().empty()) { itemElement->addNode(boost::shared_ptr(new XMLRawTextNode(item.getUnknownContent()))); } diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.h b/Swiften/Serializer/PayloadSerializers/RosterSerializer.h index ce73670..49e194b 100644 --- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: RosterSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp index 5d71fd3..a7a9fda 100644 --- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp @@ -18,7 +18,7 @@ namespace Swift { SearchPayloadSerializer::SearchPayloadSerializer() { } -String SearchPayloadSerializer::serializePayload(boost::shared_ptr searchPayload) const { +std::string SearchPayloadSerializer::serializePayload(boost::shared_ptr searchPayload) const { XMLElement searchElement("query", "jabber:iq:search"); if (searchPayload->getInstructions()) { diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h index b64749b..2d8ec85 100644 --- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h @@ -17,6 +17,6 @@ namespace Swift { public: SearchPayloadSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp index 841cb0a..b9ec55e 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp @@ -15,14 +15,14 @@ namespace Swift { SecurityLabelSerializer::SecurityLabelSerializer() : GenericPayloadSerializer() { } -String SecurityLabelSerializer::serializePayload(boost::shared_ptr label) const { +std::string SecurityLabelSerializer::serializePayload(boost::shared_ptr label) const { XMLElement element("securitylabel", "urn:xmpp:sec-label:0"); - if (!label->getDisplayMarking().isEmpty()) { + if (!label->getDisplayMarking().empty()) { boost::shared_ptr displayMarking(new XMLElement("displaymarking")); - if (!label->getForegroundColor().isEmpty()) { + if (!label->getForegroundColor().empty()) { displayMarking->setAttribute("fgcolor", label->getForegroundColor()); } - if (!label->getBackgroundColor().isEmpty()) { + if (!label->getBackgroundColor().empty()) { displayMarking->setAttribute("bgcolor", label->getBackgroundColor()); } displayMarking->addNode(boost::shared_ptr(new XMLTextNode(label->getDisplayMarking()))); @@ -33,7 +33,7 @@ String SecurityLabelSerializer::serializePayload(boost::shared_ptraddNode(boost::shared_ptr(new XMLRawTextNode(label->getLabel()))); element.addNode(labelElement); - foreach(const String& equivalentLabel, label->getEquivalentLabels()) { + foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) { boost::shared_ptr equivalentLabelElement(new XMLElement("equivalentlabel")); equivalentLabelElement->addNode(boost::shared_ptr(new XMLRawTextNode(equivalentLabel))); element.addNode(equivalentLabelElement); diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h index 513655e..a02aeb9 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SecurityLabelSerializer(); - virtual String serializePayload(boost::shared_ptr version) const; + virtual std::string serializePayload(boost::shared_ptr version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp index e44e30e..5e4d8e4 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp @@ -15,19 +15,19 @@ namespace Swift { SecurityLabelsCatalogSerializer::SecurityLabelsCatalogSerializer() : GenericPayloadSerializer() { } -String SecurityLabelsCatalogSerializer::serializePayload(boost::shared_ptr catalog) const { +std::string SecurityLabelsCatalogSerializer::serializePayload(boost::shared_ptr catalog) const { XMLElement element("catalog", "urn:xmpp:sec-label:catalog:0"); - if (!catalog->getName().isEmpty()) { + if (!catalog->getName().empty()) { element.setAttribute("name", catalog->getName()); } if (catalog->getTo().isValid()) { element.setAttribute("to", catalog->getTo()); } - if (!catalog->getDescription().isEmpty()) { + if (!catalog->getDescription().empty()) { element.setAttribute("desc", catalog->getDescription()); } foreach (const SecurityLabel& label, catalog->getLabels()) { - String serializedLabel = SecurityLabelSerializer().serialize(boost::shared_ptr(new SecurityLabel(label))); + std::string serializedLabel = SecurityLabelSerializer().serialize(boost::shared_ptr(new SecurityLabel(label))); element.addNode(boost::shared_ptr(new XMLRawTextNode(serializedLabel))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h index 2379ec1..88a1541 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SecurityLabelsCatalogSerializer(); - virtual String serializePayload(boost::shared_ptr version) const; + virtual std::string serializePayload(boost::shared_ptr version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp index f38b2fd..b2eb1ed 100644 --- a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp @@ -11,15 +11,15 @@ namespace Swift { SoftwareVersionSerializer::SoftwareVersionSerializer() : GenericPayloadSerializer() { } -String SoftwareVersionSerializer::serializePayload(boost::shared_ptr version) const { - String result(""); - if (!version->getName().isEmpty()) { +std::string SoftwareVersionSerializer::serializePayload(boost::shared_ptr version) const { + std::string result(""); + if (!version->getName().empty()) { result += "" + version->getName() + ""; } - if (!version->getVersion().isEmpty()) { + if (!version->getVersion().empty()) { result += "" + version->getVersion() + ""; } - if (!version->getOS().isEmpty()) { + if (!version->getOS().empty()) { result += "" + version->getOS() + ""; } result += ""; diff --git a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h index 7f01b12..72f4afd 100644 --- a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SoftwareVersionSerializer(); - virtual String serializePayload(boost::shared_ptr version) const; + virtual std::string serializePayload(boost::shared_ptr version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h b/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h index 58930b4..dd9ba97 100644 --- a/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: StartSessionSerializer() : GenericPayloadSerializer() {} - virtual String serializePayload(boost::shared_ptr) const { + virtual std::string serializePayload(boost::shared_ptr) const { return XMLElement("session", "urn:ietf:params:xml:ns:xmpp-session").serialize(); } }; diff --git a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h index 8de7040..565d554 100644 --- a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: StatusSerializer() : GenericPayloadSerializer() {} - virtual String serializePayload(boost::shared_ptr status) const { + virtual std::string serializePayload(boost::shared_ptr status) const { XMLElement element("status"); element.addNode(boost::shared_ptr(new XMLTextNode(status->getText()))); return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h b/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h index 9102fde..e797e81 100644 --- a/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h @@ -15,12 +15,12 @@ namespace Swift { public: StatusShowSerializer() : GenericPayloadSerializer() {} - virtual String serializePayload(boost::shared_ptr statusShow) const { + virtual std::string serializePayload(boost::shared_ptr statusShow) const { if (statusShow->getType () == StatusShow::Online || statusShow->getType() == StatusShow::None) { return ""; } else { - String result(""); + std::string result(""); switch (statusShow->getType()) { case StatusShow::Away: result += "away"; break; case StatusShow::XA: result += "xa"; break; diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp index 0de75e5..049c797 100644 --- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp @@ -17,7 +17,7 @@ namespace Swift { StorageSerializer::StorageSerializer() : GenericPayloadSerializer() { } -String StorageSerializer::serializePayload(boost::shared_ptr storage) const { +std::string StorageSerializer::serializePayload(boost::shared_ptr storage) const { XMLElement storageElement("storage", "storage:bookmarks"); foreach(const Storage::Room& room, storage->getRooms()) { @@ -25,12 +25,12 @@ String StorageSerializer::serializePayload(boost::shared_ptr storage) c conferenceElement->setAttribute("name", room.name); conferenceElement->setAttribute("jid", room.jid); conferenceElement->setAttribute("autojoin", room.autoJoin ? "1" : "0"); - if (!room.nick.isEmpty()) { + if (!room.nick.empty()) { boost::shared_ptr nickElement(new XMLElement("nick")); nickElement->addNode(boost::shared_ptr(new XMLTextNode(room.nick))); conferenceElement->addNode(nickElement); } - if (!room.password.isEmpty()) { + if (!room.password.empty()) { boost::shared_ptr passwordElement(new XMLElement("password")); passwordElement->addNode(boost::shared_ptr(new XMLTextNode(room.password))); conferenceElement->addNode(passwordElement); diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.h b/Swiften/Serializer/PayloadSerializers/StorageSerializer.h index c045234..bc682a6 100644 --- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.h @@ -14,6 +14,6 @@ namespace Swift { public: StorageSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp index 0c7f593..70fb2ac 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp @@ -25,11 +25,11 @@ namespace Swift { StreamInitiationSerializer::StreamInitiationSerializer() { } -String StreamInitiationSerializer::serializePayload(boost::shared_ptr streamInitiation) const { +std::string StreamInitiationSerializer::serializePayload(boost::shared_ptr streamInitiation) const { assert(streamInitiation->getIsFileTransfer()); XMLElement siElement("si", "http://jabber.org/protocol/si"); - if (!streamInitiation->getID().isEmpty()) { + if (!streamInitiation->getID().empty()) { siElement.setAttribute("id", streamInitiation->getID()); } siElement.setAttribute("profile", FILE_TRANSFER_NS); @@ -41,7 +41,7 @@ String StreamInitiationSerializer::serializePayload(boost::shared_ptrsetAttribute("size", boost::lexical_cast(file.size)); } - if (!file.description.isEmpty()) { + if (!file.description.empty()) { boost::shared_ptr descElement(new XMLElement("desc")); descElement->addNode(boost::shared_ptr(new XMLTextNode(file.description))); fileElement->addNode(descElement); @@ -54,13 +54,13 @@ String StreamInitiationSerializer::serializePayload(boost::shared_ptrsetName("stream-method"); - foreach(const String& method, streamInitiation->getProvidedMethods()) { + foreach(const std::string& method, streamInitiation->getProvidedMethods()) { field->addOption(FormField::Option("", method)); } form->addField(field); featureElement->addNode(boost::shared_ptr(new XMLRawTextNode(FormSerializer().serialize(form)))); } - else if (!streamInitiation->getRequestedMethod().isEmpty()) { + else if (!streamInitiation->getRequestedMethod().empty()) { Form::ref form(new Form(Form::SubmitType)); ListSingleFormField::ref field = ListSingleFormField::create(streamInitiation->getRequestedMethod()); field->setName("stream-method"); diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h index 35c71b9..0b51519 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: StreamInitiationSerializer(); - virtual String serializePayload(boost::shared_ptr) const; + virtual std::string serializePayload(boost::shared_ptr) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h b/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h index fcd82a5..cf78ddd 100644 --- a/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SubjectSerializer() : GenericPayloadSerializer() {} - virtual String serializePayload(boost::shared_ptr subject) const { + virtual std::string serializePayload(boost::shared_ptr subject) const { XMLTextNode textNode(subject->getText()); return "" + textNode.serialize() + ""; } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp index 87c5f9d..2604331 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp @@ -24,7 +24,7 @@ class CapsInfoSerializerTest : public CppUnit::TestFixture CapsInfoSerializer testling; boost::shared_ptr priority(new CapsInfo("http://swift.im", "myversion", "sha-1")); - CPPUNIT_ASSERT_EQUAL(String(""), testling.serialize(priority)); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(priority)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp index c67fcdb..3875efd 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp @@ -30,7 +30,7 @@ class DiscoInfoSerializerTest : public CppUnit::TestFixture discoInfo->addFeature("http://jabber.org/protocol/disco#info"); discoInfo->setNode("http://swift.im#bla"); - String expectedResult = + std::string expectedResult = "" "" "" @@ -50,7 +50,7 @@ class DiscoInfoSerializerTest : public CppUnit::TestFixture form->setTitle("Bot Configuration"); discoInfo->addExtension(form); - String expectedResult = + std::string expectedResult = "" "" "" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp index 2d392b0..dd06244 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp @@ -24,7 +24,7 @@ class ErrorSerializerTest : public CppUnit::TestFixture ErrorSerializer testling; boost::shared_ptr error(new ErrorPayload(ErrorPayload::BadRequest, ErrorPayload::Cancel, "My Error")); - CPPUNIT_ASSERT_EQUAL(String("My Error"), testling.serialize(error)); + CPPUNIT_ASSERT_EQUAL(std::string("My Error"), testling.serialize(error)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp index 4ed3ba9..e4a6661 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp @@ -24,7 +24,7 @@ class FormSerializerTest : public CppUnit::TestFixture { form->setTitle("Bot Configuration"); form->setInstructions("Hello!\nFill out this form to configure your new bot!"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "Bot Configuration" "Hello!" @@ -63,7 +63,7 @@ class FormSerializerTest : public CppUnit::TestFixture { field->setLabel("Password for special access"); form->addField(field); - std::vector values; + std::vector values; values.push_back("news"); values.push_back("search"); field = ListMultiFormField::create(values); @@ -96,14 +96,14 @@ class FormSerializerTest : public CppUnit::TestFixture { field->setDescription("Tell all your friends about your new bot!"); form->addField(field); - std::vector values2; + std::vector values2; values2.push_back("foo"); values2.push_back("bar"); field = UntypedFormField::create(values2); field->setName("fum"); form->addField(field); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "" "jabber:bot" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp index 1654abc..7020537 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp @@ -23,7 +23,7 @@ class InBandRegistrationPayloadSerializerTest : public CppUnit::TestFixture { boost::shared_ptr registration(new InBandRegistrationPayload()); registration->setRegistered(true); - String expectedResult = + std::string expectedResult = "" "" ""; @@ -43,7 +43,7 @@ class InBandRegistrationPayloadSerializerTest : public CppUnit::TestFixture { form->addField(field); registration->setForm(form); - String expectedResult = + std::string expectedResult = "" "Use the enclosed form to register." "" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp index d1dbba9..481d9c2 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp @@ -12,7 +12,7 @@ namespace Swift { -String PayloadsSerializer::serialize(boost::shared_ptr payload) { +std::string PayloadsSerializer::serialize(boost::shared_ptr payload) { PayloadSerializer* serializer = serializers.getPayloadSerializer(payload); if (serializer) { return serializer->serialize(payload); diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h index 066c481..038b616 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h @@ -9,13 +9,13 @@ #include #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include #include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" namespace Swift { class PayloadsSerializer { public: - String serialize(boost::shared_ptr payload); + std::string serialize(boost::shared_ptr payload); private: FullPayloadSerializerCollection serializers; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp index 12d9359..c976b12 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp @@ -24,7 +24,7 @@ class PrioritySerializerTest : public CppUnit::TestFixture PrioritySerializer testling; boost::shared_ptr priority(new Priority(-113)); - CPPUNIT_ASSERT_EQUAL(String("-113"), testling.serialize(priority)); + CPPUNIT_ASSERT_EQUAL(std::string("-113"), testling.serialize(priority)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp index 59df665..b0f4084 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp @@ -33,7 +33,7 @@ class PrivateStorageSerializerTest : public CppUnit::TestFixture { storage->addRoom(room); privateStorage->setPayload(storage); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "" " resourceBind(new ResourceBind()); resourceBind->setJID(JID("somenode@example.com/someresource")); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "somenode@example.com/someresource" ""), testling.serialize(resourceBind)); @@ -38,7 +38,7 @@ class ResourceBindSerializerTest : public CppUnit::TestFixture boost::shared_ptr resourceBind(new ResourceBind()); resourceBind->setResource("someresource"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "someresource" ""), testling.serialize(resourceBind)); @@ -48,7 +48,7 @@ class ResourceBindSerializerTest : public CppUnit::TestFixture ResourceBindSerializer testling; boost::shared_ptr resourceBind(new ResourceBind()); - CPPUNIT_ASSERT_EQUAL(String(""), testling.serialize(resourceBind)); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(resourceBind)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp index bf30db8..b8ceac3 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp @@ -39,7 +39,7 @@ class RosterSerializerTest : public CppUnit::TestFixture item2.setName("Baz"); roster->addItem(item2); - String expectedResult = + std::string expectedResult = "" "" "Group 1" @@ -60,12 +60,12 @@ class RosterSerializerTest : public CppUnit::TestFixture item.setName("Baz"); item.addGroup("Group 1"); item.addGroup("Group 2"); - item.addUnknownContent(String( + item.addUnknownContent(std::string( "Baz" "foo")); roster->addItem(item); - String expectedResult = + std::string expectedResult = "" "" "Group 1" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp index 40951ec..e8328b8 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp @@ -25,7 +25,7 @@ class SearchPayloadSerializerTest : public CppUnit::TestFixture { payload->setFirst("Juliet"); payload->setLast("Capulet"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "Juliet" "Capulet" @@ -53,7 +53,7 @@ class SearchPayloadSerializerTest : public CppUnit::TestFixture { item2.email = "tybalt@shakespeare.lit"; payload->addItem(item2); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "" "Juliet" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp index bf2139e..03bad89 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp @@ -28,7 +28,7 @@ class SecurityLabelSerializerTest : public CppUnit::TestFixture { securityLabel->addEquivalentLabel(""); securityLabel->addEquivalentLabel("MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk="); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "" "SECRET" "