summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2017-07-07 21:09:17 (GMT)
committerTobias Markmann <tm@ayena.de>2017-07-18 15:05:09 (GMT)
commitf0db4d39912e773208e9db2a3da3b68ac92ba17b (patch)
treecb6a455ba7b21d2218b3f9f2040af3bf30a39004 /Swiften/Elements/MIXJoin.h
parentf21c9448c5187493fd08574962d88c2db1405512 (diff)
downloadswift-f0db4d39912e773208e9db2a3da3b68ac92ba17b.zip
swift-f0db4d39912e773208e9db2a3da3b68ac92ba17b.tar.bz2
Add MIXUpdateSubscription Element, its Parser and Serializer
Updates MIXJoin Element list of subscriptions to an unordered_set. Remove redundant MIXSubscribe Element. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Added tests for MIXUpdateSubscription Parser and Serializer based on examples in XEP 0369, which passes. Tested on Ubuntu 16.04 LTS. Change-Id: Ied06269cf329b4fdffdde4ace67ebffa4089fbde
Diffstat (limited to 'Swiften/Elements/MIXJoin.h')
-rw-r--r--Swiften/Elements/MIXJoin.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/Swiften/Elements/MIXJoin.h b/Swiften/Elements/MIXJoin.h
index 2d82adc..ecd7b12 100644
--- a/Swiften/Elements/MIXJoin.h
+++ b/Swiften/Elements/MIXJoin.h
@@ -8,12 +8,12 @@
#include <memory>
#include <string>
+#include <unordered_set>
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Elements/Payload.h>
-#include <Swiften/Elements/MIXSubscribe.h>
#include <Swiften/Elements/Form.h>
#include <Swiften/JID/JID.h>
@@ -31,7 +31,7 @@ namespace Swift {
return channel_;
}
- void setChannel(const JID& channel) {
+ void setChannel(JID channel) {
channel_ = channel;
}
@@ -39,20 +39,24 @@ namespace Swift {
return jid_;
}
- void setJID(const JID& jid) {
+ void setJID(JID jid) {
jid_ = jid;
}
- const std::vector<MIXSubscribe::ref>& getSubscriptions() const {
+ const std::unordered_set<std::string>& getSubscriptions() const {
return subscribeItems_;
}
- void setSubscriptions(const std::vector<MIXSubscribe::ref>& value) {
- subscribeItems_ = value ;
+ void setSubscriptions(std::unordered_set<std::string> values) {
+ subscribeItems_ = values ;
}
- void addSubscription(MIXSubscribe::ref value) {
- subscribeItems_.push_back(value);
+ void addSubscription(std::string value) {
+ subscribeItems_.insert(value);
+ }
+
+ bool hasSubscription(const std::string& value) const {
+ return std::find(subscribeItems_.begin(), subscribeItems_.end(), value) != subscribeItems_.end();
}
void setForm(std::shared_ptr<Form> form) {
@@ -66,7 +70,7 @@ namespace Swift {
private:
boost::optional<JID> jid_;
boost::optional<JID> channel_;
- std::vector<MIXSubscribe::ref> subscribeItems_;
+ std::unordered_set<std::string> subscribeItems_;
std::shared_ptr<Form> form_;
// FIXME: MIXInvitation to be implemented. boost::optional<MIXInvitation> invitation_;
};