summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/Body.h5
-rw-r--r--Swiften/Elements/Bytestreams.h2
-rw-r--r--Swiften/Elements/CapsInfo.h2
-rw-r--r--Swiften/Elements/ChatState.h1
-rw-r--r--Swiften/Elements/Command.h2
-rw-r--r--Swiften/Elements/ComponentHandshake.h2
-rw-r--r--Swiften/Elements/Delay.h2
-rw-r--r--Swiften/Elements/DiscoInfo.cpp6
-rw-r--r--Swiften/Elements/DiscoInfo.h8
-rw-r--r--Swiften/Elements/DiscoItems.h3
-rw-r--r--Swiften/Elements/Element.h5
-rw-r--r--Swiften/Elements/ErrorPayload.h2
-rw-r--r--Swiften/Elements/Form.h3
-rw-r--r--Swiften/Elements/FormField.h2
-rw-r--r--Swiften/Elements/IBB.h14
-rw-r--r--Swiften/Elements/InBandRegistrationPayload.h2
-rw-r--r--Swiften/Elements/JingleContentPayload.h (renamed from Swiften/Elements/JingleContent.h)31
-rw-r--r--Swiften/Elements/JingleIBBTransportPayload.h (renamed from Swiften/Elements/JingleIBBTransport.h)8
-rw-r--r--Swiften/Elements/JinglePayload.h8
-rw-r--r--Swiften/Elements/JingleS5BTransportPayload.h (renamed from Swiften/Elements/JingleS5BTransport.h)6
-rw-r--r--Swiften/Elements/JingleTransportPayload.h (renamed from Swiften/Elements/JingleTransport.h)6
-rw-r--r--Swiften/Elements/MUCPayload.h2
-rw-r--r--Swiften/Elements/Payload.h4
-rw-r--r--Swiften/Elements/Presence.cpp46
-rw-r--r--Swiften/Elements/Presence.h37
-rw-r--r--Swiften/Elements/Priority.h4
-rw-r--r--Swiften/Elements/RosterItemExchangePayload.cpp18
-rw-r--r--Swiften/Elements/RosterItemExchangePayload.h83
-rw-r--r--Swiften/Elements/RosterItemPayload.h14
-rw-r--r--Swiften/Elements/RosterPayload.h9
-rw-r--r--Swiften/Elements/SecurityLabelsCatalog.h8
-rw-r--r--Swiften/Elements/SoftwareVersion.h4
-rw-r--r--Swiften/Elements/Stanza.cpp5
-rw-r--r--Swiften/Elements/Stanza.h27
-rw-r--r--Swiften/Elements/Status.h5
-rw-r--r--Swiften/Elements/StatusShow.cpp12
-rw-r--r--Swiften/Elements/StatusShow.h25
-rw-r--r--Swiften/Elements/StreamFeatures.cpp21
-rw-r--r--Swiften/Elements/StreamFeatures.h23
-rw-r--r--Swiften/Elements/UnitTest/StanzaTest.cpp1
40 files changed, 322 insertions, 146 deletions
diff --git a/Swiften/Elements/Body.h b/Swiften/Elements/Body.h
index 2887390..a2497f7 100644
--- a/Swiften/Elements/Body.h
+++ b/Swiften/Elements/Body.h
@@ -6,14 +6,13 @@
#pragma once
-#include "Swiften/Elements/Payload.h"
#include <string>
+#include <Swiften/Elements/Payload.h>
+
namespace Swift {
class Body : public Payload {
public:
- typedef boost::shared_ptr<Body> ref;
-
Body(const std::string& text = "") : text_(text) {
}
diff --git a/Swiften/Elements/Bytestreams.h b/Swiften/Elements/Bytestreams.h
index b493375..211396b 100644
--- a/Swiften/Elements/Bytestreams.h
+++ b/Swiften/Elements/Bytestreams.h
@@ -9,9 +9,9 @@
#include <vector>
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
+#include <string>
#include "Swiften/JID/JID.h"
-#include <string>
#include "Swiften/Elements/Payload.h"
namespace Swift {
diff --git a/Swiften/Elements/CapsInfo.h b/Swiften/Elements/CapsInfo.h
index ccad278..f1e2c37 100644
--- a/Swiften/Elements/CapsInfo.h
+++ b/Swiften/Elements/CapsInfo.h
@@ -7,8 +7,8 @@
#pragma once
#include <boost/shared_ptr.hpp>
-
#include <string>
+
#include "Swiften/Elements/Payload.h"
namespace Swift {
diff --git a/Swiften/Elements/ChatState.h b/Swiften/Elements/ChatState.h
index 2896877..ddeed79 100644
--- a/Swiften/Elements/ChatState.h
+++ b/Swiften/Elements/ChatState.h
@@ -7,6 +7,7 @@
#pragma once
#include <string>
+
#include "Swiften/Elements/Payload.h"
namespace Swift {
diff --git a/Swiften/Elements/Command.h b/Swiften/Elements/Command.h
index f4059a8..4a9c2a3 100644
--- a/Swiften/Elements/Command.h
+++ b/Swiften/Elements/Command.h
@@ -7,8 +7,8 @@
#pragma once
#include <boost/shared_ptr.hpp>
-
#include <string>
+
#include "Swiften/Elements/Payload.h"
#include "Swiften/Elements/Form.h"
diff --git a/Swiften/Elements/ComponentHandshake.h b/Swiften/Elements/ComponentHandshake.h
index 6047eab..3fe0457 100644
--- a/Swiften/Elements/ComponentHandshake.h
+++ b/Swiften/Elements/ComponentHandshake.h
@@ -7,9 +7,9 @@
#pragma once
#include <boost/shared_ptr.hpp>
+#include <string>
#include "Swiften/Elements/Element.h"
-#include <string>
namespace Swift {
class ComponentHandshake : public Element {
diff --git a/Swiften/Elements/Delay.h b/Swiften/Elements/Delay.h
index 3213037..85d167b 100644
--- a/Swiften/Elements/Delay.h
+++ b/Swiften/Elements/Delay.h
@@ -6,7 +6,7 @@
#pragma once
-#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/optional.hpp>
#include "Swiften/Elements/Payload.h"
diff --git a/Swiften/Elements/DiscoInfo.cpp b/Swiften/Elements/DiscoInfo.cpp
index f0e728e..158ea66 100644
--- a/Swiften/Elements/DiscoInfo.cpp
+++ b/Swiften/Elements/DiscoInfo.cpp
@@ -6,6 +6,8 @@
#include "Swiften/Elements/DiscoInfo.h"
+#include <algorithm>
+
namespace Swift {
const std::string DiscoInfo::ChatStatesFeature = std::string("http://jabber.org/protocol/chatstates");
@@ -33,4 +35,8 @@ bool DiscoInfo::Identity::operator<(const Identity& other) const {
}
}
+bool DiscoInfo::hasFeature(const std::string& feature) const {
+ return std::find(features_.begin(), features_.end(), feature) != features_.end();
+}
+
}
diff --git a/Swiften/Elements/DiscoInfo.h b/Swiften/Elements/DiscoInfo.h
index d5bf64a..6144b16 100644
--- a/Swiften/Elements/DiscoInfo.h
+++ b/Swiften/Elements/DiscoInfo.h
@@ -7,11 +7,9 @@
#pragma once
#include <vector>
-#include <algorithm>
-
-#include "Swiften/Elements/Payload.h"
#include <string>
+#include "Swiften/Elements/Payload.h"
#include "Swiften/Elements/Form.h"
namespace Swift {
@@ -82,9 +80,7 @@ namespace Swift {
features_.push_back(feature);
}
- bool hasFeature(const std::string& feature) const {
- return std::find(features_.begin(), features_.end(), feature) != features_.end();
- }
+ bool hasFeature(const std::string& feature) const;
void addExtension(Form::ref form) {
extensions_.push_back(form);
diff --git a/Swiften/Elements/DiscoItems.h b/Swiften/Elements/DiscoItems.h
index cc5a583..1b7063b 100644
--- a/Swiften/Elements/DiscoItems.h
+++ b/Swiften/Elements/DiscoItems.h
@@ -7,10 +7,9 @@
#pragma once
#include <vector>
-#include <algorithm>
+#include <string>
#include "Swiften/Elements/Payload.h"
-#include <string>
#include "Swiften/JID/JID.h"
namespace Swift {
diff --git a/Swiften/Elements/Element.h b/Swiften/Elements/Element.h
index aded528..1e6a9d0 100644
--- a/Swiften/Elements/Element.h
+++ b/Swiften/Elements/Element.h
@@ -4,8 +4,7 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_ELEMENT_H
-#define SWIFTEN_ELEMENT_H
+#pragma once
namespace Swift {
class Element {
@@ -13,5 +12,3 @@ namespace Swift {
virtual ~Element();
};
}
-
-#endif
diff --git a/Swiften/Elements/ErrorPayload.h b/Swiften/Elements/ErrorPayload.h
index 12ad574..cece81f 100644
--- a/Swiften/Elements/ErrorPayload.h
+++ b/Swiften/Elements/ErrorPayload.h
@@ -7,9 +7,9 @@
#pragma once
#include <boost/shared_ptr.hpp>
+#include <string>
#include "Swiften/Elements/Payload.h"
-#include <string>
namespace Swift {
class ErrorPayload : public Payload {
diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h
index 1c50f0c..4e6e9f1 100644
--- a/Swiften/Elements/Form.h
+++ b/Swiften/Elements/Form.h
@@ -7,11 +7,10 @@
#pragma once
#include <vector>
+#include <string>
#include "Swiften/Elements/Payload.h"
#include "Swiften/Elements/FormField.h"
-#include <string>
-
#include "Swiften/JID/JID.h"
namespace Swift {
diff --git a/Swiften/Elements/FormField.h b/Swiften/Elements/FormField.h
index f455303..35e05ac 100644
--- a/Swiften/Elements/FormField.h
+++ b/Swiften/Elements/FormField.h
@@ -11,8 +11,8 @@
#include <vector>
#include <boost/shared_ptr.hpp>
-
#include <string>
+
#include "Swiften/JID/JID.h"
namespace Swift {
diff --git a/Swiften/Elements/IBB.h b/Swiften/Elements/IBB.h
index 55f2c4f..8138e83 100644
--- a/Swiften/Elements/IBB.h
+++ b/Swiften/Elements/IBB.h
@@ -6,11 +6,11 @@
#pragma once
+#include <string>
+#include <vector>
#include <boost/shared_ptr.hpp>
-#include <string>
-#include "Swiften/Base/ByteArray.h"
-#include "Swiften/Elements/Payload.h"
+#include <Swiften/Elements/Payload.h>
namespace Swift {
class IBB : public Payload {
@@ -36,7 +36,7 @@ namespace Swift {
return result;
}
- static IBB::ref createIBBData(const std::string& streamID, int sequenceNumber, const ByteArray& data) {
+ static IBB::ref createIBBData(const std::string& streamID, int sequenceNumber, const std::vector<unsigned char>& data) {
IBB::ref result(new IBB(Data, streamID));
result->setSequenceNumber(sequenceNumber);
result->setData(data);
@@ -71,11 +71,11 @@ namespace Swift {
return streamID;
}
- const ByteArray& getData() const {
+ const std::vector<unsigned char>& getData() const {
return data;
}
- void setData(const ByteArray& data) {
+ void setData(const std::vector<unsigned char>& data) {
this->data = data;
}
@@ -98,7 +98,7 @@ namespace Swift {
private:
Action action;
std::string streamID;
- ByteArray data;
+ std::vector<unsigned char> data;
StanzaType stanzaType;
int blockSize;
int sequenceNumber;
diff --git a/Swiften/Elements/InBandRegistrationPayload.h b/Swiften/Elements/InBandRegistrationPayload.h
index e4e1e6f..6e0f741 100644
--- a/Swiften/Elements/InBandRegistrationPayload.h
+++ b/Swiften/Elements/InBandRegistrationPayload.h
@@ -8,10 +8,10 @@
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
+#include <string>
#include "Swiften/Elements/Payload.h"
#include "Swiften/Elements/Form.h"
-#include <string>
namespace Swift {
class InBandRegistrationPayload : public Payload {
diff --git a/Swiften/Elements/JingleContent.h b/Swiften/Elements/JingleContentPayload.h
index 4ae908b..c44a806 100644
--- a/Swiften/Elements/JingleContent.h
+++ b/Swiften/Elements/JingleContentPayload.h
@@ -8,18 +8,17 @@
#include <vector>
#include <boost/optional.hpp>
-
#include <string>
+
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/JingleDescription.h>
-#include <Swiften/Elements/JingleTransport.h>
-#include <Swiften/Base/foreach.h>
+#include <Swiften/Elements/JingleTransportPayload.h>
namespace Swift {
- class JingleContent : public Payload {
+ class JingleContentPayload : public Payload {
public:
- typedef boost::shared_ptr<JingleContent> ref;
+ typedef boost::shared_ptr<JingleContentPayload> ref;
enum Creator {
InitiatorCreator,
@@ -33,10 +32,18 @@ namespace Swift {
BothSenders,
};*/
+ Creator getCreator() const {
+ return creator;
+ }
+
void setCreator(Creator creator) {
this->creator = creator;
}
+ const std::string& getName() const {
+ return name;
+ }
+
void setName(const std::string& name) {
this->name = name;
}
@@ -49,18 +56,18 @@ namespace Swift {
descriptions.push_back(description);
}
- const std::vector<JingleTransport::ref>& getTransports() const {
+ const std::vector<boost::shared_ptr<JingleTransportPayload> >& getTransports() const {
return transports;
}
- void addTransport(JingleTransport::ref transport) {
+ void addTransport(boost::shared_ptr<JingleTransportPayload> transport) {
transports.push_back(transport);
}
template<typename T>
boost::shared_ptr<T> getDescription() const {
- foreach (JingleDescription::ref i, descriptions) {
- boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(i));
+ for (size_t i = 0; i < descriptions.size(); ++i) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(descriptions[i]));
if (result) {
return result;
}
@@ -70,8 +77,8 @@ namespace Swift {
template<typename T>
boost::shared_ptr<T> getTransport() const {
- foreach (JingleTransport::ref i, transports) {
- boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(i));
+ for (size_t i = 0; i < transports.size(); ++i) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(transports[i]));
if (result) {
return result;
}
@@ -84,6 +91,6 @@ namespace Swift {
std::string name;
//Senders senders;
std::vector<JingleDescription::ref> descriptions;
- std::vector<JingleTransport::ref> transports;
+ std::vector<boost::shared_ptr<JingleTransportPayload> > transports;
};
}
diff --git a/Swiften/Elements/JingleIBBTransport.h b/Swiften/Elements/JingleIBBTransportPayload.h
index faa5af3..67aab09 100644
--- a/Swiften/Elements/JingleIBBTransport.h
+++ b/Swiften/Elements/JingleIBBTransportPayload.h
@@ -6,12 +6,16 @@
#pragma once
+#include <boost/shared_ptr.hpp>
#include <string>
-#include <Swiften/Elements/JingleTransport.h>
+
+#include <Swiften/Elements/JingleTransportPayload.h>
namespace Swift {
- class JingleIBBTransport : public JingleTransport {
+ class JingleIBBTransportPayload : public JingleTransportPayload {
public:
+ typedef boost::shared_ptr<JingleIBBTransportPayload> ref;
+
enum StanzaType {
IQStanza,
MessageStanza,
diff --git a/Swiften/Elements/JinglePayload.h b/Swiften/Elements/JinglePayload.h
index 59d3c99..be02543 100644
--- a/Swiften/Elements/JinglePayload.h
+++ b/Swiften/Elements/JinglePayload.h
@@ -12,7 +12,7 @@
#include <string>
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/Payload.h>
-#include <Swiften/Elements/JingleContent.h>
+#include <Swiften/Elements/JingleContentPayload.h>
namespace Swift {
@@ -98,11 +98,11 @@ namespace Swift {
return sessionID;
}
- void addContent(JingleContent::ref content) {
+ void addContent(JingleContentPayload::ref content) {
this->contents.push_back(content);
}
- const std::vector<JingleContent::ref> getContents() const {
+ const std::vector<JingleContentPayload::ref> getContents() const {
return contents;
}
@@ -119,7 +119,7 @@ namespace Swift {
JID initiator;
JID responder;
std::string sessionID;
- std::vector<JingleContent::ref> contents;
+ std::vector<JingleContentPayload::ref> contents;
boost::optional<Reason> reason;
};
}
diff --git a/Swiften/Elements/JingleS5BTransport.h b/Swiften/Elements/JingleS5BTransportPayload.h
index 4522417..7b3089f 100644
--- a/Swiften/Elements/JingleS5BTransport.h
+++ b/Swiften/Elements/JingleS5BTransportPayload.h
@@ -6,11 +6,13 @@
#pragma once
-#include <Swiften/Elements/JingleTransport.h>
+#include <Swiften/Elements/JingleTransportPayload.h>
#include <Swiften/Elements/Bytestreams.h>
+// FIXME: Remove Bytestreams, and replace by our own candidate
+
namespace Swift {
- class JingleS5BTransport : public JingleTransport {
+ class JingleS5BTransportPayload : public JingleTransportPayload {
public:
const Bytestreams& getInfo() const {
return info;
diff --git a/Swiften/Elements/JingleTransport.h b/Swiften/Elements/JingleTransportPayload.h
index ecd2a34..7a9ea29 100644
--- a/Swiften/Elements/JingleTransport.h
+++ b/Swiften/Elements/JingleTransportPayload.h
@@ -6,9 +6,13 @@
#pragma once
+#include <boost/shared_ptr.hpp>
+
#include <Swiften/Elements/Payload.h>
namespace Swift {
- class JingleTransport : public Payload {
+ class JingleTransportPayload : public Payload {
+ public:
+ typedef boost::shared_ptr<JingleTransportPayload> ref;
};
}
diff --git a/Swiften/Elements/MUCPayload.h b/Swiften/Elements/MUCPayload.h
index c372360..eb3baeb 100644
--- a/Swiften/Elements/MUCPayload.h
+++ b/Swiften/Elements/MUCPayload.h
@@ -7,7 +7,7 @@
#pragma once
#include <boost/optional.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
#include "Swiften/JID/JID.h"
#include <string>
diff --git a/Swiften/Elements/Payload.h b/Swiften/Elements/Payload.h
index c87b899..8b6d44a 100644
--- a/Swiften/Elements/Payload.h
+++ b/Swiften/Elements/Payload.h
@@ -6,13 +6,9 @@
#pragma once
-#include <boost/shared_ptr.hpp>
-
namespace Swift {
class Payload {
public:
- typedef boost::shared_ptr<Payload> ref;
-
virtual ~Payload();
};
}
diff --git a/Swiften/Elements/Presence.cpp b/Swiften/Elements/Presence.cpp
new file mode 100644
index 0000000..6cde567
--- /dev/null
+++ b/Swiften/Elements/Presence.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Elements/Presence.h>
+
+#include <Swiften/Elements/Priority.h>
+#include <Swiften/Elements/Status.h>
+
+namespace Swift {
+
+Presence::Presence() : type_(Available) /*, showType_(Online)*/ {
+}
+
+Presence::Presence(const std::string& status) : type_(Available) {
+ setStatus(status);
+}
+
+Presence::~Presence() {
+}
+
+int Presence::getPriority() const {
+ boost::shared_ptr<Priority> priority(getPayload<Priority>());
+ return (priority ? priority->getPriority() : 0);
+}
+
+void Presence::setPriority(int priority) {
+ updatePayload(boost::shared_ptr<Priority>(new Priority(priority)));
+}
+
+std::string Presence::getStatus() const {
+ boost::shared_ptr<Status> status(getPayload<Status>());
+ if (status) {
+ return status->getText();
+ }
+ return "";
+}
+
+void Presence::setStatus(const std::string& status) {
+ updatePayload(boost::shared_ptr<Status>(new Status(status)));
+}
+
+
+}
diff --git a/Swiften/Elements/Presence.h b/Swiften/Elements/Presence.h
index 7f957ba..5ae482b 100644
--- a/Swiften/Elements/Presence.h
+++ b/Swiften/Elements/Presence.h
@@ -6,11 +6,8 @@
#pragma once
-
-#include "Swiften/Elements/Stanza.h"
-#include "Swiften/Elements/Status.h"
-#include "Swiften/Elements/StatusShow.h"
-#include "Swiften/Elements/Priority.h"
+#include <Swiften/Elements/Stanza.h>
+#include <Swiften/Elements/StatusShow.h>
namespace Swift {
class Presence : public Stanza {
@@ -19,10 +16,9 @@ namespace Swift {
enum Type { Available, Error, Probe, Subscribe, Subscribed, Unavailable, Unsubscribe, Unsubscribed };
- Presence() : type_(Available) /*, showType_(Online)*/ {}
- Presence(const std::string& status) : type_(Available) {
- setStatus(status);
- }
+ Presence();
+ Presence(const std::string& status);
+ virtual ~Presence();
static ref create() {
return ref(new Presence());
@@ -51,26 +47,11 @@ namespace Swift {
updatePayload(boost::shared_ptr<StatusShow>(new StatusShow(show)));
}
- std::string getStatus() const {
- boost::shared_ptr<Status> status(getPayload<Status>());
- if (status) {
- return status->getText();
- }
- return "";
- }
+ std::string getStatus() const;
+ void setStatus(const std::string& status);
- void setStatus(const std::string& status) {
- updatePayload(boost::shared_ptr<Status>(new Status(status)));
- }
-
- int getPriority() const {
- boost::shared_ptr<Priority> priority(getPayload<Priority>());
- return (priority ? priority->getPriority() : 0);
- }
-
- void setPriority(int priority) {
- updatePayload(boost::shared_ptr<Priority>(new Priority(priority)));
- }
+ int getPriority() const;
+ void setPriority(int priority);
boost::shared_ptr<Presence> clone() const {
return boost::shared_ptr<Presence>(new Presence(*this));
diff --git a/Swiften/Elements/Priority.h b/Swiften/Elements/Priority.h
index 12181d4..2c0cb9b 100644
--- a/Swiften/Elements/Priority.h
+++ b/Swiften/Elements/Priority.h
@@ -6,13 +6,11 @@
#pragma once
-#include "Swiften/Elements/Payload.h"
+#include <Swiften/Elements/Payload.h>
namespace Swift {
class Priority : public Payload {
public:
- typedef boost::shared_ptr<Priority> ref;
-
Priority(int priority = 0) : priority_(priority) {
}
diff --git a/Swiften/Elements/RosterItemExchangePayload.cpp b/Swiften/Elements/RosterItemExchangePayload.cpp
new file mode 100644
index 0000000..f4f3a57
--- /dev/null
+++ b/Swiften/Elements/RosterItemExchangePayload.cpp
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2011 Jan Kaluza
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "Swiften/Elements/RosterItemExchangePayload.h"
+#include "Swiften/Base/foreach.h"
+
+namespace Swift {
+
+RosterItemExchangePayload::Item::Item() {
+}
+
+RosterItemExchangePayload::RosterItemExchangePayload() {
+}
+
+}
diff --git a/Swiften/Elements/RosterItemExchangePayload.h b/Swiften/Elements/RosterItemExchangePayload.h
new file mode 100644
index 0000000..d9e2912
--- /dev/null
+++ b/Swiften/Elements/RosterItemExchangePayload.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011 Jan Kaluza
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <vector>
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Elements/Payload.h"
+#include "Swiften/JID/JID.h"
+
+
+namespace Swift {
+ class RosterItemExchangePayload : public Payload {
+ public:
+ typedef boost::shared_ptr<RosterItemExchangePayload> ref;
+
+ class Item {
+ public:
+ enum Action { Add, Modify, Delete };
+
+ Item();
+
+ Action getAction() const {
+ return action;
+ }
+
+ void setAction(Action action) {
+ this->action = action;
+ }
+
+ const JID& getJID() const {
+ return jid;
+ }
+
+ void setJID(const JID& jid) {
+ this->jid = jid;
+ }
+
+ const std::string& getName() const {
+ return name;
+ }
+
+ void setName(const std::string& name) {
+ this->name = name;
+ }
+
+ const std::vector<std::string>& getGroups() const {
+ return groups;
+ }
+
+ void addGroup(const std::string& group) {
+ groups.push_back(group);
+ }
+
+ private:
+ Action action;
+ JID jid;
+ std::string name;
+ std::vector<std::string> groups;
+ };
+
+ typedef std::vector<RosterItemExchangePayload::Item> RosterItemExchangePayloadItems;
+
+ public:
+ RosterItemExchangePayload();
+
+ void addItem(const RosterItemExchangePayload::Item& item) {
+ items_.push_back(item);
+ }
+
+ const RosterItemExchangePayloadItems& getItems() const {
+ return items_;
+ }
+
+ private:
+ RosterItemExchangePayloadItems items_;
+ };
+}
diff --git a/Swiften/Elements/RosterItemPayload.h b/Swiften/Elements/RosterItemPayload.h
index b8a1b10..915ae31 100644
--- a/Swiften/Elements/RosterItemPayload.h
+++ b/Swiften/Elements/RosterItemPayload.h
@@ -4,22 +4,20 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_RosterItemPayloadPayload_H
-#define SWIFTEN_RosterItemPayloadPayload_H
+#pragma once
#include <vector>
-
-#include "Swiften/JID/JID.h"
#include <string>
+#include <Swiften/JID/JID.h>
+
namespace Swift {
- class RosterItemPayload
- {
+ class RosterItemPayload {
public:
enum Subscription { None, To, From, Both, Remove };
RosterItemPayload() : subscription_(None), ask_(false) {}
- RosterItemPayload(const JID& jid, const std::string& name, Subscription subscription) : jid_(jid), name_(name), subscription_(subscription), ask_(false) { }
+ RosterItemPayload(const JID& jid, const std::string& name, Subscription subscription, const std::vector<std::string>& groups = std::vector<std::string>()) : jid_(jid), name_(name), subscription_(subscription), groups_(groups), ask_(false) { }
void setJID(const JID& jid) { jid_ = jid; }
const JID& getJID() const { return jid_; }
@@ -51,5 +49,3 @@ namespace Swift {
std::string unknownContent_;
};
}
-
-#endif
diff --git a/Swiften/Elements/RosterPayload.h b/Swiften/Elements/RosterPayload.h
index b46b384..3102f0e 100644
--- a/Swiften/Elements/RosterPayload.h
+++ b/Swiften/Elements/RosterPayload.h
@@ -33,7 +33,16 @@ namespace Swift {
return items_;
}
+ const boost::optional<std::string>& getVersion() const {
+ return version_;
+ }
+
+ void setVersion(const std::string& version) {
+ version_ = version;
+ }
+
private:
RosterItemPayloads items_;
+ boost::optional<std::string> version_;
};
}
diff --git a/Swiften/Elements/SecurityLabelsCatalog.h b/Swiften/Elements/SecurityLabelsCatalog.h
index 10ef459..cd84b0b 100644
--- a/Swiften/Elements/SecurityLabelsCatalog.h
+++ b/Swiften/Elements/SecurityLabelsCatalog.h
@@ -4,13 +4,13 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_SecurityLabelsCatalog_H
-#define SWIFTEN_SecurityLabelsCatalog_H
+#pragma once
#include <vector>
+#include <string>
+#include <boost/shared_ptr.hpp>
#include "Swiften/JID/JID.h"
-#include <string>
#include "Swiften/Elements/Payload.h"
#include "Swiften/Elements/SecurityLabel.h"
@@ -85,5 +85,3 @@ namespace Swift {
std::vector<Item> items_;
};
}
-
-#endif
diff --git a/Swiften/Elements/SoftwareVersion.h b/Swiften/Elements/SoftwareVersion.h
index 5863b38..887c6e9 100644
--- a/Swiften/Elements/SoftwareVersion.h
+++ b/Swiften/Elements/SoftwareVersion.h
@@ -6,8 +6,10 @@
#pragma once
-#include "Swiften/Elements/Payload.h"
#include <string>
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Elements/Payload.h"
namespace Swift {
class SoftwareVersion : public Payload {
diff --git a/Swiften/Elements/Stanza.cpp b/Swiften/Elements/Stanza.cpp
index d15d778..607dfd1 100644
--- a/Swiften/Elements/Stanza.cpp
+++ b/Swiften/Elements/Stanza.cpp
@@ -9,8 +9,13 @@
#include <typeinfo>
+#include <Swiften/Base/foreach.h>
+
namespace Swift {
+Stanza::Stanza() {
+}
+
Stanza::~Stanza() {
payloads_.clear();
}
diff --git a/Swiften/Elements/Stanza.h b/Swiften/Elements/Stanza.h
index 9b934e4..9e082cc 100644
--- a/Swiften/Elements/Stanza.h
+++ b/Swiften/Elements/Stanza.h
@@ -7,27 +7,28 @@
#pragma once
#include <vector>
+#include <string>
#include <boost/shared_ptr.hpp>
-#include <boost/optional.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/optional/optional_fwd.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
-#include "Swiften/Elements/Element.h"
-#include "Swiften/Elements/Payload.h"
-#include <string>
-#include "Swiften/Base/foreach.h"
-#include "Swiften/JID/JID.h"
+#include <Swiften/Elements/Element.h>
+#include <Swiften/JID/JID.h>
namespace Swift {
+ class Payload;
+
class Stanza : public Element {
public:
typedef boost::shared_ptr<Stanza> ref;
+ Stanza();
virtual ~Stanza();
template<typename T>
boost::shared_ptr<T> getPayload() const {
- foreach (const boost::shared_ptr<Payload>& i, payloads_) {
- boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(i));
+ for (size_t i = 0; i < payloads_.size(); ++i) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(payloads_[i]));
if (result) {
return result;
}
@@ -38,8 +39,8 @@ namespace Swift {
template<typename T>
std::vector< boost::shared_ptr<T> > getPayloads() const {
std::vector< boost::shared_ptr<T> > results;
- foreach (const boost::shared_ptr<Payload>& i, payloads_) {
- boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(i));
+ for (size_t i = 0; i < payloads_.size(); ++i) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(payloads_[i]));
if (result) {
results.push_back(result);
}
@@ -78,8 +79,6 @@ namespace Swift {
std::string id_;
JID from_;
JID to_;
-
- typedef std::vector< boost::shared_ptr<Payload> > Payloads;
- Payloads payloads_;
+ std::vector< boost::shared_ptr<Payload> > payloads_;
};
}
diff --git a/Swiften/Elements/Status.h b/Swiften/Elements/Status.h
index 3ef6401..bb9b6e9 100644
--- a/Swiften/Elements/Status.h
+++ b/Swiften/Elements/Status.h
@@ -4,8 +4,7 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_Status_H
-#define SWIFTEN_Status_H
+#pragma once
#include "Swiften/Elements/Payload.h"
#include <string>
@@ -28,5 +27,3 @@ namespace Swift {
std::string text_;
};
}
-
-#endif
diff --git a/Swiften/Elements/StatusShow.cpp b/Swiften/Elements/StatusShow.cpp
new file mode 100644
index 0000000..656e5c4
--- /dev/null
+++ b/Swiften/Elements/StatusShow.cpp
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Elements/StatusShow.h>
+
+using namespace Swift;
+
+StatusShow::StatusShow(const Type& type) : type_(type) {
+}
diff --git a/Swiften/Elements/StatusShow.h b/Swiften/Elements/StatusShow.h
index a158239..cd3477e 100644
--- a/Swiften/Elements/StatusShow.h
+++ b/Swiften/Elements/StatusShow.h
@@ -4,19 +4,16 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_StatusShow_H
-#define SWIFTEN_StatusShow_H
+#pragma once
-#include "Swiften/Elements/Payload.h"
-#include <string>
+#include <Swiften/Elements/Payload.h>
namespace Swift {
class StatusShow : public Payload {
public:
enum Type { Online, Away, FFC, XA, DND, None };
- StatusShow(const Type& type = Online) : type_(type) {
- }
+ StatusShow(const Type& type = Online);
void setType(const Type& type) {
type_ = type;
@@ -32,19 +29,17 @@ namespace Swift {
*/
static int typeToAvailabilityOrdering(Type type) {
switch (type) {
- case Online: return 4;
- case FFC: return 5;
- case Away: return 2;
- case XA: return 1;
- case DND: return 3;
- case None: return 0;
+ case Online: return 4;
+ case FFC: return 5;
+ case Away: return 2;
+ case XA: return 1;
+ case DND: return 3;
+ case None: return 0;
}
- return -1;
+ return 0;
}
private:
Type type_;
};
}
-
-#endif
diff --git a/Swiften/Elements/StreamFeatures.cpp b/Swiften/Elements/StreamFeatures.cpp
new file mode 100644
index 0000000..c6f6c04
--- /dev/null
+++ b/Swiften/Elements/StreamFeatures.cpp
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Elements/StreamFeatures.h>
+
+#include <algorithm>
+
+namespace Swift {
+
+bool StreamFeatures::hasCompressionMethod(const std::string& mechanism) const {
+ return std::find(compressionMethods_.begin(), compressionMethods_.end(), mechanism) != compressionMethods_.end();
+}
+
+bool StreamFeatures::hasAuthenticationMechanism(const std::string& mechanism) const {
+ return std::find(authenticationMechanisms_.begin(), authenticationMechanisms_.end(), mechanism) != authenticationMechanisms_.end();
+}
+
+}
diff --git a/Swiften/Elements/StreamFeatures.h b/Swiften/Elements/StreamFeatures.h
index fbc0bb8..5dc5a26 100644
--- a/Swiften/Elements/StreamFeatures.h
+++ b/Swiften/Elements/StreamFeatures.h
@@ -7,9 +7,9 @@
#pragma once
#include <vector>
-#include <algorithm>
-
#include <string>
+#include <boost/shared_ptr.hpp>
+
#include "Swiften/Elements/Element.h"
namespace Swift {
@@ -17,7 +17,7 @@ namespace Swift {
public:
typedef boost::shared_ptr<StreamFeatures> ref;
- StreamFeatures() : hasStartTLS_(false), hasResourceBind_(false), hasSession_(false), hasStreamManagement_(false) {}
+ StreamFeatures() : hasStartTLS_(false), hasResourceBind_(false), hasSession_(false), hasStreamManagement_(false), hasRosterVersioning_(false) {}
void setHasStartTLS() {
hasStartTLS_ = true;
@@ -51,9 +51,7 @@ namespace Swift {
compressionMethods_.push_back(mechanism);
}
- bool hasCompressionMethod(const std::string& mechanism) const {
- return std::find(compressionMethods_.begin(), compressionMethods_.end(), mechanism) != compressionMethods_.end();
- }
+ bool hasCompressionMethod(const std::string& mechanism) const;
const std::vector<std::string>& getAuthenticationMechanisms() const {
return authenticationMechanisms_;
@@ -63,9 +61,7 @@ namespace Swift {
authenticationMechanisms_.push_back(mechanism);
}
- bool hasAuthenticationMechanism(const std::string& mechanism) const {
- return std::find(authenticationMechanisms_.begin(), authenticationMechanisms_.end(), mechanism) != authenticationMechanisms_.end();
- }
+ bool hasAuthenticationMechanism(const std::string& mechanism) const;
bool hasAuthenticationMechanisms() const {
return !authenticationMechanisms_.empty();
@@ -79,6 +75,14 @@ namespace Swift {
hasStreamManagement_ = true;
}
+ bool hasRosterVersioning() const {
+ return hasRosterVersioning_;
+ }
+
+ void setHasRosterVersioning() {
+ hasRosterVersioning_ = true;
+ }
+
private:
bool hasStartTLS_;
std::vector<std::string> compressionMethods_;
@@ -86,5 +90,6 @@ namespace Swift {
bool hasResourceBind_;
bool hasSession_;
bool hasStreamManagement_;
+ bool hasRosterVersioning_;
};
}
diff --git a/Swiften/Elements/UnitTest/StanzaTest.cpp b/Swiften/Elements/UnitTest/StanzaTest.cpp
index 4020f8b..4669f16 100644
--- a/Swiften/Elements/UnitTest/StanzaTest.cpp
+++ b/Swiften/Elements/UnitTest/StanzaTest.cpp
@@ -7,6 +7,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/shared_ptr.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
#include "Swiften/Elements/Stanza.h"
#include "Swiften/Elements/Payload.h"