summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Roster')
m---------Swiften0
-rw-r--r--Swiften/Roster/AppearOffline.h26
-rw-r--r--Swiften/Roster/ContactRosterItem.cpp50
-rw-r--r--Swiften/Roster/ContactRosterItem.h41
-rw-r--r--Swiften/Roster/GroupRosterItem.h68
-rw-r--r--Swiften/Roster/OfflineRosterFilter.h24
-rw-r--r--Swiften/Roster/OpenChatRosterAction.h20
-rw-r--r--Swiften/Roster/Roster.cpp139
-rw-r--r--Swiften/Roster/Roster.h49
-rw-r--r--Swiften/Roster/RosterFilter.h17
-rw-r--r--Swiften/Roster/RosterItem.h24
-rw-r--r--Swiften/Roster/RosterItemOperation.h16
-rw-r--r--Swiften/Roster/SetAvatar.h33
-rw-r--r--Swiften/Roster/SetPresence.h38
-rw-r--r--Swiften/Roster/TreeWidget.h13
-rw-r--r--Swiften/Roster/TreeWidgetFactory.h20
-rw-r--r--Swiften/Roster/TreeWidgetItem.h34
-rw-r--r--Swiften/Roster/UnitTest/MockTreeWidget.h14
-rw-r--r--Swiften/Roster/UnitTest/MockTreeWidgetFactory.h50
-rw-r--r--Swiften/Roster/UnitTest/MockTreeWidgetItem.h30
-rw-r--r--Swiften/Roster/UnitTest/OfflineRosterFilterTest.cpp0
-rw-r--r--Swiften/Roster/UnitTest/RosterTest.cpp57
-rw-r--r--Swiften/Roster/UnitTest/XMPPRosterTest.cpp164
-rw-r--r--Swiften/Roster/UserRosterAction.h32
-rw-r--r--Swiften/Roster/XMPPRoster.cpp48
-rw-r--r--Swiften/Roster/XMPPRoster.h44
26 files changed, 0 insertions, 1051 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/Roster/AppearOffline.h b/Swiften/Roster/AppearOffline.h
deleted file mode 100644
index 673e018..0000000
--- a/Swiften/Roster/AppearOffline.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include "Swiften/Roster/RosterItemOperation.h"
-#include "Swiften/Roster/ContactRosterItem.h"
-
-namespace Swift {
-
-class RosterItem;
-
-class AppearOffline : public RosterItemOperation {
- public:
- AppearOffline() {
- }
-
- virtual void operator() (RosterItem* item) const {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
- if (contact) {
- contact->setStatusShow(StatusShow::None);
- }
- }
-
-};
-
-}
-
-
diff --git a/Swiften/Roster/ContactRosterItem.cpp b/Swiften/Roster/ContactRosterItem.cpp
deleted file mode 100644
index 968f7f1..0000000
--- a/Swiften/Roster/ContactRosterItem.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "Swiften/Roster/ContactRosterItem.h"
-#include "Swiften/Roster/GroupRosterItem.h"
-
-namespace Swift {
-
-
-ContactRosterItem::ContactRosterItem(const JID& jid, const String& name, GroupRosterItem* parent, TreeWidgetFactory* factory) : jid_(jid), name_(name) {
- parent->addChild(this);
- widget_ = factory->createTreeWidgetItem(parent->getWidget());
- widget_->setText(name.isEmpty() ? jid.toString() : name);
- widget_->onUserAction.connect(boost::bind(&ContactRosterItem::handleUserAction, this, _1));
- setStatusShow(StatusShow::None);
-}
-
-ContactRosterItem::~ContactRosterItem() {
- delete widget_;
-}
-
-StatusShow::Type ContactRosterItem::getStatusShow() {
- return statusShow_;
-}
-
-void ContactRosterItem::setStatusShow(StatusShow::Type show) {
- statusShow_ = show;
- widget_->setStatusShow(show);
-}
-
-void ContactRosterItem::setStatusText(const String& status) {
- widget_->setStatusText(status);
-}
-
-void ContactRosterItem::setAvatarPath(const String& path) {
- widget_->setAvatarPath(path);
-}
-
-const JID& ContactRosterItem::getJID() const {
- return jid_;
-}
-
-void ContactRosterItem::show() {
- widget_->show();
-}
-
-void ContactRosterItem::hide() {
- widget_->hide();
-}
-
-}
-
-
diff --git a/Swiften/Roster/ContactRosterItem.h b/Swiften/Roster/ContactRosterItem.h
deleted file mode 100644
index f1810aa..0000000
--- a/Swiften/Roster/ContactRosterItem.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef SWIFTEN_ContactRosterItem_H
-#define SWIFTEN_ContactRosterItem_H
-
-#include "Swiften/Base/String.h"
-#include "Swiften/JID/JID.h"
-#include "Swiften/Roster/TreeWidgetFactory.h"
-#include "Swiften/Roster/RosterItem.h"
-#include "Swiften/Roster/UserRosterAction.h"
-#include "Swiften/Elements/StatusShow.h"
-
-#include <boost/bind.hpp>
-#include <boost/signal.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace Swift {
-
-class TreeWidgetItem;
-class GroupRosterItem;
-class ContactRosterItem : public RosterItem {
- public:
- ContactRosterItem(const JID& jid, const String& name, GroupRosterItem* parent, TreeWidgetFactory* factory);
- ~ContactRosterItem();
-
- StatusShow::Type getStatusShow();
- void setStatusShow(StatusShow::Type show);
- void setStatusText(const String& status);
- void setAvatarPath(const String& path);
- const JID& getJID() const;
- void show();
- void hide();
-
- private:
- JID jid_;
- String name_;
- TreeWidgetItem *widget_;
- StatusShow::Type statusShow_;
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/GroupRosterItem.h b/Swiften/Roster/GroupRosterItem.h
deleted file mode 100644
index 2ab59ea..0000000
--- a/Swiften/Roster/GroupRosterItem.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef SWIFTEN_GroupRosterItem_H
-#define SWIFTEN_GroupRosterItem_H
-
-#include "Swiften/Roster/RosterItem.h"
-#include "Swiften/Base/String.h"
-#include "Swiften/Roster/TreeWidget.h"
-#include "Swiften/Roster/TreeWidgetFactory.h"
-#include "Swiften/Roster/TreeWidgetItem.h"
-#include "Swiften/Roster/ContactRosterItem.h"
-
-#include <list>
-
-namespace Swift {
-
-class GroupRosterItem : public RosterItem {
- public:
- GroupRosterItem(const String& name, TreeWidget* tree, TreeWidgetFactory* factory) : name_(name) {
- widget_ = factory->createTreeWidgetItem(tree);
- widget_->setExpanded(true);
- widget_->setText(name);
- }
-
- ~GroupRosterItem() {
- delete widget_;
- }
-
- const String& getName() const {
- return name_;
- }
-
- TreeWidgetItem* getWidget() const {
- return widget_;
- }
-
- const std::list<RosterItem*>& getChildren() const {
- return children_;
- }
-
- void addChild(RosterItem* item) {
- children_.push_back(item);
- }
-
- void removeChild(const JID& jid) {
- std::list<RosterItem*>::iterator it = children_.begin();
- while (it != children_.end()) {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(*it);
- if (contact && contact->getJID() == jid) {
- delete contact;
- it = children_.erase(it);
- continue;
- }
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(*it);
- if (group) {
- group->removeChild(jid);
- }
- it++;
- }
- }
-
- private:
- String name_;
- TreeWidgetItem* widget_;
- std::list<RosterItem*> children_;
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/OfflineRosterFilter.h b/Swiften/Roster/OfflineRosterFilter.h
deleted file mode 100644
index 512d074..0000000
--- a/Swiften/Roster/OfflineRosterFilter.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef SWIFTEN_OfflineRosterFilter_H
-#define SWIFTEN_OfflineRosterFilter_H
-
-#include "Swiften/Roster/ContactRosterItem.h"
-#include "Swiften/Roster/RosterItem.h"
-#include "Swiften/Roster/RosterFilter.h"
-#include "Swiften/Elements/StatusShow.h"
-
-namespace Swift {
-
-class OfflineRosterFilter : public RosterFilter {
- public:
- virtual ~OfflineRosterFilter() {}
- virtual bool operator() (RosterItem *item) const {
- ContactRosterItem *contactItem = dynamic_cast<ContactRosterItem*>(item);
- return contactItem && contactItem->getStatusShow() == StatusShow::None;
- }
-};
-
-}
-#endif
-
-
-
diff --git a/Swiften/Roster/OpenChatRosterAction.h b/Swiften/Roster/OpenChatRosterAction.h
deleted file mode 100644
index 03715a5..0000000
--- a/Swiften/Roster/OpenChatRosterAction.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef SWIFTEN_OpenChatRosterAction_H
-#define SWIFTEN_OpenChatRosterAction_H
-
-#include "Swiften/Roster/UserRosterAction.h"
-
-namespace Swift {
-class RosterItem;
-class TreeWidgetItem;
-
-class OpenChatRosterAction : public UserRosterAction {
- public:
- virtual ~OpenChatRosterAction() {};
-
-};
-
-}
-#endif
-
-
-
diff --git a/Swiften/Roster/Roster.cpp b/Swiften/Roster/Roster.cpp
deleted file mode 100644
index 28245af..0000000
--- a/Swiften/Roster/Roster.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-#include "Swiften/Roster/Roster.h"
-
-#include "Swiften/Base/foreach.h"
-#include "Swiften/Base/String.h"
-#include "Swiften/JID/JID.h"
-#include "Swiften/Roster/ContactRosterItem.h"
-#include "Swiften/Roster/RosterItem.h"
-#include "Swiften/Roster/GroupRosterItem.h"
-#include "Swiften/Roster/RosterItemOperation.h"
-#include "Swiften/Roster/TreeWidget.h"
-#include "Swiften/Roster/TreeWidgetFactory.h"
-
-#include <boost/bind.hpp>
-
-#include <deque>
-
-namespace Swift {
-
-Roster::Roster(TreeWidget *treeWidget, TreeWidgetFactory *widgetFactory) : treeWidget_(treeWidget), widgetFactory_(widgetFactory) {
-}
-
-Roster::~Roster() {
- foreach (RosterItem* item, items_) {
- delete item;
- }
- delete treeWidget_;
-}
-
-TreeWidget* Roster::getWidget() {
- return treeWidget_;
-}
-
-GroupRosterItem* Roster::getGroup(const String& groupName) {
- foreach (RosterItem *item, children_) {
- GroupRosterItem *group = dynamic_cast<GroupRosterItem*>(item);
- if (group && group->getName() == groupName) {
- return group;
- }
- }
- GroupRosterItem* group = new GroupRosterItem(groupName, treeWidget_, widgetFactory_);
- children_.push_back(group);
- items_.push_back(group);
- return group;
-}
-
-void Roster::handleUserAction(boost::shared_ptr<UserRosterAction> action) {
- onUserAction(action);
-}
-
-void Roster::addContact(const JID& jid, const String& name, const String& group) {
- ContactRosterItem *item = new ContactRosterItem(jid, name, getGroup(group), widgetFactory_);
- items_.push_back(item);
- item->onUserAction.connect(boost::bind(&Roster::handleUserAction, this, _1));
- filterItem(item);
-
-}
-
-void Roster::removeContact(const JID& jid) {
- std::vector<RosterItem*>::iterator it = children_.begin();
- while (it != children_.end()) {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(*it);
- if (contact && contact->getJID() == jid) {
- delete contact;
- it = children_.erase(it);
- continue;
- }
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(*it);
- if (group) {
- group->removeChild(jid);
- }
- it++;
- }
-}
-
-void Roster::removeContactFromGroup(const JID& jid, const String& groupName) {
- std::vector<RosterItem*>::iterator it = children_.begin();
- while (it != children_.end()) {
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(*it);
- if (group && group->getName() == groupName) {
- group->removeChild(jid);
- }
- it++;
- }
-}
-
-
-void Roster::applyOnItems(const RosterItemOperation& operation) {
- std::deque<RosterItem*> queue(children_.begin(), children_.end());
- while (!queue.empty()) {
- RosterItem* item = *queue.begin();
- queue.pop_front();
- operation(item);
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item);
- if (group) {
- queue.insert(queue.begin(), group->getChildren().begin(), group->getChildren().end());
- }
- }
- filterAll();
-}
-
-void Roster::removeFilter(RosterFilter *filter) {
- for (unsigned int i = 0; i < filters_.size(); i++) {
- if (filters_[i] == filter) {
- filters_.erase(filters_.begin() + i);
- break;
- }
- }
- filterAll();
-}
-
-
-void Roster::filterItem(RosterItem* rosterItem) {
- ContactRosterItem *item = dynamic_cast<ContactRosterItem*>(rosterItem);
- if (!item) {
- return;
- }
- bool hide = true;
- foreach (RosterFilter *filter, filters_) {
- hide &= (*filter)(item);
- }
- filters_.size() > 0 && hide ? item->hide() : item->show();
-}
-
-void Roster::filterAll() {
- std::deque<RosterItem*> queue(children_.begin(), children_.end());
- while (!queue.empty()) {
- RosterItem *item = *queue.begin();
- queue.pop_front();
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item);
- if (group) {
- queue.insert(queue.begin(), group->getChildren().begin(), group->getChildren().end());
- } else {
- filterItem(item);
- }
- }
-}
-
-}
-
diff --git a/Swiften/Roster/Roster.h b/Swiften/Roster/Roster.h
deleted file mode 100644
index 6010832..0000000
--- a/Swiften/Roster/Roster.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef SWIFTEN_Roster_H
-#define SWIFTEN_Roster_H
-
-#include "Swiften/Base/String.h"
-#include "Swiften/JID/JID.h"
-#include "Swiften/Roster/RosterItemOperation.h"
-#include "Swiften/Roster/UserRosterAction.h"
-#include "Swiften/Roster/RosterFilter.h"
-
-#include <vector>
-#include <boost/signal.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace Swift {
-
-class TreeWidgetFactory;
-class TreeWidget;
-class RosterItem;
-class GroupRosterItem;
-
-class Roster {
- public:
- Roster(TreeWidget *treeWidget, TreeWidgetFactory *widgetFactory);
- ~Roster();
-
- TreeWidget* getWidget();
- GroupRosterItem* getGroup(const String& groupName);
- void addContact(const JID& jid, const String& name, const String& group);
- void removeContact(const JID& jid);
- void removeContactFromGroup(const JID& jid, const String& group);
- void applyOnItems(const RosterItemOperation& operation);
- boost::signal<void (boost::shared_ptr<UserRosterAction>)> onUserAction;
- void addFilter(RosterFilter *filter) {filters_.push_back(filter);filterAll();}
- void removeFilter(RosterFilter *filter);
- std::vector<RosterFilter*> getFilters() {return filters_;}
-
- private:
- void filterItem(RosterItem* item);
- void filterAll();
- void handleUserAction(boost::shared_ptr<UserRosterAction> action);
- TreeWidget *treeWidget_;
- TreeWidgetFactory *widgetFactory_;
- std::vector<RosterItem*> children_;
- std::vector<RosterItem*> items_;
- std::vector<RosterFilter*> filters_;
-};
-}
-
-#endif
diff --git a/Swiften/Roster/RosterFilter.h b/Swiften/Roster/RosterFilter.h
deleted file mode 100644
index a824304..0000000
--- a/Swiften/Roster/RosterFilter.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef SWIFTEN_RosterFilter_H
-#define SWIFTEN_RosterFilter_H
-
-#include "Swiften/Roster/RosterItem.h"
-
-namespace Swift {
-
-class RosterFilter {
- public:
- virtual ~RosterFilter() {}
- virtual bool operator() (RosterItem* item) const = 0;
-};
-
-}
-#endif
-
-
diff --git a/Swiften/Roster/RosterItem.h b/Swiften/Roster/RosterItem.h
deleted file mode 100644
index 2707920..0000000
--- a/Swiften/Roster/RosterItem.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef SWIFTEN_RosterItem_H
-#define SWIFTEN_RosterItem_H
-
-#include "Swiften/Roster/UserRosterAction.h"
-
-#include <boost/signal.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace Swift {
-
-class RosterItem {
- public:
- virtual ~RosterItem() {};
- boost::signal<void (boost::shared_ptr<UserRosterAction>)> onUserAction;
- protected:
- void handleUserAction(boost::shared_ptr<UserRosterAction> action) {
- action->setRosterItem(this);
- onUserAction(action);
- }
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/RosterItemOperation.h b/Swiften/Roster/RosterItemOperation.h
deleted file mode 100644
index ea8e723..0000000
--- a/Swiften/Roster/RosterItemOperation.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef SWIFTEN_RosterItemOperation_H
-#define SWIFTEN_RosterItemOperation_H
-
-#include "Swiften/Roster/RosterItem.h"
-
-namespace Swift {
-
-class RosterItemOperation {
- public:
- virtual ~RosterItemOperation() {}
- virtual void operator() (RosterItem*) const = 0;
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/SetAvatar.h b/Swiften/Roster/SetAvatar.h
deleted file mode 100644
index 7bc9c37..0000000
--- a/Swiften/Roster/SetAvatar.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef SWIFTEN_SetAvatar_H
-#define SWIFTEN_SetAvatar_H
-
-#include "Swiften/Elements/Presence.h"
-#include "Swiften/JID/JID.h"
-#include "Swiften/Roster/RosterItemOperation.h"
-#include "Swiften/Roster/ContactRosterItem.h"
-
-namespace Swift {
-
-class RosterItem;
-
-class SetAvatar : public RosterItemOperation {
- public:
- SetAvatar(const JID& jid, const String& path, JID::CompareType compareType = JID::WithoutResource) : jid_(jid), path_(path), compareType_(compareType) {
- }
-
- virtual void operator() (RosterItem* item) const {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
- if (contact && contact->getJID().equals(jid_, compareType_)) {
- contact->setAvatarPath(path_);
- }
- }
-
- private:
- JID jid_;
- String path_;
- JID::CompareType compareType_;
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/SetPresence.h b/Swiften/Roster/SetPresence.h
deleted file mode 100644
index a18ae6d..0000000
--- a/Swiften/Roster/SetPresence.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef SWIFTEN_SetPresence_H
-#define SWIFTEN_SetPresence_H
-
-#include "Swiften/Elements/Presence.h"
-#include "Swiften/JID/JID.h"
-#include "Swiften/Roster/RosterItemOperation.h"
-#include "Swiften/Roster/ContactRosterItem.h"
-
-namespace Swift {
-
-class RosterItem;
-
-class SetPresence : public RosterItemOperation {
- public:
- SetPresence(boost::shared_ptr<Presence> presence, JID::CompareType compareType = JID::WithoutResource) : presence_(presence), compareType_(compareType) {
- }
-
- virtual void operator() (RosterItem* item) const {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
- if (contact && contact->getJID().equals(presence_->getFrom(), compareType_)) {
- if (presence_->getType() != Presence::Available) {
- contact->setStatusShow(StatusShow::None);
- contact->setStatusText(presence_->getStatus());
- } else {
- contact->setStatusShow(presence_->getShow());
- contact->setStatusText(presence_->getStatus());
- }
- }
- }
-
- private:
- boost::shared_ptr<Presence> presence_;
- JID::CompareType compareType_;
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/TreeWidget.h b/Swiften/Roster/TreeWidget.h
deleted file mode 100644
index a26003e..0000000
--- a/Swiften/Roster/TreeWidget.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef SWIFTEN_TreeWidget_H
-#define SWIFTEN_TreeWidget_H
-
-namespace Swift {
-
-class TreeWidget {
- public:
- virtual ~TreeWidget() {}
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/TreeWidgetFactory.h b/Swiften/Roster/TreeWidgetFactory.h
deleted file mode 100644
index f4ba68d..0000000
--- a/Swiften/Roster/TreeWidgetFactory.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef SWIFTEN_TreeWidgetFactory_H
-#define SWIFTEN_TreeWidgetFactory_H
-
-namespace Swift {
-
-class TreeWidgetItem;
-class TreeWidget;
-
-class TreeWidgetFactory {
- public:
- virtual ~TreeWidgetFactory() {}
- virtual TreeWidget* createTreeWidget() = 0;
- virtual TreeWidgetItem* createTreeWidgetItem(TreeWidgetItem* item) = 0;
- virtual TreeWidgetItem* createTreeWidgetItem(TreeWidget* item) = 0;
-};
-
-}
-
-#endif
-
diff --git a/Swiften/Roster/TreeWidgetItem.h b/Swiften/Roster/TreeWidgetItem.h
deleted file mode 100644
index 4124546..0000000
--- a/Swiften/Roster/TreeWidgetItem.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef SWIFTEN_TreeWidgetItem_H
-#define SWIFTEN_TreeWidgetItem_H
-
-#include "Swiften/Base/String.h"
-#include "Swiften/Roster/UserRosterAction.h"
-#include "Swiften/Elements/StatusShow.h"
-
-#include <boost/signal.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace Swift {
-
-class TreeWidgetItem {
- public:
- virtual ~TreeWidgetItem() {}
- virtual void setText(const String& text) = 0;
- virtual void setStatusText(const String& text) = 0;
- virtual void setAvatarPath(const String& path) = 0;
- virtual void setExpanded(bool b) = 0;
- //virtual void setTextColor(unsigned long color) = 0;
- virtual void setStatusShow(StatusShow::Type show) = 0;
- //virtual void setBackgroundColor(unsigned long color) = 0;
- boost::signal<void (boost::shared_ptr<UserRosterAction>)> onUserAction;
- virtual void show() = 0;
- virtual void hide() = 0;
- void performUserAction(boost::shared_ptr<UserRosterAction> action) {
- action->setTreeWidgetItem(this);
- onUserAction(action);
- }
-};
-
-}
-#endif
-
diff --git a/Swiften/Roster/UnitTest/MockTreeWidget.h b/Swiften/Roster/UnitTest/MockTreeWidget.h
deleted file mode 100644
index e6f6def..0000000
--- a/Swiften/Roster/UnitTest/MockTreeWidget.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef SWIFTEN_MockTreeWidget_H
-#define SWIFTEN_MockTreeWidget_H
-
-#include "Swiften/Roster/TreeWidget.h"
-
-namespace Swift {
-
-class MockTreeWidget : public TreeWidget {
- public:
- virtual ~MockTreeWidget() {}
-};
-
-}
-#endif
diff --git a/Swiften/Roster/UnitTest/MockTreeWidgetFactory.h b/Swiften/Roster/UnitTest/MockTreeWidgetFactory.h
deleted file mode 100644
index b2b4f10..0000000
--- a/Swiften/Roster/UnitTest/MockTreeWidgetFactory.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef SWIFTEN_MockTreeWidgetFactory_H
-#define SWIFTEN_MockTreeWidgetFactory_H
-
-#include "Swiften/Roster/TreeWidgetFactory.h"
-
-#include <vector>
-#include "Swiften/Base/foreach.h"
-#include "Swiften/Roster/UnitTest/MockTreeWidget.h"
-#include "Swiften/Roster/UnitTest/MockTreeWidgetItem.h"
-
-namespace Swift {
-
-class MockTreeWidgetItem;
-class MockTreeWidget;
-
-class MockTreeWidgetFactory : public TreeWidgetFactory {
- public:
- virtual ~MockTreeWidgetFactory() {}
- virtual TreeWidget* createTreeWidget() {
- root_ = new MockTreeWidget();
- return root_;
- };
- virtual TreeWidgetItem* createTreeWidgetItem(TreeWidgetItem* group) {
- MockTreeWidgetItem* entry = new MockTreeWidgetItem();
- groupMembers_[group].push_back(entry);
- return entry;
- };
- virtual TreeWidgetItem* createTreeWidgetItem(TreeWidget*) {
- MockTreeWidgetItem* group = new MockTreeWidgetItem();
- groups_.push_back(group);
- return group;
- };
- virtual std::vector<String> getGroups() {
- std::vector<String> groupNames;
- foreach (MockTreeWidgetItem* group, groups_) {
- groupNames.push_back(group->getText());
- }
- return groupNames;
- };
- private:
- std::vector<MockTreeWidgetItem*> groups_;
- std::map<TreeWidgetItem*, std::vector<MockTreeWidgetItem*> > groupMembers_;
- MockTreeWidget* root_;
-};
-
-}
-
-#endif
-
-
diff --git a/Swiften/Roster/UnitTest/MockTreeWidgetItem.h b/Swiften/Roster/UnitTest/MockTreeWidgetItem.h
deleted file mode 100644
index a40aca7..0000000
--- a/Swiften/Roster/UnitTest/MockTreeWidgetItem.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef SWIFTEN_MockTreeWidgetItem_H
-#define SWIFTEN_MockTreeWidgetItem_H
-
-#include "Swiften/Base/String.h"
-#include "Swiften/Roster/TreeWidgetItem.h"
-
-#include <boost/signal.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace Swift {
-
-class MockTreeWidgetItem : public TreeWidgetItem {
- public:
- virtual ~MockTreeWidgetItem() {};
- virtual void setText(const String& text) {text_ = text;};
- String getText() {return text_;};
- virtual void setStatusText(const String&) {};
- virtual void setAvatarPath(const String&) {};
- virtual void setExpanded(bool) {};
- virtual void setStatusShow(StatusShow::Type /*show*/) {};
- virtual void show() {};
- virtual void hide() {};
- private:
- String text_;
-};
-
-}
-#endif
-
-
diff --git a/Swiften/Roster/UnitTest/OfflineRosterFilterTest.cpp b/Swiften/Roster/UnitTest/OfflineRosterFilterTest.cpp
deleted file mode 100644
index e69de29..0000000
--- a/Swiften/Roster/UnitTest/OfflineRosterFilterTest.cpp
+++ /dev/null
diff --git a/Swiften/Roster/UnitTest/RosterTest.cpp b/Swiften/Roster/UnitTest/RosterTest.cpp
deleted file mode 100644
index b43a41c..0000000
--- a/Swiften/Roster/UnitTest/RosterTest.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <boost/shared_ptr.hpp>
-
-#include "Swiften/Roster/Roster.h"
-#include "Swiften/Roster/UnitTest/MockTreeWidget.h"
-#include "Swiften/Roster/UnitTest/MockTreeWidgetFactory.h"
-#include "Swiften/Roster/UnitTest/MockTreeWidgetItem.h"
-
-using namespace Swift;
-
-class RosterTest : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(RosterTest);
- CPPUNIT_TEST(testGetGroup);
- CPPUNIT_TEST_SUITE_END();
-
- private:
- Roster *roster_;
- TreeWidget *widget_;
- TreeWidgetFactory *factory_;
- JID jid1_;
- JID jid2_;
- JID jid3_;
-
- public:
-
- RosterTest() : jid1_(JID("a@b.c")), jid2_(JID("b@c.d")), jid3_(JID("c@d.e")) {}
-
- void setUp() {
- factory_ = new MockTreeWidgetFactory();
- widget_ = factory_->createTreeWidget();
- roster_ = new Roster(widget_, factory_);
- }
-
- void tearDown() {
- delete roster_;
- //delete widget_;
- delete factory_;
- }
-
- void testGetGroup() {
- roster_->addContact(jid1_, "Bert", "group1");
- roster_->addContact(jid2_, "Ernie", "group2");
- roster_->addContact(jid3_, "Cookie", "group1");
-
- CPPUNIT_ASSERT_EQUAL(roster_->getGroup("group1"), roster_->getGroup("group1"));
- CPPUNIT_ASSERT_EQUAL(roster_->getGroup("group2"), roster_->getGroup("group2"));
- CPPUNIT_ASSERT_EQUAL(roster_->getGroup("group3"), roster_->getGroup("group3"));
- CPPUNIT_ASSERT(roster_->getGroup("group1") != roster_->getGroup("group2"));
- CPPUNIT_ASSERT(roster_->getGroup("group2") != roster_->getGroup("group3"));
- CPPUNIT_ASSERT(roster_->getGroup("group3") != roster_->getGroup("group1"));
- }
-
-};
-CPPUNIT_TEST_SUITE_REGISTRATION(RosterTest);
-
diff --git a/Swiften/Roster/UnitTest/XMPPRosterTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterTest.cpp
deleted file mode 100644
index d03953e..0000000
--- a/Swiften/Roster/UnitTest/XMPPRosterTest.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <boost/shared_ptr.hpp>
-#include <boost/bind.hpp>
-
-#include <vector>
-
-#include "Swiften/Roster/XMPPRoster.h"
-
-
-using namespace Swift;
-
-enum XMPPRosterEvents {None, Add, Remove, Update};
-
-class XMPPRosterSignalHandler {
-public:
- XMPPRosterSignalHandler(XMPPRoster* roster) {
- lastEvent_ = None;
- roster->onJIDAdded.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDAdded, this, _1));
- roster->onJIDRemoved.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDRemoved, this, _1));
- roster->onJIDUpdated.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDUpdated, this, _1, _2, _3));
- }
-
- XMPPRosterEvents getLastEvent() {
- return lastEvent_;
- }
-
- JID getLastJID() {
- return lastJID_;
- }
-
- String getLastOldName() {
- return lastOldName_;
- }
-
- std::vector<String> getLastOldGroups() {
- return lastOldGroups_;
- }
-
- void reset() {
- lastEvent_ = None;
- }
-
-private:
- void handleJIDAdded(const JID& jid) {
- lastJID_ = jid;
- lastEvent_ = Add;
- }
-
- void handleJIDRemoved(const JID& jid) {
- lastJID_ = jid;
- lastEvent_ = Remove;
- }
-
- void handleJIDUpdated(const JID& jid, const String& oldName, const std::vector<String>& oldGroups) {
- CPPUNIT_ASSERT_EQUAL(None, lastEvent_);
- lastJID_ = jid;
- lastOldName_ = oldName;
- lastOldGroups_ = oldGroups;
- lastEvent_ = Update;
- }
-
- XMPPRosterEvents lastEvent_;
- JID lastJID_;
- String lastOldName_;
- std::vector<String> lastOldGroups_;
-
-};
-
-class XMPPRosterTest : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(XMPPRosterTest);
- CPPUNIT_TEST(testJIDAdded);
- CPPUNIT_TEST(testJIDRemoved);
- CPPUNIT_TEST(testJIDUpdated);
- CPPUNIT_TEST_SUITE_END();
-
- private:
- XMPPRoster* roster_;
- XMPPRosterSignalHandler* handler_;
- JID jid1_;
- JID jid2_;
- JID jid3_;
- std::vector<String> groups1_;
- std::vector<String> groups2_;
-
-
- public:
-
- XMPPRosterTest() : jid1_(JID("a@b.c")), jid2_(JID("b@c.d")), jid3_(JID("c@d.e")) {}
-
- void setUp() {
- roster_ = new XMPPRoster();
- handler_ = new XMPPRosterSignalHandler(roster_);
- groups1_.push_back("bobs");
- groups1_.push_back("berts");
- groups2_.push_back("ernies");
- }
-
- void tearDown() {
- delete roster_;
- }
-
- void testJIDAdded() {
- roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
- CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_));
- CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_));
- handler_->reset();
- roster_->addContact(jid2_, "NameTwo", groups1_, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID());
- CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid2_));
- CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_));
- CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid2_));
- CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_));
- handler_->reset();
- roster_->addContact(jid3_, "NewName", groups2_, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid3_, handler_->getLastJID());
- CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid3_));
- CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid3_));
- }
-
- void testJIDRemoved() {
- roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both);
- handler_->reset();
- roster_->removeContact(jid1_);
- CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
- handler_->reset();
- roster_->addContact(jid1_, "NewName2", groups1_, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
- CPPUNIT_ASSERT_EQUAL(String("NewName2"), roster_->getNameForJID(jid1_));
- roster_->addContact(jid2_, "NewName3", groups1_, RosterItemPayload::Both);
- handler_->reset();
- roster_->removeContact(jid2_);
- CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID());
- handler_->reset();
- roster_->removeContact(jid1_);
- CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
- }
-
- void testJIDUpdated() {
- roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
- CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_));
- CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_));
- handler_->reset();
- roster_->addContact(jid1_, "NameTwo", groups2_, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent());
- CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
- CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid1_));
- CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid1_));
- }
-
-};
-CPPUNIT_TEST_SUITE_REGISTRATION(XMPPRosterTest);
-
diff --git a/Swiften/Roster/UserRosterAction.h b/Swiften/Roster/UserRosterAction.h
deleted file mode 100644
index 80ace68..0000000
--- a/Swiften/Roster/UserRosterAction.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef SWIFTEN_UserRosterAction_H
-#define SWIFTEN_UserRosterAction_H
-
-namespace Swift {
-class RosterItem;
-class TreeWidgetItem;
-
-class UserRosterAction {
- public:
- virtual ~UserRosterAction() {};
- void setRosterItem(RosterItem *item) {
- rosterItem_ = item;
- };
- void setTreeWidgetItem(TreeWidgetItem *item) {
- treeWidgetItem_ = item;
- }
- RosterItem* getRosterItem() {
- return rosterItem_;
- }
- TreeWidgetItem* getTreeWidgetItem() {
- return treeWidgetItem_;
- }
-
- private:
- RosterItem *rosterItem_;
- TreeWidgetItem *treeWidgetItem_;
-};
-
-}
-#endif
-
-
diff --git a/Swiften/Roster/XMPPRoster.cpp b/Swiften/Roster/XMPPRoster.cpp
deleted file mode 100644
index 62edc45..0000000
--- a/Swiften/Roster/XMPPRoster.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "Swiften/Roster/XMPPRoster.h"
-
-namespace Swift {
-
-void XMPPRoster::addContact(const JID& jid, const String& name, const std::vector<String>& groups, RosterItemPayload::Subscription subscription) {
- JID bareJID(jid.toBare());
- bool exists = containsJID(bareJID);
- String oldName = getNameForJID(bareJID);
- std::vector<String> oldGroups = entries_[bareJID].groups;
- if (exists) {
- entries_.erase(bareJID);
- }
- XMPPRosterItem item;
- item.groups = groups;
- item.name = name;
- item.jid = jid;
- item.subscription = subscription;
- entries_[bareJID] = item;
- if (exists) {
- onJIDUpdated(bareJID, oldName, oldGroups);
- } else {
- onJIDAdded(bareJID);
- }
-}
-
-void XMPPRoster::removeContact(const JID& jid) {
- entries_.erase(JID(jid.toBare()));
- onJIDRemoved(jid);
-}
-
-bool XMPPRoster::containsJID(const JID& jid) {
- return entries_.find(JID(jid.toBare())) != entries_.end();
-}
-
-const String& XMPPRoster::getNameForJID(const JID& jid) {
- return entries_[JID(jid.toBare())].name;
-}
-
-const std::vector<String>& XMPPRoster::getGroupsForJID(const JID& jid) {
- return entries_[JID(jid.toBare())].groups;
-}
-
-RosterItemPayload::Subscription XMPPRoster::getSubscriptionStateForJID(const JID& jid) {
- return entries_[JID(jid.toBare())].subscription;
-}
-
-}
-
diff --git a/Swiften/Roster/XMPPRoster.h b/Swiften/Roster/XMPPRoster.h
deleted file mode 100644
index 47326c3..0000000
--- a/Swiften/Roster/XMPPRoster.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef SWIFTEN_XMPPRoster_H
-#define SWIFTEN_XMPPRoster_H
-
-#include "Swiften/Base/String.h"
-#include "Swiften/JID/JID.h"
-#include "Swiften/Elements/RosterItemPayload.h"
-
-#include <map>
-#include <vector>
-#include <boost/signal.hpp>
-
-namespace Swift {
-
-struct XMPPRosterItem {
- JID jid;
- String name;
- std::vector<String> groups;
- RosterItemPayload::Subscription subscription;
-};
-
-class XMPPRoster {
- public:
- XMPPRoster() {};
- ~XMPPRoster() {};
-
- void addContact(const JID& jid, const String& name, const std::vector<String>& groups, const RosterItemPayload::Subscription subscription);
- bool containsJID(const JID& jid);
- void removeContact(const JID& jid);
- RosterItemPayload::Subscription getSubscriptionStateForJID(const JID& jid);
- const String& getNameForJID(const JID& jid);
- const std::vector<String>& getGroupsForJID(const JID& jid);
-
- boost::signal<void (const JID&)> onJIDAdded;
- boost::signal<void (const JID&)> onJIDRemoved;
- boost::signal<void (const JID&, const String&, const std::vector<String>&)> onJIDUpdated;
-
- private:
- //std::map<JID, std::pair<String, std::vector<String> > > entries_;
- std::map<JID, XMPPRosterItem> entries_;
-};
-}
-
-#endif
-