summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/MIXJoin.h22
-rw-r--r--Swiften/Elements/MIXSubscribe.h38
-rw-r--r--Swiften/Elements/MIXUpdateSubscription.h56
3 files changed, 69 insertions, 47 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_;
};
diff --git a/Swiften/Elements/MIXSubscribe.h b/Swiften/Elements/MIXSubscribe.h
deleted file mode 100644
index eaf1aa9..0000000
--- a/Swiften/Elements/MIXSubscribe.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2017 Tarun Gupta
- * Licensed under the simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-#pragma once
-
-#include <memory>
-#include <string>
-
-#include <boost/optional.hpp>
-
-#include <Swiften/Base/API.h>
-#include <Swiften/Elements/Payload.h>
-
-namespace Swift {
- class SWIFTEN_API MIXSubscribe : public Payload {
-
- public:
- using ref = std::shared_ptr<MIXSubscribe>;
-
- public:
-
- MIXSubscribe() {}
-
- const std::string& getNode() const {
- return node_;
- }
-
- void setNode(const std::string& node) {
- node_ = node;
- }
-
- private:
- std::string node_;
- };
-}
diff --git a/Swiften/Elements/MIXUpdateSubscription.h b/Swiften/Elements/MIXUpdateSubscription.h
new file mode 100644
index 0000000..dc6ed27
--- /dev/null
+++ b/Swiften/Elements/MIXUpdateSubscription.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <memory>
+#include <unordered_set>
+
+#include <boost/optional.hpp>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/Payload.h>
+#include <Swiften/JID/JID.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXUpdateSubscription : public Payload {
+
+ public:
+ using ref = std::shared_ptr<MIXUpdateSubscription>;
+
+ public:
+
+ MIXUpdateSubscription() {}
+
+ const boost::optional<JID>& getJID() const {
+ return jid_;
+ }
+
+ void setJID(JID jid) {
+ jid_ = jid;
+ }
+
+ const std::unordered_set<std::string>& getSubscriptions() const {
+ return subscribeItems_;
+ }
+
+ void setSubscriptions(std::unordered_set<std::string> values) {
+ subscribeItems_ = values ;
+ }
+
+ 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();
+ }
+
+ private:
+ boost::optional<JID> jid_;
+ std::unordered_set<std::string> subscribeItems_;
+ };
+}