summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp4
-rw-r--r--Swiften/Base/Algorithm.h26
-rw-r--r--Swiften/Base/LRUCache.h16
-rw-r--r--Swiften/Base/Override.h34
-rw-r--r--Swiften/Base/SimpleIDGenerator.h7
-rw-r--r--Swiften/Base/StdRandomGenerator.h3
-rw-r--r--Swiften/Base/URL.cpp14
-rw-r--r--Swiften/Base/URL.h10
-rw-r--r--Swiften/Base/UnitTest/URLTest.cpp26
-rw-r--r--Swiften/ChangeLog.md4
-rw-r--r--Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp5
-rw-r--r--Swiften/Client/ClientXMLTracer.cpp4
-rw-r--r--Swiften/Client/CoreClient.cpp40
-rw-r--r--Swiften/Client/DummyStanzaChannel.h7
-rw-r--r--Swiften/Client/UnitTest/XMLBeautifierTest.cpp13
-rw-r--r--Swiften/Component/ComponentConnector.cpp4
-rw-r--r--Swiften/Component/ComponentConnector.h8
-rw-r--r--Swiften/Component/CoreComponent.cpp12
-rw-r--r--Swiften/Component/CoreComponent.h19
-rw-r--r--Swiften/Component/UnitTest/ComponentConnectorTest.cpp4
-rw-r--r--Swiften/Config/SConscript12
-rw-r--r--Swiften/Crypto/CommonCryptoCryptoProvider.cpp39
-rw-r--r--Swiften/Crypto/CommonCryptoCryptoProvider.h15
-rw-r--r--Swiften/Crypto/OpenSSLCryptoProvider.cpp25
-rw-r--r--Swiften/Crypto/OpenSSLCryptoProvider.h15
-rw-r--r--Swiften/Crypto/WindowsCryptoProvider.cpp10
-rw-r--r--Swiften/Crypto/WindowsCryptoProvider.h13
-rw-r--r--Swiften/Disco/UnitTest/CapsManagerTest.cpp6
-rw-r--r--Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp4
-rw-r--r--Swiften/Elements/Bytestreams.h6
-rw-r--r--Swiften/Elements/ContainerPayload.h3
-rw-r--r--Swiften/Elements/DiscoInfo.cpp3
-rw-r--r--Swiften/Elements/DiscoInfo.h3
-rw-r--r--Swiften/Elements/Form.h6
-rw-r--r--Swiften/Elements/IBB.h12
-rw-r--r--Swiften/Elements/IsodeIQDelegation.h3
-rw-r--r--Swiften/Elements/MIXJoin.h22
-rw-r--r--Swiften/Elements/MIXLeave.h37
-rw-r--r--Swiften/Elements/MIXPayload.h56
-rw-r--r--Swiften/Elements/MIXRegisterNick.h (renamed from Swiften/Elements/MIXSubscribe.h)19
-rw-r--r--Swiften/Elements/MIXSetNick.h35
-rw-r--r--Swiften/Elements/MIXUpdateSubscription.h56
-rw-r--r--Swiften/Elements/PubSub.h3
-rw-r--r--Swiften/Elements/PubSubAffiliation.h3
-rw-r--r--Swiften/Elements/PubSubAffiliations.h3
-rw-r--r--Swiften/Elements/PubSubConfigure.h3
-rw-r--r--Swiften/Elements/PubSubCreate.h3
-rw-r--r--Swiften/Elements/PubSubDefault.h3
-rw-r--r--Swiften/Elements/PubSubEvent.h3
-rw-r--r--Swiften/Elements/PubSubEventAssociate.h3
-rw-r--r--Swiften/Elements/PubSubEventCollection.h3
-rw-r--r--Swiften/Elements/PubSubEventConfiguration.h3
-rw-r--r--Swiften/Elements/PubSubEventDelete.h3
-rw-r--r--Swiften/Elements/PubSubEventDisassociate.h3
-rw-r--r--Swiften/Elements/PubSubEventItem.h3
-rw-r--r--Swiften/Elements/PubSubEventItems.h3
-rw-r--r--Swiften/Elements/PubSubEventPurge.h3
-rw-r--r--Swiften/Elements/PubSubEventRedirect.h3
-rw-r--r--Swiften/Elements/PubSubEventRetract.h3
-rw-r--r--Swiften/Elements/PubSubEventSubscription.h3
-rw-r--r--Swiften/Elements/PubSubItem.cpp5
-rw-r--r--Swiften/Elements/PubSubItem.h19
-rw-r--r--Swiften/Elements/PubSubItems.h4
-rw-r--r--Swiften/Elements/PubSubOptions.h3
-rw-r--r--Swiften/Elements/PubSubOwnerAffiliation.h3
-rw-r--r--Swiften/Elements/PubSubOwnerAffiliations.h3
-rw-r--r--Swiften/Elements/PubSubOwnerConfigure.h3
-rw-r--r--Swiften/Elements/PubSubOwnerDefault.h3
-rw-r--r--Swiften/Elements/PubSubOwnerDelete.h3
-rw-r--r--Swiften/Elements/PubSubOwnerPubSub.h3
-rw-r--r--Swiften/Elements/PubSubOwnerPurge.h3
-rw-r--r--Swiften/Elements/PubSubOwnerRedirect.h3
-rw-r--r--Swiften/Elements/PubSubOwnerSubscription.h3
-rw-r--r--Swiften/Elements/PubSubOwnerSubscriptions.h3
-rw-r--r--Swiften/Elements/PubSubPublish.h3
-rw-r--r--Swiften/Elements/PubSubSubscribe.h3
-rw-r--r--Swiften/Elements/PubSubSubscribeOptions.h3
-rw-r--r--Swiften/Elements/PubSubSubscription.h3
-rw-r--r--Swiften/Elements/PubSubSubscriptions.h3
-rw-r--r--Swiften/Elements/PubSubUnsubscribe.h3
-rw-r--r--Swiften/Elements/ReferencePayload.cpp63
-rw-r--r--Swiften/Elements/ReferencePayload.h62
-rw-r--r--Swiften/Elements/S5BProxyRequest.h4
-rw-r--r--Swiften/Elements/SecurityLabel.h4
-rw-r--r--Swiften/Elements/StanzaAck.cpp8
-rw-r--r--Swiften/Elements/StanzaAck.h4
-rw-r--r--Swiften/Elements/UserLocation.h3
-rw-r--r--Swiften/Elements/UserTune.h3
-rw-r--r--Swiften/EventLoop/EventLoop.cpp11
-rw-r--r--Swiften/FileTransfer/ByteArrayReadBytestream.cpp22
-rw-r--r--Swiften/FileTransfer/DefaultFileTransferTransporter.h31
-rw-r--r--Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h9
-rw-r--r--Swiften/FileTransfer/FailingTransportSession.h8
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.h9
-rw-r--r--Swiften/FileTransfer/FileTransferOptions.h3
-rw-r--r--Swiften/FileTransfer/IBBReceiveTransportSession.h8
-rw-r--r--Swiften/FileTransfer/IBBSendSession.cpp4
-rw-r--r--Swiften/FileTransfer/IBBSendTransportSession.h8
-rw-r--r--Swiften/FileTransfer/IncomingJingleFileTransfer.h43
-rw-r--r--Swiften/FileTransfer/JingleFileTransfer.cpp8
-rw-r--r--Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h3
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.h43
-rw-r--r--Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h3
-rw-r--r--Swiften/FileTransfer/S5BTransportSession.h8
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp6
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.h4
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp11
-rw-r--r--Swiften/FileTransfer/TransportSession.h3
-rw-r--r--Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h7
-rw-r--r--Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp4
-rw-r--r--Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp3
-rw-r--r--Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp3
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp4
-rw-r--r--Swiften/IDN/ICUConverter.cpp13
-rw-r--r--Swiften/IDN/ICUConverter.h9
-rw-r--r--Swiften/IDN/LibIDNConverter.cpp10
-rw-r--r--Swiften/IDN/LibIDNConverter.h9
-rw-r--r--Swiften/IDN/PlatformIDNConverter.cpp5
-rw-r--r--Swiften/IDN/SConscript1
-rw-r--r--Swiften/IDN/UnitTest/IDNConverterTest.cpp132
-rw-r--r--Swiften/JID/JID.cpp80
-rw-r--r--Swiften/JID/UnitTest/JIDTest.cpp69
-rw-r--r--Swiften/Jingle/AbstractJingleSessionListener.h19
-rw-r--r--Swiften/Jingle/FakeJingleSession.h23
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp4
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h4
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h6
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h17
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp5
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h4
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h24
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h17
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h19
-rw-r--r--Swiften/LinkLocal/DNSSD/DNSSDQuerier.h4
-rw-r--r--Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h6
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp6
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h6
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h6
-rw-r--r--Swiften/LinkLocal/LinkLocalService.h4
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.cpp26
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.h4
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceInfo.cpp75
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceInfo.h10
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp10
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp26
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp17
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp6
-rw-r--r--Swiften/MIX/MIX.cpp14
-rw-r--r--Swiften/MIX/MIX.h69
-rw-r--r--Swiften/MIX/MIXImpl.cpp97
-rw-r--r--Swiften/MIX/MIXImpl.h67
-rw-r--r--Swiften/MIX/UnitTest/MIXImplTest.cpp312
-rw-r--r--Swiften/MUC/MUCBookmarkManager.cpp51
-rw-r--r--Swiften/MUC/MUCBookmarkManager.h5
-rw-r--r--Swiften/MUC/MUCImpl.cpp2
-rw-r--r--Swiften/Network/BOSHConnection.cpp10
-rw-r--r--Swiften/Network/BoostConnection.cpp5
-rw-r--r--Swiften/Network/BoostConnectionServer.cpp13
-rw-r--r--Swiften/Network/BoostConnectionServer.h12
-rw-r--r--Swiften/Network/BoostConnectionServerFactory.cpp4
-rw-r--r--Swiften/Network/BoostConnectionServerFactory.h6
-rw-r--r--Swiften/Network/BoostNetworkFactories.h29
-rw-r--r--Swiften/Network/ChainedConnector.cpp4
-rw-r--r--Swiften/Network/ChainedConnector.h6
-rw-r--r--Swiften/Network/ConnectionServerFactory.h6
-rw-r--r--Swiften/Network/Connector.cpp6
-rw-r--r--Swiften/Network/Connector.h8
-rw-r--r--Swiften/Network/DomainNameServiceQuery.cpp38
-rw-r--r--Swiften/Network/DomainNameServiceQuery.h6
-rw-r--r--Swiften/Network/DummyConnectionServer.h6
-rw-r--r--Swiften/Network/DummyConnectionServerFactory.h6
-rw-r--r--Swiften/Network/EnvironmentProxyProvider.cpp10
-rw-r--r--Swiften/Network/GConfProxyProvider.cpp12
-rw-r--r--Swiften/Network/HTTPConnectProxiedConnection.cpp4
-rw-r--r--Swiften/Network/HTTPConnectProxiedConnection.h6
-rw-r--r--Swiften/Network/HTTPConnectProxiedConnectionFactory.cpp6
-rw-r--r--Swiften/Network/HTTPConnectProxiedConnectionFactory.h8
-rw-r--r--Swiften/Network/HostAddress.h6
-rw-r--r--Swiften/Network/HostAddressPort.cpp6
-rw-r--r--Swiften/Network/HostAddressPort.h15
-rw-r--r--Swiften/Network/MacOSXProxyProvider.cpp8
-rw-r--r--Swiften/Network/MiniUPnPInterface.cpp18
-rw-r--r--Swiften/Network/MiniUPnPInterface.h4
-rw-r--r--Swiften/Network/NATPMPInterface.cpp16
-rw-r--r--Swiften/Network/NATPMPInterface.h4
-rw-r--r--Swiften/Network/NATPortMapping.h16
-rw-r--r--Swiften/Network/NATTraversalInterface.h4
-rw-r--r--Swiften/Network/NATTraversalRemovePortForwardingRequest.h6
-rw-r--r--Swiften/Network/NATTraverser.h6
-rw-r--r--Swiften/Network/NullNATTraversalInterface.h2
-rw-r--r--Swiften/Network/NullNATTraverser.cpp6
-rw-r--r--Swiften/Network/NullNATTraverser.h6
-rw-r--r--Swiften/Network/PlatformDomainNameServiceQuery.cpp57
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.cpp12
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.h6
-rw-r--r--Swiften/Network/ProxiedConnection.cpp4
-rw-r--r--Swiften/Network/ProxiedConnection.h6
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnection.cpp4
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnection.h6
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnectionFactory.cpp2
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnectionFactory.h6
-rw-r--r--Swiften/Network/StaticDomainNameResolver.cpp10
-rw-r--r--Swiften/Network/StaticDomainNameResolver.h4
-rw-r--r--Swiften/Network/TLSConnection.cpp5
-rw-r--r--Swiften/Network/TLSConnection.h4
-rw-r--r--Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp8
-rw-r--r--Swiften/Network/UnitTest/BOSHConnectionTest.cpp2
-rw-r--r--Swiften/Network/UnitTest/ConnectorTest.cpp29
-rw-r--r--Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp4
-rw-r--r--Swiften/Network/UnitTest/HostAddressTest.cpp30
-rw-r--r--Swiften/Network/WindowsProxyProvider.cpp5
-rw-r--r--Swiften/Parser/AttributeMap.cpp20
-rw-r--r--Swiften/Parser/BOSHBodyExtractor.cpp10
-rw-r--r--Swiften/Parser/EnumParser.h3
-rw-r--r--Swiften/Parser/ExpatParser.cpp8
-rw-r--r--Swiften/Parser/LibXMLParser.cpp16
-rw-r--r--Swiften/Parser/PayloadParsers/BytestreamsParser.cpp7
-rw-r--r--Swiften/Parser/PayloadParsers/ForwardedParser.h9
-rw-r--r--Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp18
-rw-r--r--Swiften/Parser/PayloadParsers/IBBParser.cpp4
-rw-r--r--Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/JingleS5BTransportMethodPayloadParser.cpp9
-rw-r--r--Swiften/Parser/PayloadParsers/MAMFinParser.h9
-rw-r--r--Swiften/Parser/PayloadParsers/MAMQueryParser.h9
-rw-r--r--Swiften/Parser/PayloadParsers/MAMResultParser.h9
-rw-r--r--Swiften/Parser/PayloadParsers/MIXCreateParser.h15
-rw-r--r--Swiften/Parser/PayloadParsers/MIXDestroyParser.h15
-rw-r--r--Swiften/Parser/PayloadParsers/MIXJoinParser.cpp10
-rw-r--r--Swiften/Parser/PayloadParsers/MIXJoinParser.h15
-rw-r--r--Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h2
-rw-r--r--Swiften/Parser/PayloadParsers/MIXLeaveParser.cpp37
-rw-r--r--Swiften/Parser/PayloadParsers/MIXLeaveParser.h (renamed from Swiften/Parser/PayloadParsers/MIXSubscribeParser.h)23
-rw-r--r--Swiften/Parser/PayloadParsers/MIXPayloadParser.cpp25
-rw-r--r--Swiften/Parser/PayloadParsers/MIXPayloadParser.h25
-rw-r--r--Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h33
-rw-r--r--Swiften/Parser/PayloadParsers/MIXRegisterNickParser.cpp19
-rw-r--r--Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h19
-rw-r--r--Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h27
-rw-r--r--Swiften/Parser/PayloadParsers/MIXSetNickParser.cpp19
-rw-r--r--Swiften/Parser/PayloadParsers/MIXSetNickParser.h25
-rw-r--r--Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h33
-rw-r--r--Swiften/Parser/PayloadParsers/MIXSubscribeParser.cpp36
-rw-r--r--Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp49
-rw-r--r--Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h36
-rw-r--r--Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h15
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubConfigureParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubCreateParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubDefaultParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubErrorParser.h9
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventItemParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubItemParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubItemsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOptionsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubPublishParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubRetractParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/ReferencePayloadParser.cpp79
-rw-r--r--Swiften/Parser/PayloadParsers/ReferencePayloadParser.h35
-rw-r--r--Swiften/Parser/PayloadParsers/ResultSetParser.h7
-rw-r--r--Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp12
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp8
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp62
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp32
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp3
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp85
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp23
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp23
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp49
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp6
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/ReferencePayloadParserTest.cpp134
-rw-r--r--Swiften/Parser/PayloadParsers/UserLocationParser.h11
-rw-r--r--Swiften/Parser/PayloadParsers/UserTuneParser.h11
-rw-r--r--Swiften/Parser/PlatformXMLParserFactory.cpp4
-rw-r--r--Swiften/Parser/SConscript7
-rw-r--r--Swiften/Parser/StanzaAckParser.cpp4
-rw-r--r--Swiften/Parser/Tree/ParserElement.cpp12
-rw-r--r--Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp4
-rw-r--r--Swiften/PubSub/PubSubManager.h3
-rw-r--r--Swiften/PubSub/PubSubManagerImpl.h5
-rw-r--r--Swiften/QA/ClientTest/ClientTest.cpp15
-rw-r--r--Swiften/QA/DNSSDTest/DNSSDTest.cpp8
-rw-r--r--Swiften/QA/DNSSDTest/SConscript2
-rw-r--r--Swiften/QA/FileTransferTest/FileTransferTest.cpp9
-rw-r--r--Swiften/QA/NetworkTest/DomainNameResolverTest.cpp10
-rw-r--r--Swiften/QA/StorageTest/SConscript3
-rw-r--r--Swiften/QA/TLSTest/CertificateTest.cpp2
-rw-r--r--Swiften/QA/TLSTest/SConscript2
-rw-r--r--Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp4
-rw-r--r--Swiften/Queries/UnitTest/ResponderTest.cpp4
-rw-r--r--Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp4
-rw-r--r--Swiften/SASL/EXTERNALClientAuthenticator.cpp8
-rw-r--r--Swiften/SASL/SConscript1
-rw-r--r--Swiften/SASL/UnitTest/EXTERNALClientAuthenticatorTest.cpp47
-rw-r--r--Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp10
-rw-r--r--Swiften/SASL/WindowsServicePrincipalName.h4
-rw-r--r--Swiften/SConscript29
-rw-r--r--Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp13
-rw-r--r--Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/LastSerializer.h2
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h5
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h5
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.h11
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.h11
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.cpp15
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.h11
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.cpp31
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.h29
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.cpp44
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h26
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.cpp29
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.h (renamed from Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.h)13
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.cpp29
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.h26
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.cpp29
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.cpp43
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h30
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.h11
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp6
-rw-r--r--Swiften/Serializer/PayloadSerializers/PrioritySerializer.h2
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h5
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.cpp64
-rw-r--r--Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.h26
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp8
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h5
-rw-r--r--Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h2
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp100
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp30
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp61
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp36
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp8
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ReferencePayloadSerializerTest.cpp81
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h7
-rw-r--r--Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp56
-rw-r--r--Swiften/Serializer/StanzaAckSerializer.h2
-rw-r--r--Swiften/Serializer/StreamResumeSerializer.cpp2
-rw-r--r--Swiften/Serializer/StreamResumedSerializer.cpp2
-rw-r--r--Swiften/Session/BasicSessionStream.cpp49
-rw-r--r--Swiften/Session/BasicSessionStream.h9
-rw-r--r--Swiften/Session/Session.cpp28
-rw-r--r--Swiften/Session/Session.h16
-rw-r--r--Swiften/StreamManagement/StanzaAckRequester.cpp6
-rw-r--r--Swiften/StreamManagement/StanzaAckResponder.cpp6
-rw-r--r--Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp7
-rw-r--r--Swiften/StreamManagement/UnitTest/StanzaAckResponderTest.cpp7
-rw-r--r--Swiften/StreamStack/StreamStack.cpp24
-rw-r--r--Swiften/StreamStack/StreamStack.h30
-rw-r--r--Swiften/StreamStack/TLSLayer.cpp30
-rw-r--r--Swiften/StreamStack/TLSLayer.h8
-rw-r--r--Swiften/StreamStack/UnitTest/StreamStackTest.cpp45
-rw-r--r--Swiften/TLS/CertificateFactory.cpp23
-rw-r--r--Swiften/TLS/CertificateFactory.h8
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp4
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.cpp50
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h10
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContext.cpp368
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContext.h65
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp32
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContextFactory.h14
-rw-r--r--Swiften/TLS/PrivateKey.cpp22
-rw-r--r--Swiften/TLS/PrivateKey.h33
-rw-r--r--Swiften/TLS/SConscript4
-rw-r--r--Swiften/TLS/Schannel/SchannelContextFactory.cpp8
-rw-r--r--Swiften/TLS/Schannel/SchannelContextFactory.h7
-rw-r--r--Swiften/TLS/SecureTransport/SecureTransportCertificate.mm9
-rw-r--r--Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp8
-rw-r--r--Swiften/TLS/SecureTransport/SecureTransportContextFactory.h6
-rw-r--r--Swiften/TLS/TLSContext.cpp36
-rw-r--r--Swiften/TLS/TLSContext.h23
-rw-r--r--Swiften/TLS/TLSContextFactory.cpp7
-rw-r--r--Swiften/TLS/TLSContextFactory.h12
-rw-r--r--Swiften/TLS/TLSError.h18
-rw-r--r--Swiften/TLS/UnitTest/CertificateTest.cpp111
-rw-r--r--Swiften/TLS/UnitTest/ClientServerTest.cpp760
460 files changed, 6002 insertions, 2107 deletions
diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
index 8aca98e..3e5e9e6 100644
--- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
+++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
@@ -48,8 +48,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
public:
void setUp() {
- avatarProvider1 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider());
- avatarProvider2 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider());
+ avatarProvider1 = std::make_unique<DummyAvatarProvider>();
+ avatarProvider2 = std::make_unique<DummyAvatarProvider>();
user1 = JID("user1@bar.com/bla");
user2 = JID("user2@foo.com/baz");
avatarHash1 = "ABCDEFG";
diff --git a/Swiften/Base/Algorithm.h b/Swiften/Base/Algorithm.h
index 108dbe3..ee761b7 100644
--- a/Swiften/Base/Algorithm.h
+++ b/Swiften/Base/Algorithm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2014 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -160,4 +160,28 @@ namespace Swift {
return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), pred);
}
+
+ /**
+ * Ranges
+ */
+ template <typename T>
+ class range_t {
+ public:
+ range_t(T b, T e) : b_(b), e_(e) {}
+
+ T begin() {
+ return b_;
+ }
+ T end() {
+ return e_;
+ }
+ private:
+ T b_;
+ T e_;
+ };
+
+ template <typename T>
+ range_t<T> range(T b, T e) {
+ return range_t<T>(b, e);
+ }
}
diff --git a/Swiften/Base/LRUCache.h b/Swiften/Base/LRUCache.h
index e4e652f..1f92612 100644
--- a/Swiften/Base/LRUCache.h
+++ b/Swiften/Base/LRUCache.h
@@ -19,9 +19,9 @@ namespace Swift {
/**
- * The \ref LRUCache templaged class implements a lookup cache which removes
+ * The \ref LRUCache template class implements a lookup cache which removes
* the least recently used cached item from the cache, if the cache size hits
- * the \ref MAX_SIZE limit.
+ * the \p MAX_SIZE limit.
*
* An example use is a cache for entity capabilities hash to DiscoInfo.
*/
@@ -32,9 +32,9 @@ public:
public:
/**
- * Inserts the key/value pair in the front of the cache. If the \ref key
+ * Inserts the key/value pair in the front of the cache. If the \p key
* already exists in the cache, it is moved to the front instead. If
- * afterwards, the cahe size exceeds the \ref MAX_SIZE limit, the least
+ * afterwards, the cahe size exceeds the \p MAX_SIZE limit, the least
* recently item is removed from the cache.
*/
void insert(const KEY_TYPE& key, VALUE_TYPE value) {
@@ -48,11 +48,11 @@ public:
}
/**
- * Looks up a cache entry based on the provided \ref key and moves it back
+ * Looks up a cache entry based on the provided \p key and moves it back
* to the front of the cache. If there is no cache entry for the provided
- * \ref key, an uninitialized \ref boost::optional is returned.
- * If the optional \ref missFunction is provided, it is called on a cache miss.
- * If the \ref missFunction returns an initialized \ref boost::optional, the
+ * \p key, an uninitialized \p boost::optional is returned.
+ * If the optional \p missFunction is provided, it is called on a cache miss.
+ * If the \p missFunction returns an initialized \p boost::optional, the
* value is inserted in the cache.
*/
boost::optional<VALUE_TYPE> get(const KEY_TYPE& key, cacheMissFunction missFunction = cacheMissFunction()) {
diff --git a/Swiften/Base/Override.h b/Swiften/Base/Override.h
deleted file mode 100644
index 2806aae..0000000
--- a/Swiften/Base/Override.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#pragma once
-
-#if defined(__clang__)
-# if __has_feature(cxx_override_control) || __has_extension(cxx_override_control)
-# define SWIFTEN_OVERRIDE override
-# else
-# define SWIFTEN_OVERRIDE
-# endif
-
-#elif defined(__GNUC__)
-# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) && defined(__GXX_EXPERIMENTAL_CXX0X__)
-# define SWIFTEN_OVERRIDE override
-# else
-# define SWIFTEN_OVERRIDE
-# endif
-
-#elif defined(_MSC_VER)
-// Actually, 1700 is the first version that supports the C++11 override, but
-// older versions apparently support a similar keyword.
-# if _MSC_VER >= 1400
-# define SWIFTEN_OVERRIDE override
-# else
-# define SWIFTEN_OVERRIDE
-# endif
-
-#else
-# define SWIFTEN_OVERRIDE
-#endif
diff --git a/Swiften/Base/SimpleIDGenerator.h b/Swiften/Base/SimpleIDGenerator.h
index ff645b1..09e01de 100644
--- a/Swiften/Base/SimpleIDGenerator.h
+++ b/Swiften/Base/SimpleIDGenerator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <Swiften/Base/API.h>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/Override.h>
namespace Swift {
@@ -22,9 +21,9 @@ namespace Swift {
class SWIFTEN_API SimpleIDGenerator : public IDGenerator {
public:
SimpleIDGenerator();
- ~SimpleIDGenerator();
+ ~SimpleIDGenerator() override;
- std::string generateID() SWIFTEN_OVERRIDE;
+ std::string generateID() override;
private:
std::string currentID;
diff --git a/Swiften/Base/StdRandomGenerator.h b/Swiften/Base/StdRandomGenerator.h
index 4cc5e95..159d361 100644
--- a/Swiften/Base/StdRandomGenerator.h
+++ b/Swiften/Base/StdRandomGenerator.h
@@ -9,7 +9,6 @@
#include <random>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Base/RandomGenerator.h>
namespace Swift {
@@ -17,7 +16,7 @@ namespace Swift {
public:
StdRandomGenerator();
- int generateRandomInteger(int max) SWIFTEN_OVERRIDE;
+ int generateRandomInteger(int max) override;
private:
std::mt19937 generator;
diff --git a/Swiften/Base/URL.cpp b/Swiften/Base/URL.cpp
index 4a47a11..5c0f0d7 100644
--- a/Swiften/Base/URL.cpp
+++ b/Swiften/Base/URL.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,7 @@
namespace Swift {
-int URL::getPortOrDefaultPort(const URL& url) {
+unsigned short URL::getPortOrDefaultPort(const URL& url) {
if (url.getPort()) {
return *url.getPort();
}
@@ -62,7 +62,7 @@ URL URL::fromString(const std::string& urlString) {
}
std::string host;
- boost::optional<int> port;
+ boost::optional<unsigned short> port;
if (hostAndPort[0] == '[') {
// handle IPv6 address literals
size_t addressEndIndex = hostAndPort.find(']');
@@ -71,9 +71,9 @@ URL URL::fromString(const std::string& urlString) {
colonIndex = hostAndPort.find(':', addressEndIndex);
if (colonIndex != std::string::npos) {
try {
- port = boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1));
+ port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1)));
}
- catch (const boost::bad_lexical_cast&) {
+ catch (...) {
return URL();
}
}
@@ -87,7 +87,7 @@ URL URL::fromString(const std::string& urlString) {
if (colonIndex != std::string::npos) {
host = unescape(hostAndPort.substr(0, colonIndex));
try {
- port = boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1));
+ port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1)));
}
catch (const boost::bad_lexical_cast&) {
return URL();
@@ -132,7 +132,7 @@ std::string URL::toString() const {
}
if (port) {
result += ":";
- result += boost::lexical_cast<std::string>(*port);
+ result += std::to_string(*port);
}
result += path;
return result;
diff --git a/Swiften/Base/URL.h b/Swiften/Base/URL.h
index 1a03efe..8fdb018 100644
--- a/Swiften/Base/URL.h
+++ b/Swiften/Base/URL.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -21,7 +21,7 @@ class SWIFTEN_API URL {
URL() : scheme(""), user(""), password(""), host(""), path(""), empty(true) {
}
- URL(const std::string& scheme, const std::string& host, int port, const std::string& path) : scheme(scheme), user(), password(), host(host), port(port), path(path), empty(false) {
+ URL(const std::string& scheme, const std::string& host, unsigned short port, const std::string& path) : scheme(scheme), user(), password(), host(host), port(port), path(path), empty(false) {
}
URL(const std::string& scheme, const std::string& host, const std::string& path) : scheme(scheme), user(), password(), host(host), path(path), empty(false) {
@@ -51,7 +51,7 @@ class SWIFTEN_API URL {
/**
* Port number
*/
- boost::optional<int> getPort() const {
+ boost::optional<unsigned short> getPort() const {
return port;
}
@@ -64,7 +64,7 @@ class SWIFTEN_API URL {
std::string toString() const;
- static int getPortOrDefaultPort(const URL& url);
+ static unsigned short getPortOrDefaultPort(const URL& url);
static URL fromString(const std::string&);
static std::string unescape(const std::string&);
@@ -74,7 +74,7 @@ class SWIFTEN_API URL {
std::string user;
std::string password;
std::string host;
- boost::optional<int> port;
+ boost::optional<unsigned short> port;
std::string path;
bool empty;
};
diff --git a/Swiften/Base/UnitTest/URLTest.cpp b/Swiften/Base/UnitTest/URLTest.cpp
index c38398a..da9f15c 100644
--- a/Swiften/Base/UnitTest/URLTest.cpp
+++ b/Swiften/Base/UnitTest/URLTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -66,7 +66,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(1234, *url.getPort());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(1234), *url.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath());
}
@@ -75,7 +75,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(11440, *url.getPort());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(11440), *url.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("/http-bind/"), url.getPath());
}
@@ -84,7 +84,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(1234, *url.getPort());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(1234), *url.getPort());
CPPUNIT_ASSERT_EQUAL(std::string(""), url.getPath());
}
@@ -121,7 +121,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("127.0.0.1"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(12345, url.getPort().get_value_or(0));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(12345), url.getPort().get_value_or(0));
CPPUNIT_ASSERT_EQUAL(std::string("/foobar"), url.getPath());
}
@@ -137,7 +137,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("fdf8:f53b:82e4::53"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(12435, url.getPort().get_value_or(0));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(12435), url.getPort().get_value_or(0));
}
void test_FromString_ToString_IPv6RFC2732() {
@@ -147,7 +147,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(80, url.getPort().get_value_or(2));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(80), url.getPort().get_value_or(2));
CPPUNIT_ASSERT_EQUAL(std::string("/index.html"), url.getPath());
CPPUNIT_ASSERT_EQUAL(std::string(testVector), url.toString());
@@ -159,7 +159,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("1080:0:0:0:8:800:200C:417A"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(2, url.getPort().get_value_or(2));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(2), url.getPort().get_value_or(2));
CPPUNIT_ASSERT_EQUAL(std::string("/index.html"), url.getPath());
CPPUNIT_ASSERT_EQUAL(std::string(testVector), url.toString());
@@ -171,7 +171,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("3ffe:2a00:100:7031::1"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(2, url.getPort().get_value_or(2));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(2), url.getPort().get_value_or(2));
CPPUNIT_ASSERT_EQUAL(std::string(""), url.getPath());
CPPUNIT_ASSERT_EQUAL(std::string(testVector), url.toString());
@@ -183,7 +183,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("1080::8:800:200C:417A"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(2, url.getPort().get_value_or(2));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(2), url.getPort().get_value_or(2));
CPPUNIT_ASSERT_EQUAL(std::string("/foo"), url.getPath());
CPPUNIT_ASSERT_EQUAL(std::string(testVector), url.toString());
@@ -195,7 +195,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("::192.9.5.5"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(2, url.getPort().get_value_or(2));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(2), url.getPort().get_value_or(2));
CPPUNIT_ASSERT_EQUAL(std::string("/ipng"), url.getPath());
CPPUNIT_ASSERT_EQUAL(std::string(testVector), url.toString());
@@ -207,7 +207,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("::FFFF:129.144.52.38"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(80, url.getPort().get_value_or(2));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(80), url.getPort().get_value_or(2));
CPPUNIT_ASSERT_EQUAL(std::string("/index.html"), url.getPath());
CPPUNIT_ASSERT_EQUAL(std::string(testVector), url.toString());
@@ -219,7 +219,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("2010:836B:4179::836B:4179"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(2, url.getPort().get_value_or(2));
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(2), url.getPort().get_value_or(2));
CPPUNIT_ASSERT_EQUAL(std::string(), url.getPath());
CPPUNIT_ASSERT_EQUAL(std::string(testVector), url.toString());
diff --git a/Swiften/ChangeLog.md b/Swiften/ChangeLog.md
index 23d5185..60355b4 100644
--- a/Swiften/ChangeLog.md
+++ b/Swiften/ChangeLog.md
@@ -1,3 +1,7 @@
+5-in-progress
+-------------
+- Update build system from scons 2.4.0 to 3.0.1
+
4.0.1 (2018-03-28)
------------------
- Fix handling errors when fetching own vCard
diff --git a/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp b/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp
index efd37d9..b6c909a 100644
--- a/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp
+++ b/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,6 +13,9 @@
#include <Swiften/Disco/DummyEntityCapsProvider.h>
#include <Swiften/Network/DummyTimerFactory.h>
+// Clang wrongly things that tests for 0 are using 0 as null.
+#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
+
using namespace Swift;
class ChatStateNotifierTest : public ::testing::Test {
diff --git a/Swiften/Client/ClientXMLTracer.cpp b/Swiften/Client/ClientXMLTracer.cpp
index e205f41..e1b9e0c 100644
--- a/Swiften/Client/ClientXMLTracer.cpp
+++ b/Swiften/Client/ClientXMLTracer.cpp
@@ -16,9 +16,9 @@ namespace Swift {
ClientXMLTracer::ClientXMLTracer(CoreClient* client, bool bosh) : bosh_(bosh) {
#ifdef SWIFTEN_PLATFORM_WIN32
- beautifier_ = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false));
+ beautifier_ = std::make_unique<XMLBeautifier>(true, false);
#else
- beautifier_ = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, true));
+ beautifier_ = std::make_unique<XMLBeautifier>(true, true);
#endif
onDataReadConnection_ = client->onDataRead.connect(boost::bind(&ClientXMLTracer::printData, this, '<', _1));
onDataWrittenConnection_ = client->onDataWritten.connect(boost::bind(&ClientXMLTracer::printData, this, '>', _1));
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 1de1d61..ccde0c2 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -85,7 +85,17 @@ void CoreClient::connect(const ClientOptions& o) {
case ClientOptions::SOCKS5Proxy: {
SWIFT_LOG(debug) << " with manual configured SOCKS5 proxy" << std::endl;
std::string proxyHostname = o.manualProxyHostname.empty() ? systemSOCKS5Proxy.getAddress().toString() : o.manualProxyHostname;
- int proxyPort = o.manualProxyPort == -1 ? systemSOCKS5Proxy.getPort() : o.manualProxyPort;
+ auto proxyPort = systemSOCKS5Proxy.getPort();
+ if (o.manualProxyPort != -1) {
+ try {
+ proxyPort = boost::numeric_cast<unsigned short>(o.manualProxyPort);
+ }
+ catch (const boost::numeric::bad_numeric_cast& e) {
+ SWIFT_LOG(warning) << "Manual proxy port " << o.manualProxyPort << " is invalid: " << e.what() << std::endl;
+ onDisconnected(boost::optional<ClientError>(ClientError::ConnectionError));
+ return;
+ }
+ }
SWIFT_LOG(debug) << "Proxy: " << proxyHostname << ":" << proxyPort << std::endl;
proxyConnectionFactories.push_back(new SOCKS5ProxiedConnectionFactory(networkFactories->getDomainNameResolver(), networkFactories->getConnectionFactory(), networkFactories->getTimerFactory(), proxyHostname, proxyPort));
useDirectConnection = false;
@@ -94,7 +104,17 @@ void CoreClient::connect(const ClientOptions& o) {
case ClientOptions::HTTPConnectProxy: {
SWIFT_LOG(debug) << " with manual configured HTTPConnect proxy" << std::endl;
std::string proxyHostname = o.manualProxyHostname.empty() ? systemHTTPConnectProxy.getAddress().toString() : o.manualProxyHostname;
- int proxyPort = o.manualProxyPort == -1 ? systemHTTPConnectProxy.getPort() : o.manualProxyPort;
+ unsigned short proxyPort = systemHTTPConnectProxy.getPort();
+ if (o.manualProxyPort != -1) {
+ try {
+ proxyPort = boost::numeric_cast<unsigned short>(o.manualProxyPort);
+ }
+ catch (const boost::numeric::bad_numeric_cast& e) {
+ SWIFT_LOG(warning) << "Manual proxy port " << o.manualProxyPort << " is invalid: " << e.what() << std::endl;
+ onDisconnected(boost::optional<ClientError>(ClientError::ConnectionError));
+ return;
+ }
+ }
SWIFT_LOG(debug) << "Proxy: " << proxyHostname << ":" << proxyPort << std::endl;
proxyConnectionFactories.push_back(new HTTPConnectProxiedConnectionFactory(networkFactories->getDomainNameResolver(), networkFactories->getConnectionFactory(), networkFactories->getTimerFactory(), proxyHostname, proxyPort, o.httpTrafficFilter));
useDirectConnection = false;
@@ -108,7 +128,17 @@ void CoreClient::connect(const ClientOptions& o) {
// Create connector
std::string host = o.manualHostname.empty() ? jid_.getDomain() : o.manualHostname;
- int port = o.manualPort;
+ unsigned short port = 0;
+ if (o.manualPort != -1) {
+ try {
+ port = boost::numeric_cast<unsigned short>(o.manualPort);
+ }
+ catch (const boost::numeric::bad_numeric_cast& e) {
+ SWIFT_LOG(warning) << "Invalid manual port " << o.manualPort << ": " << e.what() << std::endl;
+ onDisconnected(boost::optional<ClientError>(ClientError::ConnectionError));
+ return;
+ }
+ }
boost::optional<std::string> serviceLookupPrefix;
if (o.manualHostname.empty()) {
serviceLookupPrefix = "_xmpp-client._tcp.";
@@ -286,6 +316,8 @@ void CoreClient::handleSessionFinished(std::shared_ptr<Error> error) {
clientError = ClientError(ClientError::CertificateCardRemoved);
break;
case TLSError::UnknownError:
+ case TLSError::AcceptFailed:
+ case TLSError::ConnectFailed:
clientError = ClientError(ClientError::TLSError);
break;
}
diff --git a/Swiften/Client/DummyStanzaChannel.h b/Swiften/Client/DummyStanzaChannel.h
index 4cc0f7e..1ba70ad 100644
--- a/Swiften/Client/DummyStanzaChannel.h
+++ b/Swiften/Client/DummyStanzaChannel.h
@@ -48,8 +48,12 @@ namespace Swift {
return available_;
}
+ virtual void setStreamManagementEnabled(bool enable) {
+ streamManagement_ = enable;
+ }
+
virtual bool getStreamManagementEnabled() const {
- return false;
+ return streamManagement_;
}
template<typename T> bool isRequestAtIndex(size_t index, const JID& jid, IQ::Type type) {
@@ -101,5 +105,6 @@ namespace Swift {
bool available_ = true;
bool uniqueIDs_ = false;
unsigned int idCounter_ = 0;
+ bool streamManagement_ = false;
};
}
diff --git a/Swiften/Client/UnitTest/XMLBeautifierTest.cpp b/Swiften/Client/UnitTest/XMLBeautifierTest.cpp
index 0188634..2a639ea 100644
--- a/Swiften/Client/UnitTest/XMLBeautifierTest.cpp
+++ b/Swiften/Client/UnitTest/XMLBeautifierTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2017 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,6 +8,9 @@
#include <Swiften/Client/XMLBeautifier.h>
#include <iostream>
+// Clang wrongly things that tests for 0 are using 0 as null.
+#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
+
using namespace Swift;
namespace {
@@ -15,7 +18,7 @@ namespace {
}
TEST(XMLBeautifierTest, testBeautify) {
- auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false));
+ auto beautifier = std::make_unique<XMLBeautifier>(true, false);
ASSERT_EQ(FULL_FORMATTED_OUTPUT, beautifier->beautify("<list><el>aqq</el><el>bzz</el></list>"));
ASSERT_TRUE(beautifier->wasReset());
@@ -26,7 +29,7 @@ TEST(XMLBeautifierTest, testBeautify) {
}
TEST(XMLBeautifierTest, testBeautifyMultipleChunks) {
- auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false));
+ auto beautifier = std::make_unique<XMLBeautifier>(true, false);
auto result = beautifier->beautify("<list><el>aqq</el>");
ASSERT_TRUE(beautifier->wasReset());
@@ -40,7 +43,7 @@ TEST(XMLBeautifierTest, testBeautifyMultipleChunks) {
}
TEST(XMLBeautifierTest, testBeautifyMultipleChunksMiddleElement) {
- auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false));
+ auto beautifier = std::make_unique<XMLBeautifier>(true, false);
auto result = beautifier->beautify("<l");
ASSERT_TRUE(beautifier->wasReset());
@@ -54,7 +57,7 @@ TEST(XMLBeautifierTest, testBeautifyMultipleChunksMiddleElement) {
}
TEST(XMLBeautifierTest, testBeautifyInvalidMultipleChunks) {
- auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false));
+ auto beautifier = std::make_unique<XMLBeautifier>(true, false);
ASSERT_EQ(std::string("<list>\n <el>aqq"), beautifier->beautify("<list><el>aqq<"));
ASSERT_TRUE(beautifier->wasReset());
diff --git a/Swiften/Component/ComponentConnector.cpp b/Swiften/Component/ComponentConnector.cpp
index a7375a7..7789c4c 100644
--- a/Swiften/Component/ComponentConnector.cpp
+++ b/Swiften/Component/ComponentConnector.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -15,7 +15,7 @@
namespace Swift {
-ComponentConnector::ComponentConnector(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0) {
+ComponentConnector::ComponentConnector(const std::string& hostname, unsigned short port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0) {
}
void ComponentConnector::setTimeoutMilliseconds(int milliseconds) {
diff --git a/Swiften/Component/ComponentConnector.h b/Swiften/Component/ComponentConnector.h
index ab36901..cfd49fe 100644
--- a/Swiften/Component/ComponentConnector.h
+++ b/Swiften/Component/ComponentConnector.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -28,7 +28,7 @@ namespace Swift {
public:
typedef std::shared_ptr<ComponentConnector> ref;
- static ComponentConnector::ref create(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) {
+ static ComponentConnector::ref create(const std::string& hostname, unsigned short port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) {
return ref(new ComponentConnector(hostname, port, resolver, connectionFactory, timerFactory));
}
@@ -40,7 +40,7 @@ namespace Swift {
boost::signals2::signal<void (std::shared_ptr<Connection>)> onConnectFinished;
private:
- ComponentConnector(const std::string& hostname, int port, DomainNameResolver*, ConnectionFactory*, TimerFactory*);
+ ComponentConnector(const std::string& hostname, unsigned short port, DomainNameResolver*, ConnectionFactory*, TimerFactory*);
void handleAddressQueryResult(const std::vector<HostAddress>& address, boost::optional<DomainNameResolveError> error);
void tryNextAddress();
@@ -53,7 +53,7 @@ namespace Swift {
private:
std::string hostname;
- int port;
+ unsigned short port;
DomainNameResolver* resolver;
ConnectionFactory* connectionFactory;
TimerFactory* timerFactory;
diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp
index 3896bdd..2d91c9c 100644
--- a/Swiften/Component/CoreComponent.cpp
+++ b/Swiften/Component/CoreComponent.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -43,7 +43,7 @@ CoreComponent::~CoreComponent() {
delete stanzaChannel_;
}
-void CoreComponent::connect(const std::string& host, int port) {
+void CoreComponent::connect(const std::string& host, unsigned short port) {
assert(!connector_);
connector_ = ComponentConnector::create(host, port, networkFactories->getDomainNameResolver(), networkFactories->getConnectionFactory(), networkFactories->getTimerFactory());
connector_->onConnectFinished.connect(boost::bind(&CoreComponent::handleConnectorFinished, this, _1));
@@ -166,4 +166,12 @@ void CoreComponent::sendData(const std::string& data) {
sessionStream_->writeData(data);
}
+bool CoreComponent::isActive() const {
+ return session_ || connector_;
+}
+
+bool CoreComponent::isAvailable() const {
+ return stanzaChannel_->isAvailable();
+}
+
}
diff --git a/Swiften/Component/CoreComponent.h b/Swiften/Component/CoreComponent.h
index f673643..7565d00 100644
--- a/Swiften/Component/CoreComponent.h
+++ b/Swiften/Component/CoreComponent.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2017 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -46,7 +46,7 @@ namespace Swift {
CoreComponent(const JID& jid, const std::string& secret, NetworkFactories* networkFactories);
virtual ~CoreComponent();
- void connect(const std::string& host, int port);
+ void connect(const std::string& host, unsigned short port);
void disconnect();
void sendMessage(std::shared_ptr<Message>);
@@ -61,9 +61,18 @@ namespace Swift {
return stanzaChannel_;
}
- bool isAvailable() const {
- return stanzaChannel_->isAvailable();
- }
+ /**
+ * Checks whether the component is connected to the server,
+ * and stanzas can be sent.
+ */
+ bool isAvailable() const;
+
+ /**
+ * Checks whether the component is active.
+ *
+ * A component is active when it is connected or connecting to the server.
+ */
+ bool isActive() const;
/**
* Returns the JID of the component
diff --git a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
index 3b4fa83..bd26989 100644
--- a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
+++ b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -146,7 +146,7 @@ class ComponentConnectorTest : public CppUnit::TestFixture {
}
private:
- ComponentConnector::ref createConnector(const std::string& hostname, int port) {
+ ComponentConnector::ref createConnector(const std::string& hostname, unsigned short port) {
ComponentConnector::ref connector = ComponentConnector::create(hostname, port, resolver, connectionFactory, timerFactory);
connector->onConnectFinished.connect(boost::bind(&ComponentConnectorTest::handleConnectorFinished, this, _1));
return connector;
diff --git a/Swiften/Config/SConscript b/Swiften/Config/SConscript
index dd06d61..ae0d37a 100644
--- a/Swiften/Config/SConscript
+++ b/Swiften/Config/SConscript
@@ -10,7 +10,7 @@ def cStringVariable(env, cVar, sconsVar) :
# FIXME: Probably not very robust
for var in sconsVar.split(" ") :
result += "\t\"" + env.subst(var).replace("\\", "\\\\") + "\",\n"
- result += "\t0\n"
+ result += "\tnullptr\n"
result += "};\n"
return result
@@ -22,15 +22,15 @@ swiften_env.UseFlags(swiften_env["SWIFTEN_DEP_FLAGS"])
cppflags = replaceSwiftenPath(" ".join([
swiften_env.subst("$CPPFLAGS").replace("-isystem ","-I"),
- swiften_env.subst("$_CPPDEFFLAGS"),
+ swiften_env.subst("$_CPPDEFFLAGS"),
swiften_env.subst("$_CPPINCFLAGS")]))
config_flags += cStringVariable(swiften_env, "CPPFLAGS", cppflags)
libflags = replaceSwiftenPath(" ".join([
- swiften_env.subst("$_LIBDIRFLAGS"),
- swiften_env.subst("$_LIBFLAGS"),
- swiften_env.subst("$_FRAMEWORKPATH"),
- swiften_env.subst("$_FRAMEWORKS"),
+ swiften_env.subst("$_LIBDIRFLAGS"),
+ swiften_env.subst("$_LIBFLAGS"),
+ swiften_env.subst("$_FRAMEWORKPATH"),
+ swiften_env.subst("$_FRAMEWORKS"),
swiften_env.subst("$_FRAMEWORKSFLAGS")
]))
config_flags += cStringVariable(swiften_env, "LIBFLAGS", libflags)
diff --git a/Swiften/Crypto/CommonCryptoCryptoProvider.cpp b/Swiften/Crypto/CommonCryptoCryptoProvider.cpp
index 9fbdb2a..3cc69b0 100644
--- a/Swiften/Crypto/CommonCryptoCryptoProvider.cpp
+++ b/Swiften/Crypto/CommonCryptoCryptoProvider.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -27,18 +27,18 @@ namespace {
}
}
- ~SHA1Hash() {
+ virtual ~SHA1Hash() override {
}
- virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const ByteArray& data) override {
return updateInternal(data);
}
- virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const SafeByteArray& data) override {
return updateInternal(data);
}
- virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE {
+ virtual std::vector<unsigned char> getHash() override {
assert(!finalized);
std::vector<unsigned char> result(CC_SHA1_DIGEST_LENGTH);
CC_SHA1_Final(vecptr(result), &context);
@@ -49,7 +49,12 @@ namespace {
template<typename ContainerType>
Hash& updateInternal(const ContainerType& data) {
assert(!finalized);
- if (!CC_SHA1_Update(&context, vecptr(data), boost::numeric_cast<CC_LONG>(data.size()))) {
+ try {
+ if (!CC_SHA1_Update(&context, vecptr(data), boost::numeric_cast<CC_LONG>(data.size()))) {
+ assert(false);
+ }
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
assert(false);
}
return *this;
@@ -68,18 +73,18 @@ namespace {
}
}
- ~MD5Hash() {
+ virtual ~MD5Hash() override {
}
- virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const ByteArray& data) override {
return updateInternal(data);
}
- virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const SafeByteArray& data) override {
return updateInternal(data);
}
- virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE {
+ virtual std::vector<unsigned char> getHash() override {
assert(!finalized);
std::vector<unsigned char> result(CC_MD5_DIGEST_LENGTH);
CC_MD5_Final(vecptr(result), &context);
@@ -90,7 +95,12 @@ namespace {
template<typename ContainerType>
Hash& updateInternal(const ContainerType& data) {
assert(!finalized);
- if (!CC_MD5_Update(&context, vecptr(data), boost::numeric_cast<CC_LONG>(data.size()))) {
+ try {
+ if (!CC_MD5_Update(&context, vecptr(data), boost::numeric_cast<CC_LONG>(data.size()))) {
+ assert(false);
+ }
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
assert(false);
}
return *this;
@@ -104,7 +114,12 @@ namespace {
template<typename T>
ByteArray getHMACSHA1Internal(const T& key, const ByteArray& data) {
std::vector<unsigned char> result(CC_SHA1_DIGEST_LENGTH);
- CCHmac(kCCHmacAlgSHA1, vecptr(key), key.size(), vecptr(data), boost::numeric_cast<CC_LONG>(data.size()), vecptr(result));
+ try {
+ CCHmac(kCCHmacAlgSHA1, vecptr(key), key.size(), vecptr(data), boost::numeric_cast<CC_LONG>(data.size()), vecptr(result));
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ assert(false);
+ }
return result;
}
}
diff --git a/Swiften/Crypto/CommonCryptoCryptoProvider.h b/Swiften/Crypto/CommonCryptoCryptoProvider.h
index 8fa7fa6..7d1675f 100644
--- a/Swiften/Crypto/CommonCryptoCryptoProvider.h
+++ b/Swiften/Crypto/CommonCryptoCryptoProvider.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,19 +7,18 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Crypto/CryptoProvider.h>
namespace Swift {
class SWIFTEN_API CommonCryptoCryptoProvider : public CryptoProvider {
public:
CommonCryptoCryptoProvider();
- ~CommonCryptoCryptoProvider();
+ virtual ~CommonCryptoCryptoProvider() override;
- virtual Hash* createSHA1() SWIFTEN_OVERRIDE;
- virtual Hash* createMD5() SWIFTEN_OVERRIDE;
- virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE;
- virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE;
- virtual bool isMD5AllowedForCrypto() const SWIFTEN_OVERRIDE;
+ virtual Hash* createSHA1() override;
+ virtual Hash* createMD5() override;
+ virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) override;
+ virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) override;
+ virtual bool isMD5AllowedForCrypto() const override;
};
}
diff --git a/Swiften/Crypto/OpenSSLCryptoProvider.cpp b/Swiften/Crypto/OpenSSLCryptoProvider.cpp
index c785041..5245bd8 100644
--- a/Swiften/Crypto/OpenSSLCryptoProvider.cpp
+++ b/Swiften/Crypto/OpenSSLCryptoProvider.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -28,18 +28,18 @@ namespace {
}
}
- ~SHA1Hash() {
+ ~SHA1Hash() override {
}
- virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const ByteArray& data) override {
return updateInternal(data);
}
- virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const SafeByteArray& data) override {
return updateInternal(data);
}
- virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE {
+ virtual std::vector<unsigned char> getHash() override {
assert(!finalized);
std::vector<unsigned char> result(SHA_DIGEST_LENGTH);
SHA1_Final(vecptr(result), &context);
@@ -69,18 +69,18 @@ namespace {
}
}
- ~MD5Hash() {
+ ~MD5Hash() override {
}
- virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const ByteArray& data) override {
return updateInternal(data);
}
- virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const SafeByteArray& data) override {
return updateInternal(data);
}
- virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE {
+ virtual std::vector<unsigned char> getHash() override {
assert(!finalized);
std::vector<unsigned char> result(MD5_DIGEST_LENGTH);
MD5_Final(vecptr(result), &context);
@@ -107,7 +107,12 @@ namespace {
ByteArray getHMACSHA1Internal(const T& key, const ByteArray& data) {
unsigned int len = SHA_DIGEST_LENGTH;
std::vector<unsigned char> result(len);
- HMAC(EVP_sha1(), vecptr(key), boost::numeric_cast<int>(key.size()), vecptr(data), data.size(), vecptr(result), &len);
+ try {
+ HMAC(EVP_sha1(), vecptr(key), boost::numeric_cast<int>(key.size()), vecptr(data), data.size(), vecptr(result), &len);
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ assert(false);
+ }
return result;
}
}
diff --git a/Swiften/Crypto/OpenSSLCryptoProvider.h b/Swiften/Crypto/OpenSSLCryptoProvider.h
index 6e0c01b..e4ee97d 100644
--- a/Swiften/Crypto/OpenSSLCryptoProvider.h
+++ b/Swiften/Crypto/OpenSSLCryptoProvider.h
@@ -1,24 +1,23 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Swiften/Base/Override.h>
#include <Swiften/Crypto/CryptoProvider.h>
namespace Swift {
class OpenSSLCryptoProvider : public CryptoProvider {
public:
OpenSSLCryptoProvider();
- ~OpenSSLCryptoProvider();
+ virtual ~OpenSSLCryptoProvider() override;
- virtual Hash* createSHA1() SWIFTEN_OVERRIDE;
- virtual Hash* createMD5() SWIFTEN_OVERRIDE;
- virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE;
- virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE;
- virtual bool isMD5AllowedForCrypto() const SWIFTEN_OVERRIDE;
+ virtual Hash* createSHA1() override;
+ virtual Hash* createMD5() override;
+ virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) override;
+ virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) override;
+ virtual bool isMD5AllowedForCrypto() const override;
};
}
diff --git a/Swiften/Crypto/WindowsCryptoProvider.cpp b/Swiften/Crypto/WindowsCryptoProvider.cpp
index 513941f..c784283 100644
--- a/Swiften/Crypto/WindowsCryptoProvider.cpp
+++ b/Swiften/Crypto/WindowsCryptoProvider.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -43,11 +43,11 @@ namespace {
CryptDestroyHash(hash);
}
- virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const ByteArray& data) override {
return updateInternal(data);
}
- virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const SafeByteArray& data) override {
return updateInternal(data);
}
@@ -123,11 +123,11 @@ namespace {
CryptDestroyHash(hash);
}
- virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const ByteArray& data) override {
return updateInternal(data);
}
- virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE {
+ virtual Hash& update(const SafeByteArray& data) override {
return updateInternal(data);
}
diff --git a/Swiften/Crypto/WindowsCryptoProvider.h b/Swiften/Crypto/WindowsCryptoProvider.h
index f446027..d0c982e 100644
--- a/Swiften/Crypto/WindowsCryptoProvider.h
+++ b/Swiften/Crypto/WindowsCryptoProvider.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <boost/noncopyable.hpp>
-#include <Swiften/Base/Override.h>
#include <Swiften/Crypto/CryptoProvider.h>
namespace Swift {
@@ -19,11 +18,11 @@ namespace Swift {
WindowsCryptoProvider();
virtual ~WindowsCryptoProvider();
- virtual Hash* createSHA1() SWIFTEN_OVERRIDE;
- virtual Hash* createMD5() SWIFTEN_OVERRIDE;
- virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE;
- virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE;
- virtual bool isMD5AllowedForCrypto() const SWIFTEN_OVERRIDE;
+ virtual Hash* createSHA1() override;
+ virtual Hash* createMD5() override;
+ virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) override;
+ virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) override;
+ virtual bool isMD5AllowedForCrypto() const override;
private:
struct Private;
diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
index 153e821..5f1aaf4 100644
--- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
@@ -47,9 +47,9 @@ class CapsManagerTest : public CppUnit::TestFixture {
public:
void setUp() {
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
- iqRouter = std::unique_ptr<IQRouter>(new IQRouter(stanzaChannel.get()));
- storage = std::unique_ptr<CapsMemoryStorage>(new CapsMemoryStorage());
+ stanzaChannel = std::make_unique<DummyStanzaChannel>();
+ iqRouter = std::make_unique<IQRouter>(stanzaChannel.get());
+ storage = std::make_unique<CapsMemoryStorage>();
user1 = JID("user1@bar.com/bla");
discoInfo1 = std::make_shared<DiscoInfo>();
discoInfo1->addFeature("http://swift.im/feature1");
diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
index 8c59741..6548485 100644
--- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
@@ -37,8 +37,8 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
void setUp() {
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
- capsProvider = std::unique_ptr<DummyCapsProvider>(new DummyCapsProvider());
+ stanzaChannel = std::make_unique<DummyStanzaChannel>();
+ capsProvider = std::make_unique<DummyCapsProvider>();
user1 = JID("user1@bar.com/bla");
discoInfo1 = std::make_shared<DiscoInfo>();
diff --git a/Swiften/Elements/Bytestreams.h b/Swiften/Elements/Bytestreams.h
index ca30922..599ed46 100644
--- a/Swiften/Elements/Bytestreams.h
+++ b/Swiften/Elements/Bytestreams.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -22,11 +22,11 @@ namespace Swift {
typedef std::shared_ptr<Bytestreams> ref;
struct StreamHost {
- StreamHost(const std::string& host = "", const JID& jid = JID(), int port = -1) : host(host), jid(jid), port(port) {}
+ StreamHost(const std::string& host = "", const JID& jid = JID(), unsigned short port = 0) : host(host), jid(jid), port(port) {}
std::string host;
JID jid;
- int port;
+ unsigned short port;
};
Bytestreams() {}
diff --git a/Swiften/Elements/ContainerPayload.h b/Swiften/Elements/ContainerPayload.h
index 3da04b7..033575a 100644
--- a/Swiften/Elements/ContainerPayload.h
+++ b/Swiften/Elements/ContainerPayload.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <vector>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/DiscoInfo.cpp b/Swiften/Elements/DiscoInfo.cpp
index 11f0623..701ed40 100644
--- a/Swiften/Elements/DiscoInfo.cpp
+++ b/Swiften/Elements/DiscoInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2015 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -26,6 +26,7 @@ const std::string DiscoInfo::MessageDeliveryReceiptsFeature = std::string("urn:x
const std::string DiscoInfo::WhiteboardFeature = std::string("http://swift.im/whiteboard");
const std::string DiscoInfo::BlockingCommandFeature = std::string("urn:xmpp:blocking");
const std::string DiscoInfo::MessageCarbonsFeature = std::string("urn:xmpp:carbons:2");
+const std::string DiscoInfo::ReferencesFeature = std::string("urn:xmpp:references:0");
bool DiscoInfo::Identity::operator<(const Identity& other) const {
if (category_ == other.category_) {
diff --git a/Swiften/Elements/DiscoInfo.h b/Swiften/Elements/DiscoInfo.h
index c8009ee..713eaba 100644
--- a/Swiften/Elements/DiscoInfo.h
+++ b/Swiften/Elements/DiscoInfo.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -37,6 +37,7 @@ namespace Swift {
static const std::string WhiteboardFeature;
static const std::string BlockingCommandFeature;
static const std::string MessageCarbonsFeature;
+ static const std::string ReferencesFeature;
class Identity {
public:
diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h
index 899fb93..827e497 100644
--- a/Swiften/Elements/Form.h
+++ b/Swiften/Elements/Form.h
@@ -89,6 +89,9 @@ namespace Swift {
return instructions_;
}
+ /** Returns the Form::Type enum (ie. ResultType, CancelType etc.).
+ * NOT to be confused with Form::getFormType().
+ */
Type getType() const {
return type_;
}
@@ -97,6 +100,9 @@ namespace Swift {
type_ = type;
}
+ /** Returns the value of the field FORM_TYPE
+ * NOT to be confused with Form::getType().
+ */
std::string getFormType() const;
FormField::ref getField(const std::string& name) const;
void addItem(const FormItem& item);
diff --git a/Swiften/Elements/IBB.h b/Swiften/Elements/IBB.h
index bd0b661..6ebe66e 100644
--- a/Swiften/Elements/IBB.h
+++ b/Swiften/Elements/IBB.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -28,10 +28,10 @@ namespace Swift {
MessageStanza
};
- IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) {
+ IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(0), sequenceNumber(-1) {
}
- static IBB::ref createIBBOpen(const std::string& streamID, int blockSize) {
+ static IBB::ref createIBBOpen(const std::string& streamID, unsigned int blockSize) {
IBB::ref result = std::make_shared<IBB>(Open, streamID);
result->setBlockSize(blockSize);
return result;
@@ -80,11 +80,11 @@ namespace Swift {
this->data = data;
}
- int getBlockSize() const {
+ unsigned int getBlockSize() const {
return blockSize;
}
- void setBlockSize(int blockSize) {
+ void setBlockSize(unsigned int blockSize) {
this->blockSize = blockSize;
}
@@ -101,7 +101,7 @@ namespace Swift {
std::string streamID;
std::vector<unsigned char> data;
StanzaType stanzaType;
- int blockSize;
+ unsigned int blockSize;
int sequenceNumber;
};
}
diff --git a/Swiften/Elements/IsodeIQDelegation.h b/Swiften/Elements/IsodeIQDelegation.h
index 39655ce..074a06d 100644
--- a/Swiften/Elements/IsodeIQDelegation.h
+++ b/Swiften/Elements/IsodeIQDelegation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Forwarded.h>
#include <Swiften/Elements/Payload.h>
diff --git a/Swiften/Elements/MIXJoin.h b/Swiften/Elements/MIXJoin.h
index 2d82adc..ecd7b12 100644
--- a/Swiften/Elements/MIXJoin.h
+++ b/Swiften/Elements/MIXJoin.h
@@ -8,12 +8,12 @@
#include <memory>
#include <string>
+#include <unordered_set>
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Elements/Payload.h>
-#include <Swiften/Elements/MIXSubscribe.h>
#include <Swiften/Elements/Form.h>
#include <Swiften/JID/JID.h>
@@ -31,7 +31,7 @@ namespace Swift {
return channel_;
}
- void setChannel(const JID& channel) {
+ void setChannel(JID channel) {
channel_ = channel;
}
@@ -39,20 +39,24 @@ namespace Swift {
return jid_;
}
- void setJID(const JID& jid) {
+ void setJID(JID jid) {
jid_ = jid;
}
- const std::vector<MIXSubscribe::ref>& getSubscriptions() const {
+ const std::unordered_set<std::string>& getSubscriptions() const {
return subscribeItems_;
}
- void setSubscriptions(const std::vector<MIXSubscribe::ref>& value) {
- subscribeItems_ = value ;
+ void setSubscriptions(std::unordered_set<std::string> values) {
+ subscribeItems_ = values ;
}
- void addSubscription(MIXSubscribe::ref value) {
- subscribeItems_.push_back(value);
+ void addSubscription(std::string value) {
+ subscribeItems_.insert(value);
+ }
+
+ bool hasSubscription(const std::string& value) const {
+ return std::find(subscribeItems_.begin(), subscribeItems_.end(), value) != subscribeItems_.end();
}
void setForm(std::shared_ptr<Form> form) {
@@ -66,7 +70,7 @@ namespace Swift {
private:
boost::optional<JID> jid_;
boost::optional<JID> channel_;
- std::vector<MIXSubscribe::ref> subscribeItems_;
+ std::unordered_set<std::string> subscribeItems_;
std::shared_ptr<Form> form_;
// FIXME: MIXInvitation to be implemented. boost::optional<MIXInvitation> invitation_;
};
diff --git a/Swiften/Elements/MIXLeave.h b/Swiften/Elements/MIXLeave.h
new file mode 100644
index 0000000..76ca09d
--- /dev/null
+++ b/Swiften/Elements/MIXLeave.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <boost/optional.hpp>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/JID/JID.h>
+#include <Swiften/Elements/Payload.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXLeave : public Payload {
+ public:
+ using ref = std::shared_ptr<MIXLeave>;
+
+ public:
+
+ MIXLeave() {}
+
+ const boost::optional<JID>& getChannel() const {
+ return channel_;
+ }
+
+ void setChannel(const JID& channel) {
+ channel_ = channel;
+ }
+
+ private:
+ boost::optional<JID> channel_;
+ };
+}
diff --git a/Swiften/Elements/MIXPayload.h b/Swiften/Elements/MIXPayload.h
new file mode 100644
index 0000000..3989c18
--- /dev/null
+++ b/Swiften/Elements/MIXPayload.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include <boost/optional.hpp>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/Payload.h>
+#include <Swiften/JID/JID.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXPayload : public Payload {
+ public:
+ using ref = std::shared_ptr<MIXPayload>;
+
+ public:
+
+ MIXPayload() {}
+
+ const boost::optional<std::string>& getNick() const {
+ return nick_;
+ }
+
+ void setNick(const std::string& nick) {
+ nick_ = nick;
+ }
+
+ const boost::optional<JID>& getJID() const {
+ return jid_;
+ }
+
+ void setJID(const JID& jid) {
+ jid_ = jid;
+ }
+
+ const boost::optional<std::string>& getSubmissionID() const {
+ return submissionId_;
+ }
+
+ void setSubmissionID(const std::string& submissionId) {
+ submissionId_ = submissionId;
+ }
+
+ private:
+ boost::optional<JID> jid_;
+ boost::optional<std::string> nick_;
+ boost::optional<std::string> submissionId_;
+ };
+}
diff --git a/Swiften/Elements/MIXSubscribe.h b/Swiften/Elements/MIXRegisterNick.h
index eaf1aa9..3bd8c4a 100644
--- a/Swiften/Elements/MIXSubscribe.h
+++ b/Swiften/Elements/MIXRegisterNick.h
@@ -9,30 +9,27 @@
#include <memory>
#include <string>
-#include <boost/optional.hpp>
-
#include <Swiften/Base/API.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
- class SWIFTEN_API MIXSubscribe : public Payload {
-
+ class SWIFTEN_API MIXRegisterNick : public Payload {
public:
- using ref = std::shared_ptr<MIXSubscribe>;
+ using ref = std::shared_ptr<MIXRegisterNick>;
public:
- MIXSubscribe() {}
+ MIXRegisterNick() {}
- const std::string& getNode() const {
- return node_;
+ const std::string& getNick() const {
+ return nick_;
}
- void setNode(const std::string& node) {
- node_ = node;
+ void setNick(const std::string& nick) {
+ nick_ = nick;
}
private:
- std::string node_;
+ std::string nick_;
};
}
diff --git a/Swiften/Elements/MIXSetNick.h b/Swiften/Elements/MIXSetNick.h
new file mode 100644
index 0000000..94c5a3b
--- /dev/null
+++ b/Swiften/Elements/MIXSetNick.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/Payload.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXSetNick : public Payload {
+ public:
+ using ref = std::shared_ptr<MIXSetNick>;
+
+ public:
+
+ MIXSetNick() {}
+
+ const std::string& getNick() const {
+ return nick_;
+ }
+
+ void setNick(const std::string& nick) {
+ nick_ = nick;
+ }
+
+ private:
+ std::string nick_;
+ };
+}
diff --git a/Swiften/Elements/MIXUpdateSubscription.h b/Swiften/Elements/MIXUpdateSubscription.h
new file mode 100644
index 0000000..dc6ed27
--- /dev/null
+++ b/Swiften/Elements/MIXUpdateSubscription.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <memory>
+#include <unordered_set>
+
+#include <boost/optional.hpp>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/Payload.h>
+#include <Swiften/JID/JID.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXUpdateSubscription : public Payload {
+
+ public:
+ using ref = std::shared_ptr<MIXUpdateSubscription>;
+
+ public:
+
+ MIXUpdateSubscription() {}
+
+ const boost::optional<JID>& getJID() const {
+ return jid_;
+ }
+
+ void setJID(JID jid) {
+ jid_ = jid;
+ }
+
+ const std::unordered_set<std::string>& getSubscriptions() const {
+ return subscribeItems_;
+ }
+
+ void setSubscriptions(std::unordered_set<std::string> values) {
+ subscribeItems_ = values ;
+ }
+
+ void addSubscription(std::string value) {
+ subscribeItems_.insert(value);
+ }
+
+ bool hasSubscription(const std::string& value) const {
+ return std::find(subscribeItems_.begin(), subscribeItems_.end(), value) != subscribeItems_.end();
+ }
+
+ private:
+ boost::optional<JID> jid_;
+ std::unordered_set<std::string> subscribeItems_;
+ };
+}
diff --git a/Swiften/Elements/PubSub.h b/Swiften/Elements/PubSub.h
index d62c54e..47b8c3f 100644
--- a/Swiften/Elements/PubSub.h
+++ b/Swiften/Elements/PubSub.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/ContainerPayload.h>
#include <Swiften/Elements/PubSubPayload.h>
diff --git a/Swiften/Elements/PubSubAffiliation.h b/Swiften/Elements/PubSubAffiliation.h
index b19e84b..058ef88 100644
--- a/Swiften/Elements/PubSubAffiliation.h
+++ b/Swiften/Elements/PubSubAffiliation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubAffiliations.h b/Swiften/Elements/PubSubAffiliations.h
index c7e22ce..f3a6dda 100644
--- a/Swiften/Elements/PubSubAffiliations.h
+++ b/Swiften/Elements/PubSubAffiliations.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,7 +13,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubAffiliation.h>
#include <Swiften/Elements/PubSubPayload.h>
diff --git a/Swiften/Elements/PubSubConfigure.h b/Swiften/Elements/PubSubConfigure.h
index 8442198..88a1ea9 100644
--- a/Swiften/Elements/PubSubConfigure.h
+++ b/Swiften/Elements/PubSubConfigure.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Form.h>
#include <Swiften/Elements/Payload.h>
diff --git a/Swiften/Elements/PubSubCreate.h b/Swiften/Elements/PubSubCreate.h
index 5ece36e..ac6b987 100644
--- a/Swiften/Elements/PubSubCreate.h
+++ b/Swiften/Elements/PubSubCreate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubConfigure.h>
#include <Swiften/Elements/PubSubPayload.h>
diff --git a/Swiften/Elements/PubSubDefault.h b/Swiften/Elements/PubSubDefault.h
index 08482b4..aa058ac 100644
--- a/Swiften/Elements/PubSubDefault.h
+++ b/Swiften/Elements/PubSubDefault.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubPayload.h>
diff --git a/Swiften/Elements/PubSubEvent.h b/Swiften/Elements/PubSubEvent.h
index 8f02258..561f731 100644
--- a/Swiften/Elements/PubSubEvent.h
+++ b/Swiften/Elements/PubSubEvent.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/ContainerPayload.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubEventPayload.h>
diff --git a/Swiften/Elements/PubSubEventAssociate.h b/Swiften/Elements/PubSubEventAssociate.h
index 5d963a0..b7bb839 100644
--- a/Swiften/Elements/PubSubEventAssociate.h
+++ b/Swiften/Elements/PubSubEventAssociate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubEventCollection.h b/Swiften/Elements/PubSubEventCollection.h
index 61056e2..367fe02 100644
--- a/Swiften/Elements/PubSubEventCollection.h
+++ b/Swiften/Elements/PubSubEventCollection.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -12,7 +12,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubEventAssociate.h>
#include <Swiften/Elements/PubSubEventDisassociate.h>
diff --git a/Swiften/Elements/PubSubEventConfiguration.h b/Swiften/Elements/PubSubEventConfiguration.h
index 6c5305d..e529014 100644
--- a/Swiften/Elements/PubSubEventConfiguration.h
+++ b/Swiften/Elements/PubSubEventConfiguration.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Form.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubEventPayload.h>
diff --git a/Swiften/Elements/PubSubEventDelete.h b/Swiften/Elements/PubSubEventDelete.h
index 787dce0..f899d4e 100644
--- a/Swiften/Elements/PubSubEventDelete.h
+++ b/Swiften/Elements/PubSubEventDelete.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubEventPayload.h>
#include <Swiften/Elements/PubSubEventRedirect.h>
diff --git a/Swiften/Elements/PubSubEventDisassociate.h b/Swiften/Elements/PubSubEventDisassociate.h
index 826b1f4..415ac29 100644
--- a/Swiften/Elements/PubSubEventDisassociate.h
+++ b/Swiften/Elements/PubSubEventDisassociate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubEventItem.h b/Swiften/Elements/PubSubEventItem.h
index 50e8757..defdbf4 100644
--- a/Swiften/Elements/PubSubEventItem.h
+++ b/Swiften/Elements/PubSubEventItem.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,7 +13,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubEventItems.h b/Swiften/Elements/PubSubEventItems.h
index 48fd340..aade826 100644
--- a/Swiften/Elements/PubSubEventItems.h
+++ b/Swiften/Elements/PubSubEventItems.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <vector>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubEventItem.h>
#include <Swiften/Elements/PubSubEventPayload.h>
diff --git a/Swiften/Elements/PubSubEventPurge.h b/Swiften/Elements/PubSubEventPurge.h
index 743cc25..647598d 100644
--- a/Swiften/Elements/PubSubEventPurge.h
+++ b/Swiften/Elements/PubSubEventPurge.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubEventPayload.h>
diff --git a/Swiften/Elements/PubSubEventRedirect.h b/Swiften/Elements/PubSubEventRedirect.h
index e0e351f..063cf8c 100644
--- a/Swiften/Elements/PubSubEventRedirect.h
+++ b/Swiften/Elements/PubSubEventRedirect.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubEventRetract.h b/Swiften/Elements/PubSubEventRetract.h
index b0aea96..19e02c9 100644
--- a/Swiften/Elements/PubSubEventRetract.h
+++ b/Swiften/Elements/PubSubEventRetract.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubEventSubscription.h b/Swiften/Elements/PubSubEventSubscription.h
index 0b8297c..37e8b74 100644
--- a/Swiften/Elements/PubSubEventSubscription.h
+++ b/Swiften/Elements/PubSubEventSubscription.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -12,7 +12,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubEventPayload.h>
#include <Swiften/JID/JID.h>
diff --git a/Swiften/Elements/PubSubItem.cpp b/Swiften/Elements/PubSubItem.cpp
index 4dc0907..b5f17cc 100644
--- a/Swiften/Elements/PubSubItem.cpp
+++ b/Swiften/Elements/PubSubItem.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,5 +11,8 @@ using namespace Swift;
PubSubItem::PubSubItem() {
}
+PubSubItem::PubSubItem(const std::string& id) : id_(id) {
+}
+
PubSubItem::~PubSubItem() {
}
diff --git a/Swiften/Elements/PubSubItem.h b/Swiften/Elements/PubSubItem.h
index d424ae4..161b733 100644
--- a/Swiften/Elements/PubSubItem.h
+++ b/Swiften/Elements/PubSubItem.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <vector>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
@@ -19,32 +18,32 @@ namespace Swift {
public:
PubSubItem();
+ PubSubItem(const std::string& id);
virtual ~PubSubItem();
const std::vector< std::shared_ptr<Payload> >& getData() const {
- return data;
+ return data_;
}
void setData(const std::vector< std::shared_ptr<Payload> >& value) {
- this->data = value ;
+ this->data_ = value ;
}
void addData(std::shared_ptr<Payload> value) {
- this->data.push_back(value);
+ this->data_.push_back(value);
}
const std::string& getID() const {
- return id;
+ return id_;
}
void setID(const std::string& value) {
- this->id = value ;
+ this->id_ = value ;
}
-
private:
- std::vector< std::shared_ptr<Payload> > data;
- std::string id;
+ std::vector< std::shared_ptr<Payload> > data_;
+ std::string id_;
};
}
diff --git a/Swiften/Elements/PubSubItems.h b/Swiften/Elements/PubSubItems.h
index 9903075..c8b7f53 100644
--- a/Swiften/Elements/PubSubItems.h
+++ b/Swiften/Elements/PubSubItems.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,7 +13,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubItem.h>
#include <Swiften/Elements/PubSubPayload.h>
@@ -62,7 +61,6 @@ namespace Swift {
this->subscriptionID = value ;
}
-
private:
std::string node;
std::vector< std::shared_ptr<PubSubItem> > items;
diff --git a/Swiften/Elements/PubSubOptions.h b/Swiften/Elements/PubSubOptions.h
index 2b312a7..80a3b03 100644
--- a/Swiften/Elements/PubSubOptions.h
+++ b/Swiften/Elements/PubSubOptions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -12,7 +12,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Form.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubPayload.h>
diff --git a/Swiften/Elements/PubSubOwnerAffiliation.h b/Swiften/Elements/PubSubOwnerAffiliation.h
index a8c1d91..77886d1 100644
--- a/Swiften/Elements/PubSubOwnerAffiliation.h
+++ b/Swiften/Elements/PubSubOwnerAffiliation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/JID/JID.h>
diff --git a/Swiften/Elements/PubSubOwnerAffiliations.h b/Swiften/Elements/PubSubOwnerAffiliations.h
index f1085bb..2434d4e 100644
--- a/Swiften/Elements/PubSubOwnerAffiliations.h
+++ b/Swiften/Elements/PubSubOwnerAffiliations.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <vector>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubOwnerAffiliation.h>
#include <Swiften/Elements/PubSubOwnerPayload.h>
diff --git a/Swiften/Elements/PubSubOwnerConfigure.h b/Swiften/Elements/PubSubOwnerConfigure.h
index 7dcf792..2b84753 100644
--- a/Swiften/Elements/PubSubOwnerConfigure.h
+++ b/Swiften/Elements/PubSubOwnerConfigure.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -12,7 +12,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Form.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubOwnerPayload.h>
diff --git a/Swiften/Elements/PubSubOwnerDefault.h b/Swiften/Elements/PubSubOwnerDefault.h
index 322f47a..a17d9f3 100644
--- a/Swiften/Elements/PubSubOwnerDefault.h
+++ b/Swiften/Elements/PubSubOwnerDefault.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Form.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubOwnerPayload.h>
diff --git a/Swiften/Elements/PubSubOwnerDelete.h b/Swiften/Elements/PubSubOwnerDelete.h
index 7cc5d79..a222e85 100644
--- a/Swiften/Elements/PubSubOwnerDelete.h
+++ b/Swiften/Elements/PubSubOwnerDelete.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubOwnerPayload.h>
#include <Swiften/Elements/PubSubOwnerRedirect.h>
diff --git a/Swiften/Elements/PubSubOwnerPubSub.h b/Swiften/Elements/PubSubOwnerPubSub.h
index f3474cf..9989cde 100644
--- a/Swiften/Elements/PubSubOwnerPubSub.h
+++ b/Swiften/Elements/PubSubOwnerPubSub.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/ContainerPayload.h>
#include <Swiften/Elements/PubSubOwnerPayload.h>
diff --git a/Swiften/Elements/PubSubOwnerPurge.h b/Swiften/Elements/PubSubOwnerPurge.h
index aca48e1..3631bd9 100644
--- a/Swiften/Elements/PubSubOwnerPurge.h
+++ b/Swiften/Elements/PubSubOwnerPurge.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubOwnerPayload.h>
diff --git a/Swiften/Elements/PubSubOwnerRedirect.h b/Swiften/Elements/PubSubOwnerRedirect.h
index c481f98..f7deca8 100644
--- a/Swiften/Elements/PubSubOwnerRedirect.h
+++ b/Swiften/Elements/PubSubOwnerRedirect.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubOwnerSubscription.h b/Swiften/Elements/PubSubOwnerSubscription.h
index 6a3fcc1..cf2edd9 100644
--- a/Swiften/Elements/PubSubOwnerSubscription.h
+++ b/Swiften/Elements/PubSubOwnerSubscription.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/JID/JID.h>
diff --git a/Swiften/Elements/PubSubOwnerSubscriptions.h b/Swiften/Elements/PubSubOwnerSubscriptions.h
index ec5aa17..d7cd8df 100644
--- a/Swiften/Elements/PubSubOwnerSubscriptions.h
+++ b/Swiften/Elements/PubSubOwnerSubscriptions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <vector>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubOwnerPayload.h>
#include <Swiften/Elements/PubSubOwnerSubscription.h>
diff --git a/Swiften/Elements/PubSubPublish.h b/Swiften/Elements/PubSubPublish.h
index dff099b..2d6d5bb 100644
--- a/Swiften/Elements/PubSubPublish.h
+++ b/Swiften/Elements/PubSubPublish.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <vector>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubItem.h>
#include <Swiften/Elements/PubSubPayload.h>
diff --git a/Swiften/Elements/PubSubSubscribe.h b/Swiften/Elements/PubSubSubscribe.h
index a4c0b68..aaaca38 100644
--- a/Swiften/Elements/PubSubSubscribe.h
+++ b/Swiften/Elements/PubSubSubscribe.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -12,7 +12,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubOptions.h>
#include <Swiften/Elements/PubSubPayload.h>
diff --git a/Swiften/Elements/PubSubSubscribeOptions.h b/Swiften/Elements/PubSubSubscribeOptions.h
index c837787..1521427 100644
--- a/Swiften/Elements/PubSubSubscribeOptions.h
+++ b/Swiften/Elements/PubSubSubscribeOptions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/PubSubSubscription.h b/Swiften/Elements/PubSubSubscription.h
index e2b527f..9645ebb 100644
--- a/Swiften/Elements/PubSubSubscription.h
+++ b/Swiften/Elements/PubSubSubscription.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -12,7 +12,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubPayload.h>
#include <Swiften/Elements/PubSubSubscribeOptions.h>
diff --git a/Swiften/Elements/PubSubSubscriptions.h b/Swiften/Elements/PubSubSubscriptions.h
index 441e6c1..f721bd5 100644
--- a/Swiften/Elements/PubSubSubscriptions.h
+++ b/Swiften/Elements/PubSubSubscriptions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,7 +13,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubPayload.h>
#include <Swiften/Elements/PubSubSubscription.h>
diff --git a/Swiften/Elements/PubSubUnsubscribe.h b/Swiften/Elements/PubSubUnsubscribe.h
index 305af9a..c0c25bd 100644
--- a/Swiften/Elements/PubSubUnsubscribe.h
+++ b/Swiften/Elements/PubSubUnsubscribe.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/PubSubPayload.h>
#include <Swiften/JID/JID.h>
diff --git a/Swiften/Elements/ReferencePayload.cpp b/Swiften/Elements/ReferencePayload.cpp
new file mode 100644
index 0000000..288f28f
--- /dev/null
+++ b/Swiften/Elements/ReferencePayload.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Elements/ReferencePayload.h>
+
+namespace Swift {
+
+ReferencePayload::ReferencePayload()
+ : type_(Type::Data) {
+}
+
+const ReferencePayload::Type& ReferencePayload::getType() const {
+ return type_;
+}
+
+void ReferencePayload::setType(const ReferencePayload::Type& type) {
+ type_ = type;
+}
+
+const boost::optional<std::string>& ReferencePayload::getUri() const {
+ return uri_;
+}
+
+void ReferencePayload::setUri(const boost::optional<std::string>& uri) {
+ uri_ = uri;
+}
+
+const boost::optional<std::string>& ReferencePayload::getBegin() const {
+ return begin_;
+}
+
+void ReferencePayload::setBegin(const boost::optional<std::string>& begin) {
+ begin_ = begin;
+}
+
+const boost::optional<std::string>& ReferencePayload::getEnd() const {
+ return end_;
+}
+
+void ReferencePayload::setEnd(const boost::optional<std::string>& end) {
+ end_ = end;
+}
+
+const boost::optional<std::string>& ReferencePayload::getAnchor() const {
+ return anchor_;
+}
+
+void ReferencePayload::setAnchor(const boost::optional<std::string>& anchor) {
+ anchor_ = anchor;
+}
+
+const std::vector<std::shared_ptr<Payload>>& ReferencePayload::getPayloads() const {
+ return payloads_;
+}
+
+void ReferencePayload::addPayload(const std::shared_ptr<Payload>& payload) {
+ payloads_.push_back(payload);
+}
+
+}
diff --git a/Swiften/Elements/ReferencePayload.h b/Swiften/Elements/ReferencePayload.h
new file mode 100644
index 0000000..b9a394e
--- /dev/null
+++ b/Swiften/Elements/ReferencePayload.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include <boost/optional.hpp>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/Payload.h>
+
+namespace Swift {
+ /**
+ * reference from XEP-0372
+ */
+ class SWIFTEN_API ReferencePayload : public Payload {
+
+ public:
+
+ typedef std::shared_ptr<ReferencePayload> ref;
+
+ enum class Type {
+ Data,
+ Mention,
+ PubSub,
+ Unknown
+ };
+
+ ReferencePayload();
+
+ const Type& getType() const;
+ const boost::optional<std::string>& getUri() const;
+ const boost::optional<std::string>& getBegin() const;
+ const boost::optional<std::string>& getEnd() const;
+ const boost::optional<std::string>& getAnchor() const;
+
+ const std::vector<std::shared_ptr<Payload>>& getPayloads() const;
+
+ void setType(const Type& type);
+ void setUri(const boost::optional<std::string>& uri);
+ void setBegin(const boost::optional<std::string>& begin);
+ void setEnd(const boost::optional<std::string>& end);
+ void setAnchor(const boost::optional<std::string>& anchor);
+
+ void addPayload(const std::shared_ptr<Payload>& payload);
+
+ private:
+
+ Type type_;
+ boost::optional<std::string> uri_;
+ boost::optional<std::string> begin_;
+ boost::optional<std::string> end_;
+ boost::optional<std::string> anchor_;
+
+ std::vector<std::shared_ptr<Payload>> payloads_;
+ };
+}
diff --git a/Swiften/Elements/S5BProxyRequest.h b/Swiften/Elements/S5BProxyRequest.h
index e3f5206..2fecae4 100644
--- a/Swiften/Elements/S5BProxyRequest.h
+++ b/Swiften/Elements/S5BProxyRequest.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -30,7 +30,7 @@ public:
public:
struct StreamHost {
std::string host;
- int port;
+ unsigned short port;
JID jid;
};
diff --git a/Swiften/Elements/SecurityLabel.h b/Swiften/Elements/SecurityLabel.h
index 748c65e..fcaa610 100644
--- a/Swiften/Elements/SecurityLabel.h
+++ b/Swiften/Elements/SecurityLabel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,12 +10,12 @@
#include <vector>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
class SWIFTEN_API SecurityLabel : public Payload {
public:
+ using ref = std::shared_ptr<SecurityLabel>;
SecurityLabel();
diff --git a/Swiften/Elements/StanzaAck.cpp b/Swiften/Elements/StanzaAck.cpp
index bd0b78d..dda97f5 100644
--- a/Swiften/Elements/StanzaAck.cpp
+++ b/Swiften/Elements/StanzaAck.cpp
@@ -1,19 +1,17 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Elements/StanzaAck.h>
-#include <boost/numeric/conversion/cast.hpp>
-
using namespace Swift;
StanzaAck::~StanzaAck() {
}
-void StanzaAck::setHandledStanzasCount(int i) {
- handledStanzasCount = boost::numeric_cast<unsigned int>(i);
+void StanzaAck::setHandledStanzasCount(unsigned int i) {
+ handledStanzasCount = i;
valid = true;
}
diff --git a/Swiften/Elements/StanzaAck.h b/Swiften/Elements/StanzaAck.h
index 68f0a2f..f664aca 100644
--- a/Swiften/Elements/StanzaAck.h
+++ b/Swiften/Elements/StanzaAck.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -24,7 +24,7 @@ namespace Swift {
return handledStanzasCount;
}
- void setHandledStanzasCount(int i);
+ void setHandledStanzasCount(unsigned int i);
bool isValid() const {
return valid;
diff --git a/Swiften/Elements/UserLocation.h b/Swiften/Elements/UserLocation.h
index 3bdaec6..b59fc5c 100644
--- a/Swiften/Elements/UserLocation.h
+++ b/Swiften/Elements/UserLocation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -12,7 +12,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/Elements/UserTune.h b/Swiften/Elements/UserTune.h
index 7def9b9..5413085 100644
--- a/Swiften/Elements/UserTune.h
+++ b/Swiften/Elements/UserTune.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp
index 186616f..f6af699 100644
--- a/Swiften/EventLoop/EventLoop.cpp
+++ b/Swiften/EventLoop/EventLoop.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,15 +10,10 @@
#include <cassert>
#include <vector>
-#include <boost/bind.hpp>
-#include <boost/lambda/bind.hpp>
-#include <boost/lambda/lambda.hpp>
#include <boost/optional.hpp>
#include <Swiften/Base/Log.h>
-namespace lambda = boost::lambda;
-
namespace Swift {
inline void invokeCallback(const Event& event) {
@@ -96,7 +91,9 @@ void EventLoop::removeEventsFromOwner(std::shared_ptr<EventOwner> owner) {
std::lock(removeLock, eventsLock);
- events_.remove_if(lambda::bind(&Event::owner, lambda::_1) == owner);
+ events_.remove_if([&](const Event& event) {
+ return event.owner == owner;
+ });
}
}
diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp
index cd9fa4a..3fdff27 100644
--- a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp
+++ b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -19,13 +19,19 @@ std::shared_ptr<ByteArray> ByteArrayReadBytestream::read(size_t size) {
if (position + readSize > data.size()) {
readSize = data.size() - position;
}
- std::shared_ptr<ByteArray> result = std::make_shared<ByteArray>(
- data.begin() + boost::numeric_cast<long long>(position),
- data.begin() + boost::numeric_cast<long long>(position) + boost::numeric_cast<long long>(readSize));
-
- onRead(*result);
- position += readSize;
- return result;
+ try {
+ std::shared_ptr<ByteArray> result = std::make_shared<ByteArray>(
+ data.begin() + boost::numeric_cast<long long>(position),
+ data.begin() + boost::numeric_cast<long long>(position) + boost::numeric_cast<long long>(readSize));
+ onRead(*result);
+ position += readSize;
+ return result;
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ // If we cannot cast to long long, we probably ran out of memory long ago
+ assert(false);
+ return {};
+ }
}
void ByteArrayReadBytestream::addData(const std::vector<unsigned char>& moreData) {
diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.h b/Swiften/FileTransfer/DefaultFileTransferTransporter.h
index 339232f..1bfe799 100644
--- a/Swiften/FileTransfer/DefaultFileTransferTransporter.h
+++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/ErrorPayload.h>
#include <Swiften/FileTransfer/FileTransferTransporter.h>
@@ -48,35 +47,35 @@ namespace Swift {
CryptoProvider*,
IQRouter*,
const FileTransferOptions&);
- virtual ~DefaultFileTransferTransporter();
+ virtual ~DefaultFileTransferTransporter() override;
virtual void initialize();
virtual void initialize(const std::string& s5bSessionID);
- virtual void startGeneratingLocalCandidates() SWIFTEN_OVERRIDE;
- virtual void stopGeneratingLocalCandidates() SWIFTEN_OVERRIDE;
+ virtual void startGeneratingLocalCandidates() override;
+ virtual void stopGeneratingLocalCandidates() override;
virtual void addRemoteCandidates(
- const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string&) SWIFTEN_OVERRIDE;
- virtual void startTryingRemoteCandidates() SWIFTEN_OVERRIDE;
- virtual void stopTryingRemoteCandidates() SWIFTEN_OVERRIDE;
+ const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string&) override;
+ virtual void startTryingRemoteCandidates() override;
+ virtual void stopTryingRemoteCandidates() override;
- virtual void startActivatingProxy(const JID& jid) SWIFTEN_OVERRIDE;
- virtual void stopActivatingProxy() SWIFTEN_OVERRIDE;
+ virtual void startActivatingProxy(const JID& jid) override;
+ virtual void stopActivatingProxy() override;
virtual std::shared_ptr<TransportSession> createIBBSendSession(
- const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE;
+ const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) override;
virtual std::shared_ptr<TransportSession> createIBBReceiveSession(
- const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE;
+ const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) override;
virtual std::shared_ptr<TransportSession> createRemoteCandidateSession(
- std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE;
+ std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override;
virtual std::shared_ptr<TransportSession> createRemoteCandidateSession(
- std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE;
+ std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override;
virtual std::shared_ptr<TransportSession> createLocalCandidateSession(
- std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE;
+ std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override;
virtual std::shared_ptr<TransportSession> createLocalCandidateSession(
- std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE;
+ std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override;
private:
void handleLocalCandidatesGenerated(const std::vector<JingleS5BTransportPayload::Candidate>&);
diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h b/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h
index 3cc3455..fe4f6ea 100644
--- a/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h
+++ b/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/FileTransfer/FileTransferTransporterFactory.h>
namespace Swift {
@@ -31,12 +30,12 @@ namespace Swift {
TimerFactory*,
CryptoProvider*,
IQRouter*);
- virtual ~DefaultFileTransferTransporterFactory();
+ virtual ~DefaultFileTransferTransporterFactory() override;
virtual FileTransferTransporter* createInitiatorTransporter(
- const JID& initiator, const JID& responder, const FileTransferOptions&) SWIFTEN_OVERRIDE;
+ const JID& initiator, const JID& responder, const FileTransferOptions&) override;
virtual FileTransferTransporter* createResponderTransporter(
- const JID& initiator, const JID& responder, const std::string& s5bSessionID, const FileTransferOptions&) SWIFTEN_OVERRIDE;
+ const JID& initiator, const JID& responder, const std::string& s5bSessionID, const FileTransferOptions&) override;
private:
SOCKS5BytestreamRegistry* s5bRegistry;
diff --git a/Swiften/FileTransfer/FailingTransportSession.h b/Swiften/FileTransfer/FailingTransportSession.h
index 6e0e16e..489786b 100644
--- a/Swiften/FileTransfer/FailingTransportSession.h
+++ b/Swiften/FileTransfer/FailingTransportSession.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,10 +13,10 @@ namespace Swift {
class SWIFTEN_API FailingTransportSession : public TransportSession {
public:
- virtual ~FailingTransportSession();
+ virtual ~FailingTransportSession() override;
- virtual void start() SWIFTEN_OVERRIDE;
- virtual void stop() SWIFTEN_OVERRIDE;
+ virtual void start() override;
+ virtual void stop() override;
};
}
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.h b/Swiften/FileTransfer/FileTransferManagerImpl.h
index 026c8b7..d3d55f0 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.h
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -22,7 +22,6 @@
#include <Swiften/Base/API.h>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/S5BProxyRequest.h>
#include <Swiften/FileTransfer/FileTransferManager.h>
#include <Swiften/FileTransfer/FileTransferOptions.h>
@@ -65,14 +64,14 @@ namespace Swift {
NetworkEnvironment* networkEnvironment,
NATTraverser* natTraverser,
CryptoProvider* crypto);
- virtual ~FileTransferManagerImpl();
+ virtual ~FileTransferManagerImpl() override;
OutgoingFileTransfer::ref createOutgoingFileTransfer(
const JID& to,
const boost::filesystem::path& filepath,
const std::string& description,
std::shared_ptr<ReadBytestream> bytestream,
- const FileTransferOptions&) SWIFTEN_OVERRIDE;
+ const FileTransferOptions&) override;
OutgoingFileTransfer::ref createOutgoingFileTransfer(
const JID& to,
const std::string& filename,
@@ -80,7 +79,7 @@ namespace Swift {
const boost::uintmax_t sizeInBytes,
const boost::posix_time::ptime& lastModified,
std::shared_ptr<ReadBytestream> bytestream,
- const FileTransferOptions&) SWIFTEN_OVERRIDE;
+ const FileTransferOptions&) override;
void start();
void stop();
diff --git a/Swiften/FileTransfer/FileTransferOptions.h b/Swiften/FileTransfer/FileTransferOptions.h
index 2bc4ee1..aa9aa97 100644
--- a/Swiften/FileTransfer/FileTransferOptions.h
+++ b/Swiften/FileTransfer/FileTransferOptions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
namespace Swift {
class SWIFTEN_API FileTransferOptions {
diff --git a/Swiften/FileTransfer/IBBReceiveTransportSession.h b/Swiften/FileTransfer/IBBReceiveTransportSession.h
index 8b304c3..5b1fd8d 100644
--- a/Swiften/FileTransfer/IBBReceiveTransportSession.h
+++ b/Swiften/FileTransfer/IBBReceiveTransportSession.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,10 +17,10 @@ namespace Swift {
class SWIFTEN_API IBBReceiveTransportSession : public TransportSession {
public:
IBBReceiveTransportSession(std::shared_ptr<IBBReceiveSession> session);
- virtual ~IBBReceiveTransportSession();
+ virtual ~IBBReceiveTransportSession() override;
- virtual void start() SWIFTEN_OVERRIDE;
- virtual void stop() SWIFTEN_OVERRIDE;
+ virtual void start() override;
+ virtual void stop() override;
private:
std::shared_ptr<IBBReceiveSession> session;
diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp
index e51c91c..258412b 100644
--- a/Swiften/FileTransfer/IBBSendSession.cpp
+++ b/Swiften/FileTransfer/IBBSendSession.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -40,7 +40,7 @@ IBBSendSession::~IBBSendSession() {
void IBBSendSession::start() {
IBBRequest::ref request = IBBRequest::create(
- from, to, IBB::createIBBOpen(id, boost::numeric_cast<int>(blockSize)), router);
+ from, to, IBB::createIBBOpen(id, blockSize), router);
request->onResponse.connect(boost::bind(&IBBSendSession::handleIBBResponse, this, _1, _2));
active = true;
request->send();
diff --git a/Swiften/FileTransfer/IBBSendTransportSession.h b/Swiften/FileTransfer/IBBSendTransportSession.h
index d1e786b..7deaaac 100644
--- a/Swiften/FileTransfer/IBBSendTransportSession.h
+++ b/Swiften/FileTransfer/IBBSendTransportSession.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,10 +17,10 @@ namespace Swift {
class SWIFTEN_API IBBSendTransportSession : public TransportSession {
public:
IBBSendTransportSession(std::shared_ptr<IBBSendSession> session);
- virtual ~IBBSendTransportSession();
+ virtual ~IBBSendTransportSession() override;
- virtual void start() SWIFTEN_OVERRIDE;
- virtual void stop() SWIFTEN_OVERRIDE;
+ virtual void start() override;
+ virtual void stop() override;
private:
std::shared_ptr<IBBSendSession> session;
diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.h b/Swiften/FileTransfer/IncomingJingleFileTransfer.h
index 7ddf700..f42004d 100644
--- a/Swiften/FileTransfer/IncomingJingleFileTransfer.h
+++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.h
@@ -13,7 +13,6 @@
#include <Swiften/Base/API.h>
#include <Swiften/Base/ByteArray.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/JingleS5BTransportPayload.h>
#include <Swiften/FileTransfer/FileTransferOptions.h>
#include <Swiften/FileTransfer/IncomingFileTransfer.h>
@@ -49,10 +48,10 @@ namespace Swift {
FileTransferTransporterFactory*,
TimerFactory*,
CryptoProvider*);
- virtual ~IncomingJingleFileTransfer();
+ virtual ~IncomingJingleFileTransfer() override;
- virtual void accept(std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) SWIFTEN_OVERRIDE;
- virtual void cancel() SWIFTEN_OVERRIDE;
+ virtual void accept(std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) override;
+ virtual void cancel() override;
private:
enum State {
@@ -68,44 +67,44 @@ namespace Swift {
};
virtual void handleSessionTerminateReceived(
- boost::optional<JinglePayload::Reason> reason) SWIFTEN_OVERRIDE;
- virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE;
+ boost::optional<JinglePayload::Reason> reason) override;
+ virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) override;
virtual void handleTransportReplaceReceived(
- const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
+ const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override;
virtual void handleLocalTransportCandidatesGenerated(
const std::string& s5bSessionID,
const std::vector<JingleS5BTransportPayload::Candidate>&,
- const std::string& dstAddr) SWIFTEN_OVERRIDE;
+ const std::string& dstAddr) override;
void handleWriteStreamDataReceived(const std::vector<unsigned char>& data);
void stopActiveTransport();
void checkCandidateSelected();
- virtual JingleContentID getContentID() const SWIFTEN_OVERRIDE;
+ virtual JingleContentID getContentID() const override;
void checkIfAllDataReceived();
bool verifyData();
void handleWaitOnHashTimerTicked();
void handleTransferFinished(boost::optional<FileTransferError>);
private:
- virtual void startTransferViaRemoteCandidate() SWIFTEN_OVERRIDE;
- virtual void startTransferViaLocalCandidate() SWIFTEN_OVERRIDE;
+ virtual void startTransferViaRemoteCandidate() override;
+ virtual void startTransferViaLocalCandidate() override;
void checkHashAndTerminate();
void stopAll();
void setState(State state);
void setFinishedState(FileTransfer::State::Type, const boost::optional<FileTransferError>& error);
- const JID& getSender() const SWIFTEN_OVERRIDE;
- const JID& getRecipient() const SWIFTEN_OVERRIDE;
+ const JID& getSender() const override;
+ const JID& getRecipient() const override;
static FileTransfer::State::Type getExternalState(State state);
- virtual bool hasPriorityOnCandidateTie() const SWIFTEN_OVERRIDE;
- virtual void fallback() SWIFTEN_OVERRIDE;
- virtual void startTransferring(std::shared_ptr<TransportSession>) SWIFTEN_OVERRIDE;
- virtual bool isWaitingForPeerProxyActivate() const SWIFTEN_OVERRIDE;
- virtual bool isWaitingForLocalProxyActivate() const SWIFTEN_OVERRIDE;
- virtual bool isTryingCandidates() const SWIFTEN_OVERRIDE;
- virtual std::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE;
- virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE;
- virtual void terminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE;
+ virtual bool hasPriorityOnCandidateTie() const override;
+ virtual void fallback() override;
+ virtual void startTransferring(std::shared_ptr<TransportSession>) override;
+ virtual bool isWaitingForPeerProxyActivate() const override;
+ virtual bool isWaitingForLocalProxyActivate() const override;
+ virtual bool isTryingCandidates() const override;
+ virtual std::shared_ptr<TransportSession> createLocalCandidateSession() override;
+ virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() override;
+ virtual void terminate(JinglePayload::Reason::Type reason) override;
private:
diff --git a/Swiften/FileTransfer/JingleFileTransfer.cpp b/Swiften/FileTransfer/JingleFileTransfer.cpp
index 62c3a53..cc1cd1c 100644
--- a/Swiften/FileTransfer/JingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/JingleFileTransfer.cpp
@@ -1,13 +1,11 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/FileTransfer/JingleFileTransfer.h>
-#include <boost/typeof/typeof.hpp>
-
#include <Swiften/Base/Log.h>
#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/FileTransfer/FileTransferTransporter.h>
@@ -29,7 +27,6 @@ JingleFileTransfer::JingleFileTransfer(
theirCandidateSelectFinished(false) {
session->addListener(this);
-
}
JingleFileTransfer::~JingleFileTransfer() {
@@ -176,7 +173,7 @@ void JingleFileTransfer::handleTransportInfoReceived(
theirCandidateSelectFinished = true;
if (!s5bPayload->hasCandidateError()) {
- BOOST_AUTO(theirCandidate, localCandidates.find(s5bPayload->getCandidateUsed()));
+ auto theirCandidate = localCandidates.find(s5bPayload->getCandidateUsed());
if (theirCandidate == localCandidates.end()) {
SWIFT_LOG(warning) << "Got invalid candidate" << std::endl;
terminate(JinglePayload::Reason::GeneralError);
@@ -231,4 +228,3 @@ void JingleFileTransfer::removeTransporter() {
transporter = nullptr;
}
}
-
diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h
index 2159063..8c53d16 100644
--- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h
+++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,7 +17,6 @@
#include <boost/signals2.hpp>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/JingleS5BTransportPayload.h>
#include <Swiften/FileTransfer/FileTransferOptions.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h>
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
index 9fd1d76..6db4e40 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
@@ -17,7 +17,6 @@
#include <boost/optional/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/JingleFileTransferFileInfo.h>
#include <Swiften/FileTransfer/FileTransferOptions.h>
#include <Swiften/FileTransfer/JingleFileTransfer.h>
@@ -46,10 +45,10 @@ namespace Swift {
const JingleFileTransferFileInfo&,
const FileTransferOptions&,
CryptoProvider*);
- virtual ~OutgoingJingleFileTransfer();
+ virtual ~OutgoingJingleFileTransfer() override;
- virtual void start() SWIFTEN_OVERRIDE;
- virtual void cancel() SWIFTEN_OVERRIDE;
+ virtual void start() override;
+ virtual void cancel() override;
private:
enum State {
@@ -66,34 +65,34 @@ namespace Swift {
Finished
};
- virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) SWIFTEN_OVERRIDE;
- virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void startTransferViaRemoteCandidate() SWIFTEN_OVERRIDE;
- virtual void startTransferViaLocalCandidate() SWIFTEN_OVERRIDE;
+ virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) override;
+ virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void startTransferViaRemoteCandidate() override;
+ virtual void startTransferViaLocalCandidate() override;
void startTransferringIfCandidateAcknowledged();
- virtual void handleLocalTransportCandidatesGenerated(const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string& dstAddr) SWIFTEN_OVERRIDE;
- virtual void handleTransportInfoAcknowledged(const std::string& id) SWIFTEN_OVERRIDE;
+ virtual void handleLocalTransportCandidatesGenerated(const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string& dstAddr) override;
+ virtual void handleTransportInfoAcknowledged(const std::string& id) override;
- virtual JingleContentID getContentID() const SWIFTEN_OVERRIDE;
+ virtual JingleContentID getContentID() const override;
- virtual void terminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE;
+ virtual void terminate(JinglePayload::Reason::Type reason) override;
- virtual void fallback() SWIFTEN_OVERRIDE;
+ virtual void fallback() override;
void handleTransferFinished(boost::optional<FileTransferError>);
void sendSessionInfoHash();
- virtual void startTransferring(std::shared_ptr<TransportSession>) SWIFTEN_OVERRIDE;
+ virtual void startTransferring(std::shared_ptr<TransportSession>) override;
- virtual bool hasPriorityOnCandidateTie() const SWIFTEN_OVERRIDE;
- virtual bool isWaitingForPeerProxyActivate() const SWIFTEN_OVERRIDE;
- virtual bool isWaitingForLocalProxyActivate() const SWIFTEN_OVERRIDE;
- virtual bool isTryingCandidates() const SWIFTEN_OVERRIDE;
- virtual std::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE;
- virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE;
+ virtual bool hasPriorityOnCandidateTie() const override;
+ virtual bool isWaitingForPeerProxyActivate() const override;
+ virtual bool isWaitingForLocalProxyActivate() const override;
+ virtual bool isTryingCandidates() const override;
+ virtual std::shared_ptr<TransportSession> createLocalCandidateSession() override;
+ virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() override;
void handleWaitForRemoteTerminationTimeout();
diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h
index c4257f6..c205516 100644
--- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h
+++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -18,7 +18,6 @@
#include <queue>
#include <vector>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/JingleS5BTransportPayload.h>
#include <Swiften/FileTransfer/FileTransferOptions.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
diff --git a/Swiften/FileTransfer/S5BTransportSession.h b/Swiften/FileTransfer/S5BTransportSession.h
index 3e064fa..fd92f2e 100644
--- a/Swiften/FileTransfer/S5BTransportSession.h
+++ b/Swiften/FileTransfer/S5BTransportSession.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -35,10 +35,10 @@ class SWIFTEN_API S5BTransportSession : public TransportSession {
initialize();
}
- virtual ~S5BTransportSession() {
+ virtual ~S5BTransportSession() override {
}
- virtual void start() SWIFTEN_OVERRIDE {
+ virtual void start() override {
if (readStream) {
session->startSending(readStream);
}
@@ -47,7 +47,7 @@ class SWIFTEN_API S5BTransportSession : public TransportSession {
}
}
- virtual void stop() SWIFTEN_OVERRIDE {
+ virtual void stop() override {
session->stop();
}
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
index f749735..a6b75da 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -114,7 +114,7 @@ void SOCKS5BytestreamServerManager::initialize() {
// Find a port to listen on
assert(!connectionServer);
- int port;
+ unsigned short port;
for (port = LISTEN_PORTS_BEGIN; port < LISTEN_PORTS_END; ++port) {
SWIFT_LOG(debug) << "Trying to start server on port " << port << std::endl;
connectionServer = connectionServerFactory->createConnectionServer(HostAddress::fromString("::").get(), port);
@@ -164,7 +164,7 @@ void SOCKS5BytestreamServerManager::setupPortForwarding() {
}
// Forward ports
- int port = server->getAddressPort().getPort();
+ auto port = server->getAddressPort().getPort();
assert(!forwardPortRequest);
portMapping = boost::optional<NATPortMapping>();
if ((forwardPortRequest = natTraverser->createForwardPortRequest(port, port))) {
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
index 3c06513..74578cc 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -78,7 +78,7 @@ namespace Swift {
enum { Start, Initializing, Initialized } state;
SOCKS5BytestreamServer* server;
std::shared_ptr<ConnectionServer> connectionServer;
- int connectionServerPort = -1;
+ unsigned short connectionServerPort = 0;
std::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest;
std::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest;
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
index bc4e8e4..0fd40bf 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -138,7 +138,14 @@ void SOCKS5BytestreamServerSession::process() {
SafeByteArray result = createSafeByteArray("\x05", 1);
result.push_back(hasBytestream ? 0x0 : 0x4);
append(result, createByteArray("\x00\x03", 2));
- result.push_back(boost::numeric_cast<unsigned char>(requestID.size()));
+ try {
+ result.push_back(boost::numeric_cast<unsigned char>(requestID.size()));
+ }
+ catch (const boost::numeric::bad_numeric_cast& e) {
+ SWIFT_LOG(warning) << "SOCKS5 request ID is too long (" << requestID.size() << "): " << e.what() << std::endl;
+ finish();
+ return;
+ }
append(result, concat(requestID, createByteArray("\x00\x00", 2)));
if (!hasBytestream) {
SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!" << std::endl;
diff --git a/Swiften/FileTransfer/TransportSession.h b/Swiften/FileTransfer/TransportSession.h
index dc6e59a..2d56517 100644
--- a/Swiften/FileTransfer/TransportSession.h
+++ b/Swiften/FileTransfer/TransportSession.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <boost/signals2.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/FileTransfer/FileTransferError.h>
namespace Swift {
diff --git a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
index 03e2476..6119658 100644
--- a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
+++ b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2016 Isode Limited.
+ * Copyright (c) 2016-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,7 +17,6 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem/path.hpp>
-#include <Swiften/Base/Override.h>
#include <Swiften/FileTransfer/FileTransferManager.h>
namespace Swift {
@@ -34,7 +33,7 @@ namespace Swift {
const boost::filesystem::path&,
const std::string&,
std::shared_ptr<ReadBytestream>,
- const FileTransferOptions&) SWIFTEN_OVERRIDE {
+ const FileTransferOptions&) override {
return OutgoingFileTransfer::ref();
}
@@ -45,7 +44,7 @@ namespace Swift {
const boost::uintmax_t,
const boost::posix_time::ptime&,
std::shared_ptr<ReadBytestream>,
- const FileTransferOptions&) SWIFTEN_OVERRIDE {
+ const FileTransferOptions&) override {
return OutgoingFileTransfer::ref();
}
diff --git a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
index f9057f8..2399cbe 100644
--- a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -58,7 +58,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<IBB>(0, JID("foo@bar.com/baz"), IQ::Set));
IBB::ref ibb = stanzaChannel->sentStanzas[0]->getPayload<IBB>();
CPPUNIT_ASSERT_EQUAL(IBB::Open, ibb->getAction());
- CPPUNIT_ASSERT_EQUAL(1234, ibb->getBlockSize());
+ CPPUNIT_ASSERT_EQUAL(1234u, ibb->getBlockSize());
CPPUNIT_ASSERT_EQUAL(std::string("myid"), ibb->getStreamID());
}
diff --git a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
index 72b933d..9793b87 100644
--- a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -18,7 +18,6 @@
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Base/Log.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Client/DummyStanzaChannel.h>
#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/Crypto/PlatformCryptoProvider.h>
diff --git a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
index 3f4d20f..a0fe057 100644
--- a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -21,7 +21,6 @@
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Client/DummyStanzaChannel.h>
#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/Crypto/PlatformCryptoProvider.h>
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index 290dda5..80667b6 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -59,8 +59,8 @@ public:
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
destination = "092a44d859d19c9eed676b551ee80025903351c2";
randomGen.seed(static_cast<unsigned int>(time(nullptr)));
- eventLoop = std::unique_ptr<DummyEventLoop>(new DummyEventLoop());
- timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory());
+ eventLoop = std::make_unique<DummyEventLoop>();
+ timerFactory = std::make_unique<DummyTimerFactory>();
connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop.get());
//connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1));
//stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")));
diff --git a/Swiften/IDN/ICUConverter.cpp b/Swiften/IDN/ICUConverter.cpp
index d6b0827..37ce708 100644
--- a/Swiften/IDN/ICUConverter.cpp
+++ b/Swiften/IDN/ICUConverter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -19,6 +19,8 @@ using namespace Swift;
using boost::numeric_cast;
namespace {
+ static constexpr auto maxStringPrepLength = 1023;
+
typedef std::vector<UChar, SafeAllocator<UChar> > ICUString;
const char* toConstCharArray(const std::string& input) {
@@ -93,15 +95,8 @@ namespace {
ICUString icuInput = convertToICUString(s);
ICUString icuResult;
UParseError parseError;
- icuResult.resize(icuInput.size());
+ icuResult.resize(maxStringPrepLength);
int32_t icuResultLength = usprep_prepare(icuProfile.get(), vecptr(icuInput), numeric_cast<int32_t>(icuInput.size()), vecptr(icuResult), numeric_cast<int32_t>(icuResult.size()), USPREP_ALLOW_UNASSIGNED, &parseError, &status);
- icuResult.resize(numeric_cast<size_t>(icuResultLength));
- if (status == U_BUFFER_OVERFLOW_ERROR) {
- status = U_ZERO_ERROR;
- icuResult.resize(numeric_cast<size_t>(icuResultLength));
- icuResultLength = usprep_prepare(icuProfile.get(), vecptr(icuInput), numeric_cast<int32_t>(icuInput.size()), vecptr(icuResult), numeric_cast<int32_t>(icuResult.size()), USPREP_ALLOW_UNASSIGNED, &parseError, &status);
- icuResult.resize(numeric_cast<size_t>(icuResultLength));
- }
if (U_FAILURE(status)) {
return std::vector<char, SafeAllocator<char> >();
}
diff --git a/Swiften/IDN/ICUConverter.h b/Swiften/IDN/ICUConverter.h
index 0a0b0d3..b0f5d85 100644
--- a/Swiften/IDN/ICUConverter.h
+++ b/Swiften/IDN/ICUConverter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,15 +9,14 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/IDN/IDNConverter.h>
namespace Swift {
class SWIFTEN_API ICUConverter : public IDNConverter {
public:
- virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) SWIFTEN_OVERRIDE;
- virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) SWIFTEN_OVERRIDE;
+ virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) override;
+ virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) override;
- virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) SWIFTEN_OVERRIDE;
+ virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) override;
};
}
diff --git a/Swiften/IDN/LibIDNConverter.cpp b/Swiften/IDN/LibIDNConverter.cpp
index 0c01352..e2a87be 100644
--- a/Swiften/IDN/LibIDNConverter.cpp
+++ b/Swiften/IDN/LibIDNConverter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -24,7 +24,7 @@ extern "C" {
using namespace Swift;
namespace {
- static const int MAX_STRINGPREP_SIZE = 1024;
+ static const size_t MAX_STRINGPREP_SIZE = 1024;
const Stringprep_profile* getLibIDNProfile(IDNConverter::StringPrepProfile profile) {
switch(profile) {
@@ -44,7 +44,8 @@ namespace {
return ContainerType();
}
- input.resize(MAX_STRINGPREP_SIZE);
+ // Ensure we have enough space for stringprepping, and that input is always NUL terminated
+ input.resize(std::max(MAX_STRINGPREP_SIZE, input.size() + 1));
if (stringprep(&input[0], MAX_STRINGPREP_SIZE, static_cast<Stringprep_profile_flags>(0), getLibIDNProfile(profile)) == 0) {
return input;
}
@@ -77,6 +78,9 @@ boost::optional<std::string> LibIDNConverter::getIDNAEncoded(const std::string&
if (idna_to_ascii_8z(domain.c_str(), &output, IDNA_USE_STD3_ASCII_RULES) == IDNA_SUCCESS) {
std::string result(output);
free(output);
+ if (result.size() > 255) {
+ return boost::optional<std::string>();
+ }
return result;
}
else {
diff --git a/Swiften/IDN/LibIDNConverter.h b/Swiften/IDN/LibIDNConverter.h
index 3f1d1f7..5553ab3 100644
--- a/Swiften/IDN/LibIDNConverter.h
+++ b/Swiften/IDN/LibIDNConverter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,16 +9,15 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/IDN/IDNConverter.h>
namespace Swift {
class SWIFTEN_API LibIDNConverter : public IDNConverter {
public:
- virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) SWIFTEN_OVERRIDE;
- virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) SWIFTEN_OVERRIDE;
+ virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) override;
+ virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) override;
- virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) SWIFTEN_OVERRIDE;
+ virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) override;
};
}
diff --git a/Swiften/IDN/PlatformIDNConverter.cpp b/Swiften/IDN/PlatformIDNConverter.cpp
index c85d3b6..c6104fb 100644
--- a/Swiften/IDN/PlatformIDNConverter.cpp
+++ b/Swiften/IDN/PlatformIDNConverter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -21,9 +21,10 @@ IDNConverter* PlatformIDNConverter::create() {
#else
#if defined(NEED_IDN)
#error "No IDN implementation"
-#endif
+#else
return nullptr;
#endif
+#endif
}
}
diff --git a/Swiften/IDN/SConscript b/Swiften/IDN/SConscript
index 28596f7..0afad0e 100644
--- a/Swiften/IDN/SConscript
+++ b/Swiften/IDN/SConscript
@@ -23,6 +23,7 @@ swiften_env.Append(SWIFTEN_OBJECTS = [objects])
if env["TEST"] :
test_env = myenv.Clone()
test_env.UseFlags(swiften_env["CPPUNIT_FLAGS"])
+ test_env.UseFlags(myenv.get("GOOGLETEST_FLAGS", ""))
env.Append(UNITTEST_OBJECTS = test_env.SwiftenObject([
File("UnitTest/IDNConverterTest.cpp"),
File("UnitTest/UTF8ValidatorTest.cpp")
diff --git a/Swiften/IDN/UnitTest/IDNConverterTest.cpp b/Swiften/IDN/UnitTest/IDNConverterTest.cpp
index 508a28c..77a1ece 100644
--- a/Swiften/IDN/UnitTest/IDNConverterTest.cpp
+++ b/Swiften/IDN/UnitTest/IDNConverterTest.cpp
@@ -1,64 +1,98 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <memory>
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <gtest/gtest.h>
#include <Swiften/IDN/IDNConverter.h>
#include <Swiften/IDN/PlatformIDNConverter.h>
using namespace Swift;
-class IDNConverterTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(IDNConverterTest);
- CPPUNIT_TEST(testStringPrep);
- CPPUNIT_TEST(testStringPrep_Empty);
- CPPUNIT_TEST(testGetEncoded);
- CPPUNIT_TEST(testGetEncoded_International);
- CPPUNIT_TEST(testGetEncoded_Invalid);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- testling = std::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
- }
-
- void testStringPrep() {
- std::string result = testling->getStringPrepared("tron\xc3\x87on", IDNConverter::NamePrep);
-
- CPPUNIT_ASSERT_EQUAL(std::string("tron\xc3\xa7on"), result);
- }
-
- void testStringPrep_Empty() {
- CPPUNIT_ASSERT_EQUAL(std::string(""), testling->getStringPrepared("", IDNConverter::NamePrep));
- CPPUNIT_ASSERT_EQUAL(std::string(""), testling->getStringPrepared("", IDNConverter::XMPPNodePrep));
- CPPUNIT_ASSERT_EQUAL(std::string(""), testling->getStringPrepared("", IDNConverter::XMPPResourcePrep));
- }
-
- void testGetEncoded() {
- boost::optional<std::string> result = testling->getIDNAEncoded("www.swift.im");
- CPPUNIT_ASSERT(!!result);
- CPPUNIT_ASSERT_EQUAL(std::string("www.swift.im"), *result);
- }
-
- void testGetEncoded_International() {
- boost::optional<std::string> result = testling->getIDNAEncoded("www.tron\xc3\x87on.com");
- CPPUNIT_ASSERT(!!result);
- CPPUNIT_ASSERT_EQUAL(std::string("www.xn--tronon-zua.com"), *result);
- }
-
- void testGetEncoded_Invalid() {
- boost::optional<std::string> result = testling->getIDNAEncoded("www.foo,bar.com");
- CPPUNIT_ASSERT(!result);
- }
-
- private:
- std::shared_ptr<IDNConverter> testling;
+class IDNConverterTest : public ::testing::Test {
+
+protected:
+ virtual void SetUp() {
+ testling_ = std::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
+ }
+
+ std::shared_ptr<IDNConverter> testling_;
};
-CPPUNIT_TEST_SUITE_REGISTRATION(IDNConverterTest);
+TEST_F(IDNConverterTest, testStringPrep) {
+ std::string result = testling_->getStringPrepared("tron\xc3\x87on", IDNConverter::NamePrep);
+
+ ASSERT_EQ(std::string("tron\xc3\xa7on"), result);
+}
+
+TEST_F(IDNConverterTest, testStringPrep_Empty) {
+ ASSERT_EQ(std::string(""), testling_->getStringPrepared("", IDNConverter::NamePrep));
+ ASSERT_EQ(std::string(""), testling_->getStringPrepared("", IDNConverter::XMPPNodePrep));
+ ASSERT_EQ(std::string(""), testling_->getStringPrepared("", IDNConverter::XMPPResourcePrep));
+}
+
+TEST_F(IDNConverterTest, testStringPrep_MaximumOutputSize) {
+ const std::string input(1023, 'x');
+ ASSERT_EQ(input, testling_->getStringPrepared(input, IDNConverter::NamePrep));
+ ASSERT_EQ(input, testling_->getStringPrepared(input, IDNConverter::XMPPNodePrep));
+ ASSERT_EQ(input, testling_->getStringPrepared(input, IDNConverter::XMPPResourcePrep));
+}
+
+TEST_F(IDNConverterTest, testStringPrep_TooLong) {
+ const std::string input(1024, 'x');
+ ASSERT_THROW(testling_->getStringPrepared(input, IDNConverter::NamePrep), std::exception);
+ ASSERT_THROW(testling_->getStringPrepared(input, IDNConverter::XMPPNodePrep), std::exception);
+ ASSERT_THROW(testling_->getStringPrepared(input, IDNConverter::XMPPResourcePrep), std::exception);
+}
+
+TEST_F(IDNConverterTest, testStringPrep_ShrinkingBelow1023) {
+ std::string input;
+ std::string expected;
+ // The four byte \u03b1\u0313 UTF-8 string will shrink to the three byte \u1f00
+ for (auto i = 0; i < 300; ++i) {
+ input +="\xce\xb1\xcc\x93"; // UTF-8 repesentation of U+03B1 U+0313
+ expected += "\xe1\xbc\x80"; // UTF-8 representation of U+1F00
+ }
+ ASSERT_EQ(expected, testling_->getStringPrepared(input, IDNConverter::NamePrep));
+ ASSERT_EQ(expected, testling_->getStringPrepared(input, IDNConverter::XMPPNodePrep));
+ ASSERT_EQ(expected, testling_->getStringPrepared(input, IDNConverter::XMPPResourcePrep));
+}
+
+TEST_F(IDNConverterTest, testGetEncoded) {
+ boost::optional<std::string> result = testling_->getIDNAEncoded("www.swift.im");
+ ASSERT_TRUE(!!result);
+ ASSERT_EQ(std::string("www.swift.im"), *result);
+}
+
+TEST_F(IDNConverterTest, testGetEncoded_International) {
+ boost::optional<std::string> result = testling_->getIDNAEncoded("www.tron\xc3\x87on.com");
+ ASSERT_TRUE(result);
+ ASSERT_EQ(std::string("www.xn--tronon-zua.com"), *result);
+}
+
+TEST_F(IDNConverterTest, testGetEncoded_Invalid) {
+ boost::optional<std::string> result = testling_->getIDNAEncoded("www.foo,bar.com");
+ ASSERT_FALSE(result);
+}
+
+TEST_F(IDNConverterTest, testRFC1035LengthRestrictions) {
+ // label size check, 63 octets or less
+ ASSERT_TRUE(testling_->getIDNAEncoded(std::string(63, 'a') + ".example"));
+ ASSERT_TRUE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(63, 'a') + ".example"));
+ ASSERT_FALSE(testling_->getIDNAEncoded(std::string(64, 'a') + "." + std::string(63, 'a') + ".example"));
+ ASSERT_FALSE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(64, 'a') + ".example"));
+ ASSERT_FALSE(testling_->getIDNAEncoded(std::string(0, 'a') + "." + std::string(63, 'a') + ".example"));
+ ASSERT_FALSE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(0, 'a') + ".example"));
+
+ // domain name 255 octets or less
+ ASSERT_TRUE(testling_->getIDNAEncoded(std::string(63, 'a') + ".example"));
+ ASSERT_TRUE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(63, 'a') + ".example"));
+ ASSERT_TRUE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(63, 'a') + "." + std::string(63, 'a') + ".example"));
+ ASSERT_TRUE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(63, 'a') + "." + std::string(63, 'a') + "." + std::string(55, 'a') + ".example"));
+ ASSERT_FALSE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(63, 'a') + "." + std::string(63, 'a') + "." + std::string(56, 'a') + ".example"));
+ ASSERT_FALSE(testling_->getIDNAEncoded(std::string(63, 'a') + "." + std::string(56, 'a') + "." + std::string(63, 'a') + "." + std::string(63, 'a') + ".example"));
+}
diff --git a/Swiften/JID/JID.cpp b/Swiften/JID/JID.cpp
index c82674d..fff88e9 100644
--- a/Swiften/JID/JID.cpp
+++ b/Swiften/JID/JID.cpp
@@ -1,20 +1,13 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#define SWIFTEN_CACHE_JID_PREP
-
#include <sstream>
#include <string>
#include <vector>
-#ifdef SWIFTEN_CACHE_JID_PREP
-#include <mutex>
-#include <unordered_map>
-#endif
-
#include <boost/optional.hpp>
#include <Swiften/Base/String.h>
@@ -28,15 +21,6 @@
using namespace Swift;
-#ifdef SWIFTEN_CACHE_JID_PREP
-typedef std::unordered_map<std::string, std::string> PrepCache;
-
-static std::mutex namePrepCacheMutex;
-static PrepCache nodePrepCache;
-static PrepCache domainPrepCache;
-static PrepCache resourcePrepCache;
-#endif
-
static const std::vector<char> escapedChars = {' ', '"', '&', '\'', '/', '<', '>', '@', ':'};
static IDNConverter* idnConverter = nullptr;
@@ -104,12 +88,12 @@ void JID::initializeFromString(const std::string& jid) {
hasResource_ = false;
bare = jid;
}
- std::pair<std::string,std::string> nodeAndDomain = String::getSplittedAtFirst(bare, '@');
- if (nodeAndDomain.second.empty()) {
- nameprepAndSetComponents("", nodeAndDomain.first, resource);
+ auto firstMatch = bare.find('@');
+ if (firstMatch != bare.npos) {
+ nameprepAndSetComponents(bare.substr(0, firstMatch), bare.substr(firstMatch + 1), resource);
}
else {
- nameprepAndSetComponents(nodeAndDomain.first, nodeAndDomain.second, resource);
+ nameprepAndSetComponents("", bare, resource);
}
}
@@ -124,54 +108,20 @@ void JID::nameprepAndSetComponents(const std::string& node, const std::string& d
valid_ = false;
return;
}
-#ifndef SWIFTEN_CACHE_JID_PREP
- node_ = idnConverter->getStringPrepared(node, IDNConverter::XMPPNodePrep);
- domain_ = idnConverter->getStringPrepared(domain, IDNConverter::NamePrep);
- resource_ = idnConverter->getStringPrepared(resource, IDNConverter::XMPPResourcePrep);
-#else
- std::unique_lock<std::mutex> lock(namePrepCacheMutex);
-
- std::pair<PrepCache::iterator, bool> r;
-
- r = nodePrepCache.insert(std::make_pair(node, std::string()));
- if (r.second) {
- try {
- r.first->second = idnConverter->getStringPrepared(node, IDNConverter::XMPPNodePrep);
- }
- catch (...) {
- nodePrepCache.erase(r.first);
- valid_ = false;
- return;
- }
- }
- node_ = r.first->second;
- r = domainPrepCache.insert(std::make_pair(domain, std::string()));
- if (r.second) {
- try {
- r.first->second = idnConverter->getStringPrepared(domain, IDNConverter::NamePrep);
- }
- catch (...) {
- domainPrepCache.erase(r.first);
- valid_ = false;
- return;
+ try {
+ node_ = idnConverter->getStringPrepared(node, IDNConverter::XMPPNodePrep);
+ if (domain.back() == '.') {
+ domain_ = idnConverter->getStringPrepared(domain.substr(0, domain.size() - 1), IDNConverter::NamePrep);
}
- }
- domain_ = r.first->second;
-
- r = resourcePrepCache.insert(std::make_pair(resource, std::string()));
- if (r.second) {
- try {
- r.first->second = idnConverter->getStringPrepared(resource, IDNConverter::XMPPResourcePrep);
- }
- catch (...) {
- resourcePrepCache.erase(r.first);
- valid_ = false;
- return;
+ else {
+ domain_ = idnConverter->getStringPrepared(domain, IDNConverter::NamePrep);
}
+ resource_ = idnConverter->getStringPrepared(resource, IDNConverter::XMPPResourcePrep);
+ } catch (...) {
+ valid_ = false;
+ return;
}
- resource_ = r.first->second;
-#endif
if (domain_.empty()) {
valid_ = false;
diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp
index ca3e5ae..0753fb5 100644
--- a/Swiften/JID/UnitTest/JIDTest.cpp
+++ b/Swiften/JID/UnitTest/JIDTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,11 +20,19 @@ class JIDTest : public CppUnit::TestFixture
CPPUNIT_TEST(testConstructorWithString_NoNode);
CPPUNIT_TEST(testConstructorWithString_EmptyResource);
CPPUNIT_TEST(testConstructorWithString_OnlyDomain);
+ CPPUNIT_TEST(testConstructorWithString_OnlyDomainWithDot);
+ CPPUNIT_TEST(testConstructorWithString_OnlyDomainDotStrippedOff);
+ CPPUNIT_TEST(testConstructorWithString_InvalidOnlyDomainSingleDot);
CPPUNIT_TEST(testConstructorWithString_InvalidDomain);
+ CPPUNIT_TEST(testConstructorWithString_InvalidDomainEmptyLabel);
CPPUNIT_TEST(testConstructorWithString_UpperCaseNode);
CPPUNIT_TEST(testConstructorWithString_UpperCaseDomain);
CPPUNIT_TEST(testConstructorWithString_UpperCaseResource);
CPPUNIT_TEST(testConstructorWithString_EmptyNode);
+ CPPUNIT_TEST(testConstructorWithString_EmptyDomain);
+ CPPUNIT_TEST(testConstructorWithString_EmptyDomainWithResource);
+ CPPUNIT_TEST(testConstructorWithString_DotDomain);
+ CPPUNIT_TEST(testConstructorWithString_DotDomainWithResource);
CPPUNIT_TEST(testConstructorWithString_IllegalResource);
CPPUNIT_TEST(testConstructorWithString_SpacesInNode);
CPPUNIT_TEST(testConstructorWithStrings);
@@ -62,6 +70,7 @@ class JIDTest : public CppUnit::TestFixture
CPPUNIT_TEST(testGetEscapedNode_BackslashAtEnd);
CPPUNIT_TEST(testGetUnescapedNode);
CPPUNIT_TEST(testGetUnescapedNode_XEP106Examples);
+ CPPUNIT_TEST(testStringPrepFailures);
CPPUNIT_TEST_SUITE_END();
public:
@@ -119,10 +128,38 @@ class JIDTest : public CppUnit::TestFixture
CPPUNIT_ASSERT(testling.isValid());
}
+ void testConstructorWithString_OnlyDomainWithDot() {
+ JID testling("bar.");
+
+ CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getNode());
+ CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain());
+ CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResource());
+ CPPUNIT_ASSERT(testling.isBare());
+ CPPUNIT_ASSERT(testling.isValid());
+ }
+
+ void testConstructorWithString_OnlyDomainDotStrippedOff() {
+ JID testling("foo.@bar./resource.");
+
+ CPPUNIT_ASSERT_EQUAL(std::string("foo."), testling.getNode());
+ CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain());
+ CPPUNIT_ASSERT_EQUAL(std::string("resource."), testling.getResource());
+ CPPUNIT_ASSERT(!testling.isBare());
+ CPPUNIT_ASSERT(testling.isValid());
+ }
+
+ void testConstructorWithString_InvalidOnlyDomainSingleDot() {
+ CPPUNIT_ASSERT(!JID(".").isValid());
+ }
+
void testConstructorWithString_InvalidDomain() {
CPPUNIT_ASSERT(!JID("foo@bar,baz").isValid());
}
+ void testConstructorWithString_InvalidDomainEmptyLabel() {
+ CPPUNIT_ASSERT(!JID("foo@bar..").isValid());
+ }
+
void testConstructorWithString_UpperCaseNode() {
JID testling("Fo\xCE\xA9@bar");
@@ -151,6 +188,36 @@ class JIDTest : public CppUnit::TestFixture
CPPUNIT_ASSERT(!testling.isValid());
}
+ void testConstructorWithString_EmptyDomain() {
+ JID testling("bar@");
+
+ CPPUNIT_ASSERT(!testling.isValid());
+ }
+
+ void testStringPrepFailures() {
+ CPPUNIT_ASSERT_EQUAL(false, JID("foo@bar", "example.com").isValid());
+ CPPUNIT_ASSERT_EQUAL(false, JID("foo^", "example*com").isValid());
+ CPPUNIT_ASSERT_EQUAL(false, JID("foobar", "example^com").isValid());
+ }
+
+ void testConstructorWithString_EmptyDomainWithResource() {
+ JID testling("bar@/resource");
+
+ CPPUNIT_ASSERT(!testling.isValid());
+ }
+
+ void testConstructorWithString_DotDomain() {
+ JID testling("bar@.");
+
+ CPPUNIT_ASSERT(!testling.isValid());
+ }
+
+ void testConstructorWithString_DotDomainWithResource() {
+ JID testling("bar@./resource");
+
+ CPPUNIT_ASSERT(!testling.isValid());
+ }
+
void testConstructorWithString_IllegalResource() {
JID testling("foo@bar.com/\xd8\xb1\xd9\x85\xd9\x82\xd9\x87\x20\xd8\xaa\xd8\xb1\xd9\x86\xd8\xb3\x20");
diff --git a/Swiften/Jingle/AbstractJingleSessionListener.h b/Swiften/Jingle/AbstractJingleSessionListener.h
index 590cd14..dd8bd1e 100644
--- a/Swiften/Jingle/AbstractJingleSessionListener.h
+++ b/Swiften/Jingle/AbstractJingleSessionListener.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,20 +7,19 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Jingle/JingleSessionListener.h>
namespace Swift {
class SWIFTEN_API AbstractJingleSessionListener : public JingleSessionListener {
public:
- virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE;
- virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) SWIFTEN_OVERRIDE;
- virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportReplaceReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportInfoAcknowledged(const std::string& id) SWIFTEN_OVERRIDE;
+ virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) override;
+ virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) override;
+ virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void handleTransportReplaceReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override;
+ virtual void handleTransportInfoAcknowledged(const std::string& id) override;
};
}
diff --git a/Swiften/Jingle/FakeJingleSession.h b/Swiften/Jingle/FakeJingleSession.h
index 6218544..0ed97d5 100644
--- a/Swiften/Jingle/FakeJingleSession.h
+++ b/Swiften/Jingle/FakeJingleSession.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,7 +20,6 @@
#include <boost/variant.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Base/SimpleIDGenerator.h>
#include <Swiften/Elements/JinglePayload.h>
#include <Swiften/JID/JID.h>
@@ -86,16 +85,16 @@ namespace Swift {
typedef std::shared_ptr<FakeJingleSession> ref;
FakeJingleSession(const JID& initiator, const std::string& id);
- virtual ~FakeJingleSession();
-
- virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTerminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE;
- virtual void sendInfo(std::shared_ptr<Payload>) SWIFTEN_OVERRIDE;
- virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) SWIFTEN_OVERRIDE;
- virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual ~FakeJingleSession() override;
+
+ virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) override;
+ virtual void sendTerminate(JinglePayload::Reason::Type reason) override;
+ virtual void sendInfo(std::shared_ptr<Payload>) override;
+ virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) override;
+ virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) override;
+ virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) override;
+ virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) override;
+ virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) override;
void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>);
void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>);
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp
index 1b79946..66b4ae8 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -25,7 +25,7 @@ std::shared_ptr<DNSSDBrowseQuery> AvahiQuerier::createBrowseQuery() {
return std::make_shared<AvahiBrowseQuery>(shared_from_this(), eventLoop);
}
-std::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) {
+std::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info) {
return std::make_shared<AvahiRegisterQuery>(name, port, info, shared_from_this(), eventLoop);
}
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h
index 5dce19d..73dd11d 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -30,7 +30,7 @@ namespace Swift {
std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info);
+ const std::string& name, unsigned short port, const ByteArray& info);
std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&);
std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h
index 68281d0..b780043 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -18,7 +18,7 @@ namespace Swift {
class AvahiRegisterQuery : public DNSSDRegisterQuery, public AvahiQuery {
public:
- AvahiRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, std::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) {
+ AvahiRegisterQuery(const std::string& name, unsigned short port, const ByteArray& txtRecord, std::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) {
}
void registerService();
@@ -50,7 +50,7 @@ namespace Swift {
private:
std::string name;
- int port;
+ unsigned short port;
ByteArray txtRecord;
AvahiEntryGroup* group;
};
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
index c049ed2..63f34db 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -50,12 +50,17 @@ namespace Swift {
}
else {
//std::cout << "Discovered service: name:" << name << " domain:" << domain << " type: " << type << std::endl;
- DNSSDServiceID service(name, domain, type, boost::numeric_cast<int>(interfaceIndex));
- if (flags & kDNSServiceFlagsAdd) {
- eventLoop->postEvent(boost::bind(boost::ref(onServiceAdded), service), shared_from_this());
+ try {
+ DNSSDServiceID service(name, domain, type, boost::numeric_cast<int>(interfaceIndex));
+ if (flags & kDNSServiceFlagsAdd) {
+ eventLoop->postEvent(boost::bind(boost::ref(onServiceAdded), service), shared_from_this());
+ }
+ else {
+ eventLoop->postEvent(boost::bind(boost::ref(onServiceRemoved), service), shared_from_this());
+ }
}
- else {
- eventLoop->postEvent(boost::bind(boost::ref(onServiceRemoved), service), shared_from_this());
+ catch (...) {
+ eventLoop->postEvent(boost::bind(boost::ref(onError)), shared_from_this());
}
}
}
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp
index 0906ffc..551421e 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <Swiften/Base/Algorithm.h>
+#include <Swiften/Base/Log.h>
#include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h>
#include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h>
#include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h>
@@ -36,7 +37,7 @@ std::shared_ptr<DNSSDBrowseQuery> BonjourQuerier::createBrowseQuery() {
return std::make_shared<BonjourBrowseQuery>(shared_from_this(), eventLoop);
}
-std::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) {
+std::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info) {
return std::make_shared<BonjourRegisterQuery>(name, port, info, shared_from_this(), eventLoop);
}
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h
index 77326bc..6af1c1f 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -25,7 +25,7 @@ namespace Swift {
std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info);
+ const std::string& name, unsigned short port, const ByteArray& info);
std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&);
std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h
index 8b2e955..9eb8cd9 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,12 +20,21 @@ namespace Swift {
class BonjourRegisterQuery : public DNSSDRegisterQuery, public BonjourQuery {
public:
- BonjourRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, std::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
+ BonjourRegisterQuery(const std::string& name, unsigned short port, const ByteArray& txtRecord, std::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
+ unsigned short recordSize = 0;
+ try {
+ recordSize = boost::numeric_cast<unsigned short>(txtRecord.size());
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not registring service" << std::endl;
+ return;
+ }
DNSServiceErrorType result = DNSServiceRegister(
- &sdRef, 0, 0, name.c_str(), "_presence._tcp", nullptr, nullptr, boost::numeric_cast<unsigned short>(port),
- boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord),
+ &sdRef, 0, 0, name.c_str(), "_presence._tcp", nullptr, nullptr, port,
+ recordSize, vecptr(txtRecord),
&BonjourRegisterQuery::handleServiceRegisteredStatic, this);
if (result != kDNSServiceErr_NoError) {
+ SWIFT_LOG(warning) << "Failed to register Bonjour service" << std::endl;
sdRef = nullptr;
}
}
@@ -45,7 +54,12 @@ namespace Swift {
void updateServiceInfo(const ByteArray& txtRecord) {
std::lock_guard<std::mutex> lock(sdRefMutex);
- DNSServiceUpdateRecord(sdRef, nullptr, 0, boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord), 0);
+ try {
+ DNSServiceUpdateRecord(sdRef, nullptr, 0, boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord), 0);
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not updating service record" << std::endl;
+ }
}
private:
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
index dbf3f0e..61f000e 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -23,11 +23,16 @@ namespace Swift {
class BonjourResolveHostnameQuery : public DNSSDResolveHostnameQuery, public BonjourQuery {
public:
BonjourResolveHostnameQuery(const std::string& hostname, int interfaceIndex, std::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
- DNSServiceErrorType result = DNSServiceGetAddrInfo(
- &sdRef, 0, boost::numeric_cast<unsigned int>(interfaceIndex), kDNSServiceProtocol_IPv4,
- hostname.c_str(),
- &BonjourResolveHostnameQuery::handleHostnameResolvedStatic, this);
- if (result != kDNSServiceErr_NoError) {
+ try {
+ DNSServiceErrorType result = DNSServiceGetAddrInfo(
+ &sdRef, 0, boost::numeric_cast<unsigned int>(interfaceIndex), kDNSServiceProtocol_IPv4,
+ hostname.c_str(),
+ &BonjourResolveHostnameQuery::handleHostnameResolvedStatic, this);
+ if (result != kDNSServiceErr_NoError) {
+ sdRef = nullptr;
+ }
+ }
+ catch (...) {
sdRef = nullptr;
}
}
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
index 7a5555e..4baf87b 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,12 +20,17 @@ namespace Swift {
class BonjourResolveServiceQuery : public DNSSDResolveServiceQuery, public BonjourQuery {
public:
BonjourResolveServiceQuery(const DNSSDServiceID& service, std::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
- DNSServiceErrorType result = DNSServiceResolve(
- &sdRef, 0, boost::numeric_cast<unsigned int>(service.getNetworkInterfaceID()),
- service.getName().c_str(), service.getType().c_str(),
- service.getDomain().c_str(),
- &BonjourResolveServiceQuery::handleServiceResolvedStatic, this);
- if (result != kDNSServiceErr_NoError) {
+ try {
+ DNSServiceErrorType result = DNSServiceResolve(
+ &sdRef, 0, boost::numeric_cast<unsigned int>(service.getNetworkInterfaceID()),
+ service.getName().c_str(), service.getType().c_str(),
+ service.getDomain().c_str(),
+ &BonjourResolveServiceQuery::handleServiceResolvedStatic, this);
+ if (result != kDNSServiceErr_NoError) {
+ sdRef = nullptr;
+ }
+ }
+ catch (...) {
sdRef = nullptr;
}
}
diff --git a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h
index 8f3c3ec..3924c05 100644
--- a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -26,7 +26,7 @@ namespace Swift {
virtual std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery() = 0;
virtual std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info) = 0;
+ const std::string& name, unsigned short port, const ByteArray& info) = 0;
virtual std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&) = 0;
virtual std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
diff --git a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h
index b55447a..6416d69 100644
--- a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h
+++ b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -16,11 +16,11 @@ namespace Swift {
class DNSSDResolveServiceQuery {
public:
struct Result {
- Result(const std::string& fullName, const std::string& host, int port, const ByteArray& info) :
+ Result(const std::string& fullName, const std::string& host, unsigned short port, const ByteArray& info) :
fullName(fullName), host(host), port(port), info(info) {}
std::string fullName;
std::string host;
- int port;
+ unsigned short port;
ByteArray info;
};
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
index c17f8b2..3381a26 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -32,7 +32,7 @@ std::shared_ptr<DNSSDBrowseQuery> FakeDNSSDQuerier::createBrowseQuery() {
return std::make_shared<FakeDNSSDBrowseQuery>(shared_from_this());
}
-std::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) {
+std::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info) {
return std::make_shared<FakeDNSSDRegisterQuery>(name, port, info, shared_from_this());
}
@@ -105,7 +105,7 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol
}
}
-bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, int port, const ByteArray& info) {
+bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, unsigned short port, const ByteArray& info) {
for (const auto& query : getQueries<FakeDNSSDRegisterQuery>()) {
if (query->name == name && query->port == port && query->info == info) {
return true;
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
index 5d4fefd..07cb75c 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2017 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -39,7 +39,7 @@ namespace Swift {
std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info);
+ const std::string& name, unsigned short port, const ByteArray& info);
std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&);
std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
@@ -51,7 +51,7 @@ namespace Swift {
void addService(const DNSSDServiceID& id);
void removeService(const DNSSDServiceID& id);
void setServiceInfo(const DNSSDServiceID& id, const DNSSDResolveServiceQuery::Result& info);
- bool isServiceRegistered(const std::string& name, int port, const ByteArray& info);
+ bool isServiceRegistered(const std::string& name, unsigned short port, const ByteArray& info);
void setAddress(const std::string& hostname, boost::optional<HostAddress> address);
void setBrowseError();
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
index 7478841..ee6bb92 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,7 +17,7 @@ namespace Swift {
class FakeDNSSDRegisterQuery : public DNSSDRegisterQuery, public FakeDNSSDQuery {
public:
- FakeDNSSDRegisterQuery(const std::string& name, int port, const ByteArray& info, std::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) {
+ FakeDNSSDRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info, std::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) {
}
void registerService() {
@@ -33,7 +33,7 @@ namespace Swift {
}
std::string name;
- int port;
+ unsigned short port;
ByteArray info;
};
}
diff --git a/Swiften/LinkLocal/LinkLocalService.h b/Swiften/LinkLocal/LinkLocalService.h
index 9b0e2ab..c51f890 100644
--- a/Swiften/LinkLocal/LinkLocalService.h
+++ b/Swiften/LinkLocal/LinkLocalService.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -31,7 +31,7 @@ namespace Swift {
return id.getName();
}
- int getPort() const {
+ unsigned short getPort() const {
return info.port;
}
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
index b79f184..0498384 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -65,17 +65,29 @@ bool LinkLocalServiceBrowser::isRegistered() const {
return !!registerQuery;
}
-void LinkLocalServiceBrowser::registerService(const std::string& name, int port, const LinkLocalServiceInfo& info) {
+void LinkLocalServiceBrowser::registerService(const std::string& name, unsigned short port, const LinkLocalServiceInfo& info) {
assert(!registerQuery);
- registerQuery = querier->createRegisterQuery(name, port, info.toTXTRecord());
- registerQuery->onRegisterFinished.connect(
- boost::bind(&LinkLocalServiceBrowser::handleRegisterFinished, this, _1));
- registerQuery->registerService();
+ if (auto txtRecord = info.toTXTRecord()) {
+ registerQuery = querier->createRegisterQuery(name, port, *txtRecord);
+ registerQuery->onRegisterFinished.connect(
+ boost::bind(&LinkLocalServiceBrowser::handleRegisterFinished, this, _1));
+ registerQuery->registerService();
+ }
+ else {
+ haveError = true;
+ stop();
+ }
}
void LinkLocalServiceBrowser::updateService(const LinkLocalServiceInfo& info) {
assert(registerQuery);
- registerQuery->updateServiceInfo(info.toTXTRecord());
+ if (auto txtRecord = info.toTXTRecord()) {
+ registerQuery->updateServiceInfo(*txtRecord);
+ }
+ else {
+ haveError = true;
+ stop();
+ }
}
void LinkLocalServiceBrowser::unregisterService() {
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.h b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
index c59a4d0..bfcfc07 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.h
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -35,7 +35,7 @@ namespace Swift {
void registerService(
const std::string& name,
- int port,
+ unsigned short port,
const LinkLocalServiceInfo& info = LinkLocalServiceInfo());
void updateService(
const LinkLocalServiceInfo& info = LinkLocalServiceInfo());
diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
index 7a7ed3b..914fab4 100644
--- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,40 +11,47 @@
#include <Swiften/Base/Algorithm.h>
#include <Swiften/Base/Concat.h>
+#include <Swiften/Base/Log.h>
namespace Swift {
-ByteArray LinkLocalServiceInfo::toTXTRecord() const {
- ByteArray result(getEncoded("txtvers=1"));
- if (!firstName.empty()) {
- append(result, getEncoded("1st=" + firstName));
- }
- if (!lastName.empty()) {
- append(result, getEncoded("last=" + lastName));
- }
- if (!email.empty()) {
- append(result, getEncoded("email=" + email));
- }
- if (jid.isValid()) {
- append(result, getEncoded("jid=" + jid.toString()));
- }
- if (!message.empty()) {
- append(result, getEncoded("msg=" + message));
- }
- if (!nick.empty()) {
- append(result, getEncoded("nick=" + nick));
- }
- if (port) {
- append(result, getEncoded("port.p2pj=" + std::string(boost::lexical_cast<std::string>(*port))));
- }
+boost::optional<ByteArray> LinkLocalServiceInfo::toTXTRecord() const {
+ try {
+ ByteArray result(getEncoded("txtvers=1"));
+ if (!firstName.empty()) {
+ append(result, getEncoded("1st=" + firstName));
+ }
+ if (!lastName.empty()) {
+ append(result, getEncoded("last=" + lastName));
+ }
+ if (!email.empty()) {
+ append(result, getEncoded("email=" + email));
+ }
+ if (jid.isValid()) {
+ append(result, getEncoded("jid=" + jid.toString()));
+ }
+ if (!message.empty()) {
+ append(result, getEncoded("msg=" + message));
+ }
+ if (!nick.empty()) {
+ append(result, getEncoded("nick=" + nick));
+ }
+ if (port) {
+ append(result, getEncoded("port.p2pj=" + std::string(std::to_string(*port))));
+ }
- switch (status) {
- case Available: append(result, getEncoded("status=avail")); break;
- case Away: append(result, getEncoded("status=away")); break;
- case DND: append(result, getEncoded("status=dnd")); break;
- }
+ switch (status) {
+ case Available: append(result, getEncoded("status=avail")); break;
+ case Away: append(result, getEncoded("status=away")); break;
+ case DND: append(result, getEncoded("status=dnd")); break;
+ }
- return result;
+ return result;
+ }
+ catch (const std::exception& e) {
+ SWIFT_LOG(warning) << "Failed to create TXT record for link local service info: " << e.what() << std::endl;
+ return boost::none;
+ }
}
ByteArray LinkLocalServiceInfo::getEncoded(const std::string& s) {
@@ -82,7 +89,13 @@ LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray&
info.setNick(entry.second);
}
else if (entry.first == "port.p2pj") {
- info.setPort(boost::lexical_cast<int>(entry.second));
+ try {
+ info.setPort(boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(entry.second)));
+ }
+ catch (const boost::bad_lexical_cast&) {
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ }
}
else if (entry.first == "status") {
if (entry.second == "away") {
diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.h b/Swiften/LinkLocal/LinkLocalServiceInfo.h
index 9f15c6e..adfd062 100644
--- a/Swiften/LinkLocal/LinkLocalServiceInfo.h
+++ b/Swiften/LinkLocal/LinkLocalServiceInfo.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -43,10 +43,10 @@ namespace Swift {
Status getStatus() const { return status; }
void setStatus(Status s) { status = s; }
- boost::optional<int> getPort() const { return port; }
- void setPort(int p) { port = p; }
+ boost::optional<unsigned short> getPort() const { return port; }
+ void setPort(unsigned short p) { port = p; }
- ByteArray toTXTRecord() const;
+ boost::optional<ByteArray> toTXTRecord() const;
static LinkLocalServiceInfo createFromTXTRecord(const ByteArray& record);
@@ -62,6 +62,6 @@ namespace Swift {
std::string message;
std::string nick;
Status status;
- boost::optional<int> port;
+ boost::optional<unsigned short> port;
};
}
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
index 85ae537..59cf996 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -53,7 +53,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(!connectError);
CPPUNIT_ASSERT(connection->connectedTo);
CPPUNIT_ASSERT_EQUAL(std::string(connection->connectedTo->getAddress().toString()), std::string("192.168.1.1"));
- CPPUNIT_ASSERT_EQUAL(connection->connectedTo->getPort(), 1234);
+ CPPUNIT_ASSERT_EQUAL(connection->connectedTo->getPort(), static_cast<unsigned short>(1234));
}
void testConnect_UnableToResolve() {
@@ -114,12 +114,14 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture {
}
private:
- std::shared_ptr<LinkLocalConnector> createConnector(const std::string& hostname, int port) {
+ std::shared_ptr<LinkLocalConnector> createConnector(const std::string& hostname, unsigned short port) {
+ auto txtRecord = LinkLocalServiceInfo().toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
LinkLocalService service(
DNSSDServiceID("myname", "local."),
DNSSDResolveServiceQuery::Result(
"myname._presence._tcp.local", hostname, port,
- LinkLocalServiceInfo().toTXTRecord()));
+ *txtRecord));
std::shared_ptr<LinkLocalConnector> result(
new LinkLocalConnector(service, querier, connection));
result->onConnectFinished.connect(
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
index a80d748..3491634 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -47,10 +47,12 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
eventLoop = new DummyEventLoop();
querier = std::make_shared<FakeDNSSDQuerier>("wonderland.lit", eventLoop);
aliceServiceID = new DNSSDServiceID("alice", "wonderland.lit");
- aliceServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.wonderland.lit", "xmpp.wonderland.lit", 1234, LinkLocalServiceInfo().toTXTRecord());
+ auto txtRecord = LinkLocalServiceInfo().toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ aliceServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.wonderland.lit", "xmpp.wonderland.lit", 1234, *txtRecord);
testServiceID = new DNSSDServiceID("foo", "bar.local");
- testServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.bar.local", "xmpp.bar.local", 1234, LinkLocalServiceInfo().toTXTRecord());
- testServiceInfo2 = new DNSSDResolveServiceQuery::Result("_presence.tcp.bar.local", "xmpp.foo.local", 2345, LinkLocalServiceInfo().toTXTRecord());
+ testServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.bar.local", "xmpp.bar.local", 1234, *txtRecord);
+ testServiceInfo2 = new DNSSDResolveServiceQuery::Result("_presence.tcp.bar.local", "xmpp.foo.local", 2345, *txtRecord);
errorStopReceived = false;
normalStopReceived = false;
}
@@ -292,7 +294,9 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
testling->registerService("foo@bar", 1234, info);
eventLoop->processEvents();
- CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, *txtRecord));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(registeredServices.size()));
CPPUNIT_ASSERT(registeredServices[0] == DNSSDServiceID("foo@bar", "wonderland.lit"));
testling->stop();
@@ -311,7 +315,9 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(!testling->isRunning());
CPPUNIT_ASSERT(testling->hasError());
CPPUNIT_ASSERT(errorStopReceived);
- CPPUNIT_ASSERT(!querier->isServiceRegistered("foo@bar", 1234, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(!querier->isServiceRegistered("foo@bar", 1234, *txtRecord));
}
void testRegisterService_Reregister() {
@@ -329,7 +335,9 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
testling->registerService("bar@baz", 3456, info);
eventLoop->processEvents();
- CPPUNIT_ASSERT(querier->isServiceRegistered("bar@baz", 3456, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(querier->isServiceRegistered("bar@baz", 3456, *txtRecord));
testling->stop();
}
@@ -346,7 +354,9 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
info.setFirstName("Bar");
testling->updateService(info);
- CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, *txtRecord));
testling->stop();
}
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp
index 0a94a98..35cb1b4 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -29,7 +29,9 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture {
info.setLastName("Tron\xc3\xe7on");
info.setStatus(LinkLocalServiceInfo::Away);
- CPPUNIT_ASSERT_EQUAL(createByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), info.toTXTRecord());
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), *txtRecord);
}
void testCreateFromTXTRecord() {
@@ -57,7 +59,9 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture {
info.setStatus(LinkLocalServiceInfo::DND);
info.setPort(1234);
- LinkLocalServiceInfo info2 = LinkLocalServiceInfo::createFromTXTRecord(info.toTXTRecord());
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ LinkLocalServiceInfo info2 = LinkLocalServiceInfo::createFromTXTRecord(*txtRecord);
CPPUNIT_ASSERT_EQUAL(info.getFirstName(), info2.getFirstName());
CPPUNIT_ASSERT_EQUAL(info.getLastName(), info2.getLastName());
CPPUNIT_ASSERT_EQUAL(info.getEMail(), info2.getEMail());
@@ -67,6 +71,13 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(info.getStatus() == info2.getStatus());
CPPUNIT_ASSERT(info.getPort() == info2.getPort());
}
+
+ void testToTXTRecordWithInvalidParameter() {
+ LinkLocalServiceInfo info;
+ info.setFirstName(std::string(256, 'x'));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(!txtRecord);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(LinkLocalServiceInfoTest);
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp
index 206d824..cb5f40a 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -58,10 +58,12 @@ class LinkLocalServiceTest : public CppUnit::TestFixture {
info.setFirstName(firstName);
info.setLastName(lastName);
info.setNick(nickName);
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
return LinkLocalService(service,
DNSSDResolveServiceQuery::Result(
name + "._presence._tcp.local", "rabbithole.local", 1234,
- info.toTXTRecord()));
+ *txtRecord));
}
};
diff --git a/Swiften/MIX/MIX.cpp b/Swiften/MIX/MIX.cpp
new file mode 100644
index 0000000..f3e3d69
--- /dev/null
+++ b/Swiften/MIX/MIX.cpp
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/MIX/MIX.h>
+
+namespace Swift {
+
+MIX::~MIX() {
+}
+
+}
diff --git a/Swiften/MIX/MIX.h b/Swiften/MIX/MIX.h
new file mode 100644
index 0000000..1398a6e
--- /dev/null
+++ b/Swiften/MIX/MIX.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+#include <unordered_set>
+
+#include <boost/signals2.hpp>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/JID/JID.h>
+#include <Swiften/Elements/Form.h>
+#include <Swiften/Elements/MIXJoin.h>
+#include <Swiften/Elements/MIXLeave.h>
+#include <Swiften/Elements/MIXUpdateSubscription.h>
+#include <Swiften/Elements/MIXUserPreference.h>
+#include <Swiften/Elements/ErrorPayload.h>
+
+namespace Swift {
+ class SWIFTEN_API MIX {
+ public:
+ using ref = std::shared_ptr<MIX>;
+
+ public:
+ virtual ~MIX();
+
+ /**
+ * Join a MIX channel and subscribe to nodes.
+ */
+ virtual void joinChannel(const std::unordered_set<std::string>& nodes) = 0;
+
+ /**
+ * Join Channel with a set of preferences.
+ */
+ virtual void joinChannelWithPreferences(const std::unordered_set<std::string>& nodes, Form::ref form) = 0;
+
+ /**
+ * Update subscription of nodes.
+ */
+ virtual void updateSubscription(const std::unordered_set<std::string>& nodes) = 0;
+
+ /**
+ * Leave a MIX channel and unsubcribe nodes.
+ */
+ virtual void leaveChannel() = 0;
+
+ /**
+ * Request a configuration form for updating preferences.
+ */
+ virtual void requestPreferencesForm() = 0;
+
+ /**
+ * Update preferences after requesting preference form.
+ */
+ virtual void updatePreferences(Form::ref form) = 0;
+
+ public:
+ boost::signals2::signal<void (MIXJoin::ref /* joinResponse */, ErrorPayload::ref /* joinError */)> onJoinResponse;
+ boost::signals2::signal<void (MIXLeave::ref /* leaveResponse */, ErrorPayload::ref /* leaveError */)> onLeaveResponse;
+ boost::signals2::signal<void (MIXUpdateSubscription::ref /* updateResponse */, ErrorPayload::ref /* updateError */)> onSubscriptionUpdateResponse;
+ boost::signals2::signal<void (Form::ref /* preferencesForm */, ErrorPayload::ref /* failedConfiguration */)> onPreferencesFormResponse;
+ boost::signals2::signal<void (MIXUserPreference::ref /* userPreferenceResponse */, ErrorPayload::ref /* failedUpdate */)> onPreferencesUpdateResponse;
+ };
+}
diff --git a/Swiften/MIX/MIXImpl.cpp b/Swiften/MIX/MIXImpl.cpp
new file mode 100644
index 0000000..cd3eb21
--- /dev/null
+++ b/Swiften/MIX/MIXImpl.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/MIX/MIXImpl.h>
+
+#include <Swiften/Client/StanzaChannel.h>
+#include <Swiften/Elements/IQ.h>
+#include <Swiften/Queries/GenericRequest.h>
+#include <Swiften/Queries/IQRouter.h>
+
+namespace Swift {
+
+MIXImpl::MIXImpl(const JID& ownJID, const JID& channelJID, IQRouter* iqRouter) : ownJID_(ownJID), channelJID_(channelJID), iqRouter_(iqRouter) {
+
+}
+
+MIXImpl::~MIXImpl() {
+
+}
+
+void MIXImpl::joinChannel(const std::unordered_set<std::string>& nodes) {
+ joinChannelWithPreferences(nodes, nullptr);
+}
+
+void MIXImpl::joinChannelWithPreferences(const std::unordered_set<std::string>& nodes, Form::ref form) {
+ auto joinPayload = std::make_shared<MIXJoin>();
+ joinPayload->setChannel(channelJID_);
+ for (auto node : nodes) {
+ joinPayload->addSubscription(node);
+ }
+ if (form) {
+ joinPayload->setForm(form);
+ }
+ auto request = std::make_shared<GenericRequest<MIXJoin>>(IQ::Set, getJID(), joinPayload, iqRouter_);
+ request->onResponse.connect(boost::bind(&MIXImpl::handleJoinResponse, this, _1, _2));
+ request->send();
+}
+
+void MIXImpl::handleJoinResponse(MIXJoin::ref payload, ErrorPayload::ref error) {
+ onJoinResponse(payload, error);
+}
+
+void MIXImpl::updateSubscription(const std::unordered_set<std::string>& nodes) {
+ auto updateSubscriptionPayload = std::make_shared<MIXUpdateSubscription>();
+ updateSubscriptionPayload->setSubscriptions(nodes);
+ auto request = std::make_shared<GenericRequest<MIXUpdateSubscription>>(IQ::Set, channelJID_, updateSubscriptionPayload, iqRouter_);
+ request->onResponse.connect(boost::bind(&MIXImpl::handleUpdateSubscriptionResponse, this, _1, _2));
+ request->send();
+}
+
+void MIXImpl::handleUpdateSubscriptionResponse(MIXUpdateSubscription::ref payload, ErrorPayload::ref error) {
+ onSubscriptionUpdateResponse(payload, error);
+}
+
+void MIXImpl::leaveChannel() {
+ auto leavePayload = std::make_shared<MIXLeave>();
+ leavePayload->setChannel(channelJID_);
+ auto request = std::make_shared<GenericRequest<MIXLeave>>(IQ::Set, getJID(), leavePayload, iqRouter_);
+ request->onResponse.connect(boost::bind(&MIXImpl::handleLeaveResponse, this, _1, _2));
+ request->send();
+}
+
+void MIXImpl::handleLeaveResponse(MIXLeave::ref payload, ErrorPayload::ref error) {
+ onLeaveResponse(payload, error);
+}
+
+void MIXImpl::requestPreferencesForm() {
+ auto prefPayload = std::make_shared<MIXUserPreference>();
+ auto request = std::make_shared<GenericRequest<MIXUserPreference>>(IQ::Get, channelJID_, prefPayload, iqRouter_);
+ request->onResponse.connect(boost::bind(&MIXImpl::handlePreferencesFormReceived, this, _1, _2));
+ request->send();
+}
+
+void MIXImpl::handlePreferencesFormReceived(MIXUserPreference::ref payload, ErrorPayload::ref error) {
+ Form::ref form = nullptr;
+ if (payload) {
+ form = payload->getData();
+ }
+ onPreferencesFormResponse(form, error);
+}
+
+void MIXImpl::handlePreferencesResultReceived(MIXUserPreference::ref payload, ErrorPayload::ref error) {
+ onPreferencesUpdateResponse(payload, error);
+}
+
+void MIXImpl::updatePreferences(Form::ref form) {
+ auto prefPayload = std::make_shared<MIXUserPreference>();
+ prefPayload->setData(form);
+ auto request = std::make_shared<GenericRequest<MIXUserPreference>>(IQ::Set, channelJID_, prefPayload, iqRouter_);
+ request->onResponse.connect(boost::bind(&MIXImpl::handlePreferencesResultReceived, this, _1, _2));
+ request->send();
+}
+
+}
diff --git a/Swiften/MIX/MIXImpl.h b/Swiften/MIX/MIXImpl.h
new file mode 100644
index 0000000..4da7a62
--- /dev/null
+++ b/Swiften/MIX/MIXImpl.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+ /*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/MIX/MIX.h>
+
+namespace Swift {
+ class StanzaChannel;
+ class IQRouter;
+
+ class SWIFTEN_API MIXImpl : public MIX {
+ public:
+ using ref = std::shared_ptr<MIXImpl>;
+
+ public:
+ MIXImpl(const JID& ownJID, const JID& channelJID, IQRouter* iqRouter);
+ virtual ~MIXImpl() override;
+
+ /**
+ * Returns the (bare) JID of the user.
+ */
+ virtual JID getJID() const {
+ return ownJID_.toBare();
+ }
+
+ /**
+ * Returns the JID of MIX channel.
+ */
+ virtual JID getChannelJID() const {
+ return channelJID_;
+ }
+
+ virtual void joinChannel(const std::unordered_set<std::string>& nodes) override;
+
+ virtual void joinChannelWithPreferences(const std::unordered_set<std::string>& nodes, Form::ref form) override;
+
+ virtual void updateSubscription(const std::unordered_set<std::string>& nodes) override;
+
+ virtual void leaveChannel() override;
+
+ virtual void requestPreferencesForm() override;
+
+ virtual void updatePreferences(Form::ref form) override;
+
+ private:
+ void handleJoinResponse(MIXJoin::ref, ErrorPayload::ref);
+ void handleLeaveResponse(MIXLeave::ref, ErrorPayload::ref);
+ void handleUpdateSubscriptionResponse(MIXUpdateSubscription::ref, ErrorPayload::ref);
+ void handlePreferencesFormReceived(MIXUserPreference::ref, ErrorPayload::ref);
+ void handlePreferencesResultReceived(MIXUserPreference::ref /*payload*/, ErrorPayload::ref error);
+
+ private:
+ JID ownJID_;
+ JID channelJID_;
+ IQRouter* iqRouter_;
+ };
+}
diff --git a/Swiften/MIX/UnitTest/MIXImplTest.cpp b/Swiften/MIX/UnitTest/MIXImplTest.cpp
new file mode 100644
index 0000000..05dde17
--- /dev/null
+++ b/Swiften/MIX/UnitTest/MIXImplTest.cpp
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <boost/bind.hpp>
+
+#include <Swiften/Elements/FormField.h>
+#include <Swiften/Client/DummyStanzaChannel.h>
+#include <Swiften/MIX/MIXImpl.h>
+#include <Swiften/Queries/IQRouter.h>
+
+using namespace Swift;
+
+class MIXImplTest : public ::testing::Test {
+
+ protected:
+ void SetUp() {
+ ownJID_ = JID("hag66@shakespeare.example/UUID-a1j/7533");
+ channelJID_ = JID("coven@mix.shakespeare.example");
+ channel_ = new DummyStanzaChannel();
+ router_ = new IQRouter(channel_);
+ successfulJoins_ = 0;
+ }
+
+ void TearDown() {
+ delete router_;
+ delete channel_;
+ }
+
+ MIX::ref createMIXClient() {
+ auto mix = std::make_shared<MIXImpl>(ownJID_, channelJID_, router_);
+ mix->onJoinResponse.connect(boost::bind(&MIXImplTest::handleJoin, this, _1, _2));
+ mix->onLeaveResponse.connect(boost::bind(&MIXImplTest::handleLeave, this, _1, _2));
+ mix->onSubscriptionUpdateResponse.connect(boost::bind(&MIXImplTest::handleSubscriptionUpdate, this, _1, _2));
+ mix->onPreferencesFormResponse.connect(boost::bind(&MIXImplTest::handlePreferencesForm, this, _1, _2));
+ return mix;
+ }
+
+ void handleJoin(MIXJoin::ref joinPayload, ErrorPayload::ref error) {
+ if (joinPayload) {
+ ASSERT_FALSE(error);
+ ASSERT_TRUE(joinPayload->getJID());
+ ASSERT_EQ(*joinPayload->getJID(), JID("123456#coven@mix.shakespeare.example"));
+ if (joinPayload->getForm()) {
+ preferenceForm_ = joinPayload->getForm();
+ }
+ ++successfulJoins_;
+ subscribedNodes_ = joinPayload->getSubscriptions();
+ }
+ }
+
+ void handleLeave(MIXLeave::ref leavePayload, ErrorPayload::ref error) {
+ ASSERT_TRUE(leavePayload);
+ ASSERT_FALSE(error);
+ ASSERT_EQ(static_cast<int>(0), subscribedNodes_.size());
+ }
+
+ void handleSubscriptionUpdate(MIXUpdateSubscription::ref payload, ErrorPayload::ref error) {
+ ASSERT_TRUE(payload);
+ ASSERT_FALSE(error);
+ if (payload) {
+ for (auto node : payload->getSubscriptions()) {
+ subscribedNodes_.insert(node);
+ }
+ }
+ }
+
+ void handlePreferencesForm(Form::ref form, ErrorPayload::ref error) {
+ ASSERT_FALSE(error);
+ if (form) {
+ preferenceForm_ = form;
+ }
+ }
+
+ IQ::ref createJoinResult(const std::unordered_set<std::string>& nodes, Form::ref form) {
+ auto joinResultPayload = std::make_shared<MIXJoin>();
+ for (auto node : nodes) {
+ joinResultPayload->addSubscription(node);
+ }
+ if (form) {
+ joinResultPayload->setForm(form);
+ }
+ joinResultPayload->setJID(JID("123456#coven@mix.shakespeare.example"));
+ return IQ::createResult(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID(), joinResultPayload);
+ }
+
+ IQ::ref createLeaveResult() {
+ auto leaveResultPayload = std::make_shared<MIXLeave>();
+ return IQ::createResult(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID(), leaveResultPayload);
+ }
+
+ IQ::ref createError() {
+ return IQ::createError(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID());
+ }
+
+ bool hasSubscription(const std::string& value) {
+ return std::find(subscribedNodes_.begin(), subscribedNodes_.end(), value) != subscribedNodes_.end();
+ }
+
+ JID ownJID_;
+ JID channelJID_;
+ DummyStanzaChannel* channel_;
+ IQRouter* router_;
+ int successfulJoins_;
+ Form::ref preferenceForm_;
+ std::unordered_set<std::string> subscribedNodes_;
+};
+
+TEST_F(MIXImplTest, testJoinError) {
+ MIX::ref testling = createMIXClient();
+ testling->joinChannel(std::unordered_set<std::string>());
+
+ ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set));
+
+ auto iq = channel_->getStanzaAtIndex<IQ>(0);
+ ASSERT_TRUE(iq);
+ ASSERT_TRUE(iq->getPayload<MIXJoin>());
+ ASSERT_FALSE(iq->getPayload<MIXJoin>()->getForm());
+ ASSERT_EQ(static_cast<size_t>(0), iq->getPayload<MIXJoin>()->getSubscriptions().size());
+
+ channel_->onIQReceived(createError());
+ ASSERT_EQ(static_cast<int>(0), successfulJoins_);
+ ASSERT_EQ(static_cast<int>(0), subscribedNodes_.size());
+}
+
+TEST_F(MIXImplTest, testJoinWithAllSubscriptions) {
+ MIX::ref testling = createMIXClient();
+ std::unordered_set<std::string> nodes;
+ nodes.insert(std::string("urn:xmpp:mix:nodes:messages"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:presence"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:participants"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:config"));
+
+ testling->joinChannel(nodes);
+
+ ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set));
+
+ auto iq = channel_->getStanzaAtIndex<IQ>(0);
+ ASSERT_TRUE(iq);
+ ASSERT_TRUE(iq->getPayload<MIXJoin>());
+ ASSERT_FALSE(iq->getPayload<MIXJoin>()->getForm());
+ ASSERT_EQ(static_cast<size_t>(4), iq->getPayload<MIXJoin>()->getSubscriptions().size());
+
+ channel_->onIQReceived(createJoinResult(nodes, nullptr));
+ ASSERT_EQ(static_cast<int>(1), successfulJoins_);
+ ASSERT_EQ(static_cast<int>(4), subscribedNodes_.size());
+}
+
+TEST_F(MIXImplTest, testJoinWithSomeSubscriptions) {
+ MIX::ref testling = createMIXClient();
+ std::unordered_set<std::string> nodes;
+ nodes.insert(std::string("urn:xmpp:mix:nodes:messages"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:presence"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:participants"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:config"));
+
+ testling->joinChannel(nodes);
+
+ ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set));
+
+ auto iq = channel_->getStanzaAtIndex<IQ>(0);
+ ASSERT_TRUE(iq);
+ ASSERT_TRUE(iq->getPayload<MIXJoin>());
+ ASSERT_FALSE(iq->getPayload<MIXJoin>()->getForm());
+ ASSERT_EQ(static_cast<size_t>(4), iq->getPayload<MIXJoin>()->getSubscriptions().size());
+
+ std::unordered_set<std::string> subscribedTo;
+ subscribedTo.insert(std::string("urn:xmpp:mix:nodes:messages"));
+
+ channel_->onIQReceived(createJoinResult(subscribedTo, nullptr));
+ ASSERT_EQ(static_cast<int>(1), successfulJoins_);
+ ASSERT_EQ(static_cast<int>(1), subscribedNodes_.size());
+ ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}
+
+TEST_F(MIXImplTest, testLeaveChannel) {
+ MIX::ref testling = createMIXClient();
+ testling->leaveChannel();
+ ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXLeave>(0, ownJID_.toBare(), IQ::Set));
+
+ auto iq = channel_->getStanzaAtIndex<IQ>(0);
+ ASSERT_TRUE(iq);
+ ASSERT_TRUE(iq->getPayload<MIXLeave>());
+ ASSERT_TRUE(iq->getPayload<MIXLeave>()->getChannel());
+
+ channel_->onIQReceived(createLeaveResult());
+}
+
+TEST_F(MIXImplTest, testUpdateSubscription) {
+ MIX::ref testling = createMIXClient();
+ std::unordered_set<std::string> nodes;
+ nodes.insert(std::string("urn:xmpp:mix:nodes:messages"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:presence"));
+
+ testling->joinChannel(nodes);
+
+ ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set));
+
+ channel_->onIQReceived(createJoinResult(nodes, nullptr));
+ ASSERT_EQ(static_cast<int>(1), successfulJoins_);
+ ASSERT_EQ(static_cast<int>(2), subscribedNodes_.size());
+
+ nodes.clear();
+ nodes.insert(std::string("urn:xmpp:mix:nodes:participants"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:config"));
+
+ testling->updateSubscription(nodes);
+
+ ASSERT_EQ(2, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXUpdateSubscription>(1, channelJID_, IQ::Set));
+
+ // fake response
+ auto subscriptionUpdate = std::make_shared<MIXUpdateSubscription>();
+ subscriptionUpdate->setSubscriptions(nodes);
+ subscriptionUpdate->setJID(JID("hag66@shakespeare.example"));
+ auto response = IQ::createResult(ownJID_, channel_->sentStanzas[1]->getTo(), channel_->sentStanzas[1]->getID(), subscriptionUpdate);
+
+ channel_->onIQReceived(response);
+ ASSERT_EQ(static_cast<int>(4), subscribedNodes_.size());
+ ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:participants")));
+ ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:config")));
+ ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}
+
+TEST_F(MIXImplTest, testJoinWithPreference) {
+ MIX::ref testling = createMIXClient();
+ std::unordered_set<std::string> nodes;
+ nodes.insert(std::string("urn:xmpp:mix:nodes:messages"));
+ nodes.insert(std::string("urn:xmpp:mix:nodes:presence"));
+
+ auto parameters = std::make_shared<Form>();
+ parameters->setType(Form::Type::SubmitType);
+
+ auto fieldType = std::make_shared<FormField>(FormField::HiddenType);
+ fieldType->setName("FORM_TYPE");
+ fieldType->addValue("urn:xmpp:mix:0");
+ parameters->addField(fieldType);
+
+ auto fieldJIDVisibility = std::make_shared<FormField>();
+ fieldJIDVisibility->setName("JID Visibility");
+ fieldJIDVisibility->addValue("never");
+ parameters->addField(fieldJIDVisibility);
+
+ testling->joinChannelWithPreferences(nodes, parameters);
+
+ ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set));
+
+ //fake response
+ auto responseForm = std::make_shared<Form>();
+ responseForm->setType(Form::Type::ResultType);
+
+ auto fieldTypeResponse = std::make_shared<FormField>(FormField::HiddenType);
+ fieldTypeResponse->setName("FORM_TYPE");
+ fieldTypeResponse->addValue("urn:xmpp:mix:0");
+ responseForm->addField(fieldTypeResponse);
+
+ auto fieldJIDVisibilityResponse = std::make_shared<FormField>();
+ fieldJIDVisibilityResponse->setName("JID Visibility");
+ fieldJIDVisibilityResponse->addValue("never");
+ responseForm->addField(fieldJIDVisibilityResponse);
+
+ auto fieldprivateMessagesResponse = std::make_shared<FormField>();
+ fieldprivateMessagesResponse->setName("Private Messages");
+ fieldprivateMessagesResponse->addValue("allow");
+ responseForm->addField(fieldprivateMessagesResponse);
+
+ auto vCardResponse = std::make_shared<FormField>();
+ vCardResponse->setName("vCard");
+ vCardResponse->addValue("block");
+ responseForm->addField(vCardResponse);
+
+ channel_->onIQReceived(createJoinResult(nodes, responseForm));
+ ASSERT_EQ(static_cast<int>(1), successfulJoins_);
+ ASSERT_EQ(static_cast<int>(2), subscribedNodes_.size());
+ ASSERT_TRUE(preferenceForm_);
+
+ ASSERT_TRUE(preferenceForm_->getField("JID Visibility"));
+ ASSERT_EQ(std::string("never"), preferenceForm_->getField("JID Visibility")->getTextSingleValue());
+}
+
+TEST_F(MIXImplTest, preferenceFormRequest) {
+ MIX::ref testling = createMIXClient();
+ testling->requestPreferencesForm();
+
+ ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size()));
+ ASSERT_TRUE(channel_->isRequestAtIndex<MIXUserPreference>(0, channelJID_, IQ::Get));
+
+ //fake response
+ auto responseForm = std::make_shared<Form>();
+ responseForm->setType(Form::Type::FormType);
+
+ auto fieldTypeResponse = std::make_shared<FormField>(FormField::HiddenType);
+ fieldTypeResponse->setName("FORM_TYPE");
+ fieldTypeResponse->addValue("urn:xmpp:mix:0");
+ responseForm->addField(fieldTypeResponse);
+
+ auto preferenceResponse = std::make_shared<MIXUserPreference>();
+ preferenceResponse->setData(responseForm);
+
+ channel_->onIQReceived(IQ::createResult(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID(), preferenceResponse));
+ ASSERT_TRUE(preferenceForm_);
+}
diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp
index 511c88a..e0922ae 100644
--- a/Swiften/MUC/MUCBookmarkManager.cpp
+++ b/Swiften/MUC/MUCBookmarkManager.cpp
@@ -1,11 +1,12 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/MUC/MUCBookmarkManager.h>
+#include <algorithm>
#include <memory>
#include <boost/bind.hpp>
@@ -30,9 +31,10 @@ void MUCBookmarkManager::handleBookmarksReceived(std::shared_ptr<Storage> payloa
}
ready_ = true;
+ handlingReceivedBookmarks_ = true;
onBookmarksReady();
- storage = payload;
+ storage_ = payload;
std::vector<MUCBookmark> receivedBookmarks;
for (const auto& room : payload->getRooms()) {
@@ -47,18 +49,25 @@ void MUCBookmarkManager::handleBookmarksReceived(std::shared_ptr<Storage> payloa
onBookmarkRemoved(oldBookmark);
}
}
-
+ std::vector<MUCBookmark> newAddedBookmarksToBeSignaled;
for (const auto& newBookmark : receivedBookmarks) {
if (!containsEquivalent(bookmarks_, newBookmark)) {
newBookmarks.push_back(newBookmark);
- onBookmarkAdded(newBookmark);
+ //If the bookmark does not exist in bookmark manager, after emmiting the signal, chatsmanager will try to join the room, if the bookmark has autojoin to true.
+ //The bookmark is not yet available in bookmark manager, therefore a new bookmark will be created which will be lost when newBookmarks replace bookmarks.
+ newAddedBookmarksToBeSignaled.push_back(newBookmark);
}
}
bookmarks_ = newBookmarks;
+ for (auto bookmark : newAddedBookmarksToBeSignaled) {
+ onBookmarkAdded(bookmark);
+ }
+
+ handlingReceivedBookmarks_ = false;
}
bool MUCBookmarkManager::containsEquivalent(const std::vector<MUCBookmark>& list, const MUCBookmark& bookmark) {
- return std::find(list.begin(), list.end(), bookmark) != list.end();
+ return std::find_if(list.begin(), list.end(), [&](const MUCBookmark& val) { return bookmark.getRoom() == val.getRoom(); }) != list.end();
}
void MUCBookmarkManager::replaceBookmark(const MUCBookmark& oldBookmark, const MUCBookmark& newBookmark) {
@@ -76,8 +85,15 @@ void MUCBookmarkManager::replaceBookmark(const MUCBookmark& oldBookmark, const M
void MUCBookmarkManager::addBookmark(const MUCBookmark& bookmark) {
if (!ready_) return;
- bookmarks_.push_back(bookmark);
- onBookmarkAdded(bookmark);
+ if (auto found = lookupBookmark(bookmark.getRoom())) {
+ if (found != bookmark) {
+ replaceBookmark(found.get(), bookmark);
+ }
+ }
+ else {
+ bookmarks_.push_back(bookmark);
+ onBookmarkAdded(bookmark);
+ }
flush();
}
@@ -96,17 +112,20 @@ void MUCBookmarkManager::removeBookmark(const MUCBookmark& bookmark) {
}
void MUCBookmarkManager::flush() {
- if (!storage) {
- storage = std::make_shared<Storage>();
+ if (handlingReceivedBookmarks_) {
+ return;
+ }
+ if (!storage_) {
+ storage_ = std::make_shared<Storage>();
}
// Update the storage element
- storage->clearRooms();
+ storage_->clearRooms();
for (const auto& bookmark : bookmarks_) {
- storage->addRoom(bookmark.toStorage());
+ storage_->addRoom(bookmark.toStorage());
}
// Send an iq to save the storage element
- SetPrivateStorageRequest<Storage>::ref request = SetPrivateStorageRequest<Storage>::create(storage, iqRouter_);
+ SetPrivateStorageRequest<Storage>::ref request = SetPrivateStorageRequest<Storage>::create(storage_, iqRouter_);
// FIXME: We should care about the result
//request->onResponse.connect(boost::bind(&MUCBookmarkManager::handleBookmarksSet, this, _1, _2));
request->send();
@@ -116,4 +135,12 @@ const std::vector<MUCBookmark>& MUCBookmarkManager::getBookmarks() const {
return bookmarks_;
}
+boost::optional<MUCBookmark> MUCBookmarkManager::lookupBookmark(const JID& bookmarkJID) const {
+ auto bookmarkIterator = std::find_if(bookmarks_.begin(), bookmarks_.end(), [&](const MUCBookmark& val) { return bookmarkJID == val.getRoom(); });
+ if (bookmarkIterator != bookmarks_.end()) {
+ return *bookmarkIterator;
+ }
+ return boost::none;
+}
+
}
diff --git a/Swiften/MUC/MUCBookmarkManager.h b/Swiften/MUC/MUCBookmarkManager.h
index 78fbbb0..1ef227d 100644
--- a/Swiften/MUC/MUCBookmarkManager.h
+++ b/Swiften/MUC/MUCBookmarkManager.h
@@ -27,8 +27,8 @@ namespace Swift {
void addBookmark(const MUCBookmark& bookmark);
void removeBookmark(const MUCBookmark& bookmark);
void replaceBookmark(const MUCBookmark& oldBookmark, const MUCBookmark& newBookmark);
-
const std::vector<MUCBookmark>& getBookmarks() const;
+ boost::optional<MUCBookmark> lookupBookmark(const JID& bookmarkJID) const;
public:
boost::signals2::signal<void (const MUCBookmark&)> onBookmarkAdded;
@@ -45,8 +45,9 @@ namespace Swift {
private:
bool ready_;
+ bool handlingReceivedBookmarks_;
std::vector<MUCBookmark> bookmarks_;
IQRouter* iqRouter_;
- std::shared_ptr<Storage> storage;
+ std::shared_ptr<Storage> storage_;
};
}
diff --git a/Swiften/MUC/MUCImpl.cpp b/Swiften/MUC/MUCImpl.cpp
index 029bb4b..d2b33f3 100644
--- a/Swiften/MUC/MUCImpl.cpp
+++ b/Swiften/MUC/MUCImpl.cpp
@@ -371,7 +371,7 @@ void MUCImpl::changeAffiliation(const JID& jid, MUCOccupant::Affiliation affilia
MUCAdminPayload::ref mucPayload = std::make_shared<MUCAdminPayload>();
MUCItem item;
item.affiliation = affiliation;
- item.realJID = jid.toBare();
+ item.realJID = jid;
mucPayload->addItem(item);
std::shared_ptr<GenericRequest<MUCAdminPayload> > request = std::make_shared<GenericRequest<MUCAdminPayload> >(IQ::Set, getJID(), mucPayload, iqRouter_);
request->onResponse.connect(boost::bind(&MUCImpl::handleAffiliationChangeResponse, this, _1, _2, jid, affiliation));
diff --git a/Swiften/Network/BOSHConnection.cpp b/Swiften/Network/BOSHConnection.cpp
index b4ffa7d..aaec9f2 100644
--- a/Swiften/Network/BOSHConnection.cpp
+++ b/Swiften/Network/BOSHConnection.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2011-2017 Isode Limited.
+ * Copyright (c) 2011-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -27,6 +27,7 @@
#include <Swiften/StreamStack/DummyStreamLayer.h>
#include <Swiften/StreamStack/TLSLayer.h>
#include <Swiften/TLS/TLSContext.h>
+#include <Swiften/TLS/TLSContextFactory.h>
#include <Swiften/TLS/TLSOptions.h>
namespace Swift {
@@ -42,7 +43,8 @@ BOSHConnection::BOSHConnection(const URL& boshURL, Connector::ref connector, XML
connectionReady_(false)
{
if (boshURL_.getScheme() == "https") {
- tlsLayer_ = std::make_shared<TLSLayer>(tlsContextFactory, tlsOptions);
+ auto tlsContext = tlsContextFactory->createTLSContext(tlsOptions);
+ tlsLayer_ = std::make_shared<TLSLayer>(std::move(tlsContext));
// The following dummyLayer_ is needed as the TLSLayer will pass the decrypted data to its parent layer.
// The dummyLayer_ will serve as the parent layer.
dummyLayer_ = std::make_shared<DummyStreamLayer>(tlsLayer_.get());
@@ -91,8 +93,8 @@ void BOSHConnection::handleRawDataRead(std::shared_ptr<SafeByteArray> data) {
tlsLayer_->handleDataRead(*data.get());
}
-void BOSHConnection::handleTLSError(std::shared_ptr<TLSError> /* error */) {
-
+void BOSHConnection::handleTLSError(std::shared_ptr<TLSError> error) {
+ SWIFT_LOG(debug) << (error ? error->getMessage() : "Unknown TLS error") << std::endl;
}
void BOSHConnection::writeData(const SafeByteArray& data) {
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index 0de7b25..551363d 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -14,7 +14,6 @@
#include <boost/asio/placeholders.hpp>
#include <boost/asio/write.hpp>
#include <boost/bind.hpp>
-#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/Algorithm.h>
#include <Swiften/Base/ByteArray.h>
@@ -64,7 +63,7 @@ void BoostConnection::listen() {
void BoostConnection::connect(const HostAddressPort& addressPort) {
boost::asio::ip::tcp::endpoint endpoint(
- boost::asio::ip::address::from_string(addressPort.getAddress().toString()), boost::numeric_cast<unsigned short>(addressPort.getPort()));
+ boost::asio::ip::address::from_string(addressPort.getAddress().toString()), addressPort.getPort());
socket_.async_connect(
endpoint,
boost::bind(&BoostConnection::handleConnectFinished, shared_from_this(), boost::asio::placeholders::error));
diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp
index 34b5799..8db9656 100644
--- a/Swiften/Network/BoostConnectionServer.cpp
+++ b/Swiften/Network/BoostConnectionServer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -19,10 +19,10 @@
namespace Swift {
-BoostConnectionServer::BoostConnectionServer(int port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(nullptr) {
+BoostConnectionServer::BoostConnectionServer(unsigned short port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(nullptr) {
}
-BoostConnectionServer::BoostConnectionServer(const HostAddress &address, int port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : address_(address), port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(nullptr) {
+BoostConnectionServer::BoostConnectionServer(const HostAddress &address, unsigned short port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : address_(address), port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(nullptr) {
}
void BoostConnectionServer::start() {
@@ -37,10 +37,10 @@ boost::optional<BoostConnectionServer::Error> BoostConnectionServer::tryStart()
assert(!acceptor_);
boost::asio::ip::tcp::endpoint endpoint;
if (address_.isValid()) {
- endpoint = boost::asio::ip::tcp::endpoint(address_.getRawAddress(), boost::numeric_cast<unsigned short>(port_));
+ endpoint = boost::asio::ip::tcp::endpoint(address_.getRawAddress(), port_);
}
else {
- endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), boost::numeric_cast<unsigned short>(port_));
+ endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), port_);
}
acceptor_ = new boost::asio::ip::tcp::acceptor(*ioService_, endpoint);
if (endpoint.protocol() == boost::asio::ip::tcp::v6()) {
@@ -58,6 +58,9 @@ boost::optional<BoostConnectionServer::Error> BoostConnectionServer::tryStart()
return UnknownError;
}
}
+ catch (const boost::numeric::bad_numeric_cast&) {
+ return UnknownError;
+ }
return boost::optional<Error>();
}
diff --git a/Swiften/Network/BoostConnectionServer.h b/Swiften/Network/BoostConnectionServer.h
index 3dd9830..917d638 100644
--- a/Swiften/Network/BoostConnectionServer.h
+++ b/Swiften/Network/BoostConnectionServer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -23,11 +23,11 @@ namespace Swift {
public:
typedef std::shared_ptr<BoostConnectionServer> ref;
- static ref create(int port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) {
+ static ref create(unsigned short port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) {
return ref(new BoostConnectionServer(port, ioService, eventLoop));
}
- static ref create(const HostAddress &address, int port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) {
+ static ref create(const HostAddress &address, unsigned short port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) {
return ref(new BoostConnectionServer(address, port, ioService, eventLoop));
}
@@ -40,8 +40,8 @@ namespace Swift {
boost::signals2::signal<void (boost::optional<Error>)> onStopped;
private:
- BoostConnectionServer(int port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop);
- BoostConnectionServer(const HostAddress &address, int port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop);
+ BoostConnectionServer(unsigned short port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop);
+ BoostConnectionServer(const HostAddress &address, unsigned short port, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop);
void stop(boost::optional<Error> e);
void acceptNextConnection();
@@ -49,7 +49,7 @@ namespace Swift {
private:
HostAddress address_;
- int port_;
+ unsigned short port_;
std::shared_ptr<boost::asio::io_service> ioService_;
EventLoop* eventLoop;
boost::asio::ip::tcp::acceptor* acceptor_;
diff --git a/Swiften/Network/BoostConnectionServerFactory.cpp b/Swiften/Network/BoostConnectionServerFactory.cpp
index 8b3fd2f..6936453 100644
--- a/Swiften/Network/BoostConnectionServerFactory.cpp
+++ b/Swiften/Network/BoostConnectionServerFactory.cpp
@@ -19,11 +19,11 @@ namespace Swift {
BoostConnectionServerFactory::BoostConnectionServerFactory(std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : ioService(ioService), eventLoop(eventLoop) {
}
-std::shared_ptr<ConnectionServer> BoostConnectionServerFactory::createConnectionServer(int port) {
+std::shared_ptr<ConnectionServer> BoostConnectionServerFactory::createConnectionServer(unsigned short port) {
return BoostConnectionServer::create(port, ioService, eventLoop);
}
-std::shared_ptr<ConnectionServer> BoostConnectionServerFactory::createConnectionServer(const Swift::HostAddress &hostAddress, int port) {
+std::shared_ptr<ConnectionServer> BoostConnectionServerFactory::createConnectionServer(const Swift::HostAddress &hostAddress, unsigned short port) {
return BoostConnectionServer::create(hostAddress, port, ioService, eventLoop);
}
diff --git a/Swiften/Network/BoostConnectionServerFactory.h b/Swiften/Network/BoostConnectionServerFactory.h
index 033e63d..956132b 100644
--- a/Swiften/Network/BoostConnectionServerFactory.h
+++ b/Swiften/Network/BoostConnectionServerFactory.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -25,9 +25,9 @@ namespace Swift {
public:
BoostConnectionServerFactory(std::shared_ptr<boost::asio::io_service>, EventLoop* eventLoop);
- virtual std::shared_ptr<ConnectionServer> createConnectionServer(int port);
+ virtual std::shared_ptr<ConnectionServer> createConnectionServer(unsigned short port);
- virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress &hostAddress, int port);
+ virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress &hostAddress, unsigned short port);
private:
std::shared_ptr<boost::asio::io_service> ioService;
diff --git a/Swiften/Network/BoostNetworkFactories.h b/Swiften/Network/BoostNetworkFactories.h
index 72afb04..2bf8d33 100644
--- a/Swiften/Network/BoostNetworkFactories.h
+++ b/Swiften/Network/BoostNetworkFactories.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,7 +7,6 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Network/BoostIOServiceThread.h>
#include <Swiften/Network/NetworkFactories.h>
@@ -24,13 +23,13 @@ namespace Swift {
* used for the construction of the BoostIOServiceThread.
*/
BoostNetworkFactories(EventLoop* eventLoop, std::shared_ptr<boost::asio::io_service> ioService = std::shared_ptr<boost::asio::io_service>());
- virtual ~BoostNetworkFactories();
+ virtual ~BoostNetworkFactories() override;
- virtual TimerFactory* getTimerFactory() const SWIFTEN_OVERRIDE {
+ virtual TimerFactory* getTimerFactory() const override {
return timerFactory;
}
- virtual ConnectionFactory* getConnectionFactory() const SWIFTEN_OVERRIDE {
+ virtual ConnectionFactory* getConnectionFactory() const override {
return connectionFactory;
}
@@ -38,41 +37,41 @@ namespace Swift {
return &ioServiceThread;
}
- DomainNameResolver* getDomainNameResolver() const SWIFTEN_OVERRIDE {
+ DomainNameResolver* getDomainNameResolver() const override {
return domainNameResolver;
}
- ConnectionServerFactory* getConnectionServerFactory() const SWIFTEN_OVERRIDE {
+ ConnectionServerFactory* getConnectionServerFactory() const override {
return connectionServerFactory;
}
- NetworkEnvironment* getNetworkEnvironment() const SWIFTEN_OVERRIDE {
+ NetworkEnvironment* getNetworkEnvironment() const override {
return networkEnvironment;
}
- NATTraverser* getNATTraverser() const SWIFTEN_OVERRIDE {
+ NATTraverser* getNATTraverser() const override {
return natTraverser;
}
- virtual XMLParserFactory* getXMLParserFactory() const SWIFTEN_OVERRIDE {
+ virtual XMLParserFactory* getXMLParserFactory() const override {
return xmlParserFactory;
}
- virtual TLSContextFactory* getTLSContextFactory() const SWIFTEN_OVERRIDE;
+ virtual TLSContextFactory* getTLSContextFactory() const override;
- virtual ProxyProvider* getProxyProvider() const SWIFTEN_OVERRIDE {
+ virtual ProxyProvider* getProxyProvider() const override {
return proxyProvider;
}
- virtual EventLoop* getEventLoop() const SWIFTEN_OVERRIDE {
+ virtual EventLoop* getEventLoop() const override {
return eventLoop;
}
- virtual IDNConverter* getIDNConverter() const SWIFTEN_OVERRIDE {
+ virtual IDNConverter* getIDNConverter() const override {
return idnConverter;
}
- virtual CryptoProvider* getCryptoProvider() const SWIFTEN_OVERRIDE {
+ virtual CryptoProvider* getCryptoProvider() const override {
return cryptoProvider;
}
diff --git a/Swiften/Network/ChainedConnector.cpp b/Swiften/Network/ChainedConnector.cpp
index ea55db3..94899ad 100644
--- a/Swiften/Network/ChainedConnector.cpp
+++ b/Swiften/Network/ChainedConnector.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -18,7 +18,7 @@ using namespace Swift;
ChainedConnector::ChainedConnector(
const std::string& hostname,
- int port,
+ unsigned short port,
const boost::optional<std::string>& serviceLookupPrefix,
DomainNameResolver* resolver,
const std::vector<ConnectionFactory*>& connectionFactories,
diff --git a/Swiften/Network/ChainedConnector.h b/Swiften/Network/ChainedConnector.h
index a00d7e5..9620293 100644
--- a/Swiften/Network/ChainedConnector.h
+++ b/Swiften/Network/ChainedConnector.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -26,7 +26,7 @@ namespace Swift {
class SWIFTEN_API ChainedConnector {
public:
- ChainedConnector(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver*, const std::vector<ConnectionFactory*>&, TimerFactory*);
+ ChainedConnector(const std::string& hostname, unsigned short port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver*, const std::vector<ConnectionFactory*>&, TimerFactory*);
~ChainedConnector();
void setTimeoutMilliseconds(int milliseconds);
@@ -42,7 +42,7 @@ namespace Swift {
private:
std::string hostname;
- int port;
+ unsigned short port;
boost::optional<std::string> serviceLookupPrefix;
DomainNameResolver* resolver;
std::vector<ConnectionFactory*> connectionFactories;
diff --git a/Swiften/Network/ConnectionServerFactory.h b/Swiften/Network/ConnectionServerFactory.h
index 413131e..2ebccc1 100644
--- a/Swiften/Network/ConnectionServerFactory.h
+++ b/Swiften/Network/ConnectionServerFactory.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -24,8 +24,8 @@ namespace Swift {
public:
virtual ~ConnectionServerFactory();
- virtual std::shared_ptr<ConnectionServer> createConnectionServer(int port) = 0;
+ virtual std::shared_ptr<ConnectionServer> createConnectionServer(unsigned short port) = 0;
- virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress& hostAddress, int port) = 0;
+ virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress& hostAddress, unsigned short port) = 0;
};
}
diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp
index 5eddaba..a0e6b23 100644
--- a/Swiften/Network/Connector.cpp
+++ b/Swiften/Network/Connector.cpp
@@ -17,7 +17,7 @@
namespace Swift {
-Connector::Connector(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), serviceLookupPrefix(serviceLookupPrefix), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0), queriedAllServices(true), foundSomeDNS(false) {
+Connector::Connector(const std::string& hostname, unsigned short port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), serviceLookupPrefix(serviceLookupPrefix), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0), queriedAllServices(true), foundSomeDNS(false) {
}
void Connector::setTimeoutMilliseconds(int milliseconds) {
@@ -29,13 +29,13 @@ void Connector::start() {
assert(!currentConnection);
assert(!serviceQuery);
assert(!timer);
- queriedAllServices = false;
auto hostAddress = HostAddress::fromString(hostname);
if (timeoutMilliseconds > 0) {
timer = timerFactory->createTimer(timeoutMilliseconds);
timer->onTick.connect(boost::bind(&Connector::handleTimeout, shared_from_this()));
}
if (serviceLookupPrefix) {
+ queriedAllServices = false;
serviceQuery = resolver->createServiceQuery(*serviceLookupPrefix, hostname);
serviceQuery->onResult.connect(boost::bind(&Connector::handleServiceQueryResult, shared_from_this(), _1));
serviceQuery->run();
@@ -122,7 +122,7 @@ void Connector::tryNextAddress() {
HostAddress address = addressQueryResults.front();
addressQueryResults.pop_front();
- int connectPort = (port == -1 ? 5222 : port);
+ unsigned short connectPort = (port == 0 ? 5222 : port);
if (!serviceQueryResults.empty()) {
connectPort = serviceQueryResults.front().port;
}
diff --git a/Swiften/Network/Connector.h b/Swiften/Network/Connector.h
index d8a1b88..c76a4af 100644
--- a/Swiften/Network/Connector.h
+++ b/Swiften/Network/Connector.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -30,7 +30,7 @@ namespace Swift {
public:
typedef std::shared_ptr<Connector> ref;
- static Connector::ref create(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) {
+ static Connector::ref create(const std::string& hostname, unsigned short port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) {
return ref(new Connector(hostname, port, serviceLookupPrefix, resolver, connectionFactory, timerFactory));
}
@@ -46,7 +46,7 @@ namespace Swift {
boost::signals2::signal<void (std::shared_ptr<Connection>, std::shared_ptr<Error>)> onConnectFinished;
private:
- Connector(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver*, ConnectionFactory*, TimerFactory*);
+ Connector(const std::string& hostname, unsigned short port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver*, ConnectionFactory*, TimerFactory*);
void handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result);
void handleAddressQueryResult(const std::vector<HostAddress>& address, boost::optional<DomainNameResolveError> error);
@@ -63,7 +63,7 @@ namespace Swift {
private:
std::string hostname;
- int port;
+ unsigned short port;
boost::optional<std::string> serviceLookupPrefix;
DomainNameResolver* resolver;
ConnectionFactory* connectionFactory;
diff --git a/Swiften/Network/DomainNameServiceQuery.cpp b/Swiften/Network/DomainNameServiceQuery.cpp
index 708bbce..5784dd7 100644
--- a/Swiften/Network/DomainNameServiceQuery.cpp
+++ b/Swiften/Network/DomainNameServiceQuery.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,15 +11,11 @@
#include <iterator>
#include <numeric>
-#include <boost/lambda/bind.hpp>
-#include <boost/lambda/lambda.hpp>
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/typeof/typeof.hpp>
#include <Swiften/Base/RandomGenerator.h>
using namespace Swift;
-namespace lambda = boost::lambda;
namespace {
struct ResultPriorityComparator {
@@ -43,19 +39,25 @@ void DomainNameServiceQuery::sortResults(std::vector<DomainNameServiceQuery::Res
std::vector<DomainNameServiceQuery::Result>::iterator next = std::upper_bound(i, queries.end(), *i, comparator);
if (std::distance(i, next) > 1) {
std::vector<int> weights;
- std::transform(i, next, std::back_inserter(weights),
- /* easy hack to account for '0' weights getting at least some weight */
- lambda::bind(&Result::weight, lambda::_1) + 1);
- for (int j = 0; j < boost::numeric_cast<int>(weights.size() - 1); ++j) {
- std::vector<int> cumulativeWeights;
- std::partial_sum(
- weights.begin() + j,
- weights.end(),
- std::back_inserter(cumulativeWeights));
- int randomNumber = generator.generateRandomInteger(cumulativeWeights.back());
- BOOST_AUTO(selectedIndex, std::lower_bound(cumulativeWeights.begin(), cumulativeWeights.end(), randomNumber) - cumulativeWeights.begin());
- std::swap(i[j], i[j + selectedIndex]);
- std::swap(weights.begin()[j], weights.begin()[j + selectedIndex]);
+ std::transform(i, next, std::back_inserter(weights), [](const DomainNameServiceQuery::Result& result) {
+ /* easy hack to account for '0' weights getting at least some weight */
+ return result.weight + 1;
+ });
+ try {
+ for (int j = 0; j < boost::numeric_cast<int>(weights.size()) - 1; ++j) {
+ std::vector<int> cumulativeWeights;
+ std::partial_sum(
+ weights.begin() + j,
+ weights.end(),
+ std::back_inserter(cumulativeWeights));
+ int randomNumber = generator.generateRandomInteger(cumulativeWeights.back());
+ auto selectedIndex = std::lower_bound(cumulativeWeights.begin(), cumulativeWeights.end(), randomNumber) - cumulativeWeights.begin();
+ std::swap(i[j], i[j + selectedIndex]);
+ std::swap(weights.begin()[j], weights.begin()[j + selectedIndex]);
+ }
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ // In the unlikely event of weights.size() being too large, use the list as-is.
}
}
i = next;
diff --git a/Swiften/Network/DomainNameServiceQuery.h b/Swiften/Network/DomainNameServiceQuery.h
index b27f32e..1631b99 100644
--- a/Swiften/Network/DomainNameServiceQuery.h
+++ b/Swiften/Network/DomainNameServiceQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -24,9 +24,9 @@ namespace Swift {
typedef std::shared_ptr<DomainNameServiceQuery> ref;
struct Result {
- Result(const std::string& hostname = "", int port = -1, int priority = -1, int weight = -1) : hostname(hostname), port(port), priority(priority), weight(weight) {}
+ Result(const std::string& hostname = "", unsigned short port = 0, int priority = -1, int weight = -1) : hostname(hostname), port(port), priority(priority), weight(weight) {}
std::string hostname;
- int port;
+ unsigned short port;
int priority;
int weight;
};
diff --git a/Swiften/Network/DummyConnectionServer.h b/Swiften/Network/DummyConnectionServer.h
index 970cbb7..a4fd07f 100644
--- a/Swiften/Network/DummyConnectionServer.h
+++ b/Swiften/Network/DummyConnectionServer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,8 +17,8 @@
namespace Swift {
class SWIFTEN_API DummyConnectionServer : public ConnectionServer, public EventOwner, public std::enable_shared_from_this<DummyConnectionServer> {
public:
- DummyConnectionServer(EventLoop* /*eventLoop*/, int port) : localAddressPort(HostAddress(), port) {}
- DummyConnectionServer(EventLoop* /*eventLoop*/, const Swift::HostAddress& hostAddress, int port) : localAddressPort(hostAddress, port) {}
+ DummyConnectionServer(EventLoop* /*eventLoop*/, unsigned short port) : localAddressPort(HostAddress(), port) {}
+ DummyConnectionServer(EventLoop* /*eventLoop*/, const Swift::HostAddress& hostAddress, unsigned short port) : localAddressPort(hostAddress, port) {}
virtual ~DummyConnectionServer() {}
virtual HostAddressPort getAddressPort() const {
diff --git a/Swiften/Network/DummyConnectionServerFactory.h b/Swiften/Network/DummyConnectionServerFactory.h
index 822f95f..4b25118 100644
--- a/Swiften/Network/DummyConnectionServerFactory.h
+++ b/Swiften/Network/DummyConnectionServerFactory.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,11 +20,11 @@ public:
DummyConnectionServerFactory(EventLoop* eventLoop) : eventLoop(eventLoop) {}
virtual ~DummyConnectionServerFactory() {}
- virtual std::shared_ptr<ConnectionServer> createConnectionServer(int port) {
+ virtual std::shared_ptr<ConnectionServer> createConnectionServer(unsigned short port) {
return std::make_shared<DummyConnectionServer>(eventLoop, port);
}
- virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress& hostAddress, int port) {
+ virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress& hostAddress, unsigned short port) {
return std::make_shared<DummyConnectionServer>(eventLoop, hostAddress, port);
}
diff --git a/Swiften/Network/EnvironmentProxyProvider.cpp b/Swiften/Network/EnvironmentProxyProvider.cpp
index 8edb136..65cf4ff 100644
--- a/Swiften/Network/EnvironmentProxyProvider.cpp
+++ b/Swiften/Network/EnvironmentProxyProvider.cpp
@@ -17,6 +17,8 @@
#include <iostream>
+#include <boost/numeric/conversion/cast.hpp>
+
#include <Swiften/Base/Log.h>
namespace Swift {
@@ -38,7 +40,7 @@ HostAddressPort EnvironmentProxyProvider::getSOCKS5Proxy() const {
HostAddressPort EnvironmentProxyProvider::getFromEnv(const char* envVarName, std::string proxyProtocol) {
char* envVar = nullptr;
std::string address;
- int port = 0;
+ unsigned short port = 0;
envVar = getenv(envVarName);
@@ -46,7 +48,11 @@ HostAddressPort EnvironmentProxyProvider::getFromEnv(const char* envVarName, std
address = envVar != nullptr ? envVar : "0.0.0.0";
if(envVar != nullptr && address.compare(0, proxyProtocol.length(), proxyProtocol) == 0) {
address = address.substr(proxyProtocol.length(), address.length());
- port = atoi(address.substr(address.find(':') + 1, address.length()).c_str());
+ try {
+ port = boost::numeric_cast<unsigned short>(atoi(address.substr(address.find(':') + 1, address.length()).c_str()));
+ }
+ catch (boost::numeric::bad_numeric_cast&) {
+ }
address = address.substr(0, address.find(':'));
}
diff --git a/Swiften/Network/GConfProxyProvider.cpp b/Swiften/Network/GConfProxyProvider.cpp
index eade450..7c31868 100644
--- a/Swiften/Network/GConfProxyProvider.cpp
+++ b/Swiften/Network/GConfProxyProvider.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2016-2017 Isode Limited.
+ * Copyright (c) 2016-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -21,6 +21,8 @@ extern "C" {
#include <gconf/gconf-client.h>
}
+#include <boost/numeric/conversion/cast.hpp>
+
#include <Swiften/Base/Log.h>
namespace Swift {
@@ -50,13 +52,17 @@ HostAddressPort GConfProxyProvider::getSOCKS5Proxy() const {
HostAddressPort GConfProxyProvider::getFromGConf(const char* gcHost, const char* gcPort) {
std::string address;
- int port = 0;
+ unsigned short port = 0;
gchar* str;
GConfClient* client = gconf_client_get_default();
str = gconf_client_get_string(client, gcHost, NULL);
- port = static_cast<int> (gconf_client_get_int(client, gcPort, NULL));
+ try {
+ port = boost::numeric_cast<unsigned short>(gconf_client_get_int(client, gcPort, NULL));
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ }
if(str) {
address = static_cast<char*> (str);
diff --git a/Swiften/Network/HTTPConnectProxiedConnection.cpp b/Swiften/Network/HTTPConnectProxiedConnection.cpp
index b5e521b..8eba49e 100644
--- a/Swiften/Network/HTTPConnectProxiedConnection.cpp
+++ b/Swiften/Network/HTTPConnectProxiedConnection.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -36,7 +36,7 @@ HTTPConnectProxiedConnection::HTTPConnectProxiedConnection(
ConnectionFactory* connectionFactory,
TimerFactory* timerFactory,
const std::string& proxyHost,
- int proxyPort,
+ unsigned short proxyPort,
const SafeString& authID,
const SafeString& authPassword) :
ProxiedConnection(resolver, connectionFactory, timerFactory, proxyHost, proxyPort),
diff --git a/Swiften/Network/HTTPConnectProxiedConnection.h b/Swiften/Network/HTTPConnectProxiedConnection.h
index 6592839..a83d47c 100644
--- a/Swiften/Network/HTTPConnectProxiedConnection.h
+++ b/Swiften/Network/HTTPConnectProxiedConnection.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2011-2017 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -30,14 +30,14 @@ namespace Swift {
virtual ~HTTPConnectProxiedConnection();
- static ref create(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort, const SafeString& authID, const SafeString& authPassword) {
+ static ref create(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort, const SafeString& authID, const SafeString& authPassword) {
return ref(new HTTPConnectProxiedConnection(resolver, connectionFactory, timerFactory, proxyHost, proxyPort, authID, authPassword));
}
void setHTTPTrafficFilter(std::shared_ptr<HTTPTrafficFilter> trafficFilter);
private:
- HTTPConnectProxiedConnection(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort, const SafeString& authID, const SafeString& authPassword);
+ HTTPConnectProxiedConnection(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort, const SafeString& authID, const SafeString& authPassword);
virtual void initializeProxy();
virtual void handleProxyInitializeData(std::shared_ptr<SafeByteArray> data);
diff --git a/Swiften/Network/HTTPConnectProxiedConnectionFactory.cpp b/Swiften/Network/HTTPConnectProxiedConnectionFactory.cpp
index 91ace3d..54b998a 100644
--- a/Swiften/Network/HTTPConnectProxiedConnectionFactory.cpp
+++ b/Swiften/Network/HTTPConnectProxiedConnectionFactory.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -16,11 +16,11 @@
namespace Swift {
-HTTPConnectProxiedConnectionFactory::HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter) : resolver_(resolver), connectionFactory_(connectionFactory), timerFactory_(timerFactory), proxyHost_(proxyHost), proxyPort_(proxyPort), authID_(""), authPassword_(""), httpTrafficFilter_(httpTrafficFilter) {
+HTTPConnectProxiedConnectionFactory::HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter) : resolver_(resolver), connectionFactory_(connectionFactory), timerFactory_(timerFactory), proxyHost_(proxyHost), proxyPort_(proxyPort), authID_(""), authPassword_(""), httpTrafficFilter_(httpTrafficFilter) {
}
-HTTPConnectProxiedConnectionFactory::HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort, const SafeString& authID, const SafeString& authPassword, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter) : resolver_(resolver), connectionFactory_(connectionFactory), timerFactory_(timerFactory), proxyHost_(proxyHost), proxyPort_(proxyPort), authID_(authID), authPassword_(authPassword), httpTrafficFilter_(httpTrafficFilter) {
+HTTPConnectProxiedConnectionFactory::HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort, const SafeString& authID, const SafeString& authPassword, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter) : resolver_(resolver), connectionFactory_(connectionFactory), timerFactory_(timerFactory), proxyHost_(proxyHost), proxyPort_(proxyPort), authID_(authID), authPassword_(authPassword), httpTrafficFilter_(httpTrafficFilter) {
}
std::shared_ptr<Connection> HTTPConnectProxiedConnectionFactory::createConnection() {
diff --git a/Swiften/Network/HTTPConnectProxiedConnectionFactory.h b/Swiften/Network/HTTPConnectProxiedConnectionFactory.h
index 395f64f..7a5f527 100644
--- a/Swiften/Network/HTTPConnectProxiedConnectionFactory.h
+++ b/Swiften/Network/HTTPConnectProxiedConnectionFactory.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2017 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -24,8 +24,8 @@ namespace Swift {
class SWIFTEN_API HTTPConnectProxiedConnectionFactory : public ConnectionFactory {
public:
- HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter = std::shared_ptr<HTTPTrafficFilter>());
- HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort, const SafeString& authID, const SafeString& authPassword, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter = std::shared_ptr<HTTPTrafficFilter>());
+ HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter = std::shared_ptr<HTTPTrafficFilter>());
+ HTTPConnectProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort, const SafeString& authID, const SafeString& authPassword, std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter = std::shared_ptr<HTTPTrafficFilter>());
virtual std::shared_ptr<Connection> createConnection();
@@ -34,7 +34,7 @@ namespace Swift {
ConnectionFactory* connectionFactory_;
TimerFactory* timerFactory_;
std::string proxyHost_;
- int proxyPort_;
+ unsigned short proxyPort_;
SafeString authID_;
SafeString authPassword_;
std::shared_ptr<HTTPTrafficFilter> httpTrafficFilter_;
diff --git a/Swiften/Network/HostAddress.h b/Swiften/Network/HostAddress.h
index e4ddffb..7a22cf4 100644
--- a/Swiften/Network/HostAddress.h
+++ b/Swiften/Network/HostAddress.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -27,6 +27,10 @@ namespace Swift {
return address_ == o.address_;
}
+ bool operator<(const HostAddress& o) const {
+ return address_ < o.address_;
+ }
+
bool isValid() const;
bool isLocalhost() const;
diff --git a/Swiften/Network/HostAddressPort.cpp b/Swiften/Network/HostAddressPort.cpp
index 76c276e..248be2d 100644
--- a/Swiften/Network/HostAddressPort.cpp
+++ b/Swiften/Network/HostAddressPort.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,7 @@
using namespace Swift;
-HostAddressPort::HostAddressPort(const HostAddress& address, int port) : address_(address), port_(port) {
+HostAddressPort::HostAddressPort(const HostAddress& address, unsigned short port) : address_(address), port_(port) {
}
HostAddressPort::HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint) {
@@ -21,7 +21,7 @@ HostAddressPort::HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint)
std::string HostAddressPort::toString() const {
std::string portAsString;
try {
- portAsString = boost::lexical_cast<std::string>(getPort());
+ portAsString = std::to_string(getPort());
} catch (boost::bad_lexical_cast&) {
}
return getAddress().toString() + ":" + portAsString;
diff --git a/Swiften/Network/HostAddressPort.h b/Swiften/Network/HostAddressPort.h
index e42e1d1..759af01 100644
--- a/Swiften/Network/HostAddressPort.h
+++ b/Swiften/Network/HostAddressPort.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -14,14 +14,14 @@
namespace Swift {
class SWIFTEN_API HostAddressPort {
public:
- HostAddressPort(const HostAddress& address = HostAddress(), int port = -1);
+ HostAddressPort(const HostAddress& address = HostAddress(), unsigned short port = 0);
HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint);
const HostAddress& getAddress() const {
return address_;
}
- int getPort() const {
+ unsigned short getPort() const {
return port_;
}
@@ -29,6 +29,13 @@ namespace Swift {
return address_ == o.address_ && port_ == o.port_;
}
+ bool operator<(const HostAddressPort& o) const {
+ if (address_ < o.address_) {
+ return true;
+ }
+ return address_ == o.address_ && port_ < o.port_;
+ }
+
bool isValid() const {
return address_.isValid() && port_ > 0;
}
@@ -37,6 +44,6 @@ namespace Swift {
private:
HostAddress address_;
- int port_;
+ unsigned short port_;
};
}
diff --git a/Swiften/Network/MacOSXProxyProvider.cpp b/Swiften/Network/MacOSXProxyProvider.cpp
index 232fc60..d3b10dd 100644
--- a/Swiften/Network/MacOSXProxyProvider.cpp
+++ b/Swiften/Network/MacOSXProxyProvider.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -40,13 +40,15 @@ static HostAddressPort getFromDictionary(CFDictionaryRef dict, CFStringRef enabl
CFRelease(zero);
if(result != kCFCompareEqualTo) {
- int port = 0;
+ unsigned short port = 0;
std::string host = "";
try {
CFNumberRef numberValue = reinterpret_cast<CFNumberRef> (CFDictionaryGetValue(dict, portKey));
if(numberValue != nullptr) {
- CFNumberGetValue(numberValue, kCFNumberIntType, &port);
+ int intPort = 0;
+ CFNumberGetValue(numberValue, kCFNumberIntType, &intPort);
+ port = boost::numeric_cast<unsigned short>(intPort);
}
CFStringRef stringValue = reinterpret_cast<CFStringRef> (CFDictionaryGetValue(dict, hostKey));
diff --git a/Swiften/Network/MiniUPnPInterface.cpp b/Swiften/Network/MiniUPnPInterface.cpp
index dbe8bcd..8425c77 100644
--- a/Swiften/Network/MiniUPnPInterface.cpp
+++ b/Swiften/Network/MiniUPnPInterface.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -14,8 +14,6 @@
#include <memory>
-#include <boost/lexical_cast.hpp>
-
#include <miniupnpc.h>
#include <upnpcommands.h>
#include <upnperrors.h>
@@ -73,16 +71,16 @@ boost::optional<HostAddress> MiniUPnPInterface::getPublicIP() {
}
}
-boost::optional<NATPortMapping> MiniUPnPInterface::addPortForward(int actualLocalPort, int actualPublicPort) {
+boost::optional<NATPortMapping> MiniUPnPInterface::addPortForward(unsigned short actualLocalPort, unsigned short actualPublicPort) {
if (!p->isValid) {
return boost::optional<NATPortMapping>();
}
NATPortMapping mapping(actualLocalPort, actualPublicPort, NATPortMapping::TCP);
- std::string publicPort = boost::lexical_cast<std::string>(mapping.getPublicPort());
- std::string localPort = boost::lexical_cast<std::string>(mapping.getLocalPort());
- std::string leaseSeconds = boost::lexical_cast<std::string>(mapping.getLeaseInSeconds());
+ std::string publicPort = std::to_string(mapping.getPublicPort());
+ std::string localPort = std::to_string(mapping.getLocalPort());
+ std::string leaseSeconds = std::to_string(mapping.getLeaseInSeconds());
int ret = UPNP_AddPortMapping(
p->urls.controlURL,
@@ -107,9 +105,9 @@ bool MiniUPnPInterface::removePortForward(const NATPortMapping& mapping) {
return false;
}
- std::string publicPort = boost::lexical_cast<std::string>(mapping.getPublicPort());
- std::string localPort = boost::lexical_cast<std::string>(mapping.getLocalPort());
- std::string leaseSeconds = boost::lexical_cast<std::string>(mapping.getLeaseInSeconds());
+ std::string publicPort = std::to_string(mapping.getPublicPort());
+ std::string localPort = std::to_string(mapping.getLocalPort());
+ std::string leaseSeconds = std::to_string(mapping.getLeaseInSeconds());
int ret = UPNP_DeletePortMapping(p->urls.controlURL, p->data.first.servicetype, publicPort.c_str(), mapping.getProtocol() == NATPortMapping::TCP ? "TCP" : "UDP", nullptr);
return ret == UPNPCOMMAND_SUCCESS;
diff --git a/Swiften/Network/MiniUPnPInterface.h b/Swiften/Network/MiniUPnPInterface.h
index 89457b8..8c68268 100644
--- a/Swiften/Network/MiniUPnPInterface.h
+++ b/Swiften/Network/MiniUPnPInterface.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
@@ -23,7 +23,7 @@ namespace Swift {
virtual bool isAvailable();
boost::optional<HostAddress> getPublicIP();
- boost::optional<NATPortMapping> addPortForward(int localPort, int publicPort);
+ boost::optional<NATPortMapping> addPortForward(unsigned short localPort, unsigned short publicPort);
bool removePortForward(const NATPortMapping&);
private:
diff --git a/Swiften/Network/NATPMPInterface.cpp b/Swiften/Network/NATPMPInterface.cpp
index 5e0b3b3..0c33c1f 100644
--- a/Swiften/Network/NATPMPInterface.cpp
+++ b/Swiften/Network/NATPMPInterface.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -14,8 +14,6 @@
#include <memory>
-#include <boost/numeric/conversion/cast.hpp>
-
#include <Swiften/Base/Log.h>
// This has to be included after the previous headers, because of WIN32 macro
@@ -74,14 +72,14 @@ boost::optional<HostAddress> NATPMPInterface::getPublicIP() {
}
}
-boost::optional<NATPortMapping> NATPMPInterface::addPortForward(int localPort, int publicPort) {
+boost::optional<NATPortMapping> NATPMPInterface::addPortForward(unsigned short localPort, unsigned short publicPort) {
NATPortMapping mapping(localPort, publicPort, NATPortMapping::TCP);
if (sendnewportmappingrequest(
&p->natpmp,
mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP,
- boost::numeric_cast<uint16_t>(mapping.getLocalPort()),
- boost::numeric_cast<uint16_t>(mapping.getPublicPort()),
- boost::numeric_cast<uint32_t>(mapping.getLeaseInSeconds())) < 0) {
+ mapping.getLocalPort(),
+ mapping.getPublicPort(),
+ mapping.getLeaseInSeconds()) < 0) {
SWIFT_LOG(debug) << "Failed to send NAT-PMP port forwarding request!" << std::endl;
return boost::optional<NATPortMapping>();
}
@@ -104,7 +102,7 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(int localPort, i
} while(false /*r == NATPMP_TRYAGAIN*/);
if (r == 0) {
- NATPortMapping result(response.pnu.newportmapping.privateport, response.pnu.newportmapping.mappedpublicport, NATPortMapping::TCP, boost::numeric_cast<int>(response.pnu.newportmapping.lifetime));
+ NATPortMapping result(response.pnu.newportmapping.privateport, response.pnu.newportmapping.mappedpublicport, NATPortMapping::TCP, response.pnu.newportmapping.lifetime);
return result;
}
else {
@@ -114,7 +112,7 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(int localPort, i
}
bool NATPMPInterface::removePortForward(const NATPortMapping& mapping) {
- if (sendnewportmappingrequest(&p->natpmp, mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP, 0, 0, boost::numeric_cast<uint32_t>(mapping.getLocalPort())) < 0) {
+ if (sendnewportmappingrequest(&p->natpmp, mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP, mapping.getLocalPort(), 0, 0) < 0) {
SWIFT_LOG(debug) << "Failed to send NAT-PMP remove forwarding request!" << std::endl;
return false;
}
diff --git a/Swiften/Network/NATPMPInterface.h b/Swiften/Network/NATPMPInterface.h
index e1666c8..58d62b6 100644
--- a/Swiften/Network/NATPMPInterface.h
+++ b/Swiften/Network/NATPMPInterface.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
@@ -23,7 +23,7 @@ namespace Swift {
virtual bool isAvailable();
virtual boost::optional<HostAddress> getPublicIP();
- virtual boost::optional<NATPortMapping> addPortForward(int localPort, int publicPort);
+ virtual boost::optional<NATPortMapping> addPortForward(unsigned short localPort, unsigned short publicPort);
virtual bool removePortForward(const NATPortMapping&);
private:
diff --git a/Swiften/Network/NATPortMapping.h b/Swiften/Network/NATPortMapping.h
index ff8fde3..bf0fb1c 100644
--- a/Swiften/Network/NATPortMapping.h
+++ b/Swiften/Network/NATPortMapping.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -23,16 +23,16 @@ namespace Swift {
UDP
};
- NATPortMapping(int localPort, int publicPort, Protocol protocol = TCP, int leaseInSeconds = 60 * 60 * 24) :
+ NATPortMapping(unsigned short localPort, unsigned short publicPort, Protocol protocol = TCP, uint32_t leaseInSeconds = 60 * 60 * 24) :
publicPort(publicPort), localPort(localPort), protocol(protocol), leaseInSeconds(leaseInSeconds) {
}
- int getPublicPort() const {
+ unsigned short getPublicPort() const {
return publicPort;
}
- int getLocalPort() const {
+ unsigned short getLocalPort() const {
return localPort;
}
@@ -40,14 +40,14 @@ namespace Swift {
return protocol;
}
- int getLeaseInSeconds() const {
+ uint32_t getLeaseInSeconds() const {
return leaseInSeconds;
}
private:
- int publicPort;
- int localPort;
+ unsigned short publicPort;
+ unsigned short localPort;
Protocol protocol;
- int leaseInSeconds;
+ uint32_t leaseInSeconds;
};
}
diff --git a/Swiften/Network/NATTraversalInterface.h b/Swiften/Network/NATTraversalInterface.h
index ea9ed6a..1655eb6 100644
--- a/Swiften/Network/NATTraversalInterface.h
+++ b/Swiften/Network/NATTraversalInterface.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2015 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
@@ -19,7 +19,7 @@ namespace Swift {
virtual bool isAvailable() = 0;
virtual boost::optional<HostAddress> getPublicIP() = 0;
- virtual boost::optional<NATPortMapping> addPortForward(int localPort, int publicPort) = 0;
+ virtual boost::optional<NATPortMapping> addPortForward(unsigned short localPort, unsigned short publicPort) = 0;
virtual bool removePortForward(const NATPortMapping&) = 0;
};
}
diff --git a/Swiften/Network/NATTraversalRemovePortForwardingRequest.h b/Swiften/Network/NATTraversalRemovePortForwardingRequest.h
index 3db9ee1..83235f9 100644
--- a/Swiften/Network/NATTraversalRemovePortForwardingRequest.h
+++ b/Swiften/Network/NATTraversalRemovePortForwardingRequest.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -26,8 +26,8 @@ namespace Swift {
UDP
};
- unsigned int publicPort;
- unsigned int localPort;
+ unsigned short publicPort;
+ unsigned short localPort;
Protocol protocol;
unsigned long leaseInSeconds;
};
diff --git a/Swiften/Network/NATTraverser.h b/Swiften/Network/NATTraverser.h
index 716bfcb..7f03c03 100644
--- a/Swiften/Network/NATTraverser.h
+++ b/Swiften/Network/NATTraverser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,7 +20,7 @@ namespace Swift {
virtual ~NATTraverser();
virtual std::shared_ptr<NATTraversalGetPublicIPRequest> createGetPublicIPRequest() = 0;
- virtual std::shared_ptr<NATTraversalForwardPortRequest> createForwardPortRequest(int localPort, int publicPort) = 0;
- virtual std::shared_ptr<NATTraversalRemovePortForwardingRequest> createRemovePortForwardingRequest(int localPort, int publicPort) = 0;
+ virtual std::shared_ptr<NATTraversalForwardPortRequest> createForwardPortRequest(unsigned short localPort, unsigned short publicPort) = 0;
+ virtual std::shared_ptr<NATTraversalRemovePortForwardingRequest> createRemovePortForwardingRequest(unsigned short localPort, unsigned short publicPort) = 0;
};
}
diff --git a/Swiften/Network/NullNATTraversalInterface.h b/Swiften/Network/NullNATTraversalInterface.h
index ecbf110..eabc197 100644
--- a/Swiften/Network/NullNATTraversalInterface.h
+++ b/Swiften/Network/NullNATTraversalInterface.h
@@ -21,7 +21,7 @@ namespace Swift {
return boost::optional<HostAddress>();
}
- virtual boost::optional<NATPortMapping> addPortForward(int, int) {
+ virtual boost::optional<NATPortMapping> addPortForward(unsigned short, unsigned short) {
return boost::optional<NATPortMapping>();
}
diff --git a/Swiften/Network/NullNATTraverser.cpp b/Swiften/Network/NullNATTraverser.cpp
index cc8bae0..0b9464e 100644
--- a/Swiften/Network/NullNATTraverser.cpp
+++ b/Swiften/Network/NullNATTraverser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -72,11 +72,11 @@ std::shared_ptr<NATTraversalGetPublicIPRequest> NullNATTraverser::createGetPubli
return std::make_shared<NullNATTraversalGetPublicIPRequest>(eventLoop);
}
-std::shared_ptr<NATTraversalForwardPortRequest> NullNATTraverser::createForwardPortRequest(int, int) {
+std::shared_ptr<NATTraversalForwardPortRequest> NullNATTraverser::createForwardPortRequest(unsigned short, unsigned short) {
return std::make_shared<NullNATTraversalForwardPortRequest>(eventLoop);
}
-std::shared_ptr<NATTraversalRemovePortForwardingRequest> NullNATTraverser::createRemovePortForwardingRequest(int, int) {
+std::shared_ptr<NATTraversalRemovePortForwardingRequest> NullNATTraverser::createRemovePortForwardingRequest(unsigned short, unsigned short) {
return std::make_shared<NullNATTraversalRemovePortForwardingRequest>(eventLoop);
}
diff --git a/Swiften/Network/NullNATTraverser.h b/Swiften/Network/NullNATTraverser.h
index d3a6640..2f975bf 100644
--- a/Swiften/Network/NullNATTraverser.h
+++ b/Swiften/Network/NullNATTraverser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -16,8 +16,8 @@ namespace Swift {
NullNATTraverser(EventLoop* eventLoop);
std::shared_ptr<NATTraversalGetPublicIPRequest> createGetPublicIPRequest();
- std::shared_ptr<NATTraversalForwardPortRequest> createForwardPortRequest(int localPort, int publicPort);
- std::shared_ptr<NATTraversalRemovePortForwardingRequest> createRemovePortForwardingRequest(int localPort, int publicPort);
+ std::shared_ptr<NATTraversalForwardPortRequest> createForwardPortRequest(unsigned short localPort, unsigned short publicPort);
+ std::shared_ptr<NATTraversalRemovePortForwardingRequest> createRemovePortForwardingRequest(unsigned short localPort, unsigned short publicPort);
private:
EventLoop* eventLoop;
diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
index a5d180b..f884500 100644
--- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp
+++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -129,35 +129,42 @@ void PlatformDomainNameServiceQuery::runBlocking() {
currentEntry += entryLength;
currentEntry += NS_RRFIXEDSZ;
- // Priority
- if (currentEntry + 2 >= messageEnd) {
- emitError();
- return;
- }
- record.priority = boost::numeric_cast<int>(ns_get16(currentEntry));
- currentEntry += 2;
-
- // Weight
- if (currentEntry + 2 >= messageEnd) {
- emitError();
- return;
+ try {
+ // Priority
+ if (currentEntry + 2 >= messageEnd) {
+ emitError();
+ return;
+ }
+ record.priority = boost::numeric_cast<int>(ns_get16(currentEntry));
+ currentEntry += 2;
+
+ // Weight
+ if (currentEntry + 2 >= messageEnd) {
+ emitError();
+ return;
+ }
+ record.weight = boost::numeric_cast<int>(ns_get16(currentEntry));
+ currentEntry += 2;
+
+ // Port
+ if (currentEntry + 2 >= messageEnd) {
+ emitError();
+ return;
+ }
+ record.port = boost::numeric_cast<unsigned short>(ns_get16(currentEntry));
+ currentEntry += 2;
+
+ // Hostname
+ if (currentEntry >= messageEnd) {
+ emitError();
+ return;
+ }
}
- record.weight = boost::numeric_cast<int>(ns_get16(currentEntry));
- currentEntry += 2;
-
- // Port
- if (currentEntry + 2 >= messageEnd) {
+ catch (const boost::numeric::bad_numeric_cast&) {
emitError();
return;
}
- record.port = boost::numeric_cast<int>(ns_get16(currentEntry));
- currentEntry += 2;
- // Hostname
- if (currentEntry >= messageEnd) {
- emitError();
- return;
- }
ByteArray entry;
entry.resize(NS_MAXDNAME);
entryLength = dn_expand(messageStart, messageEnd, currentEntry, reinterpret_cast<char*>(vecptr(entry)), entry.size());
diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp
index f56de0b..af12049 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.cpp
+++ b/Swiften/Network/PlatformNATTraversalWorker.cpp
@@ -84,7 +84,7 @@ class PlatformNATTraversalGetPublicIPRequest : public NATTraversalGetPublicIPReq
class PlatformNATTraversalForwardPortRequest : public NATTraversalForwardPortRequest, public PlatformNATTraversalRequest {
public:
- PlatformNATTraversalForwardPortRequest(PlatformNATTraversalWorker* worker, unsigned int localIP, unsigned int publicIP) : PlatformNATTraversalRequest(worker), localIP(localIP), publicIP(publicIP) {
+ PlatformNATTraversalForwardPortRequest(PlatformNATTraversalWorker* worker, unsigned short localPort, unsigned short publicPort) : PlatformNATTraversalRequest(worker), localPort(localPort), publicPort(publicPort) {
}
virtual ~PlatformNATTraversalForwardPortRequest() {
@@ -99,12 +99,12 @@ class PlatformNATTraversalForwardPortRequest : public NATTraversalForwardPortReq
}
virtual void runBlocking() {
- getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->addPortForward(boost::numeric_cast<int>(localIP), boost::numeric_cast<int>(publicIP))), shared_from_this());
+ getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->addPortForward(localPort, publicPort)), shared_from_this());
}
private:
- unsigned int localIP;
- unsigned int publicIP;
+ unsigned short localPort;
+ unsigned short publicPort;
};
class PlatformNATTraversalRemovePortForwardingRequest : public NATTraversalRemovePortForwardingRequest, public PlatformNATTraversalRequest {
@@ -181,11 +181,11 @@ std::shared_ptr<NATTraversalGetPublicIPRequest> PlatformNATTraversalWorker::crea
return std::make_shared<PlatformNATTraversalGetPublicIPRequest>(this);
}
-std::shared_ptr<NATTraversalForwardPortRequest> PlatformNATTraversalWorker::createForwardPortRequest(int localPort, int publicPort) {
+std::shared_ptr<NATTraversalForwardPortRequest> PlatformNATTraversalWorker::createForwardPortRequest(unsigned short localPort, unsigned short publicPort) {
return std::make_shared<PlatformNATTraversalForwardPortRequest>(this, localPort, publicPort);
}
-std::shared_ptr<NATTraversalRemovePortForwardingRequest> PlatformNATTraversalWorker::createRemovePortForwardingRequest(int localPort, int publicPort) {
+std::shared_ptr<NATTraversalRemovePortForwardingRequest> PlatformNATTraversalWorker::createRemovePortForwardingRequest(unsigned short localPort, unsigned short publicPort) {
NATPortMapping mapping(localPort, publicPort, NATPortMapping::TCP); // FIXME
return std::make_shared<PlatformNATTraversalRemovePortForwardingRequest>(this, mapping);
}
diff --git a/Swiften/Network/PlatformNATTraversalWorker.h b/Swiften/Network/PlatformNATTraversalWorker.h
index aee1052..368798e 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.h
+++ b/Swiften/Network/PlatformNATTraversalWorker.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2016-2017 Isode Limited.
+ * Copyright (c) 2016-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -44,8 +44,8 @@ namespace Swift {
virtual ~PlatformNATTraversalWorker();
std::shared_ptr<NATTraversalGetPublicIPRequest> createGetPublicIPRequest();
- std::shared_ptr<NATTraversalForwardPortRequest> createForwardPortRequest(int localPort, int publicPort);
- std::shared_ptr<NATTraversalRemovePortForwardingRequest> createRemovePortForwardingRequest(int localPort, int publicPort);
+ std::shared_ptr<NATTraversalForwardPortRequest> createForwardPortRequest(unsigned short localPort, unsigned short publicPort);
+ std::shared_ptr<NATTraversalRemovePortForwardingRequest> createRemovePortForwardingRequest(unsigned short localPort, unsigned short publicPort);
private:
NATTraversalInterface* getNATTraversalInterface() const;
diff --git a/Swiften/Network/ProxiedConnection.cpp b/Swiften/Network/ProxiedConnection.cpp
index aa6c4d2..4c97e31 100644
--- a/Swiften/Network/ProxiedConnection.cpp
+++ b/Swiften/Network/ProxiedConnection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,7 +20,7 @@ ProxiedConnection::ProxiedConnection(
ConnectionFactory* connectionFactory,
TimerFactory* timerFactory,
const std::string& proxyHost,
- int proxyPort) :
+ unsigned short proxyPort) :
resolver_(resolver),
connectionFactory_(connectionFactory),
timerFactory_(timerFactory),
diff --git a/Swiften/Network/ProxiedConnection.h b/Swiften/Network/ProxiedConnection.h
index 440fb86..f79845a 100644
--- a/Swiften/Network/ProxiedConnection.h
+++ b/Swiften/Network/ProxiedConnection.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2017 Isode Limited.
+ * Copyright (c) 2012-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,7 +20,7 @@ namespace Swift {
class SWIFTEN_API ProxiedConnection : public Connection, public std::enable_shared_from_this<ProxiedConnection> {
public:
- ProxiedConnection(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort);
+ ProxiedConnection(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort);
virtual ~ProxiedConnection();
virtual void listen();
@@ -55,7 +55,7 @@ namespace Swift {
ConnectionFactory* connectionFactory_;
TimerFactory* timerFactory_;
std::string proxyHost_;
- int proxyPort_;
+ unsigned short proxyPort_;
HostAddressPort server_;
Connector::ref connector_;
std::shared_ptr<Connection> connection_;
diff --git a/Swiften/Network/SOCKS5ProxiedConnection.cpp b/Swiften/Network/SOCKS5ProxiedConnection.cpp
index 2492827..d7036f2 100644
--- a/Swiften/Network/SOCKS5ProxiedConnection.cpp
+++ b/Swiften/Network/SOCKS5ProxiedConnection.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -27,7 +27,7 @@ SOCKS5ProxiedConnection::SOCKS5ProxiedConnection(
ConnectionFactory* connectionFactory,
TimerFactory* timerFactory,
const std::string& proxyHost,
- int proxyPort) :
+ unsigned short proxyPort) :
ProxiedConnection(resolver, connectionFactory, timerFactory, proxyHost, proxyPort),
proxyState_(Initial) {
}
diff --git a/Swiften/Network/SOCKS5ProxiedConnection.h b/Swiften/Network/SOCKS5ProxiedConnection.h
index c8faae9..515c5b7 100644
--- a/Swiften/Network/SOCKS5ProxiedConnection.h
+++ b/Swiften/Network/SOCKS5ProxiedConnection.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -24,12 +24,12 @@ namespace Swift {
public:
typedef std::shared_ptr<SOCKS5ProxiedConnection> ref;
- static ref create(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort) {
+ static ref create(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort) {
return ref(new SOCKS5ProxiedConnection(resolver, connectionFactory, timerFactory, proxyHost, proxyPort));
}
private:
- SOCKS5ProxiedConnection(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort);
+ SOCKS5ProxiedConnection(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort);
virtual void initializeProxy();
virtual void handleProxyInitializeData(std::shared_ptr<SafeByteArray> data);
diff --git a/Swiften/Network/SOCKS5ProxiedConnectionFactory.cpp b/Swiften/Network/SOCKS5ProxiedConnectionFactory.cpp
index 01ce8ac..abd7718 100644
--- a/Swiften/Network/SOCKS5ProxiedConnectionFactory.cpp
+++ b/Swiften/Network/SOCKS5ProxiedConnectionFactory.cpp
@@ -16,7 +16,7 @@
namespace Swift {
-SOCKS5ProxiedConnectionFactory::SOCKS5ProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort) : resolver_(resolver), connectionFactory_(connectionFactory), timerFactory_(timerFactory), proxyHost_(proxyHost), proxyPort_(proxyPort) {
+SOCKS5ProxiedConnectionFactory::SOCKS5ProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort) : resolver_(resolver), connectionFactory_(connectionFactory), timerFactory_(timerFactory), proxyHost_(proxyHost), proxyPort_(proxyPort) {
}
std::shared_ptr<Connection> SOCKS5ProxiedConnectionFactory::createConnection() {
diff --git a/Swiften/Network/SOCKS5ProxiedConnectionFactory.h b/Swiften/Network/SOCKS5ProxiedConnectionFactory.h
index 8631239..47ae9a3 100644
--- a/Swiften/Network/SOCKS5ProxiedConnectionFactory.h
+++ b/Swiften/Network/SOCKS5ProxiedConnectionFactory.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -23,7 +23,7 @@ namespace Swift {
class SWIFTEN_API SOCKS5ProxiedConnectionFactory : public ConnectionFactory {
public:
- SOCKS5ProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort);
+ SOCKS5ProxiedConnectionFactory(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, unsigned short proxyPort);
virtual std::shared_ptr<Connection> createConnection();
@@ -32,6 +32,6 @@ namespace Swift {
ConnectionFactory* connectionFactory_;
TimerFactory* timerFactory_;
std::string proxyHost_;
- int proxyPort_;
+ unsigned short proxyPort_;
};
}
diff --git a/Swiften/Network/StaticDomainNameResolver.cpp b/Swiften/Network/StaticDomainNameResolver.cpp
index 95b3dd9..eca6687 100644
--- a/Swiften/Network/StaticDomainNameResolver.cpp
+++ b/Swiften/Network/StaticDomainNameResolver.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -50,6 +50,10 @@ namespace {
if (!resolver->getIsResponsive()) {
return;
}
+ if (auto address = HostAddress::fromString(host)) {
+ // IP Literals should resolve to themselves
+ resolver->addAddress(host, *address);
+ }
StaticDomainNameResolver::AddressesMap::const_iterator i = resolver->getAddresses().find(host);
if (i != resolver->getAddresses().end()) {
eventLoop->postEvent(
@@ -98,14 +102,14 @@ void StaticDomainNameResolver::addService(const std::string& service, const Doma
void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const HostAddressPort& address) {
static int hostid = 0;
- std::string hostname(std::string("host-") + boost::lexical_cast<std::string>(hostid));
+ std::string hostname(std::string("host-") + std::to_string(hostid));
hostid++;
addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, address.getPort(), 0, 0));
addAddress(hostname, address.getAddress());
}
-void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const std::string& hostname, int port) {
+void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const std::string& hostname, unsigned short port) {
addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, port, 0, 0));
}
diff --git a/Swiften/Network/StaticDomainNameResolver.h b/Swiften/Network/StaticDomainNameResolver.h
index 76394d0..2064046 100644
--- a/Swiften/Network/StaticDomainNameResolver.h
+++ b/Swiften/Network/StaticDomainNameResolver.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -31,7 +31,7 @@ namespace Swift {
void addAddress(const std::string& domain, const HostAddress& address);
void addService(const std::string& service, const DomainNameServiceQuery::Result& result);
void addXMPPClientService(const std::string& domain, const HostAddressPort&);
- void addXMPPClientService(const std::string& domain, const std::string& host, int port);
+ void addXMPPClientService(const std::string& domain, const std::string& host, unsigned short port);
const AddressesMap& getAddresses() const {
return addresses;
diff --git a/Swiften/Network/TLSConnection.cpp b/Swiften/Network/TLSConnection.cpp
index 7c293d1..82bf114 100644
--- a/Swiften/Network/TLSConnection.cpp
+++ b/Swiften/Network/TLSConnection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -32,7 +32,6 @@ TLSConnection::~TLSConnection() {
connection->onDataRead.disconnect(boost::bind(&TLSConnection::handleRawDataRead, this, _1));
connection->onDataWritten.disconnect(boost::bind(&TLSConnection::handleRawDataWritten, this));
connection->onDisconnected.disconnect(boost::bind(&TLSConnection::handleRawDisconnected, this, _1));
- delete context;
}
void TLSConnection::handleTLSConnectFinished(bool error) {
@@ -71,7 +70,7 @@ HostAddressPort TLSConnection::getRemoteAddress() const {
}
TLSContext* TLSConnection::getTLSContext() const {
- return context;
+ return context.get();
}
void TLSConnection::handleRawConnectFinished(bool error) {
diff --git a/Swiften/Network/TLSConnection.h b/Swiften/Network/TLSConnection.h
index 0c395d1..1ab1ec6 100644
--- a/Swiften/Network/TLSConnection.h
+++ b/Swiften/Network/TLSConnection.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -46,7 +46,7 @@ namespace Swift {
void handleTLSDataForApplication(const SafeByteArray& data);
private:
- TLSContext* context;
+ std::unique_ptr<TLSContext> context;
Connection::ref connection;
};
}
diff --git a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
index 5d6fedd..4aeaf24 100644
--- a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
+++ b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
@@ -194,7 +194,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(st(2), connectionFactory->connections.size()); /* 0 was waiting for response, open and send on 1 */
CPPUNIT_ASSERT_EQUAL(st(4), boshDataWritten.size()); /* data */
c1 = connectionFactory->connections[1];
- std::string fullBody = "<body rid='" + boost::lexical_cast<std::string>(rid) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'><blah/></body>"; /* check empty write */
+ std::string fullBody = "<body rid='" + std::to_string(rid) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'><blah/></body>"; /* check empty write */
CPPUNIT_ASSERT_EQUAL(fullBody, lastBody());
CPPUNIT_ASSERT(c0->pending);
CPPUNIT_ASSERT(c1->pending);
@@ -310,7 +310,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture {
readResponse("<body></body>", c0);
eventLoop->processEvents();
CPPUNIT_ASSERT_EQUAL(st(3), boshDataWritten.size());
- std::string fullBody = "<body rid='" + boost::lexical_cast<std::string>(initialRID + 2) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'></body>";
+ std::string fullBody = "<body rid='" + std::to_string(initialRID + 2) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'></body>";
std::string response = boshDataWritten[2];
size_t bodyPosition = response.find("\r\n\r\n");
CPPUNIT_ASSERT_EQUAL(fullBody, response.substr(bodyPosition+4));
@@ -427,7 +427,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture {
"Access-Control-Allow-Headers: Content-Type\r\n"
"Content-Length: "));
connection->onDataRead(data1);
- std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(boost::lexical_cast<std::string>(response.size())));
+ std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(std::to_string(response.size())));
connection->onDataRead(data2);
std::shared_ptr<SafeByteArray> data3 = std::make_shared<SafeByteArray>(createSafeByteArray("\r\n\r\n"));
connection->onDataRead(data3);
@@ -440,7 +440,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture {
std::string result = "POST /" + path + " HTTP/1.1\r\n"
+ "Host: " + to + ":" + port + "\r\n"
+ "Content-Type: text/xml; charset=utf-8\r\n"
- + "Content-Length: " + boost::lexical_cast<std::string>(body.size()) + "\r\n\r\n"
+ + "Content-Length: " + std::to_string(body.size()) + "\r\n\r\n"
+ body;
return result;
}
diff --git a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp
index e34cb96..17d8333 100644
--- a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp
+++ b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp
@@ -318,7 +318,7 @@ class BOSHConnectionTest : public CppUnit::TestFixture {
"Access-Control-Allow-Headers: Content-Type\r\n"
"Content-Length: "));
connection->onDataRead(data1);
- std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(boost::lexical_cast<std::string>(response.size())));
+ std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(std::to_string(response.size())));
connection->onDataRead(data2);
std::shared_ptr<SafeByteArray> data3 = std::make_shared<SafeByteArray>(createSafeByteArray("\r\n\r\n"));
connection->onDataRead(data3);
diff --git a/Swiften/Network/UnitTest/ConnectorTest.cpp b/Swiften/Network/UnitTest/ConnectorTest.cpp
index 8524439..065911d 100644
--- a/Swiften/Network/UnitTest/ConnectorTest.cpp
+++ b/Swiften/Network/UnitTest/ConnectorTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -26,6 +26,7 @@ class ConnectorTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testConnect);
CPPUNIT_TEST(testConnect_NoServiceLookups);
CPPUNIT_TEST(testConnect_NoServiceLookups_DefaultPort);
+ CPPUNIT_TEST(testConnect_OnlyLiteral);
CPPUNIT_TEST(testConnect_FirstAddressHostFails);
CPPUNIT_TEST(testConnect_NoSRVHost);
CPPUNIT_TEST(testConnect_NoHosts);
@@ -91,7 +92,7 @@ class ConnectorTest : public CppUnit::TestFixture {
}
void testConnect_NoServiceLookups_DefaultPort() {
- Connector::ref testling(createConnector(-1, boost::optional<std::string>()));
+ Connector::ref testling(createConnector(0, boost::optional<std::string>()));
resolver->addXMPPClientService("foo.com", host1);
resolver->addXMPPClientService("foo.com", host2);
resolver->addAddress("foo.com", host3.getAddress());
@@ -102,7 +103,7 @@ class ConnectorTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(connections.size()));
CPPUNIT_ASSERT(connections[0]);
CPPUNIT_ASSERT(host3.getAddress() == (*(connections[0]->hostAddressPort)).getAddress());
- CPPUNIT_ASSERT_EQUAL(5222, (*(connections[0]->hostAddressPort)).getPort());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(5222), (*(connections[0]->hostAddressPort)).getPort());
CPPUNIT_ASSERT(!std::dynamic_pointer_cast<DomainNameResolveError>(error));
}
@@ -119,6 +120,21 @@ class ConnectorTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(!std::dynamic_pointer_cast<DomainNameResolveError>(error));
}
+ void testConnect_OnlyLiteral() {
+ auto testling = Connector::create("1.1.1.1", 1234, boost::none, resolver, connectionFactory, timerFactory);
+ testling->onConnectFinished.connect(boost::bind(&ConnectorTest::handleConnectorFinished, this, _1, _2));
+
+ auto address1 = HostAddress::fromString("1.1.1.1").get();
+ connectionFactory->failingPorts.push_back(HostAddressPort(address1, 1234));
+
+ testling->start();
+ eventLoop->processEvents();
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(connections.size()));
+ CPPUNIT_ASSERT(!connections[0]);
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(connectionFactory->createdConnections.size()));
+ }
+
void testConnect_FirstAddressHostFails() {
Connector::ref testling(createConnector());
@@ -312,7 +328,7 @@ class ConnectorTest : public CppUnit::TestFixture {
private:
- Connector::ref createConnector(int port = -1, boost::optional<std::string> serviceLookupPrefix = boost::optional<std::string>("_xmpp-client._tcp.")) {
+ Connector::ref createConnector(unsigned short port = 0, boost::optional<std::string> serviceLookupPrefix = boost::optional<std::string>("_xmpp-client._tcp.")) {
Connector::ref connector = Connector::create("foo.com", port, serviceLookupPrefix, resolver, connectionFactory, timerFactory);
connector->onConnectFinished.connect(boost::bind(&ConnectorTest::handleConnectorFinished, this, _1, _2));
return connector;
@@ -356,12 +372,15 @@ class ConnectorTest : public CppUnit::TestFixture {
}
std::shared_ptr<Connection> createConnection() {
- return std::make_shared<MockConnection>(failingPorts, isResponsive, eventLoop);
+ auto connection = std::make_shared<MockConnection>(failingPorts, isResponsive, eventLoop);
+ createdConnections.push_back(connection);
+ return connection;
}
EventLoop* eventLoop;
bool isResponsive;
std::vector<HostAddressPort> failingPorts;
+ std::vector<std::shared_ptr<MockConnection>> createdConnections;
};
private:
diff --git a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp
index 1a160b7..065d015 100644
--- a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp
+++ b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -421,7 +421,7 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
private:
std::string proxyHost;
HostAddressPort proxyHostAddress;
- int proxyPort;
+ unsigned short proxyPort;
HostAddressPort host;
DummyEventLoop* eventLoop;
StaticDomainNameResolver* resolver;
diff --git a/Swiften/Network/UnitTest/HostAddressTest.cpp b/Swiften/Network/UnitTest/HostAddressTest.cpp
index 226346b..bd345a7 100644
--- a/Swiften/Network/UnitTest/HostAddressTest.cpp
+++ b/Swiften/Network/UnitTest/HostAddressTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,6 +10,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <Swiften/Network/HostAddress.h>
+#include <Swiften/Network/HostAddressPort.h>
using namespace Swift;
@@ -21,6 +22,7 @@ class HostAddressTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testToString);
CPPUNIT_TEST(testToString_IPv6);
CPPUNIT_TEST(testToString_Invalid);
+ CPPUNIT_TEST(testComparison);
CPPUNIT_TEST_SUITE_END();
public:
@@ -62,6 +64,32 @@ class HostAddressTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("0.0.0.0"), testling.toString());
}
+
+ void testComparison() {
+ auto ha127_0_0_1 = *HostAddress::fromString("127.0.0.1");
+ auto ha127_0_0_2 = *HostAddress::fromString("127.0.0.2");
+ auto ha127_0_1_0 = *HostAddress::fromString("127.0.1.0");
+
+ CPPUNIT_ASSERT(ha127_0_0_1 < ha127_0_0_2);
+ CPPUNIT_ASSERT(ha127_0_0_2 < ha127_0_1_0);
+ CPPUNIT_ASSERT(!(ha127_0_0_1 < ha127_0_0_1));
+ CPPUNIT_ASSERT(!(ha127_0_0_2 < ha127_0_0_1));
+ CPPUNIT_ASSERT(!(ha127_0_0_2 == ha127_0_0_1));
+ CPPUNIT_ASSERT(ha127_0_0_1 == ha127_0_0_1);
+
+ auto hap_127_0_0_1__1 = HostAddressPort(ha127_0_0_1, 1);
+ auto hap_127_0_0_1__2 = HostAddressPort(ha127_0_0_1, 2);
+ auto hap_127_0_0_2__1 = HostAddressPort(ha127_0_0_2, 1);
+ auto hap_127_0_0_2__2 = HostAddressPort(ha127_0_0_2, 2);
+
+ CPPUNIT_ASSERT(hap_127_0_0_1__1 < hap_127_0_0_1__2);
+ CPPUNIT_ASSERT(!(hap_127_0_0_1__1 < hap_127_0_0_1__1));
+ CPPUNIT_ASSERT(!(hap_127_0_0_1__1 == hap_127_0_0_1__2));
+ CPPUNIT_ASSERT(hap_127_0_0_1__1 == hap_127_0_0_1__1);
+ CPPUNIT_ASSERT(!(hap_127_0_0_1__2 == hap_127_0_0_1__1));
+ CPPUNIT_ASSERT(hap_127_0_0_1__2 < hap_127_0_0_2__1);
+ CPPUNIT_ASSERT(hap_127_0_0_2__1 < hap_127_0_0_2__2);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(HostAddressTest);
diff --git a/Swiften/Network/WindowsProxyProvider.cpp b/Swiften/Network/WindowsProxyProvider.cpp
index 78bd72f..9a60bb4 100644
--- a/Swiften/Network/WindowsProxyProvider.cpp
+++ b/Swiften/Network/WindowsProxyProvider.cpp
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <boost/lexical_cast.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <windows.h>
@@ -77,11 +78,11 @@ HostAddressPort WindowsProxyProvider::getAsHostAddressPort(std::string proxy) {
try {
std::pair<std::string, std::string> tmp;
- int port = 0;
+ unsigned short port = 0;
tmp = String::getSplittedAtFirst(proxy, ':');
// .c_str() is needed as tmp.second can include a \0 char which will end in an exception of the lexical cast.
// with .c_str() the \0 will not be part of the string which is to be casted
- port = boost::lexical_cast<int> (tmp.second.c_str());
+ port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int> (tmp.second.c_str()));
ret = HostAddressPort(HostAddress::fromString(tmp.first).get(), port);
}
catch(...) {
diff --git a/Swiften/Parser/AttributeMap.cpp b/Swiften/Parser/AttributeMap.cpp
index c112d52..f6767de 100644
--- a/Swiften/Parser/AttributeMap.cpp
+++ b/Swiften/Parser/AttributeMap.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,19 +8,17 @@
#include <algorithm>
-#include <boost/lambda/bind.hpp>
-#include <boost/lambda/lambda.hpp>
#include <boost/optional.hpp>
using namespace Swift;
-namespace lambda = boost::lambda;
AttributeMap::AttributeMap() {
}
std::string AttributeMap::getAttribute(const std::string& attribute, const std::string& ns) const {
- AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(),
- lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, ns));
+ const auto i = std::find_if(attributes.begin(), attributes.end(), [&](const Entry& entry) {
+ return entry.getAttribute() == Attribute(attribute, ns);
+ });
if (i == attributes.end()) {
return "";
}
@@ -30,8 +28,9 @@ std::string AttributeMap::getAttribute(const std::string& attribute, const std::
}
bool AttributeMap::getBoolAttribute(const std::string& attribute, bool defaultValue) const {
- AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(),
- lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, ""));
+ const auto i = std::find_if(attributes.begin(), attributes.end(), [&](const Entry& entry) {
+ return entry.getAttribute() == Attribute(attribute, "");
+ });
if (i == attributes.end()) {
return defaultValue;
}
@@ -41,8 +40,9 @@ bool AttributeMap::getBoolAttribute(const std::string& attribute, bool defaultVa
}
boost::optional<std::string> AttributeMap::getAttributeValue(const std::string& attribute) const {
- AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(),
- lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, ""));
+ const auto i = std::find_if(attributes.begin(), attributes.end(), [&](const Entry& entry) {
+ return entry.getAttribute() == Attribute(attribute, "");
+ });
if (i == attributes.end()) {
return boost::optional<std::string>();
}
diff --git a/Swiften/Parser/BOSHBodyExtractor.cpp b/Swiften/Parser/BOSHBodyExtractor.cpp
index c45d338..ff56792 100644
--- a/Swiften/Parser/BOSHBodyExtractor.cpp
+++ b/Swiften/Parser/BOSHBodyExtractor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,8 +8,6 @@
#include <memory>
-#include <boost/numeric/conversion/cast.hpp>
-
#include <Swiften/Parser/XMLParser.h>
#include <Swiften/Parser/XMLParserClient.h>
#include <Swiften/Parser/XMLParserFactory.h>
@@ -119,17 +117,19 @@ BOSHBodyExtractor::BOSHBodyExtractor(XMLParserFactory* parserFactory, const Byte
body = BOSHBody();
if (!endElementSeen) {
+ assert(i <= j.base());
body->content = std::string(
reinterpret_cast<const char*>(vecptr(data) + std::distance(data.begin(), i)),
- boost::numeric_cast<size_t>(std::distance(i, j.base())));
+ static_cast<size_t>(std::distance(i, j.base())));
}
// Parse the body element
BOSHBodyParserClient parserClient(this);
std::shared_ptr<XMLParser> parser(parserFactory->createXMLParser(&parserClient));
+ assert(data.begin() <= i);
if (!parser->parse(std::string(
reinterpret_cast<const char*>(vecptr(data)),
- boost::numeric_cast<size_t>(std::distance(data.begin(), i))))) {
+ static_cast<size_t>(std::distance(data.begin(), i))))) {
/* TODO: This needs to be only validating the BOSH <body> element, so that XMPP parsing errors are caught at
the correct higher layer */
body = boost::optional<BOSHBody>();
diff --git a/Swiften/Parser/EnumParser.h b/Swiften/Parser/EnumParser.h
index cf17ead..0da765e 100644
--- a/Swiften/Parser/EnumParser.h
+++ b/Swiften/Parser/EnumParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,7 +13,6 @@
#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
namespace Swift {
template<typename T>
diff --git a/Swiften/Parser/ExpatParser.cpp b/Swiften/Parser/ExpatParser.cpp
index 77d959c..8415c42 100644
--- a/Swiften/Parser/ExpatParser.cpp
+++ b/Swiften/Parser/ExpatParser.cpp
@@ -7,13 +7,12 @@
#include <Swiften/Parser/ExpatParser.h>
#include <cassert>
+#include <limits>
#include <memory>
#include <string>
#include <expat.h>
-#include <boost/numeric/conversion/cast.hpp>
-
#include <Swiften/Base/String.h>
#include <Swiften/Parser/XMLParserClient.h>
@@ -84,7 +83,10 @@ ExpatParser::~ExpatParser() {
}
bool ExpatParser::parse(const std::string& data) {
- bool success = XML_Parse(p->parser_, data.c_str(), boost::numeric_cast<int>(data.size()), false) == XML_STATUS_OK;
+ if (data.size() > std::numeric_limits<int>::max()) {
+ return false;
+ }
+ bool success = XML_Parse(p->parser_, data.c_str(), static_cast<int>(data.size()), false) == XML_STATUS_OK;
/*if (!success) {
std::cout << "ERROR: " << XML_ErrorString(XML_GetErrorCode(p->parser_)) << " while parsing " << data << std::endl;
}*/
diff --git a/Swiften/Parser/LibXMLParser.cpp b/Swiften/Parser/LibXMLParser.cpp
index be0a92d..5bd3737 100644
--- a/Swiften/Parser/LibXMLParser.cpp
+++ b/Swiften/Parser/LibXMLParser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,11 +8,10 @@
#include <cassert>
#include <cstring>
+#include <limits>
#include <memory>
#include <string>
-#include <boost/numeric/conversion/cast.hpp>
-
#include <libxml/parser.h>
#include <Swiften/Base/Log.h>
@@ -36,11 +35,12 @@ static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*
if (attributes[i+2]) {
attributeNS = std::string(reinterpret_cast<const char*>(attributes[i+2]));
}
+ assert(attributes[i+4] >= attributes[i+3]);
attributeValues.addAttribute(
std::string(reinterpret_cast<const char*>(attributes[i])),
attributeNS,
std::string(reinterpret_cast<const char*>(attributes[i+3]),
- boost::numeric_cast<size_t>(attributes[i+4]-attributes[i+3])));
+ static_cast<size_t>(attributes[i+4]-attributes[i+3])));
}
static_cast<XMLParser*>(parser)->getClient()->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string()), attributeValues);
}
@@ -50,7 +50,8 @@ static void handleEndElement(void *parser, const xmlChar* name, const xmlChar*,
}
static void handleCharacterData(void* parser, const xmlChar* data, int len) {
- static_cast<XMLParser*>(parser)->getClient()->handleCharacterData(std::string(reinterpret_cast<const char*>(data), boost::numeric_cast<size_t>(len)));
+ assert(len >= 0);
+ static_cast<XMLParser*>(parser)->getClient()->handleCharacterData(std::string(reinterpret_cast<const char*>(data), static_cast<size_t>(len)));
}
static void handleError(void*, const char* /*m*/, ... ) {
@@ -94,7 +95,10 @@ LibXMLParser::~LibXMLParser() {
}
bool LibXMLParser::parse(const std::string& data) {
- if (xmlParseChunk(p->context_, data.c_str(), boost::numeric_cast<int>(data.size()), false) == XML_ERR_OK) {
+ if (data.size() > std::numeric_limits<int>::max()) {
+ return false;
+ }
+ if (xmlParseChunk(p->context_, data.c_str(), static_cast<int>(data.size()), false) == XML_ERR_OK) {
return true;
}
xmlError* error = xmlCtxtGetLastError(p->context_);
diff --git a/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp b/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp
index 405c593..71bce54 100644
--- a/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp
+++ b/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,6 +7,7 @@
#include <Swiften/Parser/PayloadParsers/BytestreamsParser.h>
#include <boost/lexical_cast.hpp>
+#include <boost/numeric/conversion/cast.hpp>
namespace Swift {
@@ -23,7 +24,9 @@ void BytestreamsParser::handleStartElement(const std::string& element, const std
else if (level == PayloadLevel) {
if (element == "streamhost") {
try {
- getPayloadInternal()->addStreamHost(Bytestreams::StreamHost(attributes.getAttribute("host"), JID(attributes.getAttribute("jid")), boost::lexical_cast<int>(attributes.getAttribute("port"))));
+ getPayloadInternal()->addStreamHost(Bytestreams::StreamHost(attributes.getAttribute("host"), JID(attributes.getAttribute("jid")), boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(attributes.getAttribute("port")))));
+ }
+ catch (boost::numeric::bad_numeric_cast&) {
}
catch (boost::bad_lexical_cast&) {
}
diff --git a/Swiften/Parser/PayloadParsers/ForwardedParser.h b/Swiften/Parser/PayloadParsers/ForwardedParser.h
index f91fda5..c9f13df 100644
--- a/Swiften/Parser/PayloadParsers/ForwardedParser.h
+++ b/Swiften/Parser/PayloadParsers/ForwardedParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Forwarded.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -22,9 +21,9 @@ namespace Swift {
public:
ForwardedParser(PayloadParserFactoryCollection* factories);
- virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
enum Level {
TopLevel = 0,
diff --git a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp
index ea7bdbf..9e56b63 100644
--- a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp
+++ b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp
@@ -53,9 +53,14 @@
#include <Swiften/Parser/PayloadParsers/MAMResultParser.h>
#include <Swiften/Parser/PayloadParsers/MIXParticipantParserFactory.h>
#include <Swiften/Parser/PayloadParsers/MIXCreateParser.h>
+#include <Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h>
+#include <Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h>
#include <Swiften/Parser/PayloadParsers/MIXDestroyParser.h>
+#include <Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h>
#include <Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h>
+#include <Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h>
#include <Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h>
+#include <Swiften/Parser/PayloadParsers/MIXLeaveParser.h>
#include <Swiften/Parser/PayloadParsers/MUCAdminPayloadParser.h>
#include <Swiften/Parser/PayloadParsers/MUCDestroyPayloadParser.h>
#include <Swiften/Parser/PayloadParsers/MUCInvitationPayloadParser.h>
@@ -70,6 +75,7 @@
#include <Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h>
#include <Swiften/Parser/PayloadParsers/PubSubParser.h>
#include <Swiften/Parser/PayloadParsers/RawXMLPayloadParserFactory.h>
+#include <Swiften/Parser/PayloadParsers/ReferencePayloadParser.h>
#include <Swiften/Parser/PayloadParsers/ReplaceParser.h>
#include <Swiften/Parser/PayloadParsers/ResourceBindParser.h>
#include <Swiften/Parser/PayloadParsers/ResultSetParser.h>
@@ -135,9 +141,14 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() {
factories_.push_back(std::make_shared<ChatStateParserFactory>());
factories_.push_back(std::make_shared<ClientStateParserFactory>());
factories_.push_back(std::make_shared<MIXParticipantParserFactory>());
- factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXDestroyParser> >("destroy", "urn:xmpp:mix:1"));
- factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXCreateParser> >("create", "urn:xmpp:mix:1"));
- factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXUserPreferenceParser> >("user-preference", "urn:xmpp:mix:1"));
+ factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXDestroyParser> >("destroy", "urn:xmpp:mix:0"));
+ factories_.push_back(std::make_shared<MIXRegisterNickParserFactory>());
+ factories_.push_back(std::make_shared<MIXSetNickParserFactory>());
+ factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXCreateParser> >("create", "urn:xmpp:mix:0"));
+ factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXUpdateSubscriptionParser> >("update-subscription", "urn:xmpp:mix:0"));
+ factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXUserPreferenceParser> >("user-preference", "urn:xmpp:mix:0"));
+ factories_.push_back(std::make_shared<MIXPayloadParserFactory>());
+ factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXLeaveParser> >("leave", "urn:xmpp:mix:0"));
factories_.push_back(std::make_shared<MUCUserPayloadParserFactory>(this));
factories_.push_back(std::make_shared<MUCOwnerPayloadParserFactory>(this));
factories_.push_back(std::make_shared<GenericPayloadParserFactory<MUCInvitationPayloadParser> >("x", "jabber:x:conference"));
@@ -177,6 +188,7 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() {
factories_.push_back(std::make_shared<GenericPayloadParserFactory2<CarbonsSentParser> >("sent", "urn:xmpp:carbons:2", this));
factories_.push_back(std::make_shared<GenericPayloadParserFactory<CarbonsPrivateParser> >("private", "urn:xmpp:carbons:2"));
factories_.push_back(std::make_shared<MIXJoinParserFactory>());
+ factories_.push_back(std::make_shared<GenericPayloadParserFactory2<ReferencePayloadParser> >("reference", "urn:xmpp:reference:0", this));
for (auto& factory : factories_) {
addFactory(factory.get());
diff --git a/Swiften/Parser/PayloadParsers/IBBParser.cpp b/Swiften/Parser/PayloadParsers/IBBParser.cpp
index 9b6babc..1ba44e1 100644
--- a/Swiften/Parser/PayloadParsers/IBBParser.cpp
+++ b/Swiften/Parser/PayloadParsers/IBBParser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -39,7 +39,7 @@ void IBBParser::handleStartElement(const std::string& element, const std::string
getPayloadInternal()->setStanzaType(IBB::IQStanza);
}
try {
- getPayloadInternal()->setBlockSize(boost::lexical_cast<int>(attributes.getAttribute("block-size")));
+ getPayloadInternal()->setBlockSize(boost::lexical_cast<unsigned int>(attributes.getAttribute("block-size")));
}
catch (boost::bad_lexical_cast&) {
}
diff --git a/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h b/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h
index eaedd27..af2f061 100644
--- a/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h
+++ b/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/IsodeIQDelegation.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API IsodeIQDelegationParser : public GenericPayloadParser<IsodeIQDelegation> {
public:
IsodeIQDelegationParser(PayloadParserFactoryCollection* parsers);
- virtual ~IsodeIQDelegationParser();
+ virtual ~IsodeIQDelegationParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/JingleS5BTransportMethodPayloadParser.cpp b/Swiften/Parser/PayloadParsers/JingleS5BTransportMethodPayloadParser.cpp
index e639e20..a405e0e 100644
--- a/Swiften/Parser/PayloadParsers/JingleS5BTransportMethodPayloadParser.cpp
+++ b/Swiften/Parser/PayloadParsers/JingleS5BTransportMethodPayloadParser.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,6 +13,7 @@
#include <Swiften/Parser/PayloadParsers/JingleS5BTransportMethodPayloadParser.h>
#include <boost/lexical_cast.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <boost/optional.hpp>
#include <Swiften/Base/Log.h>
@@ -40,10 +41,10 @@ namespace Swift {
JingleS5BTransportPayload::Candidate candidate;
candidate.cid = attributes.getAttributeValue("cid").get_value_or("");
- int port = -1;
+ unsigned short port = 0;
try {
- port = boost::lexical_cast<int>(attributes.getAttributeValue("port").get_value_or("-1"));
- } catch(boost::bad_lexical_cast &) { }
+ port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(attributes.getAttributeValue("port").get_value_or("0")));
+ } catch(...) { }
candidate.hostPort = HostAddressPort(HostAddress::fromString(attributes.getAttributeValue("host").get_value_or("")).get_value_or(HostAddress()), port);
candidate.jid = JID(attributes.getAttributeValue("jid").get_value_or(""));
int priority = -1;
diff --git a/Swiften/Parser/PayloadParsers/MAMFinParser.h b/Swiften/Parser/PayloadParsers/MAMFinParser.h
index f08231e..419d542 100644
--- a/Swiften/Parser/PayloadParsers/MAMFinParser.h
+++ b/Swiften/Parser/PayloadParsers/MAMFinParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MAMFin.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,9 +19,9 @@ namespace Swift {
public:
MAMFinParser();
- virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
enum Level {
TopLevel = 0,
diff --git a/Swiften/Parser/PayloadParsers/MAMQueryParser.h b/Swiften/Parser/PayloadParsers/MAMQueryParser.h
index 7e4b58a..ab062c5 100644
--- a/Swiften/Parser/PayloadParsers/MAMQueryParser.h
+++ b/Swiften/Parser/PayloadParsers/MAMQueryParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MAMQuery.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -22,9 +21,9 @@ namespace Swift {
public:
MAMQueryParser();
- virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
enum Level {
TopLevel = 0,
diff --git a/Swiften/Parser/PayloadParsers/MAMResultParser.h b/Swiften/Parser/PayloadParsers/MAMResultParser.h
index e68e365..f058e15 100644
--- a/Swiften/Parser/PayloadParsers/MAMResultParser.h
+++ b/Swiften/Parser/PayloadParsers/MAMResultParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MAMResult.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -22,9 +21,9 @@ namespace Swift {
public:
MAMResultParser(PayloadParserFactoryCollection* factories);
- virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
enum Level {
TopLevel = 0,
diff --git a/Swiften/Parser/PayloadParsers/MIXCreateParser.h b/Swiften/Parser/PayloadParsers/MIXCreateParser.h
index 60e3040..ef123e1 100644
--- a/Swiften/Parser/PayloadParsers/MIXCreateParser.h
+++ b/Swiften/Parser/PayloadParsers/MIXCreateParser.h
@@ -4,12 +4,17 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MIXCreate.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -19,11 +24,11 @@ namespace Swift {
class SWIFTEN_API MIXCreateParser : public GenericPayloadParser<MIXCreate> {
public:
MIXCreateParser();
- virtual ~MIXCreateParser();
+ virtual ~MIXCreateParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level_;
diff --git a/Swiften/Parser/PayloadParsers/MIXDestroyParser.h b/Swiften/Parser/PayloadParsers/MIXDestroyParser.h
index 3a925de..8cfd91e 100644
--- a/Swiften/Parser/PayloadParsers/MIXDestroyParser.h
+++ b/Swiften/Parser/PayloadParsers/MIXDestroyParser.h
@@ -4,12 +4,17 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MIXDestroy.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -19,11 +24,11 @@ namespace Swift {
class SWIFTEN_API MIXDestroyParser : public GenericPayloadParser<MIXDestroy> {
public:
MIXDestroyParser();
- virtual ~MIXDestroyParser();
+ virtual ~MIXDestroyParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level_;
diff --git a/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp b/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp
index 2509667..6e72f90 100644
--- a/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp
+++ b/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp
@@ -9,7 +9,6 @@
#include <boost/optional.hpp>
#include <Swiften/Parser/PayloadParserFactory.h>
-#include <Swiften/Parser/PayloadParsers/MIXSubscribeParser.h>
#include <Swiften/Parser/PayloadParsers/FormParser.h>
using namespace Swift;
@@ -35,8 +34,10 @@ void MIXJoinParser::handleStartElement(const std::string& element, const std::st
}
if (level_ == 1) {
- if (element == "subscribe" && ns == "urn:xmpp:mix:1") {
- currentPayloadParser_ = std::make_shared<MIXSubscribeParser>();
+ if (element == "subscribe" && ns == "urn:xmpp:mix:0") {
+ if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) {
+ getPayloadInternal()->addSubscription(*attributeValue);
+ }
}
if (element == "x" && ns == "jabber:x:data") {
currentPayloadParser_ = std::make_shared<FormParser>();
@@ -57,9 +58,6 @@ void MIXJoinParser::handleEndElement(const std::string& element, const std::stri
}
if (level_ == 1) {
- if (element == "subscribe" && ns == "urn:xmpp:mix:1") {
- getPayloadInternal()->addSubscription(std::dynamic_pointer_cast<MIXSubscribe>(currentPayloadParser_->getPayload()));
- }
if (element == "x" && ns == "jabber:x:data") {
getPayloadInternal()->setForm(std::dynamic_pointer_cast<Form>(currentPayloadParser_->getPayload()));
}
diff --git a/Swiften/Parser/PayloadParsers/MIXJoinParser.h b/Swiften/Parser/PayloadParsers/MIXJoinParser.h
index c0ded7b..f371d6f 100644
--- a/Swiften/Parser/PayloadParsers/MIXJoinParser.h
+++ b/Swiften/Parser/PayloadParsers/MIXJoinParser.h
@@ -4,12 +4,17 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MIXJoin.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -19,11 +24,11 @@ namespace Swift {
class SWIFTEN_API MIXJoinParser : public GenericPayloadParser<MIXJoin> {
public:
MIXJoinParser();
- virtual ~MIXJoinParser();
+ virtual ~MIXJoinParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level_;
diff --git a/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h b/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h
index 6103c70..8432c61 100644
--- a/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h
+++ b/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h
@@ -17,7 +17,7 @@ namespace Swift {
}
virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const {
- return element == "join" && ns == "urn:xmpp:mix:1";
+ return element == "join" && ns == "urn:xmpp:mix:0";
}
virtual PayloadParser* createPayloadParser() {
diff --git a/Swiften/Parser/PayloadParsers/MIXLeaveParser.cpp b/Swiften/Parser/PayloadParsers/MIXLeaveParser.cpp
new file mode 100644
index 0000000..6330925
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXLeaveParser.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/MIXLeaveParser.h>
+
+#include <boost/optional.hpp>
+
+namespace Swift {
+
+MIXLeaveParser::MIXLeaveParser() : level_(0) {
+}
+
+MIXLeaveParser::~MIXLeaveParser() {
+}
+
+void MIXLeaveParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) {
+ if (level_ == 0) {
+ if (auto attributeValue = attributes.getAttributeValue("channel")) {
+ if (auto jid = JID::parse(*attributeValue)) {
+ getPayloadInternal()->setChannel(*jid);
+ }
+ }
+ }
+ ++level_;
+}
+
+void MIXLeaveParser::handleEndElement(const std::string&, const std::string&) {
+ --level_;
+}
+
+void MIXLeaveParser::handleCharacterData(const std::string&) {
+
+}
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.h b/Swiften/Parser/PayloadParsers/MIXLeaveParser.h
index eecc0d2..b0798b4 100644
--- a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.h
+++ b/Swiften/Parser/PayloadParsers/MIXLeaveParser.h
@@ -4,27 +4,30 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
-#include <Swiften/Elements/MIXSubscribe.h>
+#include <Swiften/Elements/MIXLeave.h>
#include <Swiften/Parser/GenericPayloadParser.h>
namespace Swift {
- class PayloadParserFactoryCollection;
- class PayloadParser;
- class SWIFTEN_API MIXSubscribeParser : public GenericPayloadParser<MIXSubscribe> {
+ class SWIFTEN_API MIXLeaveParser : public GenericPayloadParser<MIXLeave> {
public:
- MIXSubscribeParser();
- virtual ~MIXSubscribeParser();
+ MIXLeaveParser();
+ virtual ~MIXLeaveParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level_;
diff --git a/Swiften/Parser/PayloadParsers/MIXPayloadParser.cpp b/Swiften/Parser/PayloadParsers/MIXPayloadParser.cpp
new file mode 100644
index 0000000..51ef584
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXPayloadParser.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/MIXPayloadParser.h>
+
+namespace Swift {
+
+void MIXPayloadParser::handleTree(ParserElement::ref root) {
+ for (const auto& child : root->getAllChildren()) {
+ if (child->getName() == "nick" && child->getNamespace() == root->getNamespace()) {
+ getPayloadInternal()->setNick(child->getText());
+ } else if (child->getName() == "jid" && child->getNamespace() == root->getNamespace()) {
+ if (boost::optional<JID> jid = JID::parse(child->getText())) {
+ getPayloadInternal()->setJID(*jid);
+ }
+ } else if (child->getName() == "submission-id" && child->getNamespace() == root->getNamespace()) {
+ getPayloadInternal()->setSubmissionID(child->getText());
+ }
+ }
+}
+
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXPayloadParser.h b/Swiften/Parser/PayloadParsers/MIXPayloadParser.h
new file mode 100644
index 0000000..9133e8b
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXPayloadParser.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/MIXPayload.h>
+#include <Swiften/Parser/GenericPayloadTreeParser.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXPayloadParser : public GenericPayloadTreeParser<MIXPayload> {
+ public:
+ MIXPayloadParser() {}
+ virtual void handleTree(ParserElement::ref root) override;
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h b/Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h
new file mode 100644
index 0000000..8397b78
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Parser/GenericPayloadParserFactory.h>
+#include <Swiften/Parser/PayloadParsers/MIXPayloadParser.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXPayloadParserFactory : public PayloadParserFactory {
+ public:
+ MIXPayloadParserFactory() {
+ }
+
+ virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const override {
+ return element == "mix" && ns == "urn:xmpp:mix:0";
+ }
+
+ virtual PayloadParser* createPayloadParser() override {
+ return new MIXPayloadParser();
+ }
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.cpp b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.cpp
new file mode 100644
index 0000000..945e9b2
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.cpp
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h>
+
+namespace Swift {
+
+void MIXRegisterNickParser::handleTree(ParserElement::ref root) {
+ for (const auto& child : root->getAllChildren()) {
+ if (child->getName() == "nick" && child->getNamespace() == root->getNamespace()) {
+ getPayloadInternal()->setNick(child->getText());
+ }
+ }
+}
+
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h
new file mode 100644
index 0000000..cfb618e
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/MIXRegisterNick.h>
+#include <Swiften/Parser/GenericPayloadTreeParser.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXRegisterNickParser : public GenericPayloadTreeParser<MIXRegisterNick> {
+ public:
+ MIXRegisterNickParser() {}
+ virtual void handleTree(ParserElement::ref root) override;
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h b/Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h
new file mode 100644
index 0000000..e03392c
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Parser/GenericPayloadParserFactory.h>
+#include <Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXRegisterNickParserFactory : public PayloadParserFactory {
+ public:
+ MIXRegisterNickParserFactory() {
+ }
+
+ virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const override {
+ return element == "register" && ns == "urn:xmpp:mix:0";
+ }
+
+ virtual PayloadParser* createPayloadParser() override {
+ return new MIXRegisterNickParser();
+ }
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXSetNickParser.cpp b/Swiften/Parser/PayloadParsers/MIXSetNickParser.cpp
new file mode 100644
index 0000000..34fec70
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXSetNickParser.cpp
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/MIXSetNickParser.h>
+
+namespace Swift {
+
+void MIXSetNickParser::handleTree(ParserElement::ref root) {
+ for (const auto& child : root->getAllChildren()) {
+ if (child->getName() == "nick" && child->getNamespace() == root->getNamespace()) {
+ getPayloadInternal()->setNick(child->getText());
+ }
+ }
+}
+
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXSetNickParser.h b/Swiften/Parser/PayloadParsers/MIXSetNickParser.h
new file mode 100644
index 0000000..6d552c8
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXSetNickParser.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/MIXSetNick.h>
+#include <Swiften/Parser/GenericPayloadTreeParser.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXSetNickParser : public GenericPayloadTreeParser<MIXSetNick> {
+ public:
+ MIXSetNickParser() {}
+ virtual void handleTree(ParserElement::ref root) override;
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h b/Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h
new file mode 100644
index 0000000..e028873
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Parser/GenericPayloadParserFactory.h>
+#include <Swiften/Parser/PayloadParsers/MIXSetNickParser.h>
+
+namespace Swift {
+ class SWIFTEN_API MIXSetNickParserFactory : public PayloadParserFactory {
+ public:
+ MIXSetNickParserFactory() {
+ }
+
+ virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const override {
+ return element == "setnick" && ns == "urn:xmpp:mix:0";
+ }
+
+ virtual PayloadParser* createPayloadParser() override {
+ return new MIXSetNickParser();
+ }
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.cpp b/Swiften/Parser/PayloadParsers/MIXSubscribeParser.cpp
deleted file mode 100644
index 1500716..0000000
--- a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017 Tarun Gupta
- * Licensed under the simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-#include <Swiften/Parser/PayloadParsers/MIXSubscribeParser.h>
-
-#include <boost/optional.hpp>
-
-#include <Swiften/Parser/PayloadParserFactory.h>
-#include <Swiften/Parser/PayloadParserFactoryCollection.h>
-
-using namespace Swift;
-
-MIXSubscribeParser::MIXSubscribeParser() : level_(0) {
-}
-
-MIXSubscribeParser::~MIXSubscribeParser() {
-}
-
-void MIXSubscribeParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) {
- if (level_ == 0) {
- if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) {
- getPayloadInternal()->setNode(*attributeValue);
- }
- }
- ++level_;
-}
-
-void MIXSubscribeParser::handleEndElement(const std::string& , const std::string& ) {
- --level_;
-}
-
-void MIXSubscribeParser::handleCharacterData(const std::string& ) {
-}
diff --git a/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp
new file mode 100644
index 0000000..d530e49
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h>
+
+#include <boost/optional.hpp>
+
+#include <Swiften/Parser/PayloadParserFactory.h>
+#include <Swiften/Parser/PayloadParsers/FormParser.h>
+
+namespace Swift {
+
+MIXUpdateSubscriptionParser::MIXUpdateSubscriptionParser() : level_(0) {
+}
+
+MIXUpdateSubscriptionParser::~MIXUpdateSubscriptionParser() {
+}
+
+void MIXUpdateSubscriptionParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
+ if (level_ == 0) {
+ if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("jid")) {
+ if (boost::optional<JID> jid = JID::parse(*attributeValue)) {
+ getPayloadInternal()->setJID(*jid);
+ }
+ }
+ }
+
+ if (level_ == 1) {
+ if (element == "subscribe" && ns == "urn:xmpp:mix:0") {
+ if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) {
+ getPayloadInternal()->addSubscription(*attributeValue);
+ }
+ }
+ }
+
+ ++level_;
+}
+
+void MIXUpdateSubscriptionParser::handleEndElement(const std::string&, const std::string&) {
+ --level_;
+}
+
+void MIXUpdateSubscriptionParser::handleCharacterData(const std::string&) {
+}
+
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h
new file mode 100644
index 0000000..47966ff
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+/*
+ * Copyright (c) 2017-2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/MIXUpdateSubscription.h>
+#include <Swiften/Parser/GenericPayloadParser.h>
+
+namespace Swift {
+ class PayloadParser;
+
+ class SWIFTEN_API MIXUpdateSubscriptionParser : public GenericPayloadParser<MIXUpdateSubscription> {
+ public:
+ MIXUpdateSubscriptionParser();
+ virtual ~MIXUpdateSubscriptionParser() override;
+
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
+
+ private:
+ int level_;
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h b/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h
index 505087d..b2a2c10 100644
--- a/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h
+++ b/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h
@@ -4,12 +4,17 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MIXUserPreference.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -19,11 +24,11 @@ namespace Swift {
class SWIFTEN_API MIXUserPreferenceParser : public GenericPayloadParser<MIXUserPreference> {
public:
MIXUserPreferenceParser();
- virtual ~MIXUserPreferenceParser();
+ virtual ~MIXUserPreferenceParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level_;
diff --git a/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h b/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h
index eabe3db..383ceae 100644
--- a/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubAffiliation.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubAffiliationParser : public GenericPayloadParser<PubSubAffiliation> {
public:
PubSubAffiliationParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubAffiliationParser();
+ virtual ~PubSubAffiliationParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h b/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h
index 2f80dbd..48e3825 100644
--- a/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubAffiliations.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubAffiliationsParser : public GenericPayloadParser<PubSubAffiliations> {
public:
PubSubAffiliationsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubAffiliationsParser();
+ virtual ~PubSubAffiliationsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h b/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h
index 90c2f3e..e53d477 100644
--- a/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubConfigure.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubConfigureParser : public GenericPayloadParser<PubSubConfigure> {
public:
PubSubConfigureParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubConfigureParser();
+ virtual ~PubSubConfigureParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubCreateParser.h b/Swiften/Parser/PayloadParsers/PubSubCreateParser.h
index a1ada74..626419c 100644
--- a/Swiften/Parser/PayloadParsers/PubSubCreateParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubCreateParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubCreate.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubCreateParser : public GenericPayloadParser<PubSubCreate> {
public:
PubSubCreateParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubCreateParser();
+ virtual ~PubSubCreateParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h b/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h
index 01bea7b..08f6b43 100644
--- a/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubDefault.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubDefaultParser : public GenericPayloadParser<PubSubDefault> {
public:
PubSubDefaultParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubDefaultParser();
+ virtual ~PubSubDefaultParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubErrorParser.h b/Swiften/Parser/PayloadParsers/PubSubErrorParser.h
index 9c41095..273da82 100644
--- a/Swiften/Parser/PayloadParsers/PubSubErrorParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubErrorParser.h
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubError.h>
#include <Swiften/Parser/EnumParser.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -18,11 +17,11 @@ namespace Swift {
class SWIFTEN_API PubSubErrorParser : public GenericPayloadParser<PubSubError> {
public:
PubSubErrorParser();
- virtual ~PubSubErrorParser();
+ virtual ~PubSubErrorParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h b/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h
index 4bb9bd9..f4d6327 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventAssociate.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventAssociateParser : public GenericPayloadParser<PubSubEventAssociate> {
public:
PubSubEventAssociateParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventAssociateParser();
+ virtual ~PubSubEventAssociateParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h b/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h
index ffdafcf..ffa1deb 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventCollection.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventCollectionParser : public GenericPayloadParser<PubSubEventCollection> {
public:
PubSubEventCollectionParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventCollectionParser();
+ virtual ~PubSubEventCollectionParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h b/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h
index dddb7a4..6b68d86 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventConfiguration.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventConfigurationParser : public GenericPayloadParser<PubSubEventConfiguration> {
public:
PubSubEventConfigurationParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventConfigurationParser();
+ virtual ~PubSubEventConfigurationParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h b/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h
index 270430e..54a1913 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventDelete.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventDeleteParser : public GenericPayloadParser<PubSubEventDelete> {
public:
PubSubEventDeleteParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventDeleteParser();
+ virtual ~PubSubEventDeleteParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h b/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h
index 5f7f1af..6a0a7ce 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventDisassociate.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventDisassociateParser : public GenericPayloadParser<PubSubEventDisassociate> {
public:
PubSubEventDisassociateParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventDisassociateParser();
+ virtual ~PubSubEventDisassociateParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h b/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h
index bd2e72e..e9a986d 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventItem.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventItemParser : public GenericPayloadParser<PubSubEventItem> {
public:
PubSubEventItemParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventItemParser();
+ virtual ~PubSubEventItemParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h b/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h
index 34b3669..067a9f7 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventItems.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventItemsParser : public GenericPayloadParser<PubSubEventItems> {
public:
PubSubEventItemsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventItemsParser();
+ virtual ~PubSubEventItemsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventParser.h b/Swiften/Parser/PayloadParsers/PubSubEventParser.h
index 3b231b0..02cf01f 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEvent.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventParser : public GenericPayloadParser<PubSubEvent> {
public:
PubSubEventParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventParser();
+ virtual ~PubSubEventParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h b/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h
index 563283c..1c9e623 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventPurge.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventPurgeParser : public GenericPayloadParser<PubSubEventPurge> {
public:
PubSubEventPurgeParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventPurgeParser();
+ virtual ~PubSubEventPurgeParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h b/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h
index 603fbec..be7593e 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventRedirect.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventRedirectParser : public GenericPayloadParser<PubSubEventRedirect> {
public:
PubSubEventRedirectParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventRedirectParser();
+ virtual ~PubSubEventRedirectParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h b/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h
index 141790b..83a8e66 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventRetract.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventRetractParser : public GenericPayloadParser<PubSubEventRetract> {
public:
PubSubEventRetractParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventRetractParser();
+ virtual ~PubSubEventRetractParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h b/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h
index 0d56a20..6f2eeeb 100644
--- a/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubEventSubscription.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubEventSubscriptionParser : public GenericPayloadParser<PubSubEventSubscription> {
public:
PubSubEventSubscriptionParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubEventSubscriptionParser();
+ virtual ~PubSubEventSubscriptionParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubItemParser.h b/Swiften/Parser/PayloadParsers/PubSubItemParser.h
index c6e4ccf..cbbd3a5 100644
--- a/Swiften/Parser/PayloadParsers/PubSubItemParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubItemParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubItem.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubItemParser : public GenericPayloadParser<PubSubItem> {
public:
PubSubItemParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubItemParser();
+ virtual ~PubSubItemParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubItemsParser.h b/Swiften/Parser/PayloadParsers/PubSubItemsParser.h
index ad6e746..d792e1b 100644
--- a/Swiften/Parser/PayloadParsers/PubSubItemsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubItemsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubItems.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubItemsParser : public GenericPayloadParser<PubSubItems> {
public:
PubSubItemsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubItemsParser();
+ virtual ~PubSubItemsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h
index ac14caf..ee11f70 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOptions.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOptionsParser : public GenericPayloadParser<PubSubOptions> {
public:
PubSubOptionsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOptionsParser();
+ virtual ~PubSubOptionsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h
index 0a6503f..7bb93f1 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerAffiliation.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerAffiliationParser : public GenericPayloadParser<PubSubOwnerAffiliation> {
public:
PubSubOwnerAffiliationParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerAffiliationParser();
+ virtual ~PubSubOwnerAffiliationParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h
index 52c7fa9..20df72f 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerAffiliations.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerAffiliationsParser : public GenericPayloadParser<PubSubOwnerAffiliations> {
public:
PubSubOwnerAffiliationsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerAffiliationsParser();
+ virtual ~PubSubOwnerAffiliationsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h
index 34000fa..f11f357 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerConfigure.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerConfigureParser : public GenericPayloadParser<PubSubOwnerConfigure> {
public:
PubSubOwnerConfigureParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerConfigureParser();
+ virtual ~PubSubOwnerConfigureParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h
index 528c297..2f80b85 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerDefault.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerDefaultParser : public GenericPayloadParser<PubSubOwnerDefault> {
public:
PubSubOwnerDefaultParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerDefaultParser();
+ virtual ~PubSubOwnerDefaultParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h
index 99a8c0e..4484329 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerDelete.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerDeleteParser : public GenericPayloadParser<PubSubOwnerDelete> {
public:
PubSubOwnerDeleteParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerDeleteParser();
+ virtual ~PubSubOwnerDeleteParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h
index 35420f7..cfacc97 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerPubSub.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerPubSubParser : public GenericPayloadParser<PubSubOwnerPubSub> {
public:
PubSubOwnerPubSubParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerPubSubParser();
+ virtual ~PubSubOwnerPubSubParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h
index f85b2bb..8d233b6 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerPurge.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerPurgeParser : public GenericPayloadParser<PubSubOwnerPurge> {
public:
PubSubOwnerPurgeParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerPurgeParser();
+ virtual ~PubSubOwnerPurgeParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h
index 1197952..ebb6436 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerRedirect.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerRedirectParser : public GenericPayloadParser<PubSubOwnerRedirect> {
public:
PubSubOwnerRedirectParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerRedirectParser();
+ virtual ~PubSubOwnerRedirectParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h
index 74a61a2..d68d910 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerSubscription.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerSubscriptionParser : public GenericPayloadParser<PubSubOwnerSubscription> {
public:
PubSubOwnerSubscriptionParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerSubscriptionParser();
+ virtual ~PubSubOwnerSubscriptionParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h
index 541d225..ca868e6 100644
--- a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubOwnerSubscriptions.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubOwnerSubscriptionsParser : public GenericPayloadParser<PubSubOwnerSubscriptions> {
public:
PubSubOwnerSubscriptionsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubOwnerSubscriptionsParser();
+ virtual ~PubSubOwnerSubscriptionsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubParser.h b/Swiften/Parser/PayloadParsers/PubSubParser.h
index 1f40ca9..5cc50e1 100644
--- a/Swiften/Parser/PayloadParsers/PubSubParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSub.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -22,11 +21,11 @@ namespace Swift {
class SWIFTEN_API PubSubParser : public GenericPayloadParser<PubSub> {
public:
PubSubParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubParser();
+ virtual ~PubSubParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubPublishParser.h b/Swiften/Parser/PayloadParsers/PubSubPublishParser.h
index ad7dd11..e3b05ff 100644
--- a/Swiften/Parser/PayloadParsers/PubSubPublishParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubPublishParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubPublish.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubPublishParser : public GenericPayloadParser<PubSubPublish> {
public:
PubSubPublishParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubPublishParser();
+ virtual ~PubSubPublishParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubRetractParser.h b/Swiften/Parser/PayloadParsers/PubSubRetractParser.h
index 6bea498..aa9bbcc 100644
--- a/Swiften/Parser/PayloadParsers/PubSubRetractParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubRetractParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubRetract.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubRetractParser : public GenericPayloadParser<PubSubRetract> {
public:
PubSubRetractParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubRetractParser();
+ virtual ~PubSubRetractParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h
index 328818b..9deae2d 100644
--- a/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubSubscribeOptions.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubSubscribeOptionsParser : public GenericPayloadParser<PubSubSubscribeOptions> {
public:
PubSubSubscribeOptionsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubSubscribeOptionsParser();
+ virtual ~PubSubSubscribeOptionsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h
index 31221cb..ccd8ac8 100644
--- a/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubSubscribe.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubSubscribeParser : public GenericPayloadParser<PubSubSubscribe> {
public:
PubSubSubscribeParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubSubscribeParser();
+ virtual ~PubSubSubscribeParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h
index 7075a99..3d9be23 100644
--- a/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubSubscription.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubSubscriptionParser : public GenericPayloadParser<PubSubSubscription> {
public:
PubSubSubscriptionParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubSubscriptionParser();
+ virtual ~PubSubSubscriptionParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h
index 2371a56..c7169ae 100644
--- a/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubSubscriptions.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubSubscriptionsParser : public GenericPayloadParser<PubSubSubscriptions> {
public:
PubSubSubscriptionsParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubSubscriptionsParser();
+ virtual ~PubSubSubscriptionsParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
PayloadParserFactoryCollection* parsers;
diff --git a/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h b/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h
index e471130..21d5599 100644
--- a/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h
+++ b/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/PubSubUnsubscribe.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -20,11 +19,11 @@ namespace Swift {
class SWIFTEN_API PubSubUnsubscribeParser : public GenericPayloadParser<PubSubUnsubscribe> {
public:
PubSubUnsubscribeParser(PayloadParserFactoryCollection* parsers);
- virtual ~PubSubUnsubscribeParser();
+ virtual ~PubSubUnsubscribeParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/ReferencePayloadParser.cpp b/Swiften/Parser/PayloadParsers/ReferencePayloadParser.cpp
new file mode 100644
index 0000000..a337a29
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/ReferencePayloadParser.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/ReferencePayloadParser.h>
+
+#include <cassert>
+#include <iostream>
+
+#include <Swiften/Parser/PayloadParserFactory.h>
+#include <Swiften/Parser/PayloadParserFactoryCollection.h>
+
+namespace Swift {
+
+ReferencePayloadParser::ReferencePayloadParser(PayloadParserFactoryCollection* factories) : factories_(factories) {
+}
+
+ReferencePayload::Type ReferencePayloadParser::getTypeFromString(const std::string& typeString) const {
+ if (typeString == "data") {
+ return ReferencePayload::Type::Data;
+ }
+ else if (typeString == "mention") {
+ return ReferencePayload::Type::Mention;
+ }
+ else if (typeString == "pubsub") {
+ return ReferencePayload::Type::PubSub;
+ }
+ else {
+ return ReferencePayload::Type::Unknown;
+ }
+}
+
+void ReferencePayloadParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
+ if (level_ == topLevel_) {
+ if (element == "reference") {
+ getPayloadInternal()->setType(getTypeFromString(attributes.getAttribute("type")));
+ getPayloadInternal()->setUri(attributes.getAttributeValue("uri"));
+ getPayloadInternal()->setBegin(attributes.getAttributeValue("begin"));
+ getPayloadInternal()->setEnd(attributes.getAttributeValue("end"));
+ getPayloadInternal()->setAnchor(attributes.getAttributeValue("anchor"));
+ }
+ }
+ else if (level_ == payloadLevel_) {
+ PayloadParserFactory* payloadParserFactory = factories_->getPayloadParserFactory(element, ns, attributes);
+ if (payloadParserFactory) {
+ currentPayloadParser_.reset(payloadParserFactory->createPayloadParser());
+ }
+ }
+
+ if (level_ >= payloadLevel_ && currentPayloadParser_) {
+ currentPayloadParser_->handleStartElement(element, ns, attributes);
+ }
+
+ ++level_;
+}
+
+void ReferencePayloadParser::handleEndElement(const std::string& element, const std::string& ns) {
+ --level_;
+ if (currentPayloadParser_) {
+ if (level_ >= payloadLevel_) {
+ currentPayloadParser_->handleEndElement(element, ns);
+ }
+
+ if (level_ == payloadLevel_) {
+ getPayloadInternal()->addPayload(currentPayloadParser_->getPayload());
+ currentPayloadParser_.reset();
+ }
+ }
+}
+
+void ReferencePayloadParser::handleCharacterData(const std::string& data) {
+ if (level_ > payloadLevel_ && currentPayloadParser_) {
+ currentPayloadParser_->handleCharacterData(data);
+ }
+}
+
+}
diff --git a/Swiften/Parser/PayloadParsers/ReferencePayloadParser.h b/Swiften/Parser/PayloadParsers/ReferencePayloadParser.h
new file mode 100644
index 0000000..3afd181
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/ReferencePayloadParser.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/ReferencePayload.h>
+#include <Swiften/Parser/GenericPayloadParser.h>
+
+namespace Swift {
+
+ class PayloadParserFactoryCollection;
+
+ class SWIFTEN_API ReferencePayloadParser : public GenericPayloadParser<ReferencePayload> {
+ public:
+
+ ReferencePayloadParser(PayloadParserFactoryCollection* factories);
+
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes);
+ virtual void handleEndElement(const std::string& element, const std::string& ns);
+ virtual void handleCharacterData(const std::string& data);
+
+ private:
+
+ ReferencePayload::Type getTypeFromString(const std::string& typeString) const;
+ int level_ = 0;
+ const int topLevel_ = 0;
+ const int payloadLevel_ = 1;
+ PayloadParserFactoryCollection* factories_;
+ std::shared_ptr<PayloadParser> currentPayloadParser_;
+ };
+}
diff --git a/Swiften/Parser/PayloadParsers/ResultSetParser.h b/Swiften/Parser/PayloadParsers/ResultSetParser.h
index 819c0a5..edf6f2f 100644
--- a/Swiften/Parser/PayloadParsers/ResultSetParser.h
+++ b/Swiften/Parser/PayloadParsers/ResultSetParser.h
@@ -9,7 +9,6 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/ResultSet.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -18,9 +17,9 @@ namespace Swift {
public:
ResultSetParser();
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
enum Level {
TopLevel = 0,
diff --git a/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp b/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp
index 502f400..7a5a1fd 100644
--- a/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp
+++ b/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015-2016 Isode Limited.
+ * Copyright (c) 2015-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,6 +13,7 @@
#include <Swiften/Parser/PayloadParsers/S5BProxyRequestParser.h>
#include <boost/lexical_cast.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <boost/optional.hpp>
namespace Swift {
@@ -27,15 +28,14 @@ void S5BProxyRequestParser::handleStartElement(const std::string& element, const
if (element == "streamhost") {
if (attributes.getAttributeValue("host") && attributes.getAttributeValue("jid") && attributes.getAttributeValue("port")) {
std::string host = attributes.getAttributeValue("host").get_value_or("");
- int port = -1;
+ unsigned short port = 0;
JID jid = attributes.getAttributeValue("jid").get_value_or("");
try {
- port = boost::lexical_cast<int>(attributes.getAttributeValue("port").get());
- } catch (boost::bad_lexical_cast &) {
- port = -1;
+ port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(attributes.getAttributeValue("port").get()));
+ } catch (...) {
}
- if (!host.empty() && port != -1 && jid.isValid()) {
+ if (!host.empty() && port != 0 && jid.isValid()) {
S5BProxyRequest::StreamHost streamHost;
streamHost.host = host;
streamHost.port = port;
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp
index 85c79c6..f48bbc7 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXCreateParserTest, XEP0369_Example68) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<create xmlns=\"urn:xmpp:mix:1\"/>"
+ "<create xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXCreate>();
@@ -27,7 +27,7 @@ TEST(MIXCreateParserTest, XEP0369_Example68) {
TEST(MIXCreateParserTest, XEP0369_Example66) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"
+ "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXCreate>();
@@ -42,10 +42,10 @@ TEST(MIXCreateParserTest, XEP0369_Example66) {
TEST(MIXCreateParserTest, XEP0369_Example67) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\">"
+ "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\">"
"<x xmlns=\"jabber:x:data\" type=\"result\">"
"<field var=\"FORM_TYPE\" type=\"hidden\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"Owner\">"
"<value>hecate@shakespeare.lit</value>"
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp
index fc2588a..80eb144 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXDestroyParserTest, XEP0369_Example70) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"
+ "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXDestroy>();
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp
index 8e4dff2..5fa321e 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXDestroyParserTest, XEP0369_Example70) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"
+ "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXDestroy>();
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp
index 7a422f4..0ad4589 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXJoinParserTest, XEP0369_Example22) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\" channel=\"coven@mix.shakespeare.example\">"
+ "<join xmlns=\"urn:xmpp:mix:0\" channel=\"coven@mix.shakespeare.example\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
@@ -30,18 +30,17 @@ TEST(MIXJoinParserTest, XEP0369_Example22) {
ASSERT_FALSE(payload->getJID());
ASSERT_FALSE(payload->getForm());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(4), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode());
+ ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config")));
}
TEST(MIXJoinParserTest, XEP0369_Example23) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\">"
+ "<join xmlns=\"urn:xmpp:mix:0\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
@@ -56,18 +55,17 @@ TEST(MIXJoinParserTest, XEP0369_Example23) {
ASSERT_FALSE(payload->getJID());
ASSERT_FALSE(payload->getForm());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(4), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode());
+ ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config")));
}
TEST(MIXJoinParserTest, XEP0369_Example24) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\" jid=\"123456#coven@mix.shakespeare.example\">"
+ "<join xmlns=\"urn:xmpp:mix:0\" jid=\"123456#coven@mix.shakespeare.example\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
@@ -83,23 +81,22 @@ TEST(MIXJoinParserTest, XEP0369_Example24) {
ASSERT_EQ(JID("123456#coven@mix.shakespeare.example"), *payload->getJID());
ASSERT_FALSE(payload->getForm());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(4), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode());
+ ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config")));
}
TEST(MIXJoinParserTest, XEP0369_Example29) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\">"
+ "<join xmlns=\"urn:xmpp:mix:0\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<x xmlns=\"jabber:x:data\" type=\"submit\">"
"<field var=\"FORM_TYPE\" type=\"hidden\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"JID Visibility\">"
"<value>never</value>"
@@ -112,10 +109,10 @@ TEST(MIXJoinParserTest, XEP0369_Example29) {
ASSERT_FALSE(payload->getChannel());
ASSERT_FALSE(payload->getJID());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(2), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
+
+ ASSERT_EQ(static_cast<size_t>(2), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
ASSERT_TRUE(payload->getForm());
ASSERT_EQ(Form::Type::SubmitType, payload->getForm()->getType());
@@ -130,12 +127,12 @@ TEST(MIXJoinParserTest, XEP0369_Example29) {
TEST(MIXJoinParserTest, XEP0369_Example30) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\" jid=\"hag66@shakespeare.example\">"
+ "<join xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<x xmlns=\"jabber:x:data\" type=\"result\">"
"<field var=\"FORM_TYPE\" type=\"hidden\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"JID Visibility\">"
"<value>never</value>"
@@ -156,10 +153,9 @@ TEST(MIXJoinParserTest, XEP0369_Example30) {
ASSERT_TRUE(payload->getJID());
ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(2), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
+ ASSERT_EQ(static_cast<size_t>(2), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
ASSERT_TRUE(payload->getForm());
ASSERT_EQ(Form::Type::ResultType, payload->getForm()->getType());
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp
new file mode 100644
index 0000000..0a2839e
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXLeave.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXLeaveParserTest, XEP0369_Example33) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse("<leave xmlns=\"urn:xmpp:mix:0\" channel=\"coven@mix.shakespeare.example\"/>"));
+
+ auto payload = parser.getPayload<MIXLeave>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getChannel());
+ ASSERT_EQ(JID("coven@mix.shakespeare.example"), *payload->getChannel());
+}
+
+TEST(MIXLeaveParserTest, XEP0369_Example34) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse("<leave xmlns=\"urn:xmpp:mix:0\"/>"));
+
+ auto payload = parser.getPayload<MIXLeave>();
+ ASSERT_TRUE(payload);
+ ASSERT_FALSE(payload->getChannel());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp
index 27c02e7..57d4b35 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp
@@ -54,6 +54,3 @@ TEST(MIXParticipantParserTest, XEP0369_Example27_ParticipantEmpty) {
ASSERT_FALSE(payload->getNick());
ASSERT_FALSE(payload->getJID());
}
-
-
-
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp
new file mode 100644
index 0000000..920aca7
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXPayload.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXPayloadParserTest, WithNick) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </mix>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getNick());
+ std::string nick = *payload->getNick();
+ ASSERT_EQ("thirdwitch", nick);
+
+ ASSERT_FALSE(payload->getJID());
+ ASSERT_FALSE(payload->getSubmissionID());
+}
+
+TEST(MIXPayloadParserTest, WithJID) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\"> <jid>hecate@mix.shakespeare.example</jid> </mix>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getJID());
+ JID jid = *payload->getJID();
+ ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString());
+
+ ASSERT_FALSE(payload->getNick());
+ ASSERT_FALSE(payload->getSubmissionID());
+}
+
+TEST(MIXPayloadParserTest, WithAll) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\">"
+ "<nick>thirdwitch</nick>"
+ "<jid>hecate@mix.shakespeare.example</jid>"
+ "<submission-id>92vax143g</submission-id>"
+ "</mix>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getNick());
+ std::string nick = *payload->getNick();
+ ASSERT_EQ("thirdwitch", nick);
+
+ ASSERT_TRUE(payload->getJID());
+ JID jid = *payload->getJID();
+ ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString());
+
+ ASSERT_TRUE(payload->getSubmissionID());
+ std::string subID = *payload->getSubmissionID();
+ ASSERT_EQ("92vax143g", subID);
+}
+
+TEST(MIXPayloadParserTest, Empty) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\"/>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+ ASSERT_FALSE(payload->getNick());
+ ASSERT_FALSE(payload->getJID());
+ ASSERT_FALSE(payload->getSubmissionID());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp
new file mode 100644
index 0000000..d0539fd
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXRegisterNick.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXRegisterNickParserTest, WithNick) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<register xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </register>"
+ ));
+
+ auto payload = parser.getPayload<MIXRegisterNick>();
+ ASSERT_TRUE(payload);
+ ASSERT_EQ("thirdwitch", payload->getNick());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp
new file mode 100644
index 0000000..84f8a5e
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXSetNick.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXSetNickParserTest, WithNick) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<setnick xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </setnick>"
+ ));
+
+ auto payload = parser.getPayload<MIXSetNick>();
+ ASSERT_TRUE(payload);
+ ASSERT_EQ("thirdwitch", payload->getNick());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp
new file mode 100644
index 0000000..985a34b
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXUpdateSubscription.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<update-subscription xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>"
+ ));
+
+ auto payload = parser.getPayload<MIXUpdateSubscription>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_FALSE(payload->getJID());
+
+ auto items = payload->getSubscriptions();
+ ASSERT_EQ(static_cast<size_t>(1), items.size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}
+
+TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28_WithJID) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<update-subscription xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>"
+ ));
+
+ auto payload = parser.getPayload<MIXUpdateSubscription>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getJID());
+ ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID());
+
+ auto items = payload->getSubscriptions();
+ ASSERT_EQ(static_cast<size_t>(1), items.size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp
index 3d048a5..7115f2a 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXUserPreferenceParserTest, XEP0369_Example31) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<user-preference xmlns='urn:xmpp:mix:1'/>"
+ "<user-preference xmlns='urn:xmpp:mix:0'/>"
));
auto payload = parser.getPayload<MIXUserPreference>();
@@ -26,10 +26,10 @@ TEST(MIXUserPreferenceParserTest, XEP0369_Example31) {
TEST(MIXUserPreferenceParserTest, XEP0369_Example32) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<user-preference xmlns='urn:xmpp:mix:1'>"
+ "<user-preference xmlns='urn:xmpp:mix:0'>"
"<x xmlns='jabber:x:data' type='result'>"
"<field var='FORM_TYPE' type='hidden'>"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var='JID Visibility'>"
"<value>never</value>"
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ReferencePayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ReferencePayloadParserTest.cpp
new file mode 100644
index 0000000..ca7b280
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/ReferencePayloadParserTest.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/Body.h>
+#include <Swiften/Elements/Delay.h>
+#include <Swiften/Elements/ErrorPayload.h>
+#include <Swiften/Parser/PayloadParsers/ReferencePayloadParser.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(ReferencePayloadParserTest, testParse) {
+ PayloadsParserTester parser;
+
+ ASSERT_TRUE(parser.parse(
+ "<reference xmlns='urn:xmpp:reference:0' "
+ "type='data' "
+ "uri='https://www.example.com/mindBlowingImage.jpeg' "
+ "begin='11' "
+ "end='22' "
+ "anchor='xmpp:data@localhost.example.test'>"
+ "</reference>"));
+
+ auto payload = std::dynamic_pointer_cast<ReferencePayload>(parser.getPayload());
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Data), static_cast<int>(payload->getType()));
+ ASSERT_EQ(std::string("https://www.example.com/mindBlowingImage.jpeg"), *payload->getUri());
+ ASSERT_EQ(std::string("11"), *payload->getBegin());
+ ASSERT_EQ(std::string("22"), *payload->getEnd());
+ ASSERT_EQ(std::string("xmpp:data@localhost.example.test"), *payload->getAnchor());
+}
+
+TEST(ReferencePayloadParserTest, testParseNoType) {
+ PayloadsParserTester parser;
+
+ ASSERT_TRUE(parser.parse(
+ "<reference xmlns='urn:xmpp:reference:0' "
+ "uri='https://www.example.com/mindBlowingImage.jpeg' "
+ "begin='11' "
+ "end='22' "
+ "anchor='xmpp:data@localhost.example.test'>"
+ "</reference>"));
+
+ auto payload = std::dynamic_pointer_cast<ReferencePayload>(parser.getPayload());
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Unknown), static_cast<int>(payload->getType()));
+ ASSERT_EQ(std::string("https://www.example.com/mindBlowingImage.jpeg"), *payload->getUri());
+ ASSERT_EQ(std::string("11"), *payload->getBegin());
+ ASSERT_EQ(std::string("22"), *payload->getEnd());
+ ASSERT_EQ(std::string("xmpp:data@localhost.example.test"), *payload->getAnchor());
+}
+
+TEST(ReferencePayloadParserTest, testParseEmbeddedPayloads) {
+ PayloadsParserTester parser;
+
+ ASSERT_TRUE(parser.parse(
+ "<reference xmlns='urn:xmpp:reference:0' type='data'> "
+ "<error type=\"modify\">"
+ "<bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
+ "<delay xmlns='urn:xmpp:delay' from='juliet@capulet.com/balcony' stamp='2002-09-10T23:41:07Z'/>"
+ "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">boo</text>"
+ "</error>"
+ "</reference>"));
+
+ auto payload = std::dynamic_pointer_cast<ReferencePayload>(parser.getPayload());
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Data), static_cast<int>(payload->getType()));
+ ASSERT_FALSE(payload->getUri());
+ ASSERT_FALSE(payload->getBegin());
+ ASSERT_FALSE(payload->getEnd());
+ ASSERT_FALSE(payload->getAnchor());
+ auto childPayloadList = payload->getPayloads();
+ auto errorPayload = std::dynamic_pointer_cast<ErrorPayload>(childPayloadList[0]);
+ ASSERT_TRUE(errorPayload);
+ ASSERT_EQ("boo", errorPayload->getText());
+ auto delayPayload = std::dynamic_pointer_cast<Delay>(errorPayload->getPayload());
+ ASSERT_TRUE(delayPayload);
+}
+
+TEST(ReferencePayloadParserTest, testParseEmbeddedPayloadWithText) {
+ PayloadsParserTester parser;
+
+ ASSERT_TRUE(parser.parse(
+ "<reference xmlns='urn:xmpp:reference:0' type='data'> "
+ "<body>Example Text</body>"
+ "</reference>"));
+
+ auto payload = std::dynamic_pointer_cast<ReferencePayload>(parser.getPayload());
+ auto childPayloadList = payload->getPayloads();
+ auto bodyPayload = std::dynamic_pointer_cast<Body>(childPayloadList[0]);
+ ASSERT_EQ("Example Text", bodyPayload->getText());
+}
+
+TEST(ReferencePayloadParserTest, testParseRecursive) {
+ PayloadsParserTester parser;
+
+ ASSERT_TRUE(parser.parse(
+ "<reference xmlns='urn:xmpp:reference:0' type='data'> "
+ "<reference xmlns='urn:xmpp:reference:0' type='data' uri='https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/summit.jpg' /> "
+ "<reference xmlns='urn:xmpp:reference:0' type='data' uri='xmpp:romeo@montague.lit/resource?jingle;id=9559976B-3FBF-4E7E-B457-2DAA225972BB' /> "
+ "<reference xmlns='urn:xmpp:reference:0' type='data'> "
+ "<reference xmlns='urn:xmpp:reference:0' type='data' uri='https://www.example.com/mindBlowingImage.jpeg' /> "
+ "</reference>"
+ "</reference>"));
+
+ auto payload = std::dynamic_pointer_cast<ReferencePayload>(parser.getPayload());
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Data), static_cast<int>(payload->getType()));
+ auto childPayloadList = payload->getPayloads();
+ auto childPayloadA = std::dynamic_pointer_cast<ReferencePayload>(childPayloadList[0]);
+ auto childPayloadB = std::dynamic_pointer_cast<ReferencePayload>(childPayloadList[1]);
+ auto childPayloadC = std::dynamic_pointer_cast<ReferencePayload>(childPayloadList[2]);
+ ASSERT_TRUE(childPayloadA);
+ ASSERT_TRUE(childPayloadB);
+ ASSERT_TRUE(childPayloadC);
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Data), static_cast<int>(childPayloadA->getType()));
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Data), static_cast<int>(childPayloadB->getType()));
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Data), static_cast<int>(childPayloadC->getType()));
+ ASSERT_EQ(std::string("https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/summit.jpg"), *childPayloadA->getUri());
+ ASSERT_EQ(std::string("xmpp:romeo@montague.lit/resource?jingle;id=9559976B-3FBF-4E7E-B457-2DAA225972BB"), *childPayloadB->getUri());
+ ASSERT_FALSE(childPayloadC->getUri());
+ ASSERT_FALSE(childPayloadC->getBegin());
+ ASSERT_FALSE(childPayloadC->getEnd());
+ ASSERT_FALSE(childPayloadC->getAnchor());
+ auto grandChildPayloadList = childPayloadC->getPayloads();
+ auto grandChildPayload = std::dynamic_pointer_cast<ReferencePayload>(grandChildPayloadList[0]);
+ ASSERT_TRUE(grandChildPayload);
+ ASSERT_EQ(static_cast<int>(ReferencePayload::Type::Data), static_cast<int>(grandChildPayload->getType()));
+ ASSERT_EQ(std::string("https://www.example.com/mindBlowingImage.jpeg"), *grandChildPayload->getUri());
+ ASSERT_FALSE(grandChildPayload->getBegin());
+ ASSERT_FALSE(grandChildPayload->getEnd());
+ ASSERT_FALSE(grandChildPayload->getAnchor());
+}
diff --git a/Swiften/Parser/PayloadParsers/UserLocationParser.h b/Swiften/Parser/PayloadParsers/UserLocationParser.h
index 1445d3e..39df9de 100644
--- a/Swiften/Parser/PayloadParsers/UserLocationParser.h
+++ b/Swiften/Parser/PayloadParsers/UserLocationParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/UserLocation.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -18,11 +17,11 @@ namespace Swift {
class SWIFTEN_API UserLocationParser : public GenericPayloadParser<UserLocation> {
public:
UserLocationParser();
- virtual ~UserLocationParser();
+ virtual ~UserLocationParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PayloadParsers/UserTuneParser.h b/Swiften/Parser/PayloadParsers/UserTuneParser.h
index 5a27273..8c7e8c5 100644
--- a/Swiften/Parser/PayloadParsers/UserTuneParser.h
+++ b/Swiften/Parser/PayloadParsers/UserTuneParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <string>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/UserTune.h>
#include <Swiften/Parser/GenericPayloadParser.h>
@@ -18,11 +17,11 @@ namespace Swift {
class SWIFTEN_API UserTuneParser : public GenericPayloadParser<UserTune> {
public:
UserTuneParser();
- virtual ~UserTuneParser();
+ virtual ~UserTuneParser() override;
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE;
- virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE;
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE;
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override;
+ virtual void handleEndElement(const std::string& element, const std::string&) override;
+ virtual void handleCharacterData(const std::string& data) override;
private:
int level;
diff --git a/Swiften/Parser/PlatformXMLParserFactory.cpp b/Swiften/Parser/PlatformXMLParserFactory.cpp
index 97e1c9e..bf66734 100644
--- a/Swiften/Parser/PlatformXMLParserFactory.cpp
+++ b/Swiften/Parser/PlatformXMLParserFactory.cpp
@@ -22,9 +22,9 @@ PlatformXMLParserFactory::PlatformXMLParserFactory() {
std::unique_ptr<XMLParser> PlatformXMLParserFactory::createXMLParser(XMLParserClient* client) {
#ifdef HAVE_LIBXML
- return std::unique_ptr<XMLParser>(new LibXMLParser(client));
+ return std::make_unique<LibXMLParser>(client);
#else
- return std::unique_ptr<XMLParser>(new ExpatParser(client));
+ return std::make_unique<ExpatParser>(client);
#endif
}
diff --git a/Swiften/Parser/SConscript b/Swiften/Parser/SConscript
index 3c778f5..4ac5aa4 100644
--- a/Swiften/Parser/SConscript
+++ b/Swiften/Parser/SConscript
@@ -53,6 +53,7 @@ sources = [
"PayloadParsers/PriorityParser.cpp",
"PayloadParsers/PrivateStorageParser.cpp",
"PayloadParsers/RawXMLPayloadParser.cpp",
+ "PayloadParsers/ReferencePayloadParser.cpp",
"PayloadParsers/ResourceBindParser.cpp",
"PayloadParsers/RosterItemExchangeParser.cpp",
"PayloadParsers/RosterParser.cpp",
@@ -68,11 +69,15 @@ sources = [
"PayloadParsers/VCardUpdateParser.cpp",
"PayloadParsers/DelayParser.cpp",
"PayloadParsers/MIXParticipantParser.cpp",
+ "PayloadParsers/MIXSetNickParser.cpp",
+ "PayloadParsers/MIXRegisterNickParser.cpp",
"PayloadParsers/MIXDestroyParser.cpp",
"PayloadParsers/MIXCreateParser.cpp",
+ "PayloadParsers/MIXPayloadParser.cpp",
+ "PayloadParsers/MIXLeaveParser.cpp",
"PayloadParsers/MIXJoinParser.cpp",
- "PayloadParsers/MIXSubscribeParser.cpp",
"PayloadParsers/MIXUserPreferenceParser.cpp",
+ "PayloadParsers/MIXUpdateSubscriptionParser.cpp",
"PayloadParsers/MUCUserPayloadParser.cpp",
"PayloadParsers/MUCAdminPayloadParser.cpp",
"PayloadParsers/MUCOwnerPayloadParser.cpp",
diff --git a/Swiften/Parser/StanzaAckParser.cpp b/Swiften/Parser/StanzaAckParser.cpp
index de0287e..42ab181 100644
--- a/Swiften/Parser/StanzaAckParser.cpp
+++ b/Swiften/Parser/StanzaAckParser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,7 +17,7 @@ void StanzaAckParser::handleStartElement(const std::string&, const std::string&,
if (depth == 0) {
std::string handledStanzasString = attributes.getAttribute("h");
try {
- getElementGeneric()->setHandledStanzasCount(boost::lexical_cast<int>(handledStanzasString));
+ getElementGeneric()->setHandledStanzasCount(boost::lexical_cast<unsigned int>(handledStanzasString));
}
catch (const boost::bad_lexical_cast &) {
}
diff --git a/Swiften/Parser/Tree/ParserElement.cpp b/Swiften/Parser/Tree/ParserElement.cpp
index 5415945..988bc13 100644
--- a/Swiften/Parser/Tree/ParserElement.cpp
+++ b/Swiften/Parser/Tree/ParserElement.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,13 +7,8 @@
#include <Swiften/Parser/Tree/ParserElement.h>
-#include <boost/lambda/bind.hpp>
-#include <boost/lambda/lambda.hpp>
-
#include <Swiften/Parser/Tree/NullParserElement.h>
-namespace lambda = boost::lambda;
-
namespace Swift {
ParserElement::ParserElement(const std::string& name, const std::string& xmlns, const AttributeMap& attributes) : name_(name), xmlns_(xmlns), attributes_(attributes) {
@@ -34,8 +29,9 @@ void ParserElement::appendCharacterData(const std::string& data) {
std::vector<ParserElement::ref> ParserElement::getChildren(const std::string& name, const std::string& xmlns) const {
std::vector<ParserElement::ref> result;
- std::remove_copy_if(children_.begin(), children_.end(), std::back_inserter(result),
- lambda::bind(&ParserElement::getName, *lambda::_1) != name || lambda::bind(&ParserElement::getNamespace, *lambda::_1) != xmlns);
+ std::remove_copy_if(children_.begin(), children_.end(), std::back_inserter(result), [&](const ParserElement::ref& element) {
+ return (element->getName() != name) || (element->getNamespace() != xmlns);
+ });
return result;
}
diff --git a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
index 38e67fb..e313124 100644
--- a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
+++ b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
@@ -29,12 +29,12 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture {
public:
void setUp() {
- channel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
+ channel = std::make_unique<DummyStanzaChannel>();
testPresence = std::make_shared<Presence>();
testPresence->setStatus("Foo");
secondTestPresence = std::make_shared<Presence>();
secondTestPresence->setStatus("Bar");
- stanzaChannelPresenceSender = std::unique_ptr<StanzaChannelPresenceSender>(new StanzaChannelPresenceSender(channel.get()));
+ stanzaChannelPresenceSender = std::make_unique<StanzaChannelPresenceSender>(channel.get());
}
void testSendPresence() {
diff --git a/Swiften/PubSub/PubSubManager.h b/Swiften/PubSub/PubSubManager.h
index eba5dd9..477b3de 100644
--- a/Swiften/PubSub/PubSubManager.h
+++ b/Swiften/PubSub/PubSubManager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,7 +11,6 @@
#include <boost/signals2.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Elements/IQ.h>
#include <Swiften/Elements/PubSub.h>
#include <Swiften/Elements/PubSubAffiliations.h>
diff --git a/Swiften/PubSub/PubSubManagerImpl.h b/Swiften/PubSub/PubSubManagerImpl.h
index 2f2b96b..0d0739c 100644
--- a/Swiften/PubSub/PubSubManagerImpl.h
+++ b/Swiften/PubSub/PubSubManagerImpl.h
@@ -9,11 +9,10 @@
#include <memory>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/PubSub/PubSubManager.h>
#define SWIFTEN_PUBSUBMANAGERIMPL_DECLARE_CREATE_REQUEST(payload, container, response) \
virtual std::shared_ptr< PubSubRequest<payload> > \
- createRequest(IQ::Type type, const JID& receiver, std::shared_ptr<payload> p) SWIFTEN_OVERRIDE { \
+ createRequest(IQ::Type type, const JID& receiver, std::shared_ptr<payload> p) override { \
return std::make_shared< PubSubRequest<payload> >(type, receiver, p, router); \
}
@@ -24,7 +23,7 @@ namespace Swift {
class SWIFTEN_API PubSubManagerImpl : public PubSubManager {
public:
PubSubManagerImpl(StanzaChannel* stanzaChannel, IQRouter* router);
- virtual ~PubSubManagerImpl();
+ virtual ~PubSubManagerImpl() override;
SWIFTEN_PUBSUB_FOREACH_PUBSUB_PAYLOAD_TYPE(
SWIFTEN_PUBSUBMANAGERIMPL_DECLARE_CREATE_REQUEST)
diff --git a/Swiften/QA/ClientTest/ClientTest.cpp b/Swiften/QA/ClientTest/ClientTest.cpp
index 5cb1765..c5117fa 100644
--- a/Swiften/QA/ClientTest/ClientTest.cpp
+++ b/Swiften/QA/ClientTest/ClientTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,6 +8,7 @@
#include <thread>
#include <boost/bind.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Client/Client.h>
#include <Swiften/Client/ClientXMLTracer.h>
@@ -74,7 +75,17 @@ int main(int, char**) {
if (boshHost && boshPort && boshPath) {
std::cout << "Using BOSH with URL: http://" << boshHost << ":" << boshPort << boshPath << std::endl;
- options.boshURL = URL("http", boshHost, atoi(boshPort), boshPath);
+ try {
+ options.boshURL = URL("http", boshHost, boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(boshPort)), boshPath);
+ }
+ catch (const boost::numeric::bad_numeric_cast& e) {
+ std::cerr << "SWIFT_CLIENTTEST_BOSH_PORT doesn't hold a valid port number: " << e.what() << std::endl;
+ return -1;
+ }
+ catch (const boost::bad_lexical_cast& e) {
+ std::cerr << "SWIFT_CLIENTTEST_BOSH_PORT doesn't hold a valid port number: " << e.what() << std::endl;
+ return -1;
+ }
}
client = new Swift::Client(JID(jid), std::string(pass), &networkFactories);
diff --git a/Swiften/QA/DNSSDTest/DNSSDTest.cpp b/Swiften/QA/DNSSDTest/DNSSDTest.cpp
index ae2fafd..5a78d2f 100644
--- a/Swiften/QA/DNSSDTest/DNSSDTest.cpp
+++ b/Swiften/QA/DNSSDTest/DNSSDTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -35,7 +35,7 @@ class DNSSDTest : public CppUnit::TestFixture {
public:
void setUp() {
eventLoop = new DummyEventLoop();
- querier = std::make_shared<DNSSDQuerier>();
+ querier = std::make_shared<DNSSDQuerierType>(eventLoop);
querier->start();
}
@@ -55,7 +55,7 @@ class DNSSDTest : public CppUnit::TestFixture {
// Publish the service
LinkLocalServiceInfo info;
- std::shared_ptr<DNSSDRegisterQuery> registerQuery = querier->createRegisterQuery("DNSSDTest", 1234, info.toTXTRecord());
+ std::shared_ptr<DNSSDRegisterQuery> registerQuery = querier->createRegisterQuery("DNSSDTest", 1234, *info.toTXTRecord());
registerQuery->onRegisterFinished.connect(boost::bind(&DNSSDTest::handleRegisterFinished, this, _1));
registerQuery->registerService();
@@ -137,7 +137,7 @@ class DNSSDTest : public CppUnit::TestFixture {
private:
DummyEventLoop* eventLoop;
- std::shared_ptr<DNSSDQuerier> querier;
+ std::shared_ptr<DNSSDQuerierType> querier;
std::vector<DNSSDServiceID> added;
std::vector<DNSSDServiceID> registered;
std::vector<DNSSDServiceID> toRemove;
diff --git a/Swiften/QA/DNSSDTest/SConscript b/Swiften/QA/DNSSDTest/SConscript
index 275a314..d9c9b04 100644
--- a/Swiften/QA/DNSSDTest/SConscript
+++ b/Swiften/QA/DNSSDTest/SConscript
@@ -7,6 +7,7 @@ if env["TEST"] :
myenv.MergeFlags(myenv["CHECKER_FLAGS"])
myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
myenv.MergeFlags(myenv["CPPUNIT_FLAGS"])
+ myenv.MergeFlags(myenv["GOOGLETEST_FLAGS"])
myenv.MergeFlags(myenv["BOOST