From 90ef6e3128f229c1da96cd18093c1f3bf2bcd27a 2015-11-10 11:18:48 From: Jan Kaluza Date: 2015-11-10 11:18:48 Subject: [PATCH] Fix HAVE_SWIFTEN_3 definition to work also in gcc. Fix the tests to work with swiften3 and also with swiften2. --- diff --git a/backends/libyahoo2/main.cpp b/backends/libyahoo2/main.cpp index d07a7719daa2ee9339bd6947c57a9662862c1fc8..1bafecc0c47bd258cd0bf8f9addb73251ef250b9 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 8ed12331503d38d9f8e2b83cb72e8e732e1c9138..517da09e7fe4dd67bef1eb032d404cf3c8b4b5a6 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 6e89f0cd978d644e16288fda55953d0d52a4af00..e33c1ed7ea587db3fe963960679b7dad69aedb79 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 50b1b0adffe500d2f33ac0d02401556df1c10d4f..785db1457f55408d110120eaebc004e61b1b32e8 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 b049e8635ffadea5ca7fee347beb4fcb4862ef58..369a29ac6b67ca0f59239e9e0e4f82c0431ce841 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 80d341d42ed018d4688c5dadcbf35b1a17871d52..b80e6af30037adaf21e904e876b6a484c1776a10 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 6637c6b9dfacfbc8596327b84a63c65d3a52bd22..9f2662c1182992e540d11f1cf66499836d15dfff 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 e6ae808e513a75343df4f151eaf5b75030799a68..c1e667ffd892f466aa2684368f69e27f47e47851 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 674b54fef0e3041f14b8305a690f1bc11aa13df1..4496bdf1465b808bbbdc8d45468d10a66b1e8ca1 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 1b26921635466861888bcbb343d83cba5c5edfc0..cc9c82279e362d1b050eb8304a9313c077e99bac 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 cd0e281cd7b66ab1b03205d101a2d8d6b606ad01..97a0fa58eb707d8f1d05c7b86b120941cf8b4847 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 6c64d00228063be1a04e5d4979b4b1b534f02fef..ef8b7f3c6485d848f0206f0736c062209206475f 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 94611dd49f8f28aaac2564091aae8d87849088a3..ee0e60837608d810a654104f1e530910701dd92f 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 c73d0c25162f6517a113141456e92379d0798db4..8ce3c9d64e9dc38b86c6e2b4e94ad551d88523ac 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 80bba476a94db5a011270478d48a63a4cabcc77b..5d93e6aa350763f740286c8ac09e35e5e3a9c027 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 61228018c1a7a0c013485b725344c93df3c1ffc5..d3a133fa043447c47874d421b2c8304f9bede167 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 e667642e2a09939706050e8aeea8a0e9018bfdad..dd57b3e203a8aac332a5af00ade3ada91a4ca69d 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 } };