diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-11-08 16:12:48 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-11-08 18:32:15 (GMT) |
commit | f1d74218cb432513c376b46aa115acb3e107ed3a (patch) | |
tree | 24df6a3233f1fd3c2c2592637cfcfd1846040dee /Swiften/Elements | |
parent | b6003bea740e8898127ec135e230eed421924370 (diff) | |
download | swift-f1d74218cb432513c376b46aa115acb3e107ed3a.zip swift-f1d74218cb432513c376b46aa115acb3e107ed3a.tar.bz2 |
Added Error class.
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.cpp | 4 | ||||
-rw-r--r-- | Swiften/Elements/IQ.h | 11 | ||||
-rw-r--r-- | Swiften/Elements/Message.h | 11 | ||||
-rw-r--r-- | Swiften/Elements/UnitTest/IQTest.cpp | 8 |
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()); } }; |