summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/ErrorPayload.h (renamed from Swiften/Elements/Error.h)9
-rw-r--r--Swiften/Elements/IQ.cpp4
-rw-r--r--Swiften/Elements/IQ.h11
-rw-r--r--Swiften/Elements/Message.h11
-rw-r--r--Swiften/Elements/UnitTest/IQTest.cpp8
5 files changed, 17 insertions, 26 deletions
diff --git a/Swiften/Elements/Error.h b/Swiften/Elements/ErrorPayload.h
index 8793f35..32fd067 100644
--- a/Swiften/Elements/Error.h
+++ b/Swiften/Elements/ErrorPayload.h
@@ -1,14 +1,13 @@
-#ifndef SWIFTEN_Error_H
-#define SWIFTEN_Error_H
+#pragma once
#include "Swiften/Elements/Payload.h"
#include "Swiften/Base/String.h"
namespace Swift {
- class Error : public Payload {
+ class ErrorPayload : public Payload {
public:
enum Type { Cancel, Continue, Modify, Auth, Wait };
enum Condition {
BadRequest,
Conflict,
@@ -31,13 +30,13 @@ namespace Swift {
ServiceUnavailable,
SubscriptionRequired,
UndefinedCondition,
UnexpectedRequest
};
- Error(Condition condition = UndefinedCondition, Type type = Cancel, const String& text = String()) : type_(type), condition_(condition), text_(text) { }
+ ErrorPayload(Condition condition = UndefinedCondition, Type type = Cancel, const String& text = String()) : type_(type), condition_(condition), text_(text) { }
Type getType() const {
return type_;
}
void setType(Type type) {
@@ -63,8 +62,6 @@ namespace Swift {
private:
Type type_;
Condition condition_;
String text_;
};
}
-
-#endif
diff --git a/Swiften/Elements/IQ.cpp b/Swiften/Elements/IQ.cpp
index 3f47182..53dec53 100644
--- a/Swiften/Elements/IQ.cpp
+++ b/Swiften/Elements/IQ.cpp
@@ -23,15 +23,15 @@ boost::shared_ptr<IQ> IQ::createResult(
if (payload) {
iq->addPayload(payload);
}
return iq;
}
-boost::shared_ptr<IQ> IQ::createError(const JID& to, const String& id, Error::Condition condition, Error::Type type) {
+boost::shared_ptr<IQ> IQ::createError(const JID& to, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) {
boost::shared_ptr<IQ> iq(new IQ(IQ::Error));
iq->setTo(to);
iq->setID(id);
- iq->addPayload(boost::shared_ptr<Swift::Error>(new Swift::Error(condition, type)));
+ iq->addPayload(boost::shared_ptr<Swift::ErrorPayload>(new Swift::ErrorPayload(condition, type)));
return iq;
}
}
diff --git a/Swiften/Elements/IQ.h b/Swiften/Elements/IQ.h
index 231439f..80c2913 100644
--- a/Swiften/Elements/IQ.h
+++ b/Swiften/Elements/IQ.h
@@ -1,11 +1,10 @@
-#ifndef SWIFTEN_IQ_H
-#define SWIFTEN_IQ_H
+#pragma once
#include "Swiften/Elements/Stanza.h"
-#include "Swiften/Elements/Error.h"
+#include "Swiften/Elements/ErrorPayload.h"
namespace Swift
{
class IQ : public Stanza
{
public:
@@ -25,15 +24,13 @@ namespace Swift
const JID& to,
const String& id,
boost::shared_ptr<Payload> payload = boost::shared_ptr<Payload>());
static boost::shared_ptr<IQ> createError(
const JID& to,
const String& id,
- Error::Condition condition,
- Error::Type type);
+ ErrorPayload::Condition condition,
+ ErrorPayload::Type type);
private:
Type type_;
};
}
-
-#endif
diff --git a/Swiften/Elements/Message.h b/Swiften/Elements/Message.h
index a49f496..6d9171f 100644
--- a/Swiften/Elements/Message.h
+++ b/Swiften/Elements/Message.h
@@ -1,14 +1,13 @@
-#ifndef SWIFTEN_STANZAS_MESSAGE_H
-#define SWIFTEN_STANZAS_MESSAGE_H
+#pragma once
#include <boost/optional.hpp>
#include "Swiften/Base/String.h"
#include "Swiften/Elements/Body.h"
-#include "Swiften/Elements/Error.h"
+#include "Swiften/Elements/ErrorPayload.h"
#include "Swiften/Elements/Stanza.h"
namespace Swift
{
class Message : public Stanza
{
@@ -27,20 +26,18 @@ namespace Swift
void setBody(const String& body) {
updatePayload(boost::shared_ptr<Body>(new Body(body)));
}
bool isError() {
- boost::shared_ptr<Swift::Error> error(getPayload<Swift::Error>());
- return getType() == Message::Error || error.get() != NULL;
+ boost::shared_ptr<Swift::ErrorPayload> error(getPayload<Swift::ErrorPayload>());
+ return getType() == Message::Error || error;
}
Type getType() const { return type_; }
void setType(Type type) { type_ = type; }
private:
String body_;
Type type_;
};
}
-
-#endif
diff --git a/Swiften/Elements/UnitTest/IQTest.cpp b/Swiften/Elements/UnitTest/IQTest.cpp
index bc22c81..a5e6dc8 100644
--- a/Swiften/Elements/UnitTest/IQTest.cpp
+++ b/Swiften/Elements/UnitTest/IQTest.cpp
@@ -34,19 +34,19 @@ class IQTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo());
CPPUNIT_ASSERT_EQUAL(String("myid"), iq->getID());
CPPUNIT_ASSERT(!iq->getPayload<SoftwareVersion>());
}
void testCreateError() {
- boost::shared_ptr<IQ> iq(IQ::createError(JID("foo@bar/fum"), "myid", Error::BadRequest, Error::Modify));
+ boost::shared_ptr<IQ> iq(IQ::createError(JID("foo@bar/fum"), "myid", ErrorPayload::BadRequest, ErrorPayload::Modify));
CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo());
CPPUNIT_ASSERT_EQUAL(String("myid"), iq->getID());
- boost::shared_ptr<Error> error(iq->getPayload<Error>());
+ boost::shared_ptr<ErrorPayload> error(iq->getPayload<ErrorPayload>());
CPPUNIT_ASSERT(error);
- CPPUNIT_ASSERT_EQUAL(Error::BadRequest, error->getCondition());
- CPPUNIT_ASSERT_EQUAL(Error::Modify, error->getType());
+ CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, error->getCondition());
+ CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, error->getType());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(IQTest);