summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-14 18:57:18 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-14 21:36:32 (GMT)
commitcb05f5a908e20006c954ce38755c2e422ecc2388 (patch)
treea793551a5fe279a57d4330119560e8542f745484 /Swift/Controllers/Chat
parentcad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff)
downloadswift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.zip
swift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2
Removed Swift::String.
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp28
-rw-r--r--Swift/Controllers/Chat/ChatController.h12
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp28
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.h12
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp8
-rw-r--r--Swift/Controllers/Chat/ChatsManager.h6
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp63
-rw-r--r--Swift/Controllers/Chat/MUCController.h34
-rw-r--r--Swift/Controllers/Chat/MUCSearchController.cpp11
-rw-r--r--Swift/Controllers/Chat/MUCSearchController.h22
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp42
-rw-r--r--Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp23
-rw-r--r--Swift/Controllers/Chat/UserSearchController.cpp4
-rw-r--r--Swift/Controllers/Chat/UserSearchController.h8
14 files changed, 153 insertions, 148 deletions
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 {