diff --git a/backends/libyahoo2/main.cpp b/backends/libyahoo2/main.cpp index d07a7719..1bafecc0 100644 --- a/backends/libyahoo2/main.cpp +++ b/backends/libyahoo2/main.cpp @@ -2,7 +2,7 @@ #include "transport/config.h" #include "transport/networkplugin.h" #include "transport/logging.h" -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) // Yahoo2 #include diff --git a/backends/swiften/main.cpp b/backends/swiften/main.cpp index 8ed12331..517da09e 100644 --- a/backends/swiften/main.cpp +++ b/backends/swiften/main.cpp @@ -8,7 +8,7 @@ // Swiften #include "Swiften/Swiften.h" #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) #ifndef WIN32 // for signal handler diff --git a/backends/twitter/TwitterPlugin.h b/backends/twitter/TwitterPlugin.h index 6e89f0cd..e33c1ed7 100644 --- a/backends/twitter/TwitterPlugin.h +++ b/backends/twitter/TwitterPlugin.h @@ -33,7 +33,7 @@ #include #include #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) #if HAVE_SWIFTEN_3 #include #include diff --git a/include/Swiften/FileTransfer/CombinedOutgoingFileTransferManager.h b/include/Swiften/FileTransfer/CombinedOutgoingFileTransferManager.h index 50b1b0ad..785db145 100644 --- a/include/Swiften/FileTransfer/CombinedOutgoingFileTransferManager.h +++ b/include/Swiften/FileTransfer/CombinedOutgoingFileTransferManager.h @@ -14,7 +14,7 @@ #include "transport/presenceoracle.h" #include #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Swift { diff --git a/include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.h b/include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.h index b049e863..369a29ac 100644 --- a/include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.h +++ b/include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.h @@ -19,7 +19,7 @@ #include #include #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Swift { class IQRouter; diff --git a/include/Swiften/Network/DummyConnectionServer.h b/include/Swiften/Network/DummyConnectionServer.h index 80d341d4..b80e6af3 100644 --- a/include/Swiften/Network/DummyConnectionServer.h +++ b/include/Swiften/Network/DummyConnectionServer.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace Swift { class DummyConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this { @@ -32,9 +33,11 @@ namespace Swift { void acceptConnection(boost::shared_ptr connection); - virtual boost::optional tryStart() { - return boost::optional(); +#if (SWIFTEN_VERSION >= 0x030000) + virtual boost::optional tryStart() { + return boost::optional(); } +#endif virtual void start(); virtual void stop(); diff --git a/include/Swiften/Network/DummyNetworkFactories.h b/include/Swiften/Network/DummyNetworkFactories.h index 6637c6b9..9f2662c1 100644 --- a/include/Swiften/Network/DummyNetworkFactories.h +++ b/include/Swiften/Network/DummyNetworkFactories.h @@ -7,7 +7,7 @@ #pragma once #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) #include #include diff --git a/include/Swiften/Server/ServerFromClientSession.cpp b/include/Swiften/Server/ServerFromClientSession.cpp index e6ae808e..c1e667ff 100644 --- a/include/Swiften/Server/ServerFromClientSession.cpp +++ b/include/Swiften/Server/ServerFromClientSession.cpp @@ -29,6 +29,11 @@ #include #include +#include +#if (SWIFTEN_VERSION >= 0x030000) +#include +#endif + namespace Swift { ServerFromClientSession::ServerFromClientSession( @@ -76,7 +81,11 @@ void ServerFromClientSession::handlePasswordInvalid(const std::string &error) { } } +#if (SWIFTEN_VERSION >= 0x030000) void ServerFromClientSession::handleElement(boost::shared_ptr element) { +#else +void ServerFromClientSession::handleElement(boost::shared_ptr element) { +#endif if (isInitialized()) { onElementReceived(element); } diff --git a/include/Swiften/Server/ServerFromClientSession.h b/include/Swiften/Server/ServerFromClientSession.h index 674b54fe..4496bdf1 100644 --- a/include/Swiften/Server/ServerFromClientSession.h +++ b/include/Swiften/Server/ServerFromClientSession.h @@ -17,7 +17,7 @@ #include #include #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Swift { class ProtocolHeader; diff --git a/include/Swiften/Server/ServerStanzaChannel.h b/include/Swiften/Server/ServerStanzaChannel.h index 1b269216..cc9c8227 100644 --- a/include/Swiften/Server/ServerStanzaChannel.h +++ b/include/Swiften/Server/ServerStanzaChannel.h @@ -16,7 +16,7 @@ #include "Swiften/Elements/Presence.h" #include "Swiften/TLS/Certificate.h" #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Swift { class Error; diff --git a/include/transport/filetransfermanager.h b/include/transport/filetransfermanager.h index cd0e281c..97a0fa58 100644 --- a/include/transport/filetransfermanager.h +++ b/include/transport/filetransfermanager.h @@ -20,23 +20,22 @@ #pragma once #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) + #include -#if !HAVE_SWIFTEN_3 -#include -#endif #include #include -#if !HAVE_SWIFTEN_3 -#include -#include -#else -#include -#include -#endif #include #include -#if !HAVE_SWIFTEN_3 + + +#if HAVE_SWIFTEN_3 +#include +#include +#else +#include +#include +#include #include #endif diff --git a/include/transport/networkpluginserver.h b/include/transport/networkpluginserver.h index 6c64d002..ef8b7f3c 100644 --- a/include/transport/networkpluginserver.h +++ b/include/transport/networkpluginserver.h @@ -36,7 +36,7 @@ #include "storagebackend.h" #include "transport/filetransfermanager.h" #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Transport { diff --git a/include/transport/settingsadhoccommand.h b/include/transport/settingsadhoccommand.h index 94611dd4..ee0e6083 100644 --- a/include/transport/settingsadhoccommand.h +++ b/include/transport/settingsadhoccommand.h @@ -26,7 +26,7 @@ #include "transport/adhoccommand.h" #include "transport/adhoccommandfactory.h" #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Transport { diff --git a/include/transport/userregistration.h b/include/transport/userregistration.h index c73d0c25..8ce3c9d6 100644 --- a/include/transport/userregistration.h +++ b/include/transport/userregistration.h @@ -25,7 +25,7 @@ #include "Swiften/Elements/RosterPayload.h" #include #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Transport { diff --git a/src/discoinforesponder.h b/src/discoinforesponder.h index 80bba476..5d93e6aa 100644 --- a/src/discoinforesponder.h +++ b/src/discoinforesponder.h @@ -27,7 +27,7 @@ #include "Swiften/Elements/DiscoInfo.h" #include "Swiften/Elements/CapsInfo.h" #include -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) #if HAVE_SWIFTEN_3 #include #include diff --git a/src/tests/basictest.h b/src/tests/basictest.h index 61228018..d3a133fa 100644 --- a/src/tests/basictest.h +++ b/src/tests/basictest.h @@ -45,7 +45,7 @@ #include "Swiften/Server/ServerStanzaChannel.h" #include "Swiften/Server/ServerFromClientSession.h" #include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" -#define HAVE_SWIFTEN_3 SWIFTEN_VERSION >= 0x030000 +#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) using namespace Transport; diff --git a/src/tests/settingsadhoccommand.cpp b/src/tests/settingsadhoccommand.cpp index e667642e..dd57b3e2 100644 --- a/src/tests/settingsadhoccommand.cpp +++ b/src/tests/settingsadhoccommand.cpp @@ -19,6 +19,7 @@ #include "Swiften/Server/ServerStanzaChannel.h" #include "Swiften/Server/ServerFromClientSession.h" #include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" +#include "Swiften/Version.h" #include "basictest.h" using namespace Transport; @@ -147,7 +148,11 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT // set enabled_transport = 0 Swift::FormField::ref f = getStanza(received[0])->getPayload()->getForm()->getField("enable_transport"); +#if (SWIFTEN_VERSION >= 0x030000) f->setBoolValue(false); +#else + boost::dynamic_pointer_cast(f)->setValue(false); +#endif std::string sessionId = getStanza(received[0])->getPayload()->getSessionID(); @@ -207,7 +212,11 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT // set enabled_transport = 0 f = getStanza(received[0])->getPayload()->getForm()->getField("enable_transport"); +#if (SWIFTEN_VERSION >= 0x030000) CPPUNIT_ASSERT_EQUAL(false, f->getBoolValue()); +#else + CPPUNIT_ASSERT_EQUAL(false, boost::dynamic_pointer_cast(f)->getValue()); +#endif } void executeTwoCommands() { @@ -355,7 +364,11 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT // set enabled_transport = 0 Swift::FormField::ref f = getStanza(received[0])->getPayload()->getForm()->getField("send_headlines"); +#if (SWIFTEN_VERSION >= 0x030000) f->setBoolValue(true); +#else + boost::dynamic_pointer_cast(f)->setValue(true); +#endif std::string sessionId = getStanza(received[0])->getPayload()->getSessionID(); @@ -397,7 +410,11 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT CPPUNIT_ASSERT(getStanza(received[0])->getPayload()->getForm()); CPPUNIT_ASSERT(getStanza(received[0])->getPayload()->getForm()->getField("send_headlines")); Swift::FormField::ref f = getStanza(received[0])->getPayload()->getForm()->getField("send_headlines"); +#if (SWIFTEN_VERSION >= 0x030000) CPPUNIT_ASSERT_EQUAL(true, f->getBoolValue()); +#else + CPPUNIT_ASSERT_EQUAL(true, boost::dynamic_pointer_cast(f)->getValue()); +#endif } };