summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-10 21:24:03 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-10 21:24:03 (GMT)
commit54781ce12f7654f8136e645d4ebc5934d90c6bea (patch)
tree90bad869f9f64d57a3c0af209b83a538a47c7762 /Swiften/Elements
parentfcfac59db5cb4503554f2b30854b2e91928296f6 (diff)
parent66ced3654ad295478b33d3e4f1716f66ab4048b5 (diff)
downloadswift-54781ce12f7654f8136e645d4ebc5934d90c6bea.zip
swift-54781ce12f7654f8136e645d4ebc5934d90c6bea.tar.bz2
Refactored session management.
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,11 +1,10 @@
-#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 };
@@ -34,7 +33,7 @@ namespace Swift {
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_;
@@ -66,5 +65,3 @@ namespace Swift {
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
@@ -26,11 +26,11 @@ boost::shared_ptr<IQ> IQ::createResult(
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,8 +1,7 @@
-#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
{
@@ -28,12 +27,10 @@ namespace Swift
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,11 +1,10 @@
-#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
@@ -30,8 +29,8 @@ namespace Swift
}
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_; }
@@ -42,5 +41,3 @@ namespace Swift
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
@@ -37,14 +37,14 @@ class IQTest : public CppUnit::TestFixture
}
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());
}
};