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/Roster
parentcad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff)
downloadswift-cb05f5a908e20006c954ce38755c2e422ecc2388.zip
swift-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2
Removed Swift::String.
Diffstat (limited to 'Swift/Controllers/Roster')
-rw-r--r--Swift/Controllers/Roster/ContactRosterItem.cpp20
-rw-r--r--Swift/Controllers/Roster/ContactRosterItem.h24
-rw-r--r--Swift/Controllers/Roster/GroupRosterItem.cpp4
-rw-r--r--Swift/Controllers/Roster/GroupRosterItem.h8
-rw-r--r--Swift/Controllers/Roster/Roster.cpp12
-rw-r--r--Swift/Controllers/Roster/Roster.h10
-rw-r--r--Swift/Controllers/Roster/RosterController.cpp43
-rw-r--r--Swift/Controllers/Roster/RosterController.h14
-rw-r--r--Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp15
-rw-r--r--Swift/Controllers/Roster/RosterGroupExpandinessPersister.h4
-rw-r--r--Swift/Controllers/Roster/RosterItem.cpp12
-rw-r--r--Swift/Controllers/Roster/RosterItem.h14
-rw-r--r--Swift/Controllers/Roster/SetAvatar.h4
-rw-r--r--Swift/Controllers/Roster/SetName.h4
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp46
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterTest.cpp26
16 files changed, 132 insertions, 128 deletions
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);