diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-02-14 18:57:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-02-14 21:36:32 (GMT) |
commit | cb05f5a908e20006c954ce38755c2e422ecc2388 (patch) | |
tree | a793551a5fe279a57d4330119560e8542f745484 | |
parent | cad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff) | |
download | swift-cb05f5a908e20006c954ce38755c2e422ecc2388.zip swift-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2 |
Removed Swift::String.
734 files changed, 3371 insertions, 3518 deletions
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<EchoPayload> { 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<EchoPayloadParser> { 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<EchoPayload> { public: - String serializePayload(boost::shared_ptr<EchoPayload> payload) const { + std::string serializePayload(boost::shared_ptr<EchoPayload> 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 <boost/function.hpp> -using namespace Swift; - CocoaMenulet::CocoaMenulet() { restartAction = [[CocoaAction alloc] initWithFunction: new boost::function<void()>(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<VCard> 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<VCard>(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 <string> #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<Presence> 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<String> names; + std::vector<std::string> 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<ServerError> error) { if (error) { - String message; + std::string message; switch (error->getType()) { case ServerError::C2SPortConflict: - message = String("Error: Port ") + boost::lexical_cast<std::string>(server->getClientToServerPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast<std::string>(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<std::string>(server->getLinkLocalPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast<std::string>(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 <string> #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<void ()> 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 <string> #include "Slimber/Menulet.h" #include <iostream> -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<String>& users) { +void MenuletController::setUserNames(const std::vector<std::string>& 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 <vector> #include <boost/signal.hpp> -#include "Swiften/Base/String.h" +#include <string> 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<Swift::String>&); + void setXMPPStatus(const std::string& message, Status status); + void setUserNames(const std::vector<std::string>&); boost::signal<void ()> onRestartRequested; @@ -34,6 +34,6 @@ class MenuletController { private: Menulet* menulet; Status xmppStatus; - Swift::String xmppStatusMessage; - std::vector<Swift::String> linkLocalUsers; + std::string xmppStatusMessage; + std::vector<std::string> 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 <string> #include <boost/bind.hpp> +#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 <string> #include "Swiften/LinkLocal/LinkLocalServiceInfo.h" #include "Swiften/LinkLocal/OutgoingLinkLocalSession.h" #include "Swiften/LinkLocal/IncomingLinkLocalSession.h" @@ -397,19 +398,19 @@ void Server::handleLinkLocalConnectionServerStopped(boost::optional<BoostConnect LinkLocalServiceInfo Server::getLinkLocalServiceInfo(boost::shared_ptr<Presence> presence) { LinkLocalServiceInfo info; boost::shared_ptr<VCard> 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<String,String> p = vcard->getFullName().getSplittedAtFirst(' '); + else if (!vcard->getFullName().empty()) { + std::pair<std::string,std::string> 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 <string> 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<int>(rosterChanges[0]->getItems().size())); boost::optional<RosterItemPayload> 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<int>(presenceChanges.size())); CPPUNIT_ASSERT(StatusShow::Online == presenceChanges[0]->getShow()); @@ -101,7 +101,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(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<RosterItemPayload> 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<RosterItemPayload> 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<RosterItemPayload> 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<RosterItemPayload> 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<RosterItemPayload> 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<RosterItemPayload> 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<LinkLocalService> 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<int>(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<int>(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<String> users; + std::vector<std::string> 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<String> users; + std::vector<std::string> 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<String> items; - String icon; + std::vector<std::string> 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<boost::filesystem::path> 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 <boost/filesystem.hpp> #include <vector> -#include "Swiften/Base/String.h" +#include <string> 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<boost::filesystem::path> 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 <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> +#include <string> +#include <boost/algorithm/string.hpp> #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<String> dataDirs = String(xdgDataDirs).split(':'); + std::vector<std::string> 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 <string> 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 <string> #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<std::string>(i) : ""); - NSString *labelString = [[NSString alloc] initWithUTF8String: label.getUTF8Data()]; + std::string label(i > 0 ? boost::lexical_cast<std::string>(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<char> 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 << "<a href=\"" << url << "\">" << url << "</a>"; 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 << "<a href=\"" << url << "\">" << url << "</a>"; } - 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 <string> 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()>) { +void GNTPNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()>) { 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<void()> callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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 <cassert> +#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<void()> callback) { +void GrowlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picturePath, boost::function<void()> 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<void()> callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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<void()> callback) { + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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<void()> 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<void()> 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<void()> 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 <boost/function.hpp> #include <boost/filesystem/path.hpp> - -#include "Swiften/Base/String.h" +#include <string> +#include <vector> 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<void()> callback) = 0; @@ -33,7 +33,7 @@ namespace Swift { } protected: - String typeToString(Type type); + std::string typeToString(Type type); static std::vector<Type> getAllTypes(); static std::vector<Type> 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<void()>) { + virtual void showMessage(Type, const std::string&, const std::string&, const boost::filesystem::path&, boost::function<void()>) { } }; } 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<void()> callback) { +void SnarlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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<void()> callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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<void()> callback) { + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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 <algorithm> +#include <boost/algorithm/string.hpp> #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 <vector> -#include "Swiften/Base/String.h" +#include <string> 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<String> words_; - String lastCompletion_; - String lastShort_; - std::vector<String> lastCompletionCandidates_; + std::vector<std::string> words_; + std::string lastCompletion_; + std::string lastShort_; + std::vector<std::string> 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("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"), + std::string("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"), 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("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"), + std::string("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"), result); } void testLinkify_URLWithEmptyResource() { - String result = Linkify::linkify("http://swift.im/"); + std::string result = Linkify::linkify("http://swift.im/"); CPPUNIT_ASSERT_EQUAL( - String("<a href=\"http://swift.im/\">http://swift.im/</a>"), + std::string("<a href=\"http://swift.im/\">http://swift.im/</a>"), result); } void testLinkify_BareURL() { - String result = Linkify::linkify("http://swift.im"); + std::string result = Linkify::linkify("http://swift.im"); CPPUNIT_ASSERT_EQUAL( - String("<a href=\"http://swift.im\">http://swift.im</a>"), + std::string("<a href=\"http://swift.im\">http://swift.im</a>"), 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 <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"), + std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> 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 <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> Baz"), + std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> 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("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"), + std::string("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"), 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("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"), + std::string("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"), 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("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"), + std::string("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"), 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("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"), + std::string("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"), 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("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"), + std::string("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"), 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("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"), + std::string("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"), 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("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"), + std::string("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"), 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("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"), + std::string("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"), 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("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"), + std::string("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"), 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("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"), + std::string("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"), 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("<a href=\"http://swift.im\">http://swift.im</a>\nfoo"), + std::string("<a href=\"http://swift.im\">http://swift.im</a>\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("<a href=\"http://swift.im\">http://swift.im</a>\tfoo"), + std::string("<a href=\"http://swift.im\">http://swift.im</a>\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> message) { chatStateNotifier_->addChatStateRequest(message); } -void ChatController::postSendMessage(const String& body, boost::shared_ptr<Stanza> sentStanza) { - String id = addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional<SecurityLabel>(), String(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); +void ChatController::postSendMessage(const std::string& body, boost::shared_ptr<Stanza> sentStanza) { + std::string id = addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional<SecurityLabel>(), 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<Stanz } void ChatController::handleStanzaAcked(boost::shared_ptr<Stanza> 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> stanza) { void ChatController::setOnline(bool online) { if (!online) { - std::map<boost::shared_ptr<Stanza>, String>::iterator it = unackedStanzas_.begin(); + std::map<boost::shared_ptr<Stanza>, 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> presence) { - String nick = senderDisplayNameFromMessage(presence->getFrom()); - String response = nick; +std::string ChatController::getStatusChangeString(boost::shared_ptr<Presence> 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<Presence> 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<Presence> 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<Presence> newPresence); - String getStatusChangeString(boost::shared_ptr<Presence> presence); + std::string getStatusChangeString(boost::shared_ptr<Presence> presence); bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); - void postSendMessage(const String &body, boost::shared_ptr<Stanza> sentStanza); + void postSendMessage(const std::string &body, boost::shared_ptr<Stanza> sentStanza); void preHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent); void preSendMessageRequest(boost::shared_ptr<Message>); - String senderDisplayNameFromMessage(const JID& from); + std::string senderDisplayNameFromMessage(const JID& from); virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message>) const; void handleStanzaAcked(boost::shared_ptr<Stanza> 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<boost::shared_ptr<Stanza>, String> unackedStanzas_; + std::string lastStatusChangeString_; + std::map<boost::shared_ptr<Stanza>, 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 <boost/bind.hpp> #include <boost/shared_ptr.hpp> #include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/algorithm/string.hpp> +#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> 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<SecurityLabel>& 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<SecurityLabel>& 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<MessageEvent> m unreadMessages_.push_back(messageEvent); } boost::shared_ptr<Message> message = messageEvent->getStanza(); - String body = message->getBody(); + std::string body = message->getBody(); if (message->isError()) { - String errorMessage = getErrorMessage(message->getPayload<ErrorPayload>()); + std::string errorMessage = getErrorMessage(message->getPayload<ErrorPayload>()); chatWindow_->addErrorMessage(errorMessage); } else { @@ -167,7 +169,7 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> 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<SecurityLabel> label = message->getPayload<SecurityLabel>(); boost::optional<SecurityLabel> maybeLabel = label ? boost::optional<SecurityLabel>(*label) : boost::optional<SecurityLabel>(); @@ -179,15 +181,15 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> 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<ErrorPayload> error) { - String defaultMessage = "Error sending message"; - if (!error->getText().isEmpty()) { +std::string ChatControllerBase::getErrorMessage(boost::shared_ptr<ErrorPayload> 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 <string> #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<DiscoInfo> info); void handleIncomingMessage(boost::shared_ptr<MessageEvent> message); - String addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& 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<SecurityLabel>& 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<Stanza>) {}; - virtual String senderDisplayNameFromMessage(const JID& from) = 0; + virtual void postSendMessage(const std::string&, boost::shared_ptr<Stanza>) {}; + virtual std::string senderDisplayNameFromMessage(const JID& from) = 0; virtual bool isIncomingMessageFromMe(boost::shared_ptr<Message>) = 0; virtual void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>) {}; virtual void preSendMessageRequest(boost::shared_ptr<Message>) {}; @@ -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<SecurityLabelsCatalog>, ErrorPayload::ref error); - String getErrorMessage(boost::shared_ptr<ErrorPayload>); + std::string getErrorMessage(boost::shared_ptr<ErrorPayload>); 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<String>& nickMaybe, bool autoJoin) { +void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional<std::string>& 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> message) { JID jid = message->getFrom(); boost::shared_ptr<MessageEvent> event(new MessageEvent(message)); - if (!event->isReadable() && !message->getPayload<ChatState>() && message->getSubject().isEmpty()) { + if (!event->isReadable() && !message->getPayload<ChatState>() && 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 <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #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<DiscoInfo> info); void handleIncomingMessage(boost::shared_ptr<Message> message); private: - void handleChatRequest(const String& contact); - void handleJoinMUCRequest(const JID& muc, const boost::optional<String>& nick, bool autoJoin); + void handleChatRequest(const std::string& contact); + void handleJoinMUCRequest(const JID& muc, const boost::optional<std::string>& 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 <boost/bind.hpp> #include <boost/regex.hpp> +#include <boost/algorithm/string.hpp> #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<ErrorPayload> 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<ErrorPayload> 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> 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> messageEvent) { @@ -246,7 +247,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> 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<MessageEvent> 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<MessageEvent> 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> 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<NickJoinPart>& joinParts, cons } } -String MUCController::concatenateListOfNames(const std::vector<NickJoinPart>& joinParts) { - String result; +std::string MUCController::concatenateListOfNames(const std::vector<NickJoinPart>& 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<NickJoinPart>& jo return result; } -String MUCController::generateJoinPartString(const std::vector<NickJoinPart>& joinParts) { +std::string MUCController::generateJoinPartString(const std::vector<NickJoinPart>& joinParts) { std::vector<NickJoinPart> 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<JoinPart> 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 <boost/signals/connection.hpp> #include <set> -#include "Swiften/Base/String.h" +#include <string> #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<void ()> onUserLeft; virtual void setOnline(bool online); void rejoin(); static void appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent); - static String generateJoinPartString(const std::vector<NickJoinPart>& joinParts); - static String concatenateListOfNames(const std::vector<NickJoinPart>& joinParts); + static std::string generateJoinPartString(const std::vector<NickJoinPart>& joinParts); + static std::string concatenateListOfNames(const std::vector<NickJoinPart>& joinParts); protected: void preSendMessageRequest(boost::shared_ptr<Message> message); bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); - String senderDisplayNameFromMessage(const JID& from); + std::string senderDisplayNameFromMessage(const JID& from); boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message> message) const; void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>); 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> 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<ErrorPayload> 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> 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<Timer> loginCheckTimer_; - std::set<String> currentOccupants_; + std::set<std::string> currentOccupants_; std::vector<NickJoinPart> 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 <Swiften/Disco/GetDiscoItemsRequest.h> #include <Swiften/Base/Log.h> +#include <Swiften/Base/String.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/MUCSearchWindowFactory.h> #include <Swift/Controllers/DiscoServiceWalker.h> @@ -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<DiscoInfo> 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 <boost/shared_ptr.hpp> #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include <string> #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<MUCRoom> getRooms() const {return rooms_;} private: - String name_; + std::string name_; JID jid_; std::vector<MUCRoom> 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> 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<Message> 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<Message> 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<ChatWindow>(); 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<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(bareJIDString), uiEventStream_).Return(window); @@ -171,19 +171,19 @@ public: boost::shared_ptr<Message> 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<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1); uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString1)))); - String messageJIDString2("testling2@test.com"); + std::string messageJIDString2("testling2@test.com"); ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); 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<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(bareJIDString), uiEventStream_).Return(window); @@ -207,7 +207,7 @@ public: boost::shared_ptr<Message> 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<Message> 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<JoinMUCUIEvent>(new JoinMUCUIEvent(muc, String("nick")))); + uiEventStream_->send(boost::shared_ptr<JoinMUCUIEvent>(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<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1); uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString1)))); - String messageJIDString2("testling@test.com/2"); + std::string messageJIDString2("testling@test.com/2"); ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString2), uiEventStream_).Return(window2); uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString2)))); - String messageJIDString3("testling@test.com/3"); + std::string messageJIDString3("testling@test.com/3"); ChatWindow* window3 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString3), uiEventStream_).Return(window3); @@ -308,14 +308,14 @@ public: boost::shared_ptr<Message> 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<Message> 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 <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> +#include <boost/algorithm/string.hpp> #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<NickJoinPart> 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<NickJoinPart> 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<String> features = info->getFeatures(); + std::vector<std::string> 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<SearchPayload> std::vector<UserSearchResult> results; foreach (SearchPayload::Item item, resultsPayload->getItems()) { JID jid(item.jid); - std::map<String, String> fields; + std::map<std::string, std::string> 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 <Swiften/Base/boost_bsignals.h> #include <Swiften/Elements/SearchPayload.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/DiscoItems.h> @@ -28,12 +28,12 @@ namespace Swift { class UserSearchResult { public: - UserSearchResult(const JID& jid, const std::map<String, String>& fields) : jid_(jid), fields_(fields) {} + UserSearchResult(const JID& jid, const std::map<std::string, std::string>& fields) : jid_(jid), fields_(fields) {} const JID& getJID() const {return jid_;} - const std::map<String, String>& getFields() const {return fields_;} + const std::map<std::string, std::string>& getFields() const {return fields_;} private: JID jid_; - std::map<String, String> fields_; + std::map<std::string, std::string> 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<String>& newGroups) { - std::vector<String> oldGroupsVector = currentContact->getGroups(); - std::set<String> oldGroups(oldGroupsVector.begin(), oldGroupsVector.end()); +void ContactEditController::handleChangeContactRequest(const std::string& name, const std::set<std::string>& newGroups) { + std::vector<std::string> oldGroupsVector = currentContact->getGroups(); + std::set<std::string> oldGroups(oldGroupsVector.begin(), oldGroupsVector.end()); if (oldGroups != newGroups || currentContact->getName() != name) { XMPPRosterItem newContact(*currentContact); newContact.setName(name); - newContact.setGroups(std::vector<String>(newGroups.begin(), newGroups.end())); + newContact.setGroups(std::vector<std::string>(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 <boost/optional.hpp> #include <Swiften/JID/JID.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swift/Controllers/UIEvents/UIEvent.h> #include <Swiften/Roster/XMPPRosterItem.h> @@ -30,7 +30,7 @@ namespace Swift { private: void handleRemoveContactRequest(); - void handleChangeContactRequest(const String& name, const std::set<String>& groups); + void handleChangeContactRequest(const std::string& name, const std::set<std::string>& 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<DiscoItems> 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 <boost/shared_ptr.hpp> #include <Swiften/Base/boost_bsignals.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/DiscoItems.h> 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<StanzaEvent> event) { if (boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(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<StanzaEvent> event) { } else if(boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(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<void()>()); } else if(boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(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 <string> #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> 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> presence) { notifier_->setTemporarilyDisabled(presence->getShow() == StatusShow::DND); // Add information and send - if (!vCardPhotoHash_.isEmpty()) { + if (!vCardPhotoHash_.empty()) { presence->updatePayload(boost::shared_ptr<VCardUpdate>(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> presence(new Presence()); @@ -429,8 +429,8 @@ void MainController::handleDisconnected(const boost::optional<ClientError>& 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<ClientError>& 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 <string> #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<ClientError>& error); void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, ErrorPayload::ref); void handleEventQueueLengthChange(int count); void handleVCardReceived(const JID& j, VCard::ref vCard); void handleUIEvent(boost::shared_ptr<UIEvent> event); - void handlePurgeSavedLoginRequest(const String& username); + void handlePurgeSavedLoginRequest(const std::string& username); void sendPresence(boost::shared_ptr<Presence> 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<ErrorEvent> 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<TypeStringPair> PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const String& message) { +std::vector<TypeStringPair> PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const std::string& message) { std::vector<TypeStringPair> suggestions; suggestions.push_back(TypeStringPair(status, message)); return suggestions; } -std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const String& message) { +std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const std::string& message) { std::vector<TypeStringPair> 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 <utility> /* std::pair */ #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/StatusShow.h" namespace Swift { - typedef std::pair<StatusShow::Type, String> TypeStringPair; + typedef std::pair<StatusShow::Type, std::string> TypeStringPair; class PreviousStatusStore { public: PreviousStatusStore(); ~PreviousStatusStore(); - void addStatus(StatusShow::Type status, const String& message); - std::vector<TypeStringPair> getSuggestions(const String& message); + void addStatus(StatusShow::Type status, const std::string& message); + std::vector<TypeStringPair> getSuggestions(const std::string& message); private: - std::vector<TypeStringPair> exactMatchSuggestions(StatusShow::Type status, const String& message); + std::vector<TypeStringPair> exactMatchSuggestions(StatusShow::Type status, const std::string& message); std::vector<TypeStringPair> 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<String, boost::shared_ptr<Presence> > StringPresencePair; +typedef std::pair<std::string, boost::shared_ptr<Presence> > StringPresencePair; void ContactRosterItem::calculateShownPresence() { shownPresence_ = offlinePresence_; @@ -76,12 +76,12 @@ void ContactRosterItem::clearPresence() { onDataChanged(); } -void ContactRosterItem::applyPresence(const String& resource, boost::shared_ptr<Presence> presence) { +void ContactRosterItem::applyPresence(const std::string& resource, boost::shared_ptr<Presence> presence) { if (offlinePresence_) { offlinePresence_ = boost::shared_ptr<Presence>(); } 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<String> ContactRosterItem::getGroups() const { +const std::vector<std::string> 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 <string> #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> presence); + void applyPresence(const std::string& resource, boost::shared_ptr<Presence> presence); void clearPresence(); void calculateShownPresence(); - const std::vector<String> getGroups() const; + const std::vector<std::string> 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<String, boost::shared_ptr<Presence> > presences_; + std::string avatarPath_; + std::map<std::string, boost::shared_ptr<Presence> > presences_; boost::shared_ptr<Presence> offlinePresence_; boost::shared_ptr<Presence> shownPresence_; - std::vector<String> groups_; + std::vector<std::string> 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<RosterItem*>::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 <string> #include "Swift/Controllers/Roster/ContactRosterItem.h" #include <vector> @@ -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<RosterItem*>& getChildren() const; const std::vector<RosterItem*>& 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<void ()> 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<RosterItem*> children_; std::vector<RosterItem*> 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 <string> #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<GroupRosterItem*>(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<RosterItem*> children = root_->getChildren(); std::vector<RosterItem*>::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 <string> #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<void (GroupRosterItem*)> onChildrenChanged; boost::signal<void (GroupRosterItem*)> onGroupAdded; boost::signal<void (RosterItem*)> 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 <boost/bind.hpp> #include <boost/smart_ptr/make_shared.hpp> +#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<String> groups = xmppRoster_->getGroupsForJID(jid); - String name = nickResolver_->jidToNick(jid); + std::vector<std::string> 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<String> passedOldGroups) { +void RosterController::handleOnJIDUpdated(const JID& jid, const std::string& oldName, const std::vector<std::string> passedOldGroups) { if (oldName != xmppRoster_->getNameForJID(jid)) { roster_->applyOnItems(SetName(nickResolver_->jidToNick(jid), jid)); } - std::vector<String> groups = xmppRoster_->getGroupsForJID(jid); - std::vector<String> oldGroups = passedOldGroups; - String name = nickResolver_->jidToNick(jid); - String contactsGroup = "Contacts"; + std::vector<std::string> groups = xmppRoster_->getGroupsForJID(jid); + std::vector<std::string> 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<UIEvent> event) { } else if (boost::shared_ptr<RenameGroupUIEvent> renameGroupEvent = boost::dynamic_pointer_cast<RenameGroupUIEvent>(event)) { std::vector<XMPPRosterItem> 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<String> groups = item.getGroups(); - if ( (group.isEmpty() && groups.empty()) || std::find(groups.begin(), groups.end(), group) != groups.end()) { + std::vector<std::string> 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<UIEvent> event) { } } -void RosterController::setContactGroups(const JID& jid, const std::vector<String>& groups) { +void RosterController::setContactGroups(const JID& jid, const std::vector<std::string>& 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> 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<XMPPRosterItem> RosterController::getItem(const JID& jid) const return xmppRoster_->getItem(jid); } -std::set<String> RosterController::getGroups() const { +std::set<std::string> 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 <string> #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<void (StatusShow::Type, const String&)> onChangeStatusRequest; + boost::signal<void (StatusShow::Type, const std::string&)> onChangeStatusRequest; boost::signal<void ()> onSignOutRequest; void handleAvatarChanged(const JID& jid); void setEnabled(bool enabled); boost::optional<XMPPRosterItem> getItem(const JID&) const; - std::set<String> getGroups() const; + std::set<std::string> getGroups() const; - void setContactGroups(const JID& jid, const std::vector<String>& groups); + void setContactGroups(const JID& jid, const std::vector<std::string>& 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<String> oldGroups); + void handleOnJIDUpdated(const JID &jid, const std::string& oldName, const std::vector<std::string> 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<Presence> 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<UIEvent> 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 <boost/bind.hpp> #include <vector> +#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<String> collapsed = saved.split('\n'); + std::string saved = settings_->getStringSetting(SettingPath); + std::vector<std::string> 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<String> collapsed_; + std::set<std::string> 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 <boost/algorithm/string.hpp> + #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 <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class GroupRosterItem; class RosterItem { public: - RosterItem(const String& name, GroupRosterItem* parent); + RosterItem(const std::string& name, GroupRosterItem* parent); virtual ~RosterItem(); boost::signal<void ()> 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<GroupRosterItem*>(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<String> groups; + std::vector<std::string> 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<String> groups; + std::vector<std::string> 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<String> groups; + std::vector<std::string> 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<String> groups; + std::vector<std::string> 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<String> groups; + std::vector<std::string> 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<int>(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<String> groups; + std::vector<std::string> 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<String> groups; + std::vector<std::string> groups; JID jid("test@testdomain.com"); xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(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<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(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<String> oldGroups; - std::vector<String> newGroups; + std::vector<std::string> oldGroups; + std::vector<std::string> newGroups; newGroups.push_back("A Group"); - std::vector<String> newestGroups; + std::vector<std::string> 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<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(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<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(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<String> groups; + std::vector<std::string> 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<size_t>(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<String>& v1, const std::vector<String>& v2, int line) { - foreach (const String& entry, v1) { + void assertVectorsEqual(const std::vector<std::string>& v1, const std::vector<std::string>& 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<int>(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<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Ernie"), static_cast<GroupRosterItem*>(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<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Ernie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[1])->getChildren()[0]->getDisplayName()); } void testRemoveContact() { roster_->addContact(jid1_, jid1_, "Bert", "group1", ""); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); roster_->removeContact(jid1_); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(static_cast<GroupRosterItem*>(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<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid2_); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast<GroupRosterItem*>(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<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid4b); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); } void testApplyPresenceLikeMUC() { @@ -105,9 +105,9 @@ class RosterTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(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<Presence>(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<String> getAvailableProfiles() {return std::vector<String>();} - 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<std::string> getAvailableProfiles() {return std::vector<std::string>();} + 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 <string> #include <vector> @@ -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<String> 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<std::string> 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 <string> #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 <boost/optional.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swift/Controllers/UIEvents/UIEvent.h" @@ -16,11 +16,11 @@ namespace Swift { class JoinMUCUIEvent : public UIEvent { public: typedef boost::shared_ptr<JoinMUCUIEvent> ref; - JoinMUCUIEvent(const JID& jid, const boost::optional<String>& nick = boost::optional<String>()) : jid_(jid), nick_(nick) {}; - boost::optional<String> getNick() {return nick_;}; + JoinMUCUIEvent(const JID& jid, const boost::optional<std::string>& nick = boost::optional<std::string>()) : jid_(jid), nick_(nick) {}; + boost::optional<std::string> getNick() {return nick_;}; JID getJID() {return jid_;}; private: JID jid_; - boost::optional<String> nick_; + boost::optional<std::string> 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 <Swift/Controllers/UIEvents/UIEvent.h> -#include <Swiften/Base/String.h> +#include <string> 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 <boost/optional.hpp> #include <boost/shared_ptr.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swift/Controllers/UIEvents/UIEvent.h> 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 <boost/date_time/posix_time/posix_time.hpp> #include <vector> -#include "Swiften/Base/String.h" +#include <string> #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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<void ()> onClosed; boost::signal<void ()> onAllMessagesRead; - boost::signal<void (const String&)> onSendMessageRequest; + boost::signal<void (const std::string&)> onSendMessageRequest; boost::signal<void ()> onUserTyping; boost::signal<void ()> 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 <set> #include <vector> -#include <Swiften/Base/String.h> +#include <string> 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<String>& groups, const std::set<String>& allGroups) = 0; + virtual void setContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, const std::set<std::string>& allGroups) = 0; virtual void show() = 0; virtual void hide() = 0; boost::signal<void ()> onRemoveContactRequest; - boost::signal<void (const String& /* name */, const std::set<String>& /* groups */)> onChangeContactRequest; + boost::signal<void (const std::string& /* name */, const std::set<std::string>& /* 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 <vector> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/Base/boost_bsignals.h> #include <Swiften/JID/JID.h> @@ -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<void (const JID& /* muc */, const String& /* nick */, bool /* autoJoin */)> onJoinMUC; + boost::signal<void (const JID& /* muc */, const std::string& /* nick */, bool /* autoJoin */)> onJoinMUC; boost::signal<void ()> 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 <boost/shared_ptr.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/TLS/Certificate.h> 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<void (const String&, const String&, const String& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> 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<void (const std::string&, const std::string&, const std::string& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> 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<void ()> onCancelLoginRequest; boost::signal<void ()> onQuitRequest; - boost::signal<void (const String&)> onPurgeSavedLoginRequest; + boost::signal<void (const std::string&)> 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 <vector> #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include <Swift/Controllers/Chat/MUCSearchController.h> 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 <string> #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<void (StatusShow::Type, const String&)> onChangeStatusRequest; + boost::signal<void (StatusShow::Type, const std::string&)> onChangeStatusRequest; boost::signal<void ()> 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 <vector> -#include "Swiften/Base/String.h" +#include <string> #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 <string> +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<SecurityLabel>& /*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<SecurityLabel>& /*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<SecurityLabel>& /*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<SecurityLabel>& /*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<SecurityLabel>& 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<void ()> onClosed; boost::signal<void ()> onAllMessagesRead; - boost::signal<void (const String&)> onSendMessageRequest; + boost::signal<void (const std::string&)> onSendMessageRequest; - String name_; - String lastMessageBody_; + std::string name_; + std::string lastMessageBody_; std::vector<SecurityLabel> 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<PresenceNotifier> testling = createNotifier(); - roster->addContact(user1.toBare(), "User 1", std::vector<String>(), RosterItemPayload::Both); + roster->addContact(user1.toBare(), "User 1", std::vector<std::string>(), RosterItemPayload::Both); sendPresence(user1, StatusShow::Online); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(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<int>(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<int>(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<int>(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<UIEvent> 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<UIEvent> 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 <boost/shared_ptr.hpp> #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" -#include "Swiften/Base/String.h" +#include <string> #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<Message> 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 <boost/shared_ptr.hpp> #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" -#include "Swiften/Base/String.h" +#include <string> #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<void()> onAccept; boost::signal<void()> 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 <QVBoxLayout> #include <QLineEdit> #include "../QtSwiftUtil.h" -#include "Swiften/Base/String.h" +#include <string> #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> subscriptionRequestEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(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> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(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()>) { +void FreeDesktopNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()>) { 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<void()> callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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 <iostream> #include <boost/bind.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Notifier/GrowlNotifier.h" #include <QApplication> 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<MUCBookmark> 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<MUCBookmark>(); } - 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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<ChatSnippet>(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 = "<img src='qrc:/icons/throbber.gif' alt='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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time); - String addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<SecurityLabel>& 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<String>& allGroups, QWidget* parent) : QWidget(parent), groups_(NULL) { +QtContactEditWidget::QtContactEditWidget(const std::set<std::string>& 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<String>& 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<String>& 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<String>& groups) { - foreach (String group, groups) { +void QtContactEditWidget::setSelectedGroups(const std::vector<std::string>& groups) { + foreach (std::string group, groups) { checkBoxes_[group]->setCheckState(Qt::Checked); } } -std::set<String> QtContactEditWidget::getSelectedGroups() const { - std::set<String> groups; +std::set<std::string> QtContactEditWidget::getSelectedGroups() const { + std::set<std::string> 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 <QWidget> -#include <Swiften/Base/String.h> +#include <string> class QLineEdit; class QCheckBox; @@ -22,16 +22,16 @@ namespace Swift { Q_OBJECT public: - QtContactEditWidget(const std::set<String>& allGroups, QWidget* parent); + QtContactEditWidget(const std::set<std::string>& allGroups, QWidget* parent); - void setName(const String&); - String getName() const; + void setName(const std::string&); + std::string getName() const; - void setSelectedGroups(const std::vector<String>& groups); - std::set<String> getSelectedGroups() const; + void setSelectedGroups(const std::vector<std::string>& groups); + std::set<std::string> getSelectedGroups() const; private: - typedef std::map<String, QCheckBox*> CheckBoxMap; + typedef std::map<std::string, QCheckBox*> 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<String>& groups, const std::set<String>& allGroups) { +void QtContactEditWindow::setContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, const std::set<std::string>& allGroups) { delete contactEditWidget_; jid_ = jid; jidLabel_->setText("<b>" + P2QSTRING(jid.toString()) + "</b>"); 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 <QWidget> #include <Swift/Controllers/UIInterfaces/ContactEditWindow.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> class QLabel; @@ -24,7 +24,7 @@ namespace Swift { public: QtContactEditWindow(); - virtual void setContact(const JID& jid, const String& name, const std::vector<String>& groups, const std::set<String>& allGroups); + virtual void setContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, const std::set<std::string>& 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 <Swiften/Base/String.h> +#include <string> #include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h> #include <Swift/QtUI/ui_QtJoinMUCWindow.h> @@ -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<UIEvent> 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("<center><font color=\"red\">" + P2QSTRING(message) + "</font></center>"); } 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<QMenu*> 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("<font color='red'>" + P2QSTRING(error) + "</font>"); } 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 <QSize> #include <QToolBar> -#include "Swiften/Base/String.h" +#include <string> #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<String> QtSettingsProvider::getAvailableProfiles() { - std::vector<String> profiles; +std::vector<std::string> QtSettingsProvider::getAvailableProfiles() { + std::vector<std::string> profiles; QVariant profilesVariant = settings_.value("profileList"); foreach(QString profileQString, profilesVariant.toStringList()) { profiles.push_back(Q2PSTRING(profileQString)); @@ -54,13 +54,13 @@ std::vector<String> 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<String> 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<std::string> 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 <string> #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 <Swiften/TLS/PlatformTLSFactories.h> #include <Swiften/Network/BoostNetworkFactories.h> -#include "Swiften/Base/String.h" +#include <string> #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 <QCheckBox> #include "QtSwiftUtil.h" -#include "Swiften/Base/String.h" +#include <string> 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("<!-- IN -->\n" + data + "\n", QColor(33,98,33)); } -void QtXMLConsoleWidget::handleDataWritten(const String& data) { +void QtXMLConsoleWidget::handleDataWritten(const std::string& data) { appendTextIfEnabled("<!-- OUT -->\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 <QColor> #include <QVariant> -#include "Swiften/Base/String.h" +#include <string> #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<ContactRosterItem*>(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<UIEvent> 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<String, String> fields = item->getFields(); - std::map<String, String>::const_iterator first = fields.find("first"); + const std::map<std::string, std::string> fields = item->getFields(); + std::map<std::string, std::string>::const_iterator first = fields.find("first"); if (first != fields.end()) { result += P2QSTRING((*first).second); } - std::map<String, String>::const_iterator last = fields.find("last"); + std::map<std::string, std::string>::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<void()> callback) { +void WindowsNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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<void()> callback); + virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> 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 <string> #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<String> addedGroups; - std::vector<String> removedGroups; + std::vector<std::string> addedGroups; + std::vector<std::string> 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 <map> #include <boost/filesystem.hpp> -#include "Swiften/Base/String.h" +#include <string> #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 <map> -#include "Swiften/Base/String.h" +#include <string> #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<String, ByteArray>::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<std::string, ByteArray>::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<String, ByteArray> avatars; + std::map<std::string, ByteArray> 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 <string> 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<void (const JID&)> 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 <boost/filesystem.hpp> 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<JID, String>::iterator i = avatars.find(jid); + std::string hash = getAvatarHash(jid); + std::map<JID, std::string>::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<AvatarProvider*> providers; - std::map<JID, String> avatars; + std::map<JID, std::string> 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 <boost/bind.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Avatars/CombinedAvatarProvider.h" using namespace Swift; @@ -47,7 +47,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { void testGetAvatarWithNoAvatarProviderReturnsEmpty() { std::auto_ptr<CombinedAvatarProvider> 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<JID, String>::const_iterator i = avatars.find(jid); + std::string getAvatarHash(const JID& jid) const { + std::map<JID, std::string>::const_iterator i = avatars.find(jid); if (i != avatars.end()) { return i->second; } else { - return String(); + return std::string(); } } - std::map<JID, String> avatars; + std::map<JID, std::string> 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<JID> 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<VCardAvatarManager> 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<VCardAvatarManager> 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<VCardAvatarManager> 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<JID> 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<int>(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<Presence> createPresenceWithPhotoHash(const JID& jid, const String& hash) { + boost::shared_ptr<Presence> createPresenceWithPhotoHash(const JID& jid, const std::string& hash) { boost::shared_ptr<Presence> presence(new Presence()); presence->setFrom(jid); presence->addPayload(boost::shared_ptr<VCardUpdate>(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<JID> 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<JID, String>::const_iterator i = avatarHashes_.find(getAvatarJID(jid)); +std::string VCardUpdateAvatarManager::getAvatarHash(const JID& jid) const { + std::map<JID, std::string>::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<JID, String> oldAvatarHashes; + std::map<JID, std::string> oldAvatarHashes; avatarHashes_.swap(oldAvatarHashes); - for(std::map<JID, String>::const_iterator i = oldAvatarHashes.begin(); i != oldAvatarHashes.end(); ++i) { + for(std::map<JID, std::string>::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<Presence>); 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<JID, String> avatarHashes_; + std::map<JID, std::string> 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 <vector> #include <iostream> -#include "Swiften/Base/String.h" +#include <string> 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 <string> 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 <cassert> #include <algorithm> -#include "Swiften/Base/String.h" +#include <Swiften/Base/String.h> namespace Swift { @@ -34,11 +34,11 @@ static inline size_t sequenceLength(char firstByte) { return 1; } -std::vector<unsigned int> String::getUnicodeCodePoints() const { +std::vector<unsigned int> String::getUnicodeCodePoints(const std::string& s) { std::vector<unsigned int> 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<unsigned int> 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<unsigned int> String::getUnicodeCodePoints() const { } -std::pair<String,String> String::getSplittedAtFirst(char c) const { +std::pair<std::string,std::string> 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> String::split(char c) const { +std::vector<std::string> String::split(const std::string& s, char c) { assert((c & 0x80) == 0); - std::vector<String> result; - String accumulator; - for (size_t i = 0; i < data_.size(); ++i) { - if (data_[i] == c) { + std::vector<std::string> 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 <boost/algorithm/string.hpp> - -#include <ostream> +#include <map> #include <string> -#include <utility> #include <vector> -#include <cassert> -#include <algorithm> #define SWIFTEN_STRING_TO_CFSTRING(a) \ - CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.getUTF8Data()), a.getUTF8Size(), kCFStringEncodingUTF8, false) + CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(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<unsigned int> 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<String,String> getSplittedAtFirst(char c) const; - - std::vector<String> 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<unsigned int> getUnicodeCodePoints(const std::string&); + std::pair<std::string, std::string> getSplittedAtFirst(const std::string&, char c); + std::vector<std::string> 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<String> generatedIDs_; + std::set<std::string> 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 <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> +#include <string> -#include "Swiften/Base/String.h" +#include <Swiften/Base/String.h> 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<unsigned int> points = testling.getUnicodeCodePoints(); + std::string testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d"); + std::vector<unsigned int> 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<String,String> result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT_EQUAL(String("cd@ef"), result.second); + std::pair<std::string,std::string> 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<String,String> result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT(result.second.isEmpty()); + std::pair<std::string,std::string> 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<String,String> 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<std::string,std::string> 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<String> result = String("abc def ghi").split(' '); + std::vector<std::string> result = String::split("abc def ghi", ' '); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(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> 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 <string> #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<Stanza>); 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<Presence> 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> stanza); void handleSessionFinished(boost::shared_ptr<Error> error); void handleStanza(boost::shared_ptr<Stanza> 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<Connection> connectio assert(!sessionStream_); sessionStream_ = boost::shared_ptr<BasicSessionStream>(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 <string> #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<void (const String&)> onDataRead; + boost::signal<void (const std::string&)> 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<void (const String&)> onDataWritten; + boost::signal<void (const std::string&)> onDataWritten; /** * Emitted when a message is received. @@ -197,15 +197,15 @@ namespace Swift { void handleStanzaChannelAvailableChanged(bool available); void handleSessionFinished(boost::shared_ptr<Error>); 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> connection_; boost::shared_ptr<BasicSessionStream> sessionStream_; boost::shared_ptr<ClientSession> 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 <Swiften/Base/boost_bsignals.h> -#include <Swiften/Base/String.h> +#include <string> 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<void (const String&)> onOwnNickChanged; + boost::signal<void (const std::string&)> 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 <Swiften/Client/NickManager.h> #include <Swiften/Elements/VCard.h> #include <Swiften/JID/JID.h> -#include <Swiften/Base/String.h> +#include <string> 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<String>& /*groups*/) { +void NickResolver::handleJIDUpdated(const JID& jid, const std::string& previousNick, const std::vector<std::string>& /*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 <boost/signals.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #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<void (const JID&, const String& /*previousNick*/)> onNickChanged; + boost::signal<void (const JID&, const std::string& /*previousNick*/)> onNickChanged; private: void handleVCardReceived(const JID& jid, VCard::ref vCard); - void handleJIDUpdated(const JID& jid, const String& previousNick, const std::vector<String>& groups); + void handleJIDUpdated(const JID& jid, const std::string& previousNick, const std::vector<std::string>& 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<StartTLSRequest>(event.element)); } - void receiveAuthRequest(const String& mech) { + void receiveAuthRequest(const std::string& mech) { Event event = popEvent(); CPPUNIT_ASSERT(event.element); boost::shared_ptr<AuthRequest> request(boost::dynamic_pointer_cast<AuthRequest>(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<Event> 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<String> groups_; + std::vector<std::string> 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 <string> #include "Swiften/Network/DomainNameResolveError.h" namespace Swift { @@ -26,7 +26,7 @@ namespace Swift { public: typedef boost::shared_ptr<ComponentConnector> 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<void (boost::shared_ptr<Connection>)> 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<HostAddress>& address, boost::optional<DomainNameResolveError> 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 <Swiften/Base/String.h> 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 <string> 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<SessionStream> stream) : jid(jid), secret(secret), stream(stream), state(Initial) { +ComponentSession::ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream> 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 <string> #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<ComponentSession> create(const JID& jid, const String& secret, boost::shared_ptr<SessionStream> stream) { + static boost::shared_ptr<ComponentSession> create(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream> stream) { return boost::shared_ptr<ComponentSession>(new ComponentSession(jid, secret, stream)); } @@ -60,7 +60,7 @@ namespace Swift { boost::signal<void (boost::shared_ptr<Stanza>)> onStanzaReceived; private: - ComponentSession(const JID& jid, const String& secret, boost::shared_ptr<SessionStream>); + ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream>); void finishSession(Error::Type error); void finishSession(boost::shared_ptr<Swift::Error> error); @@ -75,7 +75,7 @@ namespace Swift { private: JID jid; - String secret; + std::string secret; boost::shared_ptr<SessionStream> stream; boost::shared_ptr<Swift::Error> 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<Presence> 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> stanza); void handleSessionFinished(boost::shared_ptr<Error> error); void handleStanza(boost::shared_ptr<Stanza> 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> 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 <string> #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<Message>); @@ -72,8 +72,8 @@ namespace Swift { public: boost::signal<void (const ComponentError&)> onError; boost::signal<void ()> onConnected; - boost::signal<void (const String&)> onDataRead; - boost::signal<void (const String&)> onDataWritten; + boost::signal<void (const std::string&)> onDataRead; + boost::signal<void (const std::string&)> onDataWritten; boost::signal<void (boost::shared_ptr<Message>)> onMessageReceived; boost::signal<void (boost::shared_ptr<Presence>) > onPresenceReceived; @@ -82,15 +82,15 @@ namespace Swift { void handleConnectorFinished(boost::shared_ptr<Connection>); void handleStanzaChannelAvailableChanged(bool available); void handleSessionFinished(boost::shared_ptr<Error>); - 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<ComponentHandshake>(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<Event> 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 <boost/program_options/variables_map.hpp> #include <boost/program_options.hpp> #include <boost/version.hpp> +#include <string> -#include <Swiften/Base/String.h> #include <Swiften/Base/foreach.h> #include <Swiften/Base/Platform.h> #include <Swiften/Base/Paths.h> +#include <Swiften/Base/String.h> #include "swiften-config.h" using namespace Swift; -void printFlags(const std::vector<String>& flags) { +void printFlags(const std::vector<std::string>& 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<String> libs; + std::vector<std::string> libs; for (size_t i = 0; LIBFLAGS[i]; ++i) { libs.push_back(LIBFLAGS[i]); } - std::vector<String> cflags; + std::vector<std::string> 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<DiscoInfo>(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 <boost/filesystem.hpp> #include "Swiften/Disco/CapsStorage.h" -#include "Swiften/Base/String.h" +#include <string> 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<DiscoInfo::Identity> 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<String> features(discoInfo.getFeatures()); + std::vector<std::string> 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<String> values(field->getRawValues()); + std::vector<std::string> 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 <string> #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> presence) { if (!capsInfo || capsInfo->getHash() != "sha-1" || presence->getPayload<ErrorPayload>()) { 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<String, std::set< std::pair<JID, String> > >::iterator i = fallbacks.find(hash); + std::map<std::string, std::set< std::pair<JID, std::string> > >::iterator i = fallbacks.find(hash); if (i != fallbacks.end() && !i->second.empty()) { - std::pair<JID,String> fallbackAndNode = *i->second.begin(); + std::pair<JID,std::string> 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<Presence>); 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<String> requestedDiscoInfos; - std::set< std::pair<JID, String> > failingCaps; - std::map<String, std::set< std::pair<JID, String> > > fallbacks; + std::set<std::string> requestedDiscoInfos; + std::set< std::pair<JID, std::string> > failingCaps; + std::map<std::string, std::set< std::pair<JID, std::string> > > 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 <boost/shared_ptr.hpp> #include <map> -#include "Swiften/Base/String.h" +#include <string> #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<String, DiscoInfo::ref> CapsMap; + typedef std::map<std::string, DiscoInfo::ref> 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<void (const String&)> onCapsAvailable; + boost::signal<void (const std::string&)> 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<DiscoInfo> info) { - if (info->getNode().isEmpty()) { +bool DiscoInfoResponder::handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<DiscoInfo> info) { + if (info->getNode().empty()) { sendResponse(from, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(info_))); } else { - std::map<String,DiscoInfo>::const_iterator i = nodeInfo_.find(info->getNode()); + std::map<std::string,DiscoInfo>::const_iterator i = nodeInfo_.find(info->getNode()); if (i != nodeInfo_.end()) { sendResponse(from, id, boost::shared_ptr<DiscoInfo>(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<DiscoInfo> payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<DiscoInfo> payload); private: DiscoInfo info_; - std::map<String, DiscoInfo> nodeInfo_; + std::map<std::string, DiscoInfo> 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<Presence> prese if (!capsInfo || capsInfo->getHash() != "sha-1" || presence->getPayload<ErrorPayload>()) { return; } - String hash = capsInfo->getVersion(); - std::map<JID, String>::iterator i = caps.find(from); + std::string hash = capsInfo->getVersion(); + std::map<JID, std::string>::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<Presence> prese } } else { - std::map<JID, String>::iterator i = caps.find(from); + std::map<JID, std::string>::iterator i = caps.find(from); if (i != caps.end()) { caps.erase(i); onCapsChanged(from); @@ -51,17 +51,17 @@ void EntityCapsManager::handlePresenceReceived(boost::shared_ptr<Presence> prese void EntityCapsManager::handleStanzaChannelAvailableChanged(bool available) { if (available) { - std::map<JID, String> capsCopy; + std::map<JID, std::string> capsCopy; capsCopy.swap(caps); - for (std::map<JID,String>::const_iterator i = capsCopy.begin(); i != capsCopy.end(); ++i) { + for (std::map<JID,std::string>::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<JID,String>::const_iterator i = caps.begin(); i != caps.end(); ++i) { + for (std::map<JID,std::string>::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<JID, String>::const_iterator i = caps.find(jid); + std::map<JID, std::string>::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<Presence>); void handleStanzaChannelAvailableChanged(bool); - void handleCapsAvailable(const String&); + void handleCapsAvailable(const std::string&); private: CapsProvider* capsProvider; - std::map<JID, String> caps; + std::map<JID, std::string> 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<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(new DiscoInfo()), router) { } - GetDiscoInfoRequest(const JID& jid, const String& node, IQRouter* router) : + GetDiscoInfoRequest(const JID& jid, const std::string& node, IQRouter* router) : GenericRequest<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(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> discoInfo) { +bool JIDDiscoInfoResponder::handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<DiscoInfo> 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<DiscoInfo>(new DiscoInfo(i->second.discoInfo))); } else { - std::map<String,DiscoInfo>::const_iterator j = i->second.nodeDiscoInfo.find(discoInfo->getNode()); + std::map<std::string,DiscoInfo>::const_iterator j = i->second.nodeDiscoInfo.find(discoInfo->getNode()); if (j != i->second.nodeDiscoInfo.end()) { sendResponse(from, to, id, boost::shared_ptr<DiscoInfo>(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<DiscoInfo> payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<DiscoInfo> payload); private: struct JIDDiscoInfo { DiscoInfo discoInfo; - std::map<String, DiscoInfo> nodeDiscoInfo; + std::map<std::string, DiscoInfo> nodeDiscoInfo; }; typedef std::map<JID, JIDDiscoInfo> 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<String> ipVersions; + std::vector<std::string> 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<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); 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<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); 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<String, DiscoInfo::ref>::const_iterator i = caps.find(hash); + virtual DiscoInfo::ref getCaps(const std::string& hash) const { + std::map<std::string, DiscoInfo::ref>::const_iterator i = caps.find(hash); if (i != caps.end()) { return i->second; } return DiscoInfo::ref(); } - std::map<String, DiscoInfo::ref> caps; + std::map<std::string, DiscoInfo::ref> 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<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); 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<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); 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<ByteArray>& message) : + AuthRequest(const std::string& mechanism, const boost::optional<ByteArray>& message) : mechanism_(mechanism), message_(message) { } @@ -33,16 +33,16 @@ namespace Swift { message_ = boost::optional<ByteArray>(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<ByteArray> 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 <string> namespace Swift { class Body : public Payload { public: typedef boost::shared_ptr<Body> 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 <boost/shared_ptr.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -20,20 +20,20 @@ namespace Swift { typedef boost::shared_ptr<Bytestreams> 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<JID> usedStreamHost; std::vector<StreamHost> 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 <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -16,7 +16,7 @@ namespace Swift { public: typedef boost::shared_ptr<CapsInfo> 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 <string> #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 <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #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 <boost/shared_ptr.hpp> #include "Swiften/Elements/Element.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ComponentHandshake : public Element { public: typedef boost::shared_ptr<ComponentHandshake> 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 <algorithm> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Form.h" @@ -19,29 +19,29 @@ namespace Swift { public: typedef boost::shared_ptr<DiscoInfo> 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<String>& getFeatures() const { + const std::vector<std::string>& 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<Identity> identities_; - std::vector<String> features_; + std::vector<std::string> features_; std::vector<Form::ref> 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 <algorithm> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> #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<Item> 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 <boost/shared_ptr.hpp> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> 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<HiddenFormField> f = boost::dynamic_pointer_cast<HiddenFormField>(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 <string> #include "Swiften/JID/JID.h" @@ -31,23 +31,23 @@ namespace Swift { void addField(boost::shared_ptr<FormField> field) { fields_.push_back(field); } const std::vector<boost::shared_ptr<FormField> >& 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<boost::shared_ptr<FormField> > 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 <vector> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #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<String> getRawValues() const { + const std::vector<std::string> 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<Option> options; - std::vector<String> rawValues; + std::vector<std::string> rawValues; }; template<typename T> class GenericFormField : public FormField { @@ -102,14 +102,14 @@ namespace Swift { }; SWIFTEN_DECLARE_FORM_FIELD(Boolean, bool); - SWIFTEN_DECLARE_FORM_FIELD(Fixed, String); - SWIFTEN_DECLARE_FORM_FIELD(Hidden, String); - SWIFTEN_DECLARE_FORM_FIELD(ListSingle, String); - SWIFTEN_DECLARE_FORM_FIELD(TextMulti, String); - SWIFTEN_DECLARE_FORM_FIELD(TextPrivate, String); - SWIFTEN_DECLARE_FORM_FIELD(TextSingle, String); + SWIFTEN_DECLARE_FORM_FIELD(Fixed, std::string); + SWIFTEN_DECLARE_FORM_FIELD(Hidden, std::string); + SWIFTEN_DECLARE_FORM_FIELD(ListSingle, std::string); + SWIFTEN_DECLARE_FORM_FIELD(TextMulti, std::string); + SWIFTEN_DECLARE_FORM_FIELD(TextPrivate, std::string); + SWIFTEN_DECLARE_FORM_FIELD(TextSingle, std::string); SWIFTEN_DECLARE_FORM_FIELD(JIDSingle, JID); SWIFTEN_DECLARE_FORM_FIELD(JIDMulti, std::vector<JID>); - SWIFTEN_DECLARE_FORM_FIELD(ListMulti, std::vector<String>); - SWIFTEN_DECLARE_FORM_FIELD(Untyped, std::vector<String>); + SWIFTEN_DECLARE_FORM_FIELD(ListMulti, std::vector<std::string>); + SWIFTEN_DECLARE_FORM_FIELD(Untyped, std::vector<std::string>); } diff --git a/Swiften/Elements/IBB.h b/Swiften/Elements/IBB.h index 727755f..55f2c4f 100644 --- a/Swiften/Elements/IBB.h +++ b/Swiften/Elements/IBB.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Elements/Payload.h" @@ -27,23 +27,23 @@ namespace Swift { MessageStanza, }; - IBB(Action action = Open, const String& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) { + IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) { } - static IBB::ref createIBBOpen(const String& streamID, int blockSize) { + static IBB::ref createIBBOpen(const std::string& streamID, int blockSize) { IBB::ref result(new IBB(Open, streamID)); result->setBlockSize(blockSize); return result; } - static IBB::ref createIBBData(const String& streamID, int sequenceNumber, const ByteArray& data) { + static IBB::ref createIBBData(const std::string& streamID, int sequenceNumber, const ByteArray& data) { IBB::ref result(new IBB(Data, streamID)); result->setSequenceNumber(sequenceNumber); result->setData(data); return result; } - static IBB::ref createIBBClose(const String& streamID) { + static IBB::ref createIBBClose(const std::string& streamID) { return IBB::ref(new IBB(Close, streamID)); } @@ -63,11 +63,11 @@ namespace Swift { return stanzaType; } - void setStreamID(const String& id) { + void setStreamID(const std::string& id) { streamID = id; } - const String& getStreamID() const { + const std::string& getStreamID() const { return streamID; } @@ -97,7 +97,7 @@ namespace Swift { private: Action action; - String streamID; + std::string streamID; ByteArray data; StanzaType stanzaType; int blockSize; diff --git a/Swiften/Elements/IQ.cpp b/Swiften/Elements/IQ.cpp index abf32e9..eb62ee4 100644 --- a/Swiften/Elements/IQ.cpp +++ b/Swiften/Elements/IQ.cpp @@ -9,7 +9,7 @@ namespace Swift { boost::shared_ptr<IQ> IQ::createRequest( - Type type, const JID& to, const String& id, boost::shared_ptr<Payload> payload) { + Type type, const JID& to, const std::string& id, boost::shared_ptr<Payload> payload) { boost::shared_ptr<IQ> iq(new IQ(type)); if (to.isValid()) { iq->setTo(to); @@ -21,7 +21,7 @@ boost::shared_ptr<IQ> IQ::createRequest( return iq; } -boost::shared_ptr<IQ> IQ::createResult(const JID& to, const String& id, boost::shared_ptr<Payload> payload) { +boost::shared_ptr<IQ> IQ::createResult(const JID& to, const std::string& id, boost::shared_ptr<Payload> payload) { boost::shared_ptr<IQ> iq(new IQ(Result)); iq->setTo(to); iq->setID(id); @@ -31,7 +31,7 @@ boost::shared_ptr<IQ> IQ::createResult(const JID& to, const String& id, boost::s return iq; } -boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const String& id, boost::shared_ptr<Payload> payload) { +boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const std::string& id, boost::shared_ptr<Payload> payload) { boost::shared_ptr<IQ> iq(new IQ(Result)); iq->setTo(to); iq->setFrom(from); @@ -42,7 +42,7 @@ boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const Str return iq; } -boost::shared_ptr<IQ> IQ::createError(const JID& to, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { +boost::shared_ptr<IQ> IQ::createError(const JID& to, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); iq->setTo(to); iq->setID(id); @@ -50,7 +50,7 @@ boost::shared_ptr<IQ> IQ::createError(const JID& to, const String& id, ErrorPayl return iq; } -boost::shared_ptr<IQ> IQ::createError(const JID& to, const JID& from, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { +boost::shared_ptr<IQ> IQ::createError(const JID& to, const JID& from, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); iq->setTo(to); iq->setFrom(from); diff --git a/Swiften/Elements/IQ.h b/Swiften/Elements/IQ.h index 007dda2..78a8bbd 100644 --- a/Swiften/Elements/IQ.h +++ b/Swiften/Elements/IQ.h @@ -26,26 +26,26 @@ namespace Swift { static boost::shared_ptr<IQ> createRequest( Type type, const JID& to, - const String& id, + const std::string& id, boost::shared_ptr<Payload> payload); static boost::shared_ptr<IQ> createResult( const JID& to, - const String& id, + const std::string& id, boost::shared_ptr<Payload> payload = boost::shared_ptr<Payload>()); static boost::shared_ptr<IQ> createResult( const JID& to, const JID& from, - const String& id, + const std::string& id, boost::shared_ptr<Payload> payload = boost::shared_ptr<Payload>()); static boost::shared_ptr<IQ> createError( const JID& to, - const String& id, + const std::string& id, ErrorPayload::Condition condition = ErrorPayload::BadRequest, ErrorPayload::Type type = ErrorPayload::Cancel); static boost::shared_ptr<IQ> createError( const JID& to, const JID& from, - const String& id, + const std::string& id, ErrorPayload::Condition condition = ErrorPayload::BadRequest, ErrorPayload::Type type = ErrorPayload::Cancel); diff --git a/Swiften/Elements/InBandRegistrationPayload.h b/Swiften/Elements/InBandRegistrationPayload.h index 1a293ba..e4e1e6f 100644 --- a/Swiften/Elements/InBandRegistrationPayload.h +++ b/Swiften/Elements/InBandRegistrationPayload.h @@ -11,7 +11,7 @@ #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/Form.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class InBandRegistrationPayload : public Payload { @@ -39,147 +39,147 @@ namespace Swift { remove = b; } - const boost::optional<String>& getInstructions() const { + const boost::optional<std::string>& getInstructions() const { return instructions; } - const boost::optional<String>& getUsername() const { + const boost::optional<std::string>& getUsername() const { return username; } - const boost::optional<String>& getNick() const { + const boost::optional<std::string>& getNick() const { return nick; } - const boost::optional<String>& getPassword() const { + const boost::optional<std::string>& getPassword() const { return password; } - const boost::optional<String>& getName() const { + const boost::optional<std::string>& getName() const { return name; } - const boost::optional<String>& getFirst() const { + const boost::optional<std::string>& getFirst() const { return first; } - const boost::optional<String>& getLast() const { + const boost::optional<std::string>& getLast() const { return last; } - const boost::optional<String>& getEMail() const { + const boost::optional<std::string>& getEMail() const { return email; } - const boost::optional<String>& getAddress() const { + const boost::optional<std::string>& getAddress() const { return address; } - const boost::optional<String>& getCity() const { + const boost::optional<std::string>& getCity() const { return city; } - const boost::optional<String>& getState() const { + const boost::optional<std::string>& getState() const { return state; } - const boost::optional<String>& getZip() const { + const boost::optional<std::string>& getZip() const { return zip; } - const boost::optional<String>& getPhone() const { + const boost::optional<std::string>& getPhone() const { return phone; } - const boost::optional<String>& getURL() const { + const boost::optional<std::string>& getURL() const { return url; } - const boost::optional<String>& getDate() const { + const boost::optional<std::string>& getDate() const { return date; } - const boost::optional<String>& getMisc() const { + const boost::optional<std::string>& getMisc() const { return misc; } - const boost::optional<String>& getText() const { + const boost::optional<std::string>& getText() const { return text; } - const boost::optional<String>& getKey() const { + const boost::optional<std::string>& getKey() const { return key; } - void setInstructions(const String& v) { + void setInstructions(const std::string& v) { this->instructions = v; } - void setUsername(const String& v) { + void setUsername(const std::string& v) { this->username = v; } - void setNick(const String& v) { + void setNick(const std::string& v) { this->nick = v; } - void setPassword(const String& v) { + void setPassword(const std::string& v) { this->password = v; } - void setName(const String& v) { + void setName(const std::string& v) { this->name = v; } - void setFirst(const String& v) { + void setFirst(const std::string& v) { this->first = v; } - void setLast(const String& v) { + void setLast(const std::string& v) { this->last = v; } - void setEMail(const String& v) { + void setEMail(const std::string& v) { this->email = v; } - void setAddress(const String& v) { + void setAddress(const std::string& v) { this->address = v; } - void setCity(const String& v) { + void setCity(const std::string& v) { this->city = v; } - void setState(const String& v) { + void setState(const std::string& v) { this->state = v; } - void setZip(const String& v) { + void setZip(const std::string& v) { this->zip = v; } - void setPhone(const String& v) { + void setPhone(const std::string& v) { this->phone = v; } - void setURL(const String& v) { + void setURL(const std::string& v) { this->url = v; } - void setDate(const String& v) { + void setDate(const std::string& v) { this->date = v; } - void setMisc(const String& v) { + void setMisc(const std::string& v) { this->misc = v; } - void setText(const String& v) { + void setText(const std::string& v) { this->text = v; } - void setKey(const String& v) { + void setKey(const std::string& v) { this->key = v; } @@ -187,23 +187,23 @@ namespace Swift { Form::ref form; bool registered; bool remove; - boost::optional<String> instructions; - boost::optional<String> username; - boost::optional<String> nick; - boost::optional<String> password; - boost::optional<String> name; - boost::optional<String> first; - boost::optional<String> last; - boost::optional<String> email; - boost::optional<String> address; - boost::optional<String> city; - boost::optional<String> state; - boost::optional<String> zip; - boost::optional<String> phone; - boost::optional<String> url; - boost::optional<String> date; - boost::optional<String> misc; - boost::optional<String> text; - boost::optional<String> key; + boost::optional<std::string> instructions; + boost::optional<std::string> username; + boost::optional<std::string> nick; + boost::optional<std::string> password; + boost::optional<std::string> name; + boost::optional<std::string> first; + boost::optional<std::string> last; + boost::optional<std::string> email; + boost::optional<std::string> address; + boost::optional<std::string> city; + boost::optional<std::string> state; + boost::optional<std::string> zip; + boost::optional<std::string> phone; + boost::optional<std::string> url; + boost::optional<std::string> date; + boost::optional<std::string> misc; + boost::optional<std::string> text; + boost::optional<std::string> key; }; } diff --git a/Swiften/Elements/JingleContent.h b/Swiften/Elements/JingleContent.h index bf419aa..4ae908b 100644 --- a/Swiften/Elements/JingleContent.h +++ b/Swiften/Elements/JingleContent.h @@ -9,7 +9,7 @@ #include <vector> #include <boost/optional.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/JingleDescription.h> @@ -37,7 +37,7 @@ namespace Swift { this->creator = creator; } - void setName(const String& name) { + void setName(const std::string& name) { this->name = name; } @@ -81,7 +81,7 @@ namespace Swift { private: Creator creator; - String name; + std::string name; //Senders senders; std::vector<JingleDescription::ref> descriptions; std::vector<JingleTransport::ref> transports; diff --git a/Swiften/Elements/JingleIBBTransport.h b/Swiften/Elements/JingleIBBTransport.h index ca3ecc8..faa5af3 100644 --- a/Swiften/Elements/JingleIBBTransport.h +++ b/Swiften/Elements/JingleIBBTransport.h @@ -6,7 +6,7 @@ #pragma once -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/Elements/JingleTransport.h> namespace Swift { @@ -25,11 +25,11 @@ namespace Swift { return stanzaType; } - void setSessionID(const String& id) { + void setSessionID(const std::string& id) { sessionID = id; } - const String& getSessionID() const { + const std::string& getSessionID() const { return sessionID; } @@ -42,7 +42,7 @@ namespace Swift { } private: - String sessionID; + std::string sessionID; int blockSize; StanzaType stanzaType; }; diff --git a/Swiften/Elements/JinglePayload.h b/Swiften/Elements/JinglePayload.h index 66b6d43..59d3c99 100644 --- a/Swiften/Elements/JinglePayload.h +++ b/Swiften/Elements/JinglePayload.h @@ -9,7 +9,7 @@ #include <vector> #include <boost/optional.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/JingleContent.h> @@ -40,9 +40,9 @@ namespace Swift { UnsupportedTransports }; - Reason(Type type, const String& text = "") : type(type), text(text) {} + Reason(Type type, const std::string& text = "") : type(type), text(text) {} Type type; - String text; + std::string text; }; enum Action { @@ -63,7 +63,7 @@ namespace Swift { TransportReplace }; - JinglePayload(Action action, const String& sessionID) : action(action), sessionID(sessionID) { + JinglePayload(Action action, const std::string& sessionID) : action(action), sessionID(sessionID) { } void setAction(Action action) { @@ -90,11 +90,11 @@ namespace Swift { return responder; } - void setSessionID(const String& id) { + void setSessionID(const std::string& id) { sessionID = id; } - const String& getSessionID() const { + const std::string& getSessionID() const { return sessionID; } @@ -118,7 +118,7 @@ namespace Swift { Action action; JID initiator; JID responder; - String sessionID; + std::string sessionID; std::vector<JingleContent::ref> contents; boost::optional<Reason> reason; }; diff --git a/Swiften/Elements/MUCOccupant.cpp b/Swiften/Elements/MUCOccupant.cpp index 0d3773e..a5d8f0e 100644 --- a/Swiften/Elements/MUCOccupant.cpp +++ b/Swiften/Elements/MUCOccupant.cpp @@ -8,7 +8,7 @@ namespace Swift { -MUCOccupant::MUCOccupant(const String &nick, Role role, Affiliation affiliation) : nick_(nick), role_(role), affiliation_(affiliation) { +MUCOccupant::MUCOccupant(const std::string &nick, Role role, Affiliation affiliation) : nick_(nick), role_(role), affiliation_(affiliation) { } MUCOccupant::~MUCOccupant() { @@ -18,7 +18,7 @@ MUCOccupant::MUCOccupant(const MUCOccupant& other) : nick_(other.getNick()), rol } -String MUCOccupant::getNick() const { +std::string MUCOccupant::getNick() const { return nick_; } @@ -34,7 +34,7 @@ void MUCOccupant::setRealJID(const JID& realJID) { realJID_ = realJID; } -void MUCOccupant::setNick(const String& nick) { +void MUCOccupant::setNick(const std::string& nick) { nick_ = nick; } diff --git a/Swiften/Elements/MUCOccupant.h b/Swiften/Elements/MUCOccupant.h index 96ac5ad..b3ae4aa 100644 --- a/Swiften/Elements/MUCOccupant.h +++ b/Swiften/Elements/MUCOccupant.h @@ -8,7 +8,7 @@ #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -19,19 +19,19 @@ namespace Swift { enum Role {Moderator, Participant, Visitor, NoRole}; enum Affiliation {Owner, Admin, Member, Outcast, NoAffiliation}; - MUCOccupant(const String &nick, Role role, Affiliation affiliation); + MUCOccupant(const std::string &nick, Role role, Affiliation affiliation); MUCOccupant(const MUCOccupant& other); ~MUCOccupant(); - String getNick() const; + std::string getNick() const; Role getRole() const; Affiliation getAffiliation() const; boost::optional<JID> getRealJID() const; void setRealJID(const JID& jid); - void setNick(const String& nick); + void setNick(const std::string& nick); private: - String nick_; + std::string nick_; Role role_; Affiliation affiliation_; boost::optional<JID> realJID_; diff --git a/Swiften/Elements/MUCPayload.h b/Swiften/Elements/MUCPayload.h index b8210e1..c372360 100644 --- a/Swiften/Elements/MUCPayload.h +++ b/Swiften/Elements/MUCPayload.h @@ -10,7 +10,7 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { diff --git a/Swiften/Elements/MUCUserPayload.h b/Swiften/Elements/MUCUserPayload.h index 2364b6c..fb6d4c4 100644 --- a/Swiften/Elements/MUCUserPayload.h +++ b/Swiften/Elements/MUCUserPayload.h @@ -8,9 +8,10 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> +#include <string> +#include <vector> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/MUCOccupant.h" @@ -22,7 +23,7 @@ namespace Swift { struct Item { Item(MUCOccupant::Affiliation affiliation = MUCOccupant::NoAffiliation, MUCOccupant::Role role = MUCOccupant::NoRole) : affiliation(affiliation), role(role) {} boost::optional<JID> realJID; - boost::optional<String> nick; + boost::optional<std::string> nick; MUCOccupant::Affiliation affiliation; MUCOccupant::Role role; }; diff --git a/Swiften/Elements/Message.h b/Swiften/Elements/Message.h index ea03299..a553eb3 100644 --- a/Swiften/Elements/Message.h +++ b/Swiften/Elements/Message.h @@ -9,7 +9,7 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Body.h" #include "Swiften/Elements/Subject.h" #include "Swiften/Elements/ErrorPayload.h" @@ -24,7 +24,7 @@ namespace Swift { Message() : type_(Chat) { } - String getSubject() const { + std::string getSubject() const { boost::shared_ptr<Subject> subject(getPayload<Subject>()); if (subject) { return subject->getText(); @@ -32,11 +32,11 @@ namespace Swift { return ""; } - void setSubject(const String& subject) { + void setSubject(const std::string& subject) { updatePayload(boost::shared_ptr<Subject>(new Subject(subject))); } - String getBody() const { + std::string getBody() const { boost::shared_ptr<Body> body(getPayload<Body>()); if (body) { return body->getText(); @@ -44,7 +44,7 @@ namespace Swift { return ""; } - void setBody(const String& body) { + void setBody(const std::string& body) { updatePayload(boost::shared_ptr<Body>(new Body(body))); } diff --git a/Swiften/Elements/Nickname.h b/Swiften/Elements/Nickname.h index 1a8d648..540f6da 100644 --- a/Swiften/Elements/Nickname.h +++ b/Swiften/Elements/Nickname.h @@ -7,23 +7,23 @@ #pragma once #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class Nickname : public Payload { public: - Nickname(const String& nickname = "") : nickname(nickname) { + Nickname(const std::string& nickname = "") : nickname(nickname) { } - void setNickname(const String& nickname) { + void setNickname(const std::string& nickname) { this->nickname = nickname; } - const String& getNickname() const { + const std::string& getNickname() const { return nickname; } private: - String nickname; + std::string nickname; }; } diff --git a/Swiften/Elements/Presence.h b/Swiften/Elements/Presence.h index 642262c..7f957ba 100644 --- a/Swiften/Elements/Presence.h +++ b/Swiften/Elements/Presence.h @@ -20,7 +20,7 @@ namespace Swift { enum Type { Available, Error, Probe, Subscribe, Subscribed, Unavailable, Unsubscribe, Unsubscribed }; Presence() : type_(Available) /*, showType_(Online)*/ {} - Presence(const String& status) : type_(Available) { + Presence(const std::string& status) : type_(Available) { setStatus(status); } @@ -28,7 +28,7 @@ namespace Swift { return ref(new Presence()); } - static ref create(const String& status) { + static ref create(const std::string& status) { return ref(new Presence(status)); } @@ -51,7 +51,7 @@ namespace Swift { updatePayload(boost::shared_ptr<StatusShow>(new StatusShow(show))); } - String getStatus() const { + std::string getStatus() const { boost::shared_ptr<Status> status(getPayload<Status>()); if (status) { return status->getText(); @@ -59,7 +59,7 @@ namespace Swift { return ""; } - void setStatus(const String& status) { + void setStatus(const std::string& status) { updatePayload(boost::shared_ptr<Status>(new Status(status))); } diff --git a/Swiften/Elements/ProtocolHeader.h b/Swiften/Elements/ProtocolHeader.h index 36ece34..841f7a0 100644 --- a/Swiften/Elements/ProtocolHeader.h +++ b/Swiften/Elements/ProtocolHeader.h @@ -6,37 +6,37 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ProtocolHeader { public: ProtocolHeader() : version("1.0") {} - const String& getTo() const { return to; } - void setTo(const String& a) { + const std::string& getTo() const { return to; } + void setTo(const std::string& a) { to = a; } - const String& getFrom() const { return from; } - void setFrom(const String& a) { + const std::string& getFrom() const { return from; } + void setFrom(const std::string& a) { from = a; } - const String& getVersion() const { return version; } - void setVersion(const String& a) { + const std::string& getVersion() const { return version; } + void setVersion(const std::string& a) { version = a; } - const String& getID() const { return id; } - void setID(const String& a) { + const std::string& getID() const { return id; } + void setID(const std::string& a) { id = a; } private: - String to; - String from; - String id; - String version; + std::string to; + std::string from; + std::string id; + std::string version; }; } diff --git a/Swiften/Elements/RawXMLPayload.h b/Swiften/Elements/RawXMLPayload.h index 0a381ac..b042b95 100644 --- a/Swiften/Elements/RawXMLPayload.h +++ b/Swiften/Elements/RawXMLPayload.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -14,15 +14,15 @@ namespace Swift { public: RawXMLPayload() {} - void setRawXML(const String& data) { + void setRawXML(const std::string& data) { rawXML_ = data; } - const String& getRawXML() const { + const std::string& getRawXML() const { return rawXML_; } private: - String rawXML_; + std::string rawXML_; }; } diff --git a/Swiften/Elements/ResourceBind.h b/Swiften/Elements/ResourceBind.h index c13ac69..3569eb3 100644 --- a/Swiften/Elements/ResourceBind.h +++ b/Swiften/Elements/ResourceBind.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_ResourceBind_H #define SWIFTEN_ResourceBind_H -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" #include "Swiften/JID/JID.h" @@ -25,17 +25,17 @@ namespace Swift { return jid_; } - void setResource(const String& resource) { + void setResource(const std::string& resource) { resource_ = resource; } - const String& getResource() const { + const std::string& getResource() const { return resource_; } private: JID jid_; - String resource_; + std::string resource_; }; } diff --git a/Swiften/Elements/RosterItemPayload.h b/Swiften/Elements/RosterItemPayload.h index 84b2887..b8a1b10 100644 --- a/Swiften/Elements/RosterItemPayload.h +++ b/Swiften/Elements/RosterItemPayload.h @@ -10,7 +10,7 @@ #include <vector> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class RosterItemPayload @@ -19,36 +19,36 @@ namespace Swift { enum Subscription { None, To, From, Both, Remove }; RosterItemPayload() : subscription_(None), ask_(false) {} - RosterItemPayload(const JID& jid, const String& name, Subscription subscription) : jid_(jid), name_(name), subscription_(subscription), ask_(false) { } + RosterItemPayload(const JID& jid, const std::string& name, Subscription subscription) : jid_(jid), name_(name), subscription_(subscription), ask_(false) { } void setJID(const JID& jid) { jid_ = jid; } const JID& getJID() const { return jid_; } - void setName(const String& name) { name_ = name; } - const String& getName() const { return name_; } + void setName(const std::string& name) { name_ = name; } + const std::string& getName() const { return name_; } void setSubscription(Subscription subscription) { subscription_ = subscription; } const Subscription& getSubscription() const { return subscription_; } - void addGroup(const String& group) { groups_.push_back(group); } - void setGroups(const std::vector<String>& groups) { groups_ = groups; } - const std::vector<String>& getGroups() const { return groups_; } + void addGroup(const std::string& group) { groups_.push_back(group); } + void setGroups(const std::vector<std::string>& groups) { groups_ = groups; } + const std::vector<std::string>& getGroups() const { return groups_; } void setSubscriptionRequested() { ask_ = true; } bool getSubscriptionRequested() const { return ask_; } - const String& getUnknownContent() const { return unknownContent_; } - void addUnknownContent(const String& c) { + const std::string& getUnknownContent() const { return unknownContent_; } + void addUnknownContent(const std::string& c) { unknownContent_ += c; } private: JID jid_; - String name_; + std::string name_; Subscription subscription_; - std::vector<String> groups_; + std::vector<std::string> groups_; bool ask_; - String unknownContent_; + std::string unknownContent_; }; } diff --git a/Swiften/Elements/SearchPayload.h b/Swiften/Elements/SearchPayload.h index 61b8547..3a484cc 100644 --- a/Swiften/Elements/SearchPayload.h +++ b/Swiften/Elements/SearchPayload.h @@ -11,7 +11,7 @@ #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/Form.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { /** @@ -22,10 +22,10 @@ namespace Swift { typedef boost::shared_ptr<SearchPayload> ref; struct Item { - String first; - String last; - String nick; - String email; + std::string first; + std::string last; + std::string nick; + std::string email; JID jid; }; @@ -34,43 +34,43 @@ namespace Swift { Form::ref getForm() const { return form; } void setForm(Form::ref f) { form = f; } - const boost::optional<String>& getInstructions() const { + const boost::optional<std::string>& getInstructions() const { return instructions; } - const boost::optional<String>& getNick() const { + const boost::optional<std::string>& getNick() const { return nick; } - const boost::optional<String>& getFirst() const { + const boost::optional<std::string>& getFirst() const { return first; } - const boost::optional<String>& getLast() const { + const boost::optional<std::string>& getLast() const { return last; } - const boost::optional<String>& getEMail() const { + const boost::optional<std::string>& getEMail() const { return email; } - void setInstructions(const String& v) { + void setInstructions(const std::string& v) { this->instructions = v; } - void setNick(const String& v) { + void setNick(const std::string& v) { this->nick = v; } - void setFirst(const String& v) { + void setFirst(const std::string& v) { this->first = v; } - void setLast(const String& v) { + void setLast(const std::string& v) { this->last = v; } - void setEMail(const String& v) { + void setEMail(const std::string& v) { this->email = v; } @@ -84,11 +84,11 @@ namespace Swift { private: Form::ref form; - boost::optional<String> instructions; - boost::optional<String> nick; - boost::optional<String> first; - boost::optional<String> last; - boost::optional<String> email; |