summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/Serializer
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.cpp24
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.h10
-rw-r--r--Swiften/Serializer/AuthFailureSerializer.h16
-rw-r--r--Swiften/Serializer/AuthRequestSerializer.cpp24
-rw-r--r--Swiften/Serializer/AuthRequestSerializer.h10
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.cpp26
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.h10
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.cpp24
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.h10
-rw-r--r--Swiften/Serializer/ComponentHandshakeSerializer.cpp4
-rw-r--r--Swiften/Serializer/ComponentHandshakeSerializer.h10
-rw-r--r--Swiften/Serializer/CompressFailureSerializer.h16
-rw-r--r--Swiften/Serializer/CompressRequestSerializer.cpp6
-rw-r--r--Swiften/Serializer/CompressRequestSerializer.h12
-rw-r--r--Swiften/Serializer/ElementSerializer.h12
-rw-r--r--Swiften/Serializer/EnableStreamManagementSerializer.h16
-rw-r--r--Swiften/Serializer/GenericElementSerializer.h16
-rw-r--r--Swiften/Serializer/GenericPayloadSerializer.h22
-rw-r--r--Swiften/Serializer/GenericStanzaSerializer.h34
-rw-r--r--Swiften/Serializer/IQSerializer.h34
-rw-r--r--Swiften/Serializer/MessageSerializer.cpp30
-rw-r--r--Swiften/Serializer/MessageSerializer.h18
-rw-r--r--Swiften/Serializer/PayloadSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializerCollection.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializerCollection.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/BlockSerializer.h36
-rw-r--r--Swiften/Serializer/PayloadSerializers/BodySerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp10
-rw-r--r--Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.cpp16
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.cpp16
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.cpp16
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.cpp24
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.cpp24
-rw-r--r--Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp124
-rw-r--r--Swiften/Serializer/PayloadSerializers/CommandSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/DelaySerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.cpp6
-rw-r--r--Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp46
-rw-r--r--Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp28
-rw-r--r--Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp94
-rw-r--r--Swiften/Serializer/PayloadSerializers/ErrorSerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/FormSerializer.cpp322
-rw-r--r--Swiften/Serializer/PayloadSerializers/FormSerializer.h28
-rw-r--r--Swiften/Serializer/PayloadSerializers/ForwardedSerializer.cpp50
-rw-r--r--Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h18
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp166
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp58
-rw-r--r--Swiften/Serializer/PayloadSerializers/IBBSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/IdleSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp132
-rw-r--r--Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp88
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp10
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.h18
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp74
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp16
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.h18
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.h18
-rw-r--r--Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp204
-rw-r--r--Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h32
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp114
-rw-r--r--Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.h26
-rw-r--r--Swiften/Serializer/PayloadSerializers/LastSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMFinSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMResultSerializer.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h18
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp10
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp40
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h100
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp18
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp64
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp76
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp6
-rw-r--r--Swiften/Serializer/PayloadSerializers/NicknameSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/PrioritySerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp32
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp168
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h20
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp14
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp14
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp24
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h24
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp40
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp36
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp18
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp18
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp14
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h24
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp30
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp18
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp18
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp56
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSerializer.h20
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp18
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp44
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp24
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp24
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp60
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp44
-rw-r--r--Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp72
-rw-r--r--Swiften/Serializer/PayloadSerializers/RosterSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h38
-rw-r--r--Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp60
-rw-r--r--Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp46
-rw-r--r--Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp46
-rw-r--r--Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp24
-rw-r--r--Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h14
-rw-r--r--Swiften/Serializer/PayloadSerializers/StatusSerializer.h18
-rw-r--r--Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h44
-rw-r--r--Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp58
-rw-r--r--Swiften/Serializer/PayloadSerializers/StorageSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp56
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp84
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/SubjectSerializer.h16
-rw-r--r--Swiften/Serializer/PayloadSerializers/ThreadSerializer.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/ThreadSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/BlockSerializerTest.cpp66
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/CarbonsSerializerTest.cpp212
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ChatStateSerializerTest.cpp72
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/DeliveryReceiptSerializerTest.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp82
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp50
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp562
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ForwardedSerializerTest.cpp186
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/IBBSerializerTest.cpp36
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/IdleSerializerTest.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp88
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/IsodeIQDelegationSerializerTest.cpp196
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp742
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp70
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MAMQuerySerializerTest.cpp80
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MAMResultSerializerTest.cpp76
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MUCAdminPayloadSerializerTest.cpp38
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp16
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h12
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp62
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemSerializerTest.cpp54
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemsSerializerTest.cpp84
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp26
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp74
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp144
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp72
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp168
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp316
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp86
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp102
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp20
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp78
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp96
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp94
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp142
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/UserTuneSerializerTest.cpp72
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp260
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp30
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp142
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp52
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp448
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp12
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h10
-rw-r--r--Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp364
-rw-r--r--Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h46
-rw-r--r--Swiften/Serializer/PresenceSerializer.cpp26
-rw-r--r--Swiften/Serializer/PresenceSerializer.h18
-rw-r--r--Swiften/Serializer/StanzaAckRequestSerializer.h16
-rw-r--r--Swiften/Serializer/StanzaAckSerializer.h24
-rw-r--r--Swiften/Serializer/StanzaSerializer.cpp64
-rw-r--r--Swiften/Serializer/StanzaSerializer.h32
-rw-r--r--Swiften/Serializer/StartTLSFailureSerializer.h16
-rw-r--r--Swiften/Serializer/StartTLSRequestSerializer.h16
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.cpp76
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.h10
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.cpp74
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.h10
-rw-r--r--Swiften/Serializer/StreamManagementEnabledSerializer.cpp18
-rw-r--r--Swiften/Serializer/StreamManagementEnabledSerializer.h10
-rw-r--r--Swiften/Serializer/StreamManagementFailedSerializer.h16
-rw-r--r--Swiften/Serializer/StreamResumeSerializer.cpp14
-rw-r--r--Swiften/Serializer/StreamResumeSerializer.h10
-rw-r--r--Swiften/Serializer/StreamResumedSerializer.cpp14
-rw-r--r--Swiften/Serializer/StreamResumedSerializer.h10
-rw-r--r--Swiften/Serializer/TLSProceedSerializer.h16
-rw-r--r--Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp74
-rw-r--r--Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp74
-rw-r--r--Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp74
-rw-r--r--Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp74
-rw-r--r--Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp74
-rw-r--r--Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp90
-rw-r--r--Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp98
-rw-r--r--Swiften/Serializer/XML/XMLElement.cpp68
-rw-r--r--Swiften/Serializer/XML/XMLElement.h24
-rw-r--r--Swiften/Serializer/XML/XMLNode.h10
-rw-r--r--Swiften/Serializer/XML/XMLRawTextNode.h20
-rw-r--r--Swiften/Serializer/XML/XMLTextNode.h42
-rw-r--r--Swiften/Serializer/XMPPSerializer.cpp108
-rw-r--r--Swiften/Serializer/XMPPSerializer.h38
303 files changed, 6600 insertions, 6600 deletions
diff --git a/Swiften/Serializer/AuthChallengeSerializer.cpp b/Swiften/Serializer/AuthChallengeSerializer.cpp
index a9f573f..2796a2d 100644
--- a/Swiften/Serializer/AuthChallengeSerializer.cpp
+++ b/Swiften/Serializer/AuthChallengeSerializer.cpp
@@ -16,18 +16,18 @@ AuthChallengeSerializer::AuthChallengeSerializer() {
}
SafeByteArray AuthChallengeSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- boost::shared_ptr<AuthChallenge> authChallenge(boost::dynamic_pointer_cast<AuthChallenge>(element));
- std::string value;
- boost::optional<std::vector<unsigned char> > message = authChallenge->getValue();
- if (message) {
- if ((*message).empty()) {
- value = "=";
- }
- else {
- value = Base64::encode(ByteArray(*message));
- }
- }
- return createSafeByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</challenge>");
+ boost::shared_ptr<AuthChallenge> authChallenge(boost::dynamic_pointer_cast<AuthChallenge>(element));
+ std::string value;
+ boost::optional<std::vector<unsigned char> > message = authChallenge->getValue();
+ if (message) {
+ if ((*message).empty()) {
+ value = "=";
+ }
+ else {
+ value = Base64::encode(ByteArray(*message));
+ }
+ }
+ return createSafeByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</challenge>");
}
}
diff --git a/Swiften/Serializer/AuthChallengeSerializer.h b/Swiften/Serializer/AuthChallengeSerializer.h
index 4d6915a..6c88d0a 100644
--- a/Swiften/Serializer/AuthChallengeSerializer.h
+++ b/Swiften/Serializer/AuthChallengeSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API AuthChallengeSerializer : public GenericElementSerializer<AuthChallenge> {
- public:
- AuthChallengeSerializer();
+ class SWIFTEN_API AuthChallengeSerializer : public GenericElementSerializer<AuthChallenge> {
+ public:
+ AuthChallengeSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ };
}
diff --git a/Swiften/Serializer/AuthFailureSerializer.h b/Swiften/Serializer/AuthFailureSerializer.h
index 9c1d66e..fe85d2c 100644
--- a/Swiften/Serializer/AuthFailureSerializer.h
+++ b/Swiften/Serializer/AuthFailureSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API AuthFailureSerializer : public GenericElementSerializer<AuthFailure> {
- public:
- AuthFailureSerializer() : GenericElementSerializer<AuthFailure>() {
- }
+ class SWIFTEN_API AuthFailureSerializer : public GenericElementSerializer<AuthFailure> {
+ public:
+ AuthFailureSerializer() : GenericElementSerializer<AuthFailure>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-sasl").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-sasl").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/AuthRequestSerializer.cpp b/Swiften/Serializer/AuthRequestSerializer.cpp
index bde0d2d..f479eac 100644
--- a/Swiften/Serializer/AuthRequestSerializer.cpp
+++ b/Swiften/Serializer/AuthRequestSerializer.cpp
@@ -17,18 +17,18 @@ AuthRequestSerializer::AuthRequestSerializer() {
}
SafeByteArray AuthRequestSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element));
- SafeByteArray value;
- boost::optional<SafeByteArray> message = authRequest->getMessage();
- if (message) {
- if ((*message).empty()) {
- value = createSafeByteArray("=");
- }
- else {
- value = Base64::encode(*message);
- }
- }
- return concat(createSafeByteArray("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">"), value, createSafeByteArray("</auth>"));
+ boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element));
+ SafeByteArray value;
+ boost::optional<SafeByteArray> message = authRequest->getMessage();
+ if (message) {
+ if ((*message).empty()) {
+ value = createSafeByteArray("=");
+ }
+ else {
+ value = Base64::encode(*message);
+ }
+ }
+ return concat(createSafeByteArray("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">"), value, createSafeByteArray("</auth>"));
}
}
diff --git a/Swiften/Serializer/AuthRequestSerializer.h b/Swiften/Serializer/AuthRequestSerializer.h
index c4c59ff..8522c35 100644
--- a/Swiften/Serializer/AuthRequestSerializer.h
+++ b/Swiften/Serializer/AuthRequestSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API AuthRequestSerializer : public GenericElementSerializer<AuthRequest> {
- public:
- AuthRequestSerializer();
+ class SWIFTEN_API AuthRequestSerializer : public GenericElementSerializer<AuthRequest> {
+ public:
+ AuthRequestSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ };
}
diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp
index 0f3128b..b4be521 100644
--- a/Swiften/Serializer/AuthResponseSerializer.cpp
+++ b/Swiften/Serializer/AuthResponseSerializer.cpp
@@ -16,19 +16,19 @@ namespace Swift {
AuthResponseSerializer::AuthResponseSerializer() {
}
-SafeByteArray AuthResponseSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element));
- SafeByteArray value;
- boost::optional<SafeByteArray> message = authResponse->getValue();
- if (message) {
- if ((*message).empty()) {
- value = createSafeByteArray("");
- }
- else {
- value = Base64::encode(*message);
- }
- }
- return concat(createSafeByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"), value, createSafeByteArray("</response>"));
+SafeByteArray AuthResponseSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
+ boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element));
+ SafeByteArray value;
+ boost::optional<SafeByteArray> message = authResponse->getValue();
+ if (message) {
+ if ((*message).empty()) {
+ value = createSafeByteArray("");
+ }
+ else {
+ value = Base64::encode(*message);
+ }
+ }
+ return concat(createSafeByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"), value, createSafeByteArray("</response>"));
}
}
diff --git a/Swiften/Serializer/AuthResponseSerializer.h b/Swiften/Serializer/AuthResponseSerializer.h
index 52b1d07..2017f75 100644
--- a/Swiften/Serializer/AuthResponseSerializer.h
+++ b/Swiften/Serializer/AuthResponseSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API AuthResponseSerializer : public GenericElementSerializer<AuthResponse> {
- public:
- AuthResponseSerializer();
+ class SWIFTEN_API AuthResponseSerializer : public GenericElementSerializer<AuthResponse> {
+ public:
+ AuthResponseSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ };
}
diff --git a/Swiften/Serializer/AuthSuccessSerializer.cpp b/Swiften/Serializer/AuthSuccessSerializer.cpp
index d506fb9..78fe6a1 100644
--- a/Swiften/Serializer/AuthSuccessSerializer.cpp
+++ b/Swiften/Serializer/AuthSuccessSerializer.cpp
@@ -16,18 +16,18 @@ AuthSuccessSerializer::AuthSuccessSerializer() {
}
SafeByteArray AuthSuccessSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- boost::shared_ptr<AuthSuccess> authSuccess(boost::dynamic_pointer_cast<AuthSuccess>(element));
- std::string value;
- boost::optional<std::vector<unsigned char> > message = authSuccess->getValue();
- if (message) {
- if ((*message).empty()) {
- value = "=";
- }
- else {
- value = Base64::encode(ByteArray(*message));
- }
- }
- return createSafeByteArray("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</success>");
+ boost::shared_ptr<AuthSuccess> authSuccess(boost::dynamic_pointer_cast<AuthSuccess>(element));
+ std::string value;
+ boost::optional<std::vector<unsigned char> > message = authSuccess->getValue();
+ if (message) {
+ if ((*message).empty()) {
+ value = "=";
+ }
+ else {
+ value = Base64::encode(ByteArray(*message));
+ }
+ }
+ return createSafeByteArray("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</success>");
}
}
diff --git a/Swiften/Serializer/AuthSuccessSerializer.h b/Swiften/Serializer/AuthSuccessSerializer.h
index 87fa846..99133fa 100644
--- a/Swiften/Serializer/AuthSuccessSerializer.h
+++ b/Swiften/Serializer/AuthSuccessSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API AuthSuccessSerializer : public GenericElementSerializer<AuthSuccess> {
- public:
- AuthSuccessSerializer();
+ class SWIFTEN_API AuthSuccessSerializer : public GenericElementSerializer<AuthSuccess> {
+ public:
+ AuthSuccessSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ };
}
diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.cpp b/Swiften/Serializer/ComponentHandshakeSerializer.cpp
index 0611b17..1ac1ce7 100644
--- a/Swiften/Serializer/ComponentHandshakeSerializer.cpp
+++ b/Swiften/Serializer/ComponentHandshakeSerializer.cpp
@@ -14,8 +14,8 @@ ComponentHandshakeSerializer::ComponentHandshakeSerializer() {
}
SafeByteArray ComponentHandshakeSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- boost::shared_ptr<ComponentHandshake> handshake(boost::dynamic_pointer_cast<ComponentHandshake>(element));
- return createSafeByteArray("<handshake>" + handshake->getData() + "</handshake>");
+ boost::shared_ptr<ComponentHandshake> handshake(boost::dynamic_pointer_cast<ComponentHandshake>(element));
+ return createSafeByteArray("<handshake>" + handshake->getData() + "</handshake>");
}
}
diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.h b/Swiften/Serializer/ComponentHandshakeSerializer.h
index 0d102e2..651903f 100644
--- a/Swiften/Serializer/ComponentHandshakeSerializer.h
+++ b/Swiften/Serializer/ComponentHandshakeSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API ComponentHandshakeSerializer : public GenericElementSerializer<ComponentHandshake> {
- public:
- ComponentHandshakeSerializer();
+ class SWIFTEN_API ComponentHandshakeSerializer : public GenericElementSerializer<ComponentHandshake> {
+ public:
+ ComponentHandshakeSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ };
}
diff --git a/Swiften/Serializer/CompressFailureSerializer.h b/Swiften/Serializer/CompressFailureSerializer.h
index e20d458..154f167 100644
--- a/Swiften/Serializer/CompressFailureSerializer.h
+++ b/Swiften/Serializer/CompressFailureSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API CompressFailureSerializer : public GenericElementSerializer<CompressFailure> {
- public:
- CompressFailureSerializer() : GenericElementSerializer<CompressFailure>() {
- }
+ class SWIFTEN_API CompressFailureSerializer : public GenericElementSerializer<CompressFailure> {
+ public:
+ CompressFailureSerializer() : GenericElementSerializer<CompressFailure>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("failure", "http://jabber.org/protocol/compress").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("failure", "http://jabber.org/protocol/compress").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/CompressRequestSerializer.cpp b/Swiften/Serializer/CompressRequestSerializer.cpp
index aecf9f4..c053cca 100644
--- a/Swiften/Serializer/CompressRequestSerializer.cpp
+++ b/Swiften/Serializer/CompressRequestSerializer.cpp
@@ -14,12 +14,12 @@ CompressRequestSerializer::CompressRequestSerializer() {
}
SafeByteArray CompressRequestSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- boost::shared_ptr<CompressRequest> compressRequest(boost::dynamic_pointer_cast<CompressRequest>(element));
- return createSafeByteArray("<compress xmlns='http://jabber.org/protocol/compress'><method>" + compressRequest->getMethod() + "</method></compress>");
+ boost::shared_ptr<CompressRequest> compressRequest(boost::dynamic_pointer_cast<CompressRequest>(element));
+ return createSafeByteArray("<compress xmlns='http://jabber.org/protocol/compress'><method>" + compressRequest->getMethod() + "</method></compress>");
}
bool CompressRequestSerializer::canSerialize(boost::shared_ptr<ToplevelElement> element) const {
- return boost::dynamic_pointer_cast<CompressRequest>(element) != 0;
+ return boost::dynamic_pointer_cast<CompressRequest>(element) != 0;
}
}
diff --git a/Swiften/Serializer/CompressRequestSerializer.h b/Swiften/Serializer/CompressRequestSerializer.h
index 2ff349d..1472a81 100644
--- a/Swiften/Serializer/CompressRequestSerializer.h
+++ b/Swiften/Serializer/CompressRequestSerializer.h
@@ -12,11 +12,11 @@
#include <Swiften/Serializer/ElementSerializer.h>
namespace Swift {
- class SWIFTEN_API CompressRequestSerializer : public ElementSerializer {
- public:
- CompressRequestSerializer();
+ class SWIFTEN_API CompressRequestSerializer : public ElementSerializer {
+ public:
+ CompressRequestSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const;
+ };
}
diff --git a/Swiften/Serializer/ElementSerializer.h b/Swiften/Serializer/ElementSerializer.h
index 3f4f5c1..15f69da 100644
--- a/Swiften/Serializer/ElementSerializer.h
+++ b/Swiften/Serializer/ElementSerializer.h
@@ -12,11 +12,11 @@
#include <Swiften/Elements/ToplevelElement.h>
namespace Swift {
- class ElementSerializer {
- public:
- virtual ~ElementSerializer();
+ class ElementSerializer {
+ public:
+ virtual ~ElementSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const = 0;
- virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const = 0;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const = 0;
+ virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const = 0;
+ };
}
diff --git a/Swiften/Serializer/EnableStreamManagementSerializer.h b/Swiften/Serializer/EnableStreamManagementSerializer.h
index f837e9f..ffbcf8b 100644
--- a/Swiften/Serializer/EnableStreamManagementSerializer.h
+++ b/Swiften/Serializer/EnableStreamManagementSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API EnableStreamManagementSerializer : public GenericElementSerializer<EnableStreamManagement> {
- public:
- EnableStreamManagementSerializer() : GenericElementSerializer<EnableStreamManagement>() {
- }
+ class SWIFTEN_API EnableStreamManagementSerializer : public GenericElementSerializer<EnableStreamManagement> {
+ public:
+ EnableStreamManagementSerializer() : GenericElementSerializer<EnableStreamManagement>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("enable", "urn:xmpp:sm:2").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("enable", "urn:xmpp:sm:2").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/GenericElementSerializer.h b/Swiften/Serializer/GenericElementSerializer.h
index 40ecb0f..053a163 100644
--- a/Swiften/Serializer/GenericElementSerializer.h
+++ b/Swiften/Serializer/GenericElementSerializer.h
@@ -12,13 +12,13 @@
#include <Swiften/Serializer/ElementSerializer.h>
namespace Swift {
- template<typename T>
- class SWIFTEN_API GenericElementSerializer : public ElementSerializer {
- public:
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const = 0;
+ template<typename T>
+ class SWIFTEN_API GenericElementSerializer : public ElementSerializer {
+ public:
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const = 0;
- virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const {
- return !!boost::dynamic_pointer_cast<T>(element);
- }
- };
+ virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const {
+ return !!boost::dynamic_pointer_cast<T>(element);
+ }
+ };
}
diff --git a/Swiften/Serializer/GenericPayloadSerializer.h b/Swiften/Serializer/GenericPayloadSerializer.h
index f02ccda..080d04b 100644
--- a/Swiften/Serializer/GenericPayloadSerializer.h
+++ b/Swiften/Serializer/GenericPayloadSerializer.h
@@ -12,17 +12,17 @@
#include <Swiften/Serializer/PayloadSerializer.h>
namespace Swift {
- template<typename PAYLOAD_TYPE>
- class GenericPayloadSerializer : public PayloadSerializer {
- public:
- virtual std::string serialize(boost::shared_ptr<Payload> element) const {
- return serializePayload(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(element));
- }
+ template<typename PAYLOAD_TYPE>
+ class GenericPayloadSerializer : public PayloadSerializer {
+ public:
+ virtual std::string serialize(boost::shared_ptr<Payload> element) const {
+ return serializePayload(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(element));
+ }
- virtual bool canSerialize(boost::shared_ptr<Payload> element) const {
- return !!boost::dynamic_pointer_cast<PAYLOAD_TYPE>(element);
- }
+ virtual bool canSerialize(boost::shared_ptr<Payload> element) const {
+ return !!boost::dynamic_pointer_cast<PAYLOAD_TYPE>(element);
+ }
- virtual std::string serializePayload(boost::shared_ptr<PAYLOAD_TYPE>) const = 0;
- };
+ virtual std::string serializePayload(boost::shared_ptr<PAYLOAD_TYPE>) const = 0;
+ };
}
diff --git a/Swiften/Serializer/GenericStanzaSerializer.h b/Swiften/Serializer/GenericStanzaSerializer.h
index 319ea67..e3eaae6 100644
--- a/Swiften/Serializer/GenericStanzaSerializer.h
+++ b/Swiften/Serializer/GenericStanzaSerializer.h
@@ -10,24 +10,24 @@
#include <Swiften/Serializer/StanzaSerializer.h>
namespace Swift {
- template<typename STANZA_TYPE>
- class SWIFTEN_API GenericStanzaSerializer : public StanzaSerializer {
- public:
- GenericStanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>()) : StanzaSerializer(tag, payloadSerializers, explicitNS) {}
+ template<typename STANZA_TYPE>
+ class SWIFTEN_API GenericStanzaSerializer : public StanzaSerializer {
+ public:
+ GenericStanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>()) : StanzaSerializer(tag, payloadSerializers, explicitNS) {}
- virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const {
- return dynamic_cast<STANZA_TYPE*>(element.get()) != 0;
- }
+ virtual bool canSerialize(boost::shared_ptr<ToplevelElement> element) const {
+ return dynamic_cast<STANZA_TYPE*>(element.get()) != 0;
+ }
- virtual void setStanzaSpecificAttributes(
- boost::shared_ptr<ToplevelElement> stanza,
- XMLElement& element) const {
- setStanzaSpecificAttributesGeneric(
- boost::dynamic_pointer_cast<STANZA_TYPE>(stanza), element);
- }
+ virtual void setStanzaSpecificAttributes(
+ boost::shared_ptr<ToplevelElement> stanza,
+ XMLElement& element) const {
+ setStanzaSpecificAttributesGeneric(
+ boost::dynamic_pointer_cast<STANZA_TYPE>(stanza), element);
+ }
- virtual void setStanzaSpecificAttributesGeneric(
- boost::shared_ptr<STANZA_TYPE>,
- XMLElement&) const = 0;
- };
+ virtual void setStanzaSpecificAttributesGeneric(
+ boost::shared_ptr<STANZA_TYPE>,
+ XMLElement&) const = 0;
+ };
}
diff --git a/Swiften/Serializer/IQSerializer.h b/Swiften/Serializer/IQSerializer.h
index f870ca1..db052fb 100644
--- a/Swiften/Serializer/IQSerializer.h
+++ b/Swiften/Serializer/IQSerializer.h
@@ -14,22 +14,22 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API IQSerializer : public GenericStanzaSerializer<IQ> {
- public:
- IQSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>()) :
- GenericStanzaSerializer<IQ>("iq", payloadSerializers, explicitNS) {
- }
+ class SWIFTEN_API IQSerializer : public GenericStanzaSerializer<IQ> {
+ public:
+ IQSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>()) :
+ GenericStanzaSerializer<IQ>("iq", payloadSerializers, explicitNS) {
+ }
- private:
- virtual void setStanzaSpecificAttributesGeneric(
- boost::shared_ptr<IQ> iq,
- XMLElement& element) const {
- switch (iq->getType()) {
- case IQ::Get: element.setAttribute("type","get"); break;
- case IQ::Set: element.setAttribute("type","set"); break;
- case IQ::Result: element.setAttribute("type","result"); break;
- case IQ::Error: element.setAttribute("type","error"); break;
- }
- }
- };
+ private:
+ virtual void setStanzaSpecificAttributesGeneric(
+ boost::shared_ptr<IQ> iq,
+ XMLElement& element) const {
+ switch (iq->getType()) {
+ case IQ::Get: element.setAttribute("type","get"); break;
+ case IQ::Set: element.setAttribute("type","set"); break;
+ case IQ::Result: element.setAttribute("type","result"); break;
+ case IQ::Error: element.setAttribute("type","error"); break;
+ }
+ }
+ };
}
diff --git a/Swiften/Serializer/MessageSerializer.cpp b/Swiften/Serializer/MessageSerializer.cpp
index 63a399a..fb16393 100644
--- a/Swiften/Serializer/MessageSerializer.cpp
+++ b/Swiften/Serializer/MessageSerializer.cpp
@@ -11,24 +11,24 @@
namespace Swift {
MessageSerializer::MessageSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS) :
- GenericStanzaSerializer<Message>("message", payloadSerializers, explicitNS) {
+ GenericStanzaSerializer<Message>("message", payloadSerializers, explicitNS) {
}
void MessageSerializer::setStanzaSpecificAttributesGeneric(
- boost::shared_ptr<Message> message,
- XMLElement& element) const {
- if (message->getType() == Message::Chat) {
- element.setAttribute("type", "chat");
- }
- else if (message->getType() == Message::Groupchat) {
- element.setAttribute("type", "groupchat");
- }
- else if (message->getType() == Message::Headline) {
- element.setAttribute("type", "headline");
- }
- else if (message->getType() == Message::Error) {
- element.setAttribute("type", "error");
- }
+ boost::shared_ptr<Message> message,
+ XMLElement& element) const {
+ if (message->getType() == Message::Chat) {
+ element.setAttribute("type", "chat");
+ }
+ else if (message->getType() == Message::Groupchat) {
+ element.setAttribute("type", "groupchat");
+ }
+ else if (message->getType() == Message::Headline) {
+ element.setAttribute("type", "headline");
+ }
+ else if (message->getType() == Message::Error) {
+ element.setAttribute("type", "error");
+ }
}
}
diff --git a/Swiften/Serializer/MessageSerializer.h b/Swiften/Serializer/MessageSerializer.h
index 91eee31..50df353 100644
--- a/Swiften/Serializer/MessageSerializer.h
+++ b/Swiften/Serializer/MessageSerializer.h
@@ -13,15 +13,15 @@
#include <Swiften/Serializer/GenericStanzaSerializer.h>
namespace Swift {
- class XMLElement;
+ class XMLElement;
- class SWIFTEN_API MessageSerializer : public GenericStanzaSerializer<Message> {
- public:
- MessageSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explitNS = boost::optional<std::string>());
+ class SWIFTEN_API MessageSerializer : public GenericStanzaSerializer<Message> {
+ public:
+ MessageSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explitNS = boost::optional<std::string>());
- private:
- void setStanzaSpecificAttributesGeneric(
- boost::shared_ptr<Message> message,
- XMLElement& element) const;
- };
+ private:
+ void setStanzaSpecificAttributesGeneric(
+ boost::shared_ptr<Message> message,
+ XMLElement& element) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializer.h b/Swiften/Serializer/PayloadSerializer.h
index fd97b74..642247d 100644
--- a/Swiften/Serializer/PayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializer.h
@@ -13,13 +13,13 @@
#include <Swiften/Base/API.h>
namespace Swift {
- class Payload;
+ class Payload;
- class SWIFTEN_API PayloadSerializer {
- public:
- virtual ~PayloadSerializer();
+ class SWIFTEN_API PayloadSerializer {
+ public:
+ virtual ~PayloadSerializer();
- virtual bool canSerialize(boost::shared_ptr<Payload>) const = 0;
- virtual std::string serialize(boost::shared_ptr<Payload>) const = 0;
- };
+ virtual bool canSerialize(boost::shared_ptr<Payload>) const = 0;
+ virtual std::string serialize(boost::shared_ptr<Payload>) const = 0;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializerCollection.cpp
index 080fc7c..ba8b191 100644
--- a/Swiften/Serializer/PayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializerCollection.cpp
@@ -18,18 +18,18 @@ PayloadSerializerCollection::PayloadSerializerCollection() {
}
void PayloadSerializerCollection::addSerializer(PayloadSerializer* serializer) {
- serializers_.push_back(serializer);
+ serializers_.push_back(serializer);
}
void PayloadSerializerCollection::removeSerializer(PayloadSerializer* serializer) {
- serializers_.erase(std::remove(serializers_.begin(), serializers_.end(), serializer), serializers_.end());
+ serializers_.erase(std::remove(serializers_.begin(), serializers_.end(), serializer), serializers_.end());
}
PayloadSerializer* PayloadSerializerCollection::getPayloadSerializer(boost::shared_ptr<Payload> payload) const {
- std::vector<PayloadSerializer*>::const_iterator i = std::find_if(
- serializers_.begin(), serializers_.end(),
- boost::bind(&PayloadSerializer::canSerialize, _1, payload));
- return (i != serializers_.end() ? *i : NULL);
+ std::vector<PayloadSerializer*>::const_iterator i = std::find_if(
+ serializers_.begin(), serializers_.end(),
+ boost::bind(&PayloadSerializer::canSerialize, _1, payload));
+ return (i != serializers_.end() ? *i : NULL);
}
}
diff --git a/Swiften/Serializer/PayloadSerializerCollection.h b/Swiften/Serializer/PayloadSerializerCollection.h
index abda457..47ba6a1 100644
--- a/Swiften/Serializer/PayloadSerializerCollection.h
+++ b/Swiften/Serializer/PayloadSerializerCollection.h
@@ -14,18 +14,18 @@
#include <Swiften/Elements/Payload.h>
namespace Swift {
- class PayloadSerializer;
-
+ class PayloadSerializer;
- class SWIFTEN_API PayloadSerializerCollection {
- public:
- PayloadSerializerCollection();
- void addSerializer(PayloadSerializer* factory);
- void removeSerializer(PayloadSerializer* factory);
- PayloadSerializer* getPayloadSerializer(boost::shared_ptr<Payload>) const;
+ class SWIFTEN_API PayloadSerializerCollection {
+ public:
+ PayloadSerializerCollection();
- private:
- std::vector<PayloadSerializer*> serializers_;
- };
+ void addSerializer(PayloadSerializer* factory);
+ void removeSerializer(PayloadSerializer* factory);
+ PayloadSerializer* getPayloadSerializer(boost::shared_ptr<Payload>) const;
+
+ private:
+ std::vector<PayloadSerializer*> serializers_;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/BlockSerializer.h b/Swiften/Serializer/PayloadSerializers/BlockSerializer.h
index 48c8004..7490e4f 100644
--- a/Swiften/Serializer/PayloadSerializers/BlockSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/BlockSerializer.h
@@ -14,24 +14,24 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- template<typename BLOCK_ELEMENT>
- class SWIFTEN_API BlockSerializer : public GenericPayloadSerializer<BLOCK_ELEMENT> {
- public:
- BlockSerializer(std::string tag) : GenericPayloadSerializer<BLOCK_ELEMENT>(), tag(tag) {
- }
+ template<typename BLOCK_ELEMENT>
+ class SWIFTEN_API BlockSerializer : public GenericPayloadSerializer<BLOCK_ELEMENT> {
+ public:
+ BlockSerializer(std::string tag) : GenericPayloadSerializer<BLOCK_ELEMENT>(), tag(tag) {
+ }
- virtual std::string serializePayload(boost::shared_ptr<BLOCK_ELEMENT> payload) const {
- XMLElement element(tag, "urn:xmpp:blocking");
- const std::vector<JID>& items = payload->getItems();
- for (std::vector<JID>::const_iterator i = items.begin(); i != items.end(); ++i) {
- boost::shared_ptr<XMLElement> item = boost::make_shared<XMLElement>("item");
- item->setAttribute("jid", *i);
- element.addNode(item);
- }
- return element.serialize();
- }
+ virtual std::string serializePayload(boost::shared_ptr<BLOCK_ELEMENT> payload) const {
+ XMLElement element(tag, "urn:xmpp:blocking");
+ const std::vector<JID>& items = payload->getItems();
+ for (std::vector<JID>::const_iterator i = items.begin(); i != items.end(); ++i) {
+ boost::shared_ptr<XMLElement> item = boost::make_shared<XMLElement>("item");
+ item->setAttribute("jid", *i);
+ element.addNode(item);
+ }
+ return element.serialize();
+ }
- private:
- std::string tag;
- };
+ private:
+ std::string tag;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/BodySerializer.h b/Swiften/Serializer/PayloadSerializers/BodySerializer.h
index 4f4b5b3..f2d7a8d 100644
--- a/Swiften/Serializer/PayloadSerializers/BodySerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/BodySerializer.h
@@ -12,13 +12,13 @@
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
- class SWIFTEN_API BodySerializer : public GenericPayloadSerializer<Body> {
- public:
- BodySerializer() : GenericPayloadSerializer<Body>() {}
+ class SWIFTEN_API BodySerializer : public GenericPayloadSerializer<Body> {
+ public:
+ BodySerializer() : GenericPayloadSerializer<Body>() {}
- virtual std::string serializePayload(boost::shared_ptr<Body> body) const {
- XMLTextNode textNode(body->getText());
- return "<body>" + textNode.serialize() + "</body>";
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<Body> body) const {
+ XMLTextNode textNode(body->getText());
+ return "<body>" + textNode.serialize() + "</body>";
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp
index bf1b8cb..b5218ee 100644
--- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp
@@ -18,23 +18,23 @@ namespace Swift {
BytestreamsSerializer::BytestreamsSerializer() {
}
-std::string BytestreamsSerializer::serializePayload(boost::shared_ptr<Bytestreams> bytestreams) const {
- XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams");
- queryElement.setAttribute("sid", bytestreams->getStreamID());
- foreach(const Bytestreams::StreamHost& streamHost, bytestreams->getStreamHosts()) {
- boost::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost"));
- streamHostElement->setAttribute("host", streamHost.host);
- streamHostElement->setAttribute("jid", streamHost.jid.toString());
- streamHostElement->setAttribute("port", boost::lexical_cast<std::string>(streamHost.port));
- queryElement.addNode(streamHostElement);
- }
-
- if (bytestreams->getUsedStreamHost()) {
- boost::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost-used"));
- streamHostElement->setAttribute("jid", *bytestreams->getUsedStreamHost());
- queryElement.addNode(streamHostElement);
- }
- return queryElement.serialize();
+std::string BytestreamsSerializer::serializePayload(boost::shared_ptr<Bytestreams> bytestreams) const {
+ XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams");
+ queryElement.setAttribute("sid", bytestreams->getStreamID());
+ foreach(const Bytestreams::StreamHost& streamHost, bytestreams->getStreamHosts()) {
+ boost::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost"));
+ streamHostElement->setAttribute("host", streamHost.host);
+ streamHostElement->setAttribute("jid", streamHost.jid.toString());
+ streamHostElement->setAttribute("port", boost::lexical_cast<std::string>(streamHost.port));
+ queryElement.addNode(streamHostElement);
+ }
+
+ if (bytestreams->getUsedStreamHost()) {
+ boost::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost-used"));
+ streamHostElement->setAttribute("jid", *bytestreams->getUsedStreamHost());
+ queryElement.addNode(streamHostElement);
+ }
+ return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h
index 5cf4dee..6056cad 100644
--- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h
@@ -11,12 +11,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API BytestreamsSerializer : public GenericPayloadSerializer<Bytestreams> {
- public:
- BytestreamsSerializer();
+ class SWIFTEN_API BytestreamsSerializer : public GenericPayloadSerializer<Bytestreams> {
+ public:
+ BytestreamsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<Bytestreams>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<Bytestreams>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp
index 87c45f6..799e662 100644
--- a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp
@@ -16,11 +16,11 @@ CapsInfoSerializer::CapsInfoSerializer() : GenericPayloadSerializer<CapsInfo>()
}
std::string CapsInfoSerializer::serializePayload(boost::shared_ptr<CapsInfo> capsInfo) const {
- XMLElement capsElement("c", "http://jabber.org/protocol/caps");
- capsElement.setAttribute("node", capsInfo->getNode());
- capsElement.setAttribute("hash", capsInfo->getHash());
- capsElement.setAttribute("ver", capsInfo->getVersion());
- return capsElement.serialize();
+ XMLElement capsElement("c", "http://jabber.org/protocol/caps");
+ capsElement.setAttribute("node", capsInfo->getNode());
+ capsElement.setAttribute("hash", capsInfo->getHash());
+ capsElement.setAttribute("ver", capsInfo->getVersion());
+ return capsElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h
index 9f20d06..bbf4c09 100644
--- a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API CapsInfoSerializer : public GenericPayloadSerializer<CapsInfo> {
- public:
- CapsInfoSerializer();
+ class SWIFTEN_API CapsInfoSerializer : public GenericPayloadSerializer<CapsInfo> {
+ public:
+ CapsInfoSerializer();
- virtual std::string serializePayload(boost::shared_ptr<CapsInfo>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<CapsInfo>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.cpp
index e39d005..406fdbc 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.cpp
@@ -9,16 +9,16 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- CarbonsDisableSerializer::CarbonsDisableSerializer() : GenericPayloadSerializer<CarbonsDisable>() {
+ CarbonsDisableSerializer::CarbonsDisableSerializer() : GenericPayloadSerializer<CarbonsDisable>() {
- }
+ }
- CarbonsDisableSerializer::~CarbonsDisableSerializer() {
+ CarbonsDisableSerializer::~CarbonsDisableSerializer() {
- }
+ }
- std::string CarbonsDisableSerializer::serializePayload(boost::shared_ptr<CarbonsDisable>) const {
- XMLElement element("disable", "urn:xmpp:carbons:2");
- return element.serialize();
- }
+ std::string CarbonsDisableSerializer::serializePayload(boost::shared_ptr<CarbonsDisable>) const {
+ XMLElement element("disable", "urn:xmpp:carbons:2");
+ return element.serialize();
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.h b/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.h
index 6eeb5d5..da01ead 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsDisableSerializer.h
@@ -11,11 +11,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API CarbonsDisableSerializer : public GenericPayloadSerializer<CarbonsDisable> {
- public:
- CarbonsDisableSerializer();
- virtual ~CarbonsDisableSerializer();
+ class SWIFTEN_API CarbonsDisableSerializer : public GenericPayloadSerializer<CarbonsDisable> {
+ public:
+ CarbonsDisableSerializer();
+ virtual ~CarbonsDisableSerializer();
- virtual std::string serializePayload(boost::shared_ptr<CarbonsDisable>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<CarbonsDisable>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.cpp
index 0bc3822..a2520f9 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.cpp
@@ -9,15 +9,15 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- CarbonsEnableSerializer::CarbonsEnableSerializer() : GenericPayloadSerializer<CarbonsEnable>() {
- }
+ CarbonsEnableSerializer::CarbonsEnableSerializer() : GenericPayloadSerializer<CarbonsEnable>() {
+ }
- CarbonsEnableSerializer::~CarbonsEnableSerializer() {
+ CarbonsEnableSerializer::~CarbonsEnableSerializer() {
- }
+ }
- std::string CarbonsEnableSerializer::serializePayload(boost::shared_ptr<CarbonsEnable>) const {
- XMLElement element("enable", "urn:xmpp:carbons:2");
- return element.serialize();
- }
+ std::string CarbonsEnableSerializer::serializePayload(boost::shared_ptr<CarbonsEnable>) const {
+ XMLElement element("enable", "urn:xmpp:carbons:2");
+ return element.serialize();
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.h b/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.h
index aa76d5f..8b26901 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.h
@@ -12,11 +12,11 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API CarbonsEnableSerializer : public GenericPayloadSerializer<CarbonsEnable> {
- public:
- CarbonsEnableSerializer();
- virtual ~CarbonsEnableSerializer();
+ class SWIFTEN_API CarbonsEnableSerializer : public GenericPayloadSerializer<CarbonsEnable> {
+ public:
+ CarbonsEnableSerializer();
+ virtual ~CarbonsEnableSerializer();
- virtual std::string serializePayload(boost::shared_ptr<CarbonsEnable>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<CarbonsEnable>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.cpp
index 1e77470..6fbfc26 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.cpp
@@ -9,15 +9,15 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- CarbonsPrivateSerializer::CarbonsPrivateSerializer() : GenericPayloadSerializer<CarbonsPrivate>() {
- }
+ CarbonsPrivateSerializer::CarbonsPrivateSerializer() : GenericPayloadSerializer<CarbonsPrivate>() {
+ }
- CarbonsPrivateSerializer::~CarbonsPrivateSerializer() {
+ CarbonsPrivateSerializer::~CarbonsPrivateSerializer() {
- }
+ }
- std::string CarbonsPrivateSerializer::serializePayload(boost::shared_ptr<CarbonsPrivate>) const {
- XMLElement element("private", "urn:xmpp:carbons:2");
- return element.serialize();
- }
+ std::string CarbonsPrivateSerializer::serializePayload(boost::shared_ptr<CarbonsPrivate>) const {
+ XMLElement element("private", "urn:xmpp:carbons:2");
+ return element.serialize();
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.h b/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.h
index 37a6dd1..a93d87f 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.h
@@ -12,11 +12,11 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API CarbonsPrivateSerializer : public GenericPayloadSerializer<CarbonsPrivate> {
- public:
- CarbonsPrivateSerializer();
- virtual ~CarbonsPrivateSerializer();
+ class SWIFTEN_API CarbonsPrivateSerializer : public GenericPayloadSerializer<CarbonsPrivate> {
+ public:
+ CarbonsPrivateSerializer();
+ virtual ~CarbonsPrivateSerializer();
- virtual std::string serializePayload(boost::shared_ptr<CarbonsPrivate>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<CarbonsPrivate>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.cpp
index bf63a69..981421b 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.cpp
@@ -9,18 +9,18 @@
#include <boost/make_shared.hpp>
namespace Swift {
- CarbonsReceivedSerializer::CarbonsReceivedSerializer(PayloadSerializerCollection* serializers) : GenericPayloadSerializer<CarbonsReceived>(), serializers_(serializers) {
- }
+ CarbonsReceivedSerializer::CarbonsReceivedSerializer(PayloadSerializerCollection* serializers) : GenericPayloadSerializer<CarbonsReceived>(), serializers_(serializers) {
+ }
- CarbonsReceivedSerializer::~CarbonsReceivedSerializer() {
- }
-
- std::string CarbonsReceivedSerializer::serializePayload(boost::shared_ptr<CarbonsReceived> received) const {
- XMLElement element("received", "urn:xmpp:carbons:2");
- if (received->getForwarded()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(ForwardedSerializer(serializers_).serialize(received->getForwarded())));
- }
- return element.serialize();
- }
+ CarbonsReceivedSerializer::~CarbonsReceivedSerializer() {
+ }
+
+ std::string CarbonsReceivedSerializer::serializePayload(boost::shared_ptr<CarbonsReceived> received) const {
+ XMLElement element("received", "urn:xmpp:carbons:2");
+ if (received->getForwarded()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(ForwardedSerializer(serializers_).serialize(received->getForwarded())));
+ }
+ return element.serialize();
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.h b/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.h
index 072b98f..719e84a 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.h
@@ -15,15 +15,15 @@
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
namespace Swift {
- class SWIFTEN_API CarbonsReceivedSerializer : public GenericPayloadSerializer<CarbonsReceived> {
- public:
- CarbonsReceivedSerializer(PayloadSerializerCollection* serializers);
- virtual ~CarbonsReceivedSerializer();
+ class SWIFTEN_API CarbonsReceivedSerializer : public GenericPayloadSerializer<CarbonsReceived> {
+ public:
+ CarbonsReceivedSerializer(PayloadSerializerCollection* serializers);
+ virtual ~CarbonsReceivedSerializer();
- virtual std::string serializePayload(boost::shared_ptr<CarbonsReceived> received) const;
+ virtual std::string serializePayload(boost::shared_ptr<CarbonsReceived> received) const;
- private:
- PayloadSerializerCollection* serializers_;
- };
+ private:
+ PayloadSerializerCollection* serializers_;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.cpp
index 30a283e..f71208f 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.cpp
@@ -7,18 +7,18 @@
#include <Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h>
namespace Swift {
- CarbonsSentSerializer::CarbonsSentSerializer(PayloadSerializerCollection* serializers) : GenericPayloadSerializer<CarbonsSent>(), serializers_(serializers) {
- }
+ CarbonsSentSerializer::CarbonsSentSerializer(PayloadSerializerCollection* serializers) : GenericPayloadSerializer<CarbonsSent>(), serializers_(serializers) {
+ }
- CarbonsSentSerializer::~CarbonsSentSerializer() {
- }
-
- std::string CarbonsSentSerializer::serializePayload(boost::shared_ptr<CarbonsSent> sent) const {
- XMLElement element("sent", "urn:xmpp:carbons:2");
- if (sent->getForwarded()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(ForwardedSerializer(serializers_).serialize(sent->getForwarded())));
- }
- return element.serialize();
- }
+ CarbonsSentSerializer::~CarbonsSentSerializer() {
+ }
+
+ std::string CarbonsSentSerializer::serializePayload(boost::shared_ptr<CarbonsSent> sent) const {
+ XMLElement element("sent", "urn:xmpp:carbons:2");
+ if (sent->getForwarded()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(ForwardedSerializer(serializers_).serialize(sent->getForwarded())));
+ }
+ return element.serialize();
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h b/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h
index f79def4..cecb3b8 100644
--- a/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h
@@ -17,15 +17,15 @@
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
namespace Swift {
- class SWIFTEN_API CarbonsSentSerializer : public GenericPayloadSerializer<CarbonsSent> {
- public:
- CarbonsSentSerializer(PayloadSerializerCollection* serializers);
- virtual ~CarbonsSentSerializer();
+ class SWIFTEN_API CarbonsSentSerializer : public GenericPayloadSerializer<CarbonsSent> {
+ public:
+ CarbonsSentSerializer(PayloadSerializerCollection* serializers);
+ virtual ~CarbonsSentSerializer();
- virtual std::string serializePayload(boost::shared_ptr<CarbonsSent> sent) const;
+ virtual std::string serializePayload(boost::shared_ptr<CarbonsSent> sent) const;
- private:
- PayloadSerializerCollection* serializers_;
- };
+ private:
+ PayloadSerializerCollection* serializers_;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp
index 767d9ce..325215a 100644
--- a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp
@@ -12,16 +12,16 @@ ChatStateSerializer::ChatStateSerializer() : GenericPayloadSerializer<ChatState>
}
std::string ChatStateSerializer::serializePayload(boost::shared_ptr<ChatState> chatState) const {
- std::string result("<");
- switch (chatState->getChatState()) {
- case ChatState::Active: result += "active"; break;
- case ChatState::Composing: result += "composing"; break;
- case ChatState::Paused: result += "paused"; break;
- case ChatState::Inactive: result += "inactive"; break;
- case ChatState::Gone: result += "gone"; break;
- }
- result += " xmlns=\"http://jabber.org/protocol/chatstates\"/>";
- return result;
+ std::string result("<");
+ switch (chatState->getChatState()) {
+ case ChatState::Active: result += "active"; break;
+ case ChatState::Composing: result += "composing"; break;
+ case ChatState::Paused: result += "paused"; break;
+ case ChatState::Inactive: result += "inactive"; break;
+ case ChatState::Gone: result += "gone"; break;
+ }
+ result += " xmlns=\"http://jabber.org/protocol/chatstates\"/>";
+ return result;
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h
index 2b279f1..cfdaf83 100644
--- a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API ChatStateSerializer : public GenericPayloadSerializer<ChatState> {
- public:
- ChatStateSerializer();
+ class SWIFTEN_API ChatStateSerializer : public GenericPayloadSerializer<ChatState> {
+ public:
+ ChatStateSerializer();
- virtual std::string serializePayload(boost::shared_ptr<ChatState> error) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<ChatState> error) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp
index 6b6a542..9ed17dc 100644
--- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp
@@ -20,77 +20,77 @@ namespace Swift {
CommandSerializer::CommandSerializer() {
}
-std::string CommandSerializer::serializePayload(boost::shared_ptr<Command> command) const {
- XMLElement commandElement("command", "http://jabber.org/protocol/commands");
- commandElement.setAttribute("node", command->getNode());
+std::string CommandSerializer::serializePayload(boost::shared_ptr<Command> command) const {
+ XMLElement commandElement("command", "http://jabber.org/protocol/commands");
+ commandElement.setAttribute("node", command->getNode());
- if (!command->getSessionID().empty()) {
- commandElement.setAttribute("sessionid", command->getSessionID());
- }
+ if (!command->getSessionID().empty()) {
+ commandElement.setAttribute("sessionid", command->getSessionID());
+ }
- std::string action = actionToString(command->getAction());
- if (!action.empty()) {
- commandElement.setAttribute("action", action);
- }
+ std::string action = actionToString(command->getAction());
+ if (!action.empty()) {
+ commandElement.setAttribute("action", action);
+ }
- std::string status;
- switch (command->getStatus()) {
- case Command::Executing: status = "executing";break;
- case Command::Completed: status = "completed";break;
- case Command::Canceled: status = "canceled";break;
- case Command::NoStatus: break;
- }
- if (!status.empty()) {
- commandElement.setAttribute("status", status);
- }
+ std::string status;
+ switch (command->getStatus()) {
+ case Command::Executing: status = "executing";break;
+ case Command::Completed: status = "completed";break;
+ case Command::Canceled: status = "canceled";break;
+ case Command::NoStatus: break;
+ }
+ if (!status.empty()) {
+ commandElement.setAttribute("status", status);
+ }
- if (command->getAvailableActions().size() > 0) {
- std::string actions = "<actions";
- std::string executeAction = actionToString(command->getExecuteAction());
- if (!executeAction.empty()) {
- actions += " execute='" + executeAction + "'";
- }
- actions += ">";
- foreach (Command::Action action, command->getAvailableActions()) {
- actions += "<" + actionToString(action) + "/>";
- }
- actions += "</actions>";
- commandElement.addNode(boost::make_shared<XMLRawTextNode>(actions));
- }
+ if (command->getAvailableActions().size() > 0) {
+ std::string actions = "<actions";
+ std::string executeAction = actionToString(command->getExecuteAction());
+ if (!executeAction.empty()) {
+ actions += " execute='" + executeAction + "'";
+ }
+ actions += ">";
+ foreach (Command::Action action, command->getAvailableActions()) {
+ actions += "<" + actionToString(action) + "/>";
+ }
+ actions += "</actions>";
+ commandElement.addNode(boost::make_shared<XMLRawTextNode>(actions));
+ }
- foreach (Command::Note note, command->getNotes()) {
- boost::shared_ptr<XMLElement> noteElement(new XMLElement("note"));
- std::string type;
- switch (note.type) {
- case Command::Note::Info: type = "info"; break;
- case Command::Note::Warn: type = "warn"; break;
- case Command::Note::Error: type = "error"; break;
- }
- if (!type.empty()) {
- noteElement->setAttribute("type", type);
- }
- noteElement->addNode(boost::make_shared<XMLTextNode>(note.note));
- commandElement.addNode(noteElement);
- }
+ foreach (Command::Note note, command->getNotes()) {
+ boost::shared_ptr<XMLElement> noteElement(new XMLElement("note"));
+ std::string type;
+ switch (note.type) {
+ case Command::Note::Info: type = "info"; break;
+ case Command::Note::Warn: type = "warn"; break;
+ case Command::Note::Error: type = "error"; break;
+ }
+ if (!type.empty()) {
+ noteElement->setAttribute("type", type);
+ }
+ noteElement->addNode(boost::make_shared<XMLTextNode>(note.note));
+ commandElement.addNode(noteElement);
+ }
- Form::ref form = command->getForm();
- if (form) {
- commandElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
- }
- return commandElement.serialize();
+ Form::ref form = command->getForm();
+ if (form) {
+ commandElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
+ }
+ return commandElement.serialize();
}
std::string CommandSerializer::actionToString(Command::Action action) const {
- std::string string;
- switch (action) {
- case Command::Cancel: string = "cancel"; break;
- case Command::Execute: string = "execute"; break;
- case Command::Complete: string = "complete"; break;
- case Command::Prev: string = "prev"; break;
- case Command::Next: string = "next"; break;
- case Command::NoAction: break;
- }
- return string;
+ std::string string;
+ switch (action) {
+ case Command::Cancel: string = "cancel"; break;
+ case Command::Execute: string = "execute"; break;
+ case Command::Complete: string = "complete"; break;
+ case Command::Prev: string = "prev"; break;
+ case Command::Next: string = "next"; break;
+ case Command::NoAction: break;
+ }
+ return string;
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h
index 6fea85e..bc3642d 100644
--- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h
@@ -11,13 +11,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API CommandSerializer : public GenericPayloadSerializer<Command> {
- public:
- CommandSerializer();
+ class SWIFTEN_API CommandSerializer : public GenericPayloadSerializer<Command> {
+ public:
+ CommandSerializer();
- virtual std::string serializePayload(boost::shared_ptr<Command>) const;
+ virtual std::string serializePayload(boost::shared_ptr<Command>) const;
- private:
- std::string actionToString(Command::Action action) const;
- };
+ private:
+ std::string actionToString(Command::Action action) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
index ad16c21..428b565 100644
--- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
@@ -19,12 +19,12 @@ DelaySerializer::DelaySerializer() : GenericPayloadSerializer<Delay>() {
}
std::string DelaySerializer::serializePayload(boost::shared_ptr<Delay> delay) const {
- XMLElement delayElement("delay", "urn:xmpp:delay");
- if (delay->getFrom() && delay->getFrom()->isValid()) {
- delayElement.setAttribute("from", delay->getFrom()->toString());
- }
- delayElement.setAttribute("stamp", dateTimeToString(delay->getStamp()));
- return delayElement.serialize();
+ XMLElement delayElement("delay", "urn:xmpp:delay");
+ if (delay->getFrom() && delay->getFrom()->isValid()) {
+ delayElement.setAttribute("from", delay->getFrom()->toString());
+ }
+ delayElement.setAttribute("stamp", dateTimeToString(delay->getStamp()));
+ return delayElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
index 493fe4c..71039f2 100644
--- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
@@ -11,12 +11,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API DelaySerializer : public GenericPayloadSerializer<Delay> {
- public:
- DelaySerializer();
+ class SWIFTEN_API DelaySerializer : public GenericPayloadSerializer<Delay> {
+ public:
+ DelaySerializer();
- virtual std::string serializePayload(boost::shared_ptr<Delay>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<Delay>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.cpp
index f4e5c60..887502a 100644
--- a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.cpp
@@ -21,8 +21,8 @@ DeliveryReceiptRequestSerializer::DeliveryReceiptRequestSerializer() : GenericPa
}
std::string DeliveryReceiptRequestSerializer::serializePayload(boost::shared_ptr<DeliveryReceiptRequest> /* request*/) const {
- XMLElement requestXML("request", "urn:xmpp:receipts");
- return requestXML.serialize();
+ XMLElement requestXML("request", "urn:xmpp:receipts");
+ return requestXML.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.h b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.h
index def5a38..97377d6 100644
--- a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptRequestSerializer.h
@@ -17,10 +17,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API DeliveryReceiptRequestSerializer : public GenericPayloadSerializer<DeliveryReceiptRequest> {
- public:
- DeliveryReceiptRequestSerializer();
+ class SWIFTEN_API DeliveryReceiptRequestSerializer : public GenericPayloadSerializer<DeliveryReceiptRequest> {
+ public:
+ DeliveryReceiptRequestSerializer();
- virtual std::string serializePayload(boost::shared_ptr<DeliveryReceiptRequest> request) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<DeliveryReceiptRequest> request) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.cpp
index 30fcb33..d3e1480 100644
--- a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.cpp
@@ -20,9 +20,9 @@ DeliveryReceiptSerializer::DeliveryReceiptSerializer() : GenericPayloadSerialize
}
std::string DeliveryReceiptSerializer::serializePayload(boost::shared_ptr<DeliveryReceipt> receipt) const {
- XMLElement received("received", "urn:xmpp:receipts");
- received.setAttribute("id", receipt->getReceivedID());
- return received.serialize();
+ XMLElement received("received", "urn:xmpp:receipts");
+ received.setAttribute("id", receipt->getReceivedID());
+ return received.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.h b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.h
index 16c8258..943f4b9 100644
--- a/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/DeliveryReceiptSerializer.h
@@ -17,10 +17,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API DeliveryReceiptSerializer : public GenericPayloadSerializer<DeliveryReceipt> {
- public:
- DeliveryReceiptSerializer();
+ class SWIFTEN_API DeliveryReceiptSerializer : public GenericPayloadSerializer<DeliveryReceipt> {
+ public:
+ DeliveryReceiptSerializer();
- virtual std::string serializePayload(boost::shared_ptr<DeliveryReceipt> receipt) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<DeliveryReceipt> receipt) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp
index 76909c7..e57fd12 100644
--- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp
@@ -20,29 +20,29 @@ DiscoInfoSerializer::DiscoInfoSerializer() : GenericPayloadSerializer<DiscoInfo>
}
std::string DiscoInfoSerializer::serializePayload(boost::shared_ptr<DiscoInfo> discoInfo) const {
- XMLElement queryElement("query", "http://jabber.org/protocol/disco#info");
- if (!discoInfo->getNode().empty()) {
- queryElement.setAttribute("node", discoInfo->getNode());
- }
- foreach(const DiscoInfo::Identity& identity, discoInfo->getIdentities()) {
- boost::shared_ptr<XMLElement> identityElement(new XMLElement("identity"));
- if (!identity.getLanguage().empty()) {
- identityElement->setAttribute("xml:lang", identity.getLanguage());
- }
- identityElement->setAttribute("category", identity.getCategory());
- identityElement->setAttribute("name", identity.getName());
- identityElement->setAttribute("type", identity.getType());
- queryElement.addNode(identityElement);
- }
- foreach(const std::string& feature, discoInfo->getFeatures()) {
- boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature"));
- featureElement->setAttribute("var", feature);
- queryElement.addNode(featureElement);
- }
- foreach(const Form::ref extension, discoInfo->getExtensions()) {
- queryElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(extension)));
- }
- return queryElement.serialize();
+ XMLElement queryElement("query", "http://jabber.org/protocol/disco#info");
+ if (!discoInfo->getNode().empty()) {
+ queryElement.setAttribute("node", discoInfo->getNode());
+ }
+ foreach(const DiscoInfo::Identity& identity, discoInfo->getIdentities()) {
+ boost::shared_ptr<XMLElement> identityElement(new XMLElement("identity"));
+ if (!identity.getLanguage().empty()) {
+ identityElement->setAttribute("xml:lang", identity.getLanguage());
+ }
+ identityElement->setAttribute("category", identity.getCategory());
+ identityElement->setAttribute("name", identity.getName());
+ identityElement->setAttribute("type", identity.getType());
+ queryElement.addNode(identityElement);
+ }
+ foreach(const std::string& feature, discoInfo->getFeatures()) {
+ boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature"));
+ featureElement->setAttribute("var", feature);
+ queryElement.addNode(featureElement);
+ }
+ foreach(const Form::ref extension, discoInfo->getExtensions()) {
+ queryElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(extension)));
+ }
+ return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h
index 9eb627c..9850714 100644
--- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API DiscoInfoSerializer : public GenericPayloadSerializer<DiscoInfo> {
- public:
- DiscoInfoSerializer();
+ class SWIFTEN_API DiscoInfoSerializer : public GenericPayloadSerializer<DiscoInfo> {
+ public:
+ DiscoInfoSerializer();
- virtual std::string serializePayload(boost::shared_ptr<DiscoInfo>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<DiscoInfo>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp
index 91a467c..f537f40 100644
--- a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp
@@ -17,20 +17,20 @@ DiscoItemsSerializer::DiscoItemsSerializer() : GenericPayloadSerializer<DiscoIte
}
std::string DiscoItemsSerializer::serializePayload(boost::shared_ptr<DiscoItems> discoItems) const {
- XMLElement queryElement("query", "http://jabber.org/protocol/disco#items");
- if (!discoItems->getNode().empty()) {
- queryElement.setAttribute("node", discoItems->getNode());
- }
- foreach(const DiscoItems::Item& item, discoItems->getItems()) {
- boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
- itemElement->setAttribute("name", item.getName());
- itemElement->setAttribute("jid", item.getJID());
- if (!item.getNode().empty()) {
- itemElement->setAttribute("node", item.getNode());
- }
- queryElement.addNode(itemElement);
- }
- return queryElement.serialize();
+ XMLElement queryElement("query", "http://jabber.org/protocol/disco#items");
+ if (!discoItems->getNode().empty()) {
+ queryElement.setAttribute("node", discoItems->getNode());
+ }
+ foreach(const DiscoItems::Item& item, discoItems->getItems()) {
+ boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
+ itemElement->setAttribute("name", item.getName());
+ itemElement->setAttribute("jid", item.getJID());
+ if (!item.getNode().empty()) {
+ itemElement->setAttribute("node", item.getNode());
+ }
+ queryElement.addNode(itemElement);
+ }
+ return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h
index 4be08e6..acc5a7b 100644
--- a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h
@@ -11,11 +11,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API DiscoItemsSerializer : public GenericPayloadSerializer<DiscoItems> {
- public:
- DiscoItemsSerializer();
+ class SWIFTEN_API DiscoItemsSerializer : public GenericPayloadSerializer<DiscoItems> {
+ public:
+ DiscoItemsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<DiscoItems>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<DiscoItems>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp
index 14329b9..1ed60d1 100644
--- a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp
@@ -15,57 +15,57 @@ ErrorSerializer::ErrorSerializer(PayloadSerializerCollection* serializers) : Gen
}
std::string ErrorSerializer::serializePayload(boost::shared_ptr<ErrorPayload> error) const {
- std::string result("<error type=\"");
- switch (error->getType()) {
- case ErrorPayload::Continue: result += "continue"; break;
- case ErrorPayload::Modify: result += "modify"; break;
- case ErrorPayload::Auth: result += "auth"; break;
- case ErrorPayload::Wait: result += "wait"; break;
- case ErrorPayload::Cancel: result += "cancel"; break;
- }
- result += "\">";
+ std::string result("<error type=\"");
+ switch (error->getType()) {
+ case ErrorPayload::Continue: result += "continue"; break;
+ case ErrorPayload::Modify: result += "modify"; break;
+ case ErrorPayload::Auth: result += "auth"; break;
+ case ErrorPayload::Wait: result += "wait"; break;
+ case ErrorPayload::Cancel: result += "cancel"; break;
+ }
+ result += "\">";
- std::string conditionElement;
- switch (error->getCondition()) {
- case ErrorPayload::BadRequest: conditionElement = "bad-request"; break;
- case ErrorPayload::Conflict: conditionElement = "conflict"; break;
- case ErrorPayload::FeatureNotImplemented: conditionElement = "feature-not-implemented"; break;
- case ErrorPayload::Forbidden: conditionElement = "forbidden"; break;
- case ErrorPayload::Gone: conditionElement = "gone"; break;
- case ErrorPayload::InternalServerError: conditionElement = "internal-server-error"; break;
- case ErrorPayload::ItemNotFound: conditionElement = "item-not-found"; break;
- case ErrorPayload::JIDMalformed: conditionElement = "jid-malformed"; break;
- case ErrorPayload::NotAcceptable: conditionElement = "not-acceptable"; break;
- case ErrorPayload::NotAllowed: conditionElement = "not-allowed"; break;
- case ErrorPayload::NotAuthorized: conditionElement = "not-authorized"; break;
- case ErrorPayload::PaymentRequired: conditionElement = "payment-required"; break;
- case ErrorPayload::RecipientUnavailable: conditionElement = "recipient-unavailable"; break;
- case ErrorPayload::Redirect: conditionElement = "redirect"; break;
- case ErrorPayload::RegistrationRequired: conditionElement = "registration-required"; break;
- case ErrorPayload::RemoteServerNotFound: conditionElement = "remote-server-not-found"; break;
- case ErrorPayload::RemoteServerTimeout: conditionElement = "remote-server-timeout"; break;
- case ErrorPayload::ResourceConstraint: conditionElement = "resource-constraint"; break;
- case ErrorPayload::ServiceUnavailable: conditionElement = "service-unavailable"; break;
- case ErrorPayload::SubscriptionRequired: conditionElement = "subscription-required"; break;
- case ErrorPayload::UnexpectedRequest: conditionElement = "unexpected-request"; break;
- case ErrorPayload::UndefinedCondition: conditionElement = "undefined-condition"; break;
- }
- result += "<" + conditionElement + " xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>";
+ std::string conditionElement;
+ switch (error->getCondition()) {
+ case ErrorPayload::BadRequest: conditionElement = "bad-request"; break;
+ case ErrorPayload::Conflict: conditionElement = "conflict"; break;
+ case ErrorPayload::FeatureNotImplemented: conditionElement = "feature-not-implemented"; break;
+ case ErrorPayload::Forbidden: conditionElement = "forbidden"; break;
+ case ErrorPayload::Gone: conditionElement = "gone"; break;
+ case ErrorPayload::InternalServerError: conditionElement = "internal-server-error"; break;
+ case ErrorPayload::ItemNotFound: conditionElement = "item-not-found"; break;
+ case ErrorPayload::JIDMalformed: conditionElement = "jid-malformed"; break;
+ case ErrorPayload::NotAcceptable: conditionElement = "not-acceptable"; break;
+ case ErrorPayload::NotAllowed: conditionElement = "not-allowed"; break;
+ case ErrorPayload::NotAuthorized: conditionElement = "not-authorized"; break;
+ case ErrorPayload::PaymentRequired: conditionElement = "payment-required"; break;
+ case ErrorPayload::RecipientUnavailable: conditionElement = "recipient-unavailable"; break;
+ case ErrorPayload::Redirect: conditionElement = "redirect"; break;
+ case ErrorPayload::RegistrationRequired: conditionElement = "registration-required"; break;
+ case ErrorPayload::RemoteServerNotFound: conditionElement = "remote-server-not-found"; break;
+ case ErrorPayload::RemoteServerTimeout: conditionElement = "remote-server-timeout"; break;
+ case ErrorPayload::ResourceConstraint: conditionElement = "resource-constraint"; break;
+ case ErrorPayload::ServiceUnavailable: conditionElement = "service-unavailable"; break;
+ case ErrorPayload::SubscriptionRequired: conditionElement = "subscription-required"; break;
+ case ErrorPayload::UnexpectedRequest: conditionElement = "unexpected-request"; break;
+ case ErrorPayload::UndefinedCondition: conditionElement = "undefined-condition"; break;
+ }
+ result += "<" + conditionElement + " xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>";
- if (!error->getText().empty()) {
- XMLTextNode textNode(error->getText());
- result += "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">" + textNode.serialize() + "</text>";
- }
+ if (!error->getText().empty()) {
+ XMLTextNode textNode(error->getText());
+ result += "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">" + textNode.serialize() + "</text>";
+ }
- if (error->getPayload()) {
- PayloadSerializer* serializer = serializers->getPayloadSerializer(error->getPayload());
- if (serializer) {
- result += serializer->serialize(error->getPayload());
- }
- }
+ if (error->getPayload()) {
+ PayloadSerializer* serializer = serializers->getPayloadSerializer(error->getPayload());
+ if (serializer) {
+ result += serializer->serialize(error->getPayload());
+ }
+ }
- result += "</error>";
- return result;
+ result += "</error>";
+ return result;
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h
index 14666f4..2ccd5df 100644
--- a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h
@@ -11,15 +11,15 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API ErrorSerializer : public GenericPayloadSerializer<ErrorPayload> {
- public:
- ErrorSerializer(PayloadSerializerCollection* serializers);
+ class SWIFTEN_API ErrorSerializer : public GenericPayloadSerializer<ErrorPayload> {
+ public:
+ ErrorSerializer(PayloadSerializerCollection* serializers);
- virtual std::string serializePayload(boost::shared_ptr<ErrorPayload> error) const;
+ virtual std::string serializePayload(boost::shared_ptr<ErrorPayload> error) const;
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
index f05c9cb..cc6339c 100644
--- a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
@@ -21,14 +21,14 @@
using namespace Swift;
namespace {
- template<typename T> void serializeValueAsString(boost::shared_ptr<FormField> field, boost::shared_ptr<XMLElement> parent) {
- std::string value = boost::dynamic_pointer_cast<T>(field)->getValue();
- if (!value.empty()) {
- boost::shared_ptr<XMLElement> valueElement(new XMLElement("value"));
- valueElement->addNode(XMLTextNode::create(value));
- parent->addNode(valueElement);
- }
- }
+ template<typename T> void serializeValueAsString(boost::shared_ptr<FormField> field, boost::shared_ptr<XMLElement> parent) {
+ std::string value = boost::dynamic_pointer_cast<T>(field)->getValue();
+ if (!value.empty()) {
+ boost::shared_ptr<XMLElement> valueElement(new XMLElement("value"));
+ valueElement->addNode(XMLTextNode::create(value));
+ parent->addNode(valueElement);
+ }
+ }
}
namespace Swift {
@@ -36,176 +36,176 @@ namespace Swift {
FormSerializer::FormSerializer() : GenericPayloadSerializer<Form>() {}
std::string FormSerializer::serializePayload(boost::shared_ptr<Form> form) const {
- if (!form) {
- return "";
- }
-
- boost::shared_ptr<XMLElement> formElement(new XMLElement("x", "jabber:x:data"));
- std::string type;
- switch (form->getType()) {
- case Form::FormType: type = "form"; break;
- case Form::SubmitType: type = "submit"; break;
- case Form::CancelType: type = "cancel"; break;
- case Form::ResultType: type = "result"; break;
- }
- formElement->setAttribute("type", type);
- if (!form->getTitle().empty()) {
- multiLineify(form->getTitle(), "title", formElement);
- }
- if (!form->getInstructions().empty()) {
- multiLineify(form->getInstructions(), "instructions", formElement);
- }
- foreach(boost::shared_ptr<FormPage> page, form->getPages()) {
- formElement->addNode(pageToXML(page));
- }
- foreach(boost::shared_ptr<FormField> field, form->getFields()) {
- formElement->addNode(fieldToXML(field, true));
- }
- if (!form->getReportedFields().empty()) {
- boost::shared_ptr<XMLElement> reportedElement(new XMLElement("reported"));
- foreach(FormField::ref field, form->getReportedFields()) {
- reportedElement->addNode(fieldToXML(field, true));
- }
- formElement->addNode(reportedElement);
- }
-
- foreach(Form::FormItem item, form->getItems()) {
- boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
- foreach(FormField::ref field, item) {
- itemElement->addNode(fieldToXML(field, false));
- }
- formElement->addNode(itemElement);
- }
-
- foreach(const FormText::text text, form->getTextElements()) {
- formElement->addNode(textToXML(text));
- }
-
- foreach (boost::shared_ptr<FormField> field, fields_) {
- formElement->addNode(fieldToXML(field,true));
- }
-
- return formElement->serialize();
+ if (!form) {
+ return "";
+ }
+
+ boost::shared_ptr<XMLElement> formElement(new XMLElement("x", "jabber:x:data"));
+ std::string type;
+ switch (form->getType()) {
+ case Form::FormType: type = "form"; break;
+ case Form::SubmitType: type = "submit"; break;
+ case Form::CancelType: type = "cancel"; break;
+ case Form::ResultType: type = "result"; break;
+ }
+ formElement->setAttribute("type", type);
+ if (!form->getTitle().empty()) {
+ multiLineify(form->getTitle(), "title", formElement);
+ }
+ if (!form->getInstructions().empty()) {
+ multiLineify(form->getInstructions(), "instructions", formElement);
+ }
+ foreach(boost::shared_ptr<FormPage> page, form->getPages()) {
+ formElement->addNode(pageToXML(page));
+ }
+ foreach(boost::shared_ptr<FormField> field, form->getFields()) {
+ formElement->addNode(fieldToXML(field, true));
+ }
+ if (!form->getReportedFields().empty()) {
+ boost::shared_ptr<XMLElement> reportedElement(new XMLElement("reported"));
+ foreach(FormField::ref field, form->getReportedFields()) {
+ reportedElement->addNode(fieldToXML(field, true));
+ }
+ formElement->addNode(reportedElement);
+ }
+
+ foreach(Form::FormItem item, form->getItems()) {
+ boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
+ foreach(FormField::ref field, item) {
+ itemElement->addNode(fieldToXML(field, false));
+ }
+ formElement->addNode(itemElement);
+ }
+
+ foreach(const FormText::text text, form->getTextElements()) {
+ formElement->addNode(textToXML(text));
+ }
+
+ foreach (boost::shared_ptr<FormField> field, fields_) {
+ formElement->addNode(fieldToXML(field,true));
+ }
+
+ return formElement->serialize();
}
boost::shared_ptr<XMLElement> FormSerializer::textToXML(boost::shared_ptr<FormText> text) const {
- boost::shared_ptr<XMLElement> textElement (new XMLElement("text"));
- textElement->addNode(boost::make_shared<XMLTextNode>(text->getTextString()));
- return textElement;
+ boost::shared_ptr<XMLElement> textElement (new XMLElement("text"));
+ textElement->addNode(boost::make_shared<XMLTextNode>(text->getTextString()));
+ return textElement;
}
boost::shared_ptr<XMLElement> FormSerializer::fieldRefToXML(const std::string& ref) const {
- boost::shared_ptr<XMLElement> fieldRefElement(new XMLElement("fieldref"));
- fieldRefElement->setAttribute("var", ref);
- return fieldRefElement;
+ boost::shared_ptr<XMLElement> fieldRefElement(new XMLElement("fieldref"));
+ fieldRefElement->setAttribute("var", ref);
+ return fieldRefElement;
}
boost::shared_ptr<XMLElement> FormSerializer::pageToXML(boost::shared_ptr<FormPage> page) const {
- boost::shared_ptr<XMLElement> pageElement(new XMLElement("page"));
- pageElement->setAttribute("xmlns", "http://jabber.org/protocol/xdata-layout");
- if (!page->getLabel().empty()) {
- pageElement->setAttribute("label", page->getLabel());
- }
- foreach(const FormText::text text, page->getTextElements()) {
- pageElement->addNode(textToXML(text));
- }
- foreach (const boost::shared_ptr<FormField> field, page->getFields()) {
- pageElement->addNode(fieldRefToXML(field->getName()));
- fields_.push_back(field);
- }
- foreach(const FormReportedRef::ref reportedRef, page->getReportedRefs()) {
- pageElement->addNode(boost::make_shared<XMLElement>("reportedref"));
- }
- foreach(const FormSection::section section, page->getChildSections()) {
- pageElement->addNode(sectionToXML(section));
- }
- return pageElement;
+ boost::shared_ptr<XMLElement> pageElement(new XMLElement("page"));
+ pageElement->setAttribute("xmlns", "http://jabber.org/protocol/xdata-layout");
+ if (!page->getLabel().empty()) {
+ pageElement->setAttribute("label", page->getLabel());
+ }
+ foreach(const FormText::text text, page->getTextElements()) {
+ pageElement->addNode(textToXML(text));
+ }
+ foreach (const boost::shared_ptr<FormField> field, page->getFields()) {
+ pageElement->addNode(fieldRefToXML(field->getName()));
+ fields_.push_back(field);
+ }
+ foreach(const FormReportedRef::ref reportedRef, page->getReportedRefs()) {
+ pageElement->addNode(boost::make_shared<XMLElement>("reportedref"));
+ }
+ foreach(const FormSection::section section, page->getChildSections()) {
+ pageElement->addNode(sectionToXML(section));
+ }
+ return pageElement;
}
boost::shared_ptr<XMLElement> FormSerializer::sectionToXML(boost::shared_ptr<FormSection> section) const {
- boost::shared_ptr<XMLElement> sectionElement(new XMLElement("section"));
- if (!section->getLabel().empty()) {
- sectionElement->setAttribute("label", section->getLabel());
- }
- foreach(const FormText::text text, section->getTextElements()) {
- sectionElement->addNode(textToXML(text));
- }
- foreach(const boost::shared_ptr<FormField> field, section->getFields()) {
- sectionElement->addNode(fieldRefToXML(field->getName()));
- fields_.push_back(field);
- }
- foreach(const FormReportedRef::ref reportedRef, section->getReportedRefs()) {
- sectionElement->addNode(boost::make_shared<XMLElement>("reportedref"));
- }
- foreach(const FormSection::section childSection, section->getChildSections()) {
- sectionElement->addNode(sectionToXML(childSection));
- }
- return sectionElement;
+ boost::shared_ptr<XMLElement> sectionElement(new XMLElement("section"));
+ if (!section->getLabel().empty()) {
+ sectionElement->setAttribute("label", section->getLabel());
+ }
+ foreach(const FormText::text text, section->getTextElements()) {
+ sectionElement->addNode(textToXML(text));
+ }
+ foreach(const boost::shared_ptr<FormField> field, section->getFields()) {
+ sectionElement->addNode(fieldRefToXML(field->getName()));
+ fields_.push_back(field);
+ }
+ foreach(const FormReportedRef::ref reportedRef, section->getReportedRefs()) {
+ sectionElement->addNode(boost::make_shared<XMLElement>("reportedref"));
+ }
+ foreach(const FormSection::section childSection, section->getChildSections()) {
+ sectionElement->addNode(sectionToXML(childSection));
+ }
+ return sectionElement;
}
boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormField> field, bool withTypeAttribute) const {
- boost::shared_ptr<XMLElement> fieldElement(new XMLElement("field"));
- if (!field->getName().empty()) {
- fieldElement->setAttribute("var", field->getName());
- }
- if (!field->getLabel().empty()) {
- fieldElement->setAttribute("label", field->getLabel());
- }
- if (field->getRequired()) {
- fieldElement->addNode(boost::make_shared<XMLElement>("required"));
- }
- if (!field->getDescription().empty()) {
- boost::shared_ptr<XMLElement> descriptionElement(new XMLElement("desc"));
- descriptionElement->addNode(boost::make_shared<XMLTextNode>(field->getDescription()));
- fieldElement->addNode(descriptionElement);
- }
-
- // Set the value and type
- std::string fieldType;
- switch (field->getType()) {
- case FormField::UnknownType: fieldType = ""; break;
- case FormField::BooleanType: fieldType = "boolean"; break;
- case FormField::FixedType: fieldType = "fixed"; break;
- case FormField::HiddenType: fieldType = "hidden"; break;
- case FormField::ListSingleType: fieldType = "list-single"; break;
- case FormField::TextMultiType: fieldType = "text-multi"; break;
- case FormField::TextPrivateType: fieldType = "text-private"; break;
- case FormField::TextSingleType: fieldType = "text-single"; break;
- case FormField::JIDSingleType: fieldType = "jid-single"; break;
- case FormField::JIDMultiType: fieldType = "jid-multi"; break;
- case FormField::ListMultiType: fieldType = "list-multi"; break;
- }
- if (!fieldType.empty() && withTypeAttribute) {
- fieldElement->setAttribute("type", fieldType);
- }
- foreach (const std::string& value, field->getValues()) {
- boost::shared_ptr<XMLElement> valueElement = boost::make_shared<XMLElement>("value");
- valueElement->addNode(boost::make_shared<XMLTextNode>(value));
- fieldElement->addNode(valueElement);
- }
-
- foreach (const FormField::Option& option, field->getOptions()) {
- boost::shared_ptr<XMLElement> optionElement(new XMLElement("option"));
- if (!option.label.empty()) {
- optionElement->setAttribute("label", option.label);
- }
-
- boost::shared_ptr<XMLElement> valueElement(new XMLElement("value"));
- valueElement->addNode(XMLTextNode::create(option.value));
- optionElement->addNode(valueElement);
- fieldElement->addNode(optionElement);
- }
- return fieldElement;
+ boost::shared_ptr<XMLElement> fieldElement(new XMLElement("field"));
+ if (!field->getName().empty()) {
+ fieldElement->setAttribute("var", field->getName());
+ }
+ if (!field->getLabel().empty()) {
+ fieldElement->setAttribute("label", field->getLabel());
+ }
+ if (field->getRequired()) {
+ fieldElement->addNode(boost::make_shared<XMLElement>("required"));
+ }
+ if (!field->getDescription().empty()) {
+ boost::shared_ptr<XMLElement> descriptionElement(new XMLElement("desc"));
+ descriptionElement->addNode(boost::make_shared<XMLTextNode>(field->getDescription()));
+ fieldElement->addNode(descriptionElement);
+ }
+
+ // Set the value and type
+ std::string fieldType;
+ switch (field->getType()) {
+ case FormField::UnknownType: fieldType = ""; break;
+ case FormField::BooleanType: fieldType = "boolean"; break;
+ case FormField::FixedType: fieldType = "fixed"; break;
+ case FormField::HiddenType: fieldType = "hidden"; break;
+ case FormField::ListSingleType: fieldType = "list-single"; break;
+ case FormField::TextMultiType: fieldType = "text-multi"; break;
+ case FormField::TextPrivateType: fieldType = "text-private"; break;
+ case FormField::TextSingleType: fieldType = "text-single"; break;
+ case FormField::JIDSingleType: fieldType = "jid-single"; break;
+ case FormField::JIDMultiType: fieldType = "jid-multi"; break;
+ case FormField::ListMultiType: fieldType = "list-multi"; break;
+ }
+ if (!fieldType.empty() && withTypeAttribute) {
+ fieldElement->setAttribute("type", fieldType);
+ }
+ foreach (const std::string& value, field->getValues()) {
+ boost::shared_ptr<XMLElement> valueElement = boost::make_shared<XMLElement>("value");
+ valueElement->addNode(boost::make_shared<XMLTextNode>(value));
+ fieldElement->addNode(valueElement);
+ }
+
+ foreach (const FormField::Option& option, field->getOptions()) {
+ boost::shared_ptr<XMLElement> optionElement(new XMLElement("option"));
+ if (!option.label.empty()) {
+ optionElement->setAttribute("label", option.label);
+ }
+
+ boost::shared_ptr<XMLElement> valueElement(new XMLElement("value"));
+ valueElement->addNode(XMLTextNode::create(option.value));
+ optionElement->addNode(valueElement);
+ fieldElement->addNode(optionElement);
+ }
+ return fieldElement;
}
void FormSerializer::multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr<XMLElement> element) const {
- std::string unRdText(text);
- erase(unRdText, '\r');
- std::vector<std::string> lines = String::split(unRdText, '\n');
- foreach (std::string line, lines) {
- boost::shared_ptr<XMLElement> lineElement(new XMLElement(elementName));
- lineElement->addNode(boost::make_shared<XMLTextNode>(line));
- element->addNode(lineElement);
- }
+ std::string unRdText(text);
+ erase(unRdText, '\r');
+ std::vector<std::string> lines = String::split(unRdText, '\n');
+ foreach (std::string line, lines) {
+ boost::shared_ptr<XMLElement> lineElement(new XMLElement(elementName));
+ lineElement->addNode(boost::make_shared<XMLTextNode>(line));
+ element->addNode(lineElement);
+ }
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.h b/Swiften/Serializer/PayloadSerializers/FormSerializer.h
index a01ecdb..62f6484 100644
--- a/Swiften/Serializer/PayloadSerializers/FormSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.h
@@ -15,19 +15,19 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API FormSerializer : public GenericPayloadSerializer<Form> {
- public:
- FormSerializer();
- virtual std::string serializePayload(boost::shared_ptr<Form>) const;
+ class SWIFTEN_API FormSerializer : public GenericPayloadSerializer<Form> {
+ public:
+ FormSerializer();
+ virtual std::string serializePayload(boost::shared_ptr<Form>) const;
- private:
- boost::shared_ptr<XMLElement> textToXML(boost::shared_ptr<FormText> textElement) const;
- boost::shared_ptr<XMLElement> fieldRefToXML(const std::string& ref) const;
- boost::shared_ptr<XMLElement> reportedRefToXML(boost::shared_ptr<FormReportedRef> reportedRef) const;
- boost::shared_ptr<XMLElement> pageToXML(boost::shared_ptr<FormPage> page) const;
- boost::shared_ptr<XMLElement> sectionToXML(boost::shared_ptr<FormSection> section) const;
- boost::shared_ptr<XMLElement> fieldToXML(boost::shared_ptr<FormField> field, bool withTypeAttribute) const;
- void multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr<XMLElement> parent) const;
- mutable std::vector<boost::shared_ptr<FormField> > fields_;
- };
+ private:
+ boost::shared_ptr<XMLElement> textToXML(boost::shared_ptr<FormText> textElement) const;
+ boost::shared_ptr<XMLElement> fieldRefToXML(const std::string& ref) const;
+ boost::shared_ptr<XMLElement> reportedRefToXML(boost::shared_ptr<FormReportedRef> reportedRef) const;
+ boost::shared_ptr<XMLElement> pageToXML(boost::shared_ptr<FormPage> page) const;
+ boost::shared_ptr<XMLElement> sectionToXML(boost::shared_ptr<FormSection> section) const;
+ boost::shared_ptr<XMLElement> fieldToXML(boost::shared_ptr<FormField> field, bool withTypeAttribute) const;
+ void multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr<XMLElement> parent) const;
+ mutable std::vector<boost::shared_ptr<FormField> > fields_;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.cpp
index 61fe698..8df5793 100644
--- a/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.cpp
@@ -31,29 +31,29 @@ ForwardedSerializer::~ForwardedSerializer() {
}
std::string ForwardedSerializer::serializePayload(boost::shared_ptr<Forwarded> payload) const {
- if (!payload) {
- return "";
- }
-
- XMLElement element("forwarded", "urn:xmpp:forward:0");
-
- if (payload->getDelay()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(DelaySerializer().serialize(payload->getDelay())));
- }
-
- if (payload->getStanza()) { /* find out what type of stanza we are dealing with and branch into the correct serializer*/
- boost::shared_ptr<IQ> iq;
- boost::shared_ptr<Message> message;
- boost::shared_ptr<Presence> presence;
- const std::string ns = "jabber:client";
- if ((iq = boost::dynamic_pointer_cast<IQ>(payload->getStanza()))) {
- element.addNode(boost::make_shared<XMLRawTextNode>(safeByteArrayToString(IQSerializer(serializers_).serialize(iq, ns))));
- } else if ((message = boost::dynamic_pointer_cast<Message>(payload->getStanza()))) {
- element.addNode(boost::make_shared<XMLRawTextNode>(safeByteArrayToString(MessageSerializer(serializers_).serialize(message, ns))));
- } else if ((presence = boost::dynamic_pointer_cast<Presence>(payload->getStanza()))) {
- element.addNode(boost::make_shared<XMLRawTextNode>(safeByteArrayToString(PresenceSerializer(serializers_).serialize(presence, ns))));
- }
- }
-
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+
+ XMLElement element("forwarded", "urn:xmpp:forward:0");
+
+ if (payload->getDelay()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(DelaySerializer().serialize(payload->getDelay())));
+ }
+
+ if (payload->getStanza()) { /* find out what type of stanza we are dealing with and branch into the correct serializer*/
+ boost::shared_ptr<IQ> iq;
+ boost::shared_ptr<Message> message;
+ boost::shared_ptr<Presence> presence;
+ const std::string ns = "jabber:client";
+ if ((iq = boost::dynamic_pointer_cast<IQ>(payload->getStanza()))) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(safeByteArrayToString(IQSerializer(serializers_).serialize(iq, ns))));
+ } else if ((message = boost::dynamic_pointer_cast<Message>(payload->getStanza()))) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(safeByteArrayToString(MessageSerializer(serializers_).serialize(message, ns))));
+ } else if ((presence = boost::dynamic_pointer_cast<Presence>(payload->getStanza()))) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(safeByteArrayToString(PresenceSerializer(serializers_).serialize(presence, ns))));
+ }
+ }
+
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h b/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h
index c325233..08b82b9 100644
--- a/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h
@@ -14,16 +14,16 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API ForwardedSerializer : public GenericPayloadSerializer<Forwarded> {
- public:
- ForwardedSerializer(PayloadSerializerCollection* serializers);
- virtual ~ForwardedSerializer();
+ class SWIFTEN_API ForwardedSerializer : public GenericPayloadSerializer<Forwarded> {
+ public:
+ ForwardedSerializer(PayloadSerializerCollection* serializers);
+ virtual ~ForwardedSerializer();
- virtual std::string serializePayload(boost::shared_ptr<Forwarded>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<Forwarded>) const SWIFTEN_OVERRIDE;
- private:
- PayloadSerializerCollection* serializers_;
- };
+ private:
+ PayloadSerializerCollection* serializers_;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index 589eeef..175de1e 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -86,96 +86,96 @@
namespace Swift {
FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
- serializers_.push_back(new IBBSerializer());
- serializers_.push_back(new BodySerializer());
- serializers_.push_back(new SubjectSerializer());
- serializers_.push_back(new ThreadSerializer());
- serializers_.push_back(new ChatStateSerializer());
- serializers_.push_back(new PrioritySerializer());
- serializers_.push_back(new ErrorSerializer(this));
- serializers_.push_back(new RosterSerializer());
- serializers_.push_back(new RosterItemExchangeSerializer());
- serializers_.push_back(new MUCPayloadSerializer());
- serializers_.push_back(new MUCDestroyPayloadSerializer());
- serializers_.push_back(new MUCAdminPayloadSerializer());
- serializers_.push_back(new MUCInvitationPayloadSerializer());
- serializers_.push_back(new MUCOwnerPayloadSerializer(this));
- serializers_.push_back(new MUCUserPayloadSerializer(this));
- serializers_.push_back(new SoftwareVersionSerializer());
- serializers_.push_back(new StatusSerializer());
- serializers_.push_back(new StatusShowSerializer());
- serializers_.push_back(new DiscoInfoSerializer());
- serializers_.push_back(new DiscoItemsSerializer());
- serializers_.push_back(new CapsInfoSerializer());
- serializers_.push_back(new BlockSerializer<BlockPayload>("block"));
- serializers_.push_back(new BlockSerializer<UnblockPayload>("unblock"));
- serializers_.push_back(new BlockSerializer<BlockListPayload>("blocklist"));
- serializers_.push_back(new ResourceBindSerializer());
- serializers_.push_back(new StartSessionSerializer());
- serializers_.push_back(new SecurityLabelSerializer());
- serializers_.push_back(new SecurityLabelsCatalogSerializer());
- serializers_.push_back(new StreamInitiationSerializer());
- serializers_.push_back(new BytestreamsSerializer());
- serializers_.push_back(new VCardSerializer());
- serializers_.push_back(new VCardUpdateSerializer());
- serializers_.push_back(new RawXMLPayloadSerializer());
- serializers_.push_back(new StorageSerializer());
- serializers_.push_back(new DelaySerializer());
- serializers_.push_back(new FormSerializer());
- serializers_.push_back(new PrivateStorageSerializer(this));
- serializers_.push_back(new CommandSerializer());
- serializers_.push_back(new InBandRegistrationPayloadSerializer());
- serializers_.push_back(new NicknameSerializer());
- serializers_.push_back(new SearchPayloadSerializer());
- serializers_.push_back(new ReplaceSerializer());
- serializers_.push_back(new LastSerializer());
- serializers_.push_back(new WhiteboardSerializer());
- serializers_.push_back(new UserLocationSerializer(this));
- serializers_.push_back(new UserTuneSerializer(this));
- serializers_.push_back(new IdleSerializer());
-
- serializers_.push_back(new StreamInitiationFileInfoSerializer());
- serializers_.push_back(new JingleFileTransferFileInfoSerializer());
- serializers_.push_back(new JingleContentPayloadSerializer());
- serializers_.push_back(new JingleFileTransferDescriptionSerializer());
- serializers_.push_back(new JingleFileTransferHashSerializer());
- serializers_.push_back(new JingleIBBTransportPayloadSerializer());
- serializers_.push_back(new JingleS5BTransportPayloadSerializer());
- serializers_.push_back(new JinglePayloadSerializer(this));
- serializers_.push_back(new S5BProxyRequestSerializer());
- serializers_.push_back(new DeliveryReceiptSerializer());
- serializers_.push_back(new DeliveryReceiptRequestSerializer());
+ serializers_.push_back(new IBBSerializer());
+ serializers_.push_back(new BodySerializer());
+ serializers_.push_back(new SubjectSerializer());
+ serializers_.push_back(new ThreadSerializer());
+ serializers_.push_back(new ChatStateSerializer());
+ serializers_.push_back(new PrioritySerializer());
+ serializers_.push_back(new ErrorSerializer(this));
+ serializers_.push_back(new RosterSerializer());
+ serializers_.push_back(new RosterItemExchangeSerializer());
+ serializers_.push_back(new MUCPayloadSerializer());
+ serializers_.push_back(new MUCDestroyPayloadSerializer());
+ serializers_.push_back(new MUCAdminPayloadSerializer());
+ serializers_.push_back(new MUCInvitationPayloadSerializer());
+ serializers_.push_back(new MUCOwnerPayloadSerializer(this));
+ serializers_.push_back(new MUCUserPayloadSerializer(this));
+ serializers_.push_back(new SoftwareVersionSerializer());
+ serializers_.push_back(new StatusSerializer());
+ serializers_.push_back(new StatusShowSerializer());
+ serializers_.push_back(new DiscoInfoSerializer());
+ serializers_.push_back(new DiscoItemsSerializer());
+ serializers_.push_back(new CapsInfoSerializer());
+ serializers_.push_back(new BlockSerializer<BlockPayload>("block"));
+ serializers_.push_back(new BlockSerializer<UnblockPayload>("unblock"));
+ serializers_.push_back(new BlockSerializer<BlockListPayload>("blocklist"));
+ serializers_.push_back(new ResourceBindSerializer());
+ serializers_.push_back(new StartSessionSerializer());
+ serializers_.push_back(new SecurityLabelSerializer());
+ serializers_.push_back(new SecurityLabelsCatalogSerializer());
+ serializers_.push_back(new StreamInitiationSerializer());
+ serializers_.push_back(new BytestreamsSerializer());
+ serializers_.push_back(new VCardSerializer());
+ serializers_.push_back(new VCardUpdateSerializer());
+ serializers_.push_back(new RawXMLPayloadSerializer());
+ serializers_.push_back(new StorageSerializer());
+ serializers_.push_back(new DelaySerializer());
+ serializers_.push_back(new FormSerializer());
+ serializers_.push_back(new PrivateStorageSerializer(this));
+ serializers_.push_back(new CommandSerializer());
+ serializers_.push_back(new InBandRegistrationPayloadSerializer());
+ serializers_.push_back(new NicknameSerializer());
+ serializers_.push_back(new SearchPayloadSerializer());
+ serializers_.push_back(new ReplaceSerializer());
+ serializers_.push_back(new LastSerializer());
+ serializers_.push_back(new WhiteboardSerializer());
+ serializers_.push_back(new UserLocationSerializer(this));
+ serializers_.push_back(new UserTuneSerializer(this));
+ serializers_.push_back(new IdleSerializer());
- serializers_.push_back(new PubSubSerializer(this));
- serializers_.push_back(new PubSubEventSerializer(this));
- serializers_.push_back(new PubSubOwnerPubSubSerializer(this));
- serializers_.push_back(new PubSubErrorSerializer());
+ serializers_.push_back(new StreamInitiationFileInfoSerializer());
+ serializers_.push_back(new JingleFileTransferFileInfoSerializer());
+ serializers_.push_back(new JingleContentPayloadSerializer());
+ serializers_.push_back(new JingleFileTransferDescriptionSerializer());
+ serializers_.push_back(new JingleFileTransferHashSerializer());
+ serializers_.push_back(new JingleIBBTransportPayloadSerializer());
+ serializers_.push_back(new JingleS5BTransportPayloadSerializer());
+ serializers_.push_back(new JinglePayloadSerializer(this));
+ serializers_.push_back(new S5BProxyRequestSerializer());
+ serializers_.push_back(new DeliveryReceiptSerializer());
+ serializers_.push_back(new DeliveryReceiptRequestSerializer());
- serializers_.push_back(new ResultSetSerializer());
- serializers_.push_back(new ForwardedSerializer(this));
- serializers_.push_back(new MAMResultSerializer(this));
- serializers_.push_back(new MAMQuerySerializer());
- serializers_.push_back(new MAMFinSerializer());
+ serializers_.push_back(new PubSubSerializer(this));
+ serializers_.push_back(new PubSubEventSerializer(this));
+ serializers_.push_back(new PubSubOwnerPubSubSerializer(this));
+ serializers_.push_back(new PubSubErrorSerializer());
- serializers_.push_back(new CarbonsDisableSerializer());
- serializers_.push_back(new CarbonsEnableSerializer());
- serializers_.push_back(new CarbonsPrivateSerializer());
- serializers_.push_back(new CarbonsReceivedSerializer(this));
- serializers_.push_back(new CarbonsSentSerializer(this));
+ serializers_.push_back(new ResultSetSerializer());
+ serializers_.push_back(new ForwardedSerializer(this));
+ serializers_.push_back(new MAMResultSerializer(this));
+ serializers_.push_back(new MAMQuerySerializer());
+ serializers_.push_back(new MAMFinSerializer());
- serializers_.push_back(new IsodeIQDelegationSerializer(this));
-
- foreach(PayloadSerializer* serializer, serializers_) {
- addSerializer(serializer);
- }
+ serializers_.push_back(new CarbonsDisableSerializer());
+ serializers_.push_back(new CarbonsEnableSerializer());
+ serializers_.push_back(new CarbonsPrivateSerializer());
+ serializers_.push_back(new CarbonsReceivedSerializer(this));
+ serializers_.push_back(new CarbonsSentSerializer(this));
+
+ serializers_.push_back(new IsodeIQDelegationSerializer(this));
+
+ foreach(PayloadSerializer* serializer, serializers_) {
+ addSerializer(serializer);
+ }
}
FullPayloadSerializerCollection::~FullPayloadSerializerCollection() {
- foreach(PayloadSerializer* serializer, serializers_) {
- removeSerializer(serializer);
- delete serializer;
- }
- serializers_.clear();
+ foreach(PayloadSerializer* serializer, serializers_) {
+ removeSerializer(serializer);
+ delete serializer;
+ }
+ serializers_.clear();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h
index 35f5713..59354ea 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h
@@ -12,12 +12,12 @@
#include <Swiften/Serializer/PayloadSerializerCollection.h>
namespace Swift {
- class SWIFTEN_API FullPayloadSerializerCollection : public PayloadSerializerCollection {
- public:
- FullPayloadSerializerCollection();
- virtual ~FullPayloadSerializerCollection();
+ class SWIFTEN_API FullPayloadSerializerCollection : public PayloadSerializerCollection {
+ public:
+ FullPayloadSerializerCollection();
+ virtual ~FullPayloadSerializerCollection();
- private:
- std::vector<PayloadSerializer*> serializers_;
- };
+ private:
+ std::vector<PayloadSerializer*> serializers_;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp
index de8958a..53ae0d2 100644
--- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp
@@ -23,35 +23,35 @@ IBBSerializer::IBBSerializer() {
}
std::string IBBSerializer::serializePayload(boost::shared_ptr<IBB> ibb) const {
- switch(ibb->getAction()) {
- case IBB::Data: {
- XMLElement ibbElement("data", "http://jabber.org/protocol/ibb");
- ibbElement.setAttribute("sid", ibb->getStreamID());
- if (ibb->getSequenceNumber() >= 0) {
- ibbElement.setAttribute("seq", boost::lexical_cast<std::string>(ibb->getSequenceNumber()));
- }
- ibbElement.addNode(boost::make_shared<XMLTextNode>(Base64::encode(ibb->getData())));
- return ibbElement.serialize();
- }
- case IBB::Open: {
- XMLElement ibbElement("open", "http://jabber.org/protocol/ibb");
- ibbElement.setAttribute("sid", ibb->getStreamID());
- switch (ibb->getStanzaType()) {
- case IBB::IQStanza: ibbElement.setAttribute("stanza", "iq"); break;
- case IBB::MessageStanza: ibbElement.setAttribute("stanza", "message"); break;
- }
- assert(ibb->getBlockSize() > 0);
- ibbElement.setAttribute("block-size", boost::lexical_cast<std::string>(ibb->getBlockSize()));
- return ibbElement.serialize();
- }
- case IBB::Close: {
- XMLElement ibbElement("close", "http://jabber.org/protocol/ibb");
- ibbElement.setAttribute("sid", ibb->getStreamID());
- return ibbElement.serialize();
- }
- }
- assert(false);
- return "";
+ switch(ibb->getAction()) {
+ case IBB::Data: {
+ XMLElement ibbElement("data", "http://jabber.org/protocol/ibb");
+ ibbElement.setAttribute("sid", ibb->getStreamID());
+ if (ibb->getSequenceNumber() >= 0) {
+ ibbElement.setAttribute("seq", boost::lexical_cast<std::string>(ibb->getSequenceNumber()));
+ }
+ ibbElement.addNode(boost::make_shared<XMLTextNode>(Base64::encode(ibb->getData())));
+ return ibbElement.serialize();
+ }
+ case IBB::Open: {
+ XMLElement ibbElement("open", "http://jabber.org/protocol/ibb");
+ ibbElement.setAttribute("sid", ibb->getStreamID());
+ switch (ibb->getStanzaType()) {
+ case IBB::IQStanza: ibbElement.setAttribute("stanza", "iq"); break;
+ case IBB::MessageStanza: ibbElement.setAttribute("stanza", "message"); break;
+ }
+ assert(ibb->getBlockSize() > 0);
+ ibbElement.setAttribute("block-size", boost::lexical_cast<std::string>(ibb->getBlockSize()));
+ return ibbElement.serialize();
+ }
+ case IBB::Close: {
+ XMLElement ibbElement("close", "http://jabber.org/protocol/ibb");
+ ibbElement.setAttribute("sid", ibb->getStreamID());
+ return ibbElement.serialize();
+ }
+ }
+ assert(false);
+ return "";
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.h b/Swiften/Serializer/PayloadSerializers/IBBSerializer.h
index d8914c1..fe45eac 100644
--- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API IBBSerializer : public GenericPayloadSerializer<IBB> {
- public:
- IBBSerializer();
+ class SWIFTEN_API IBBSerializer : public GenericPayloadSerializer<IBB> {
+ public:
+ IBBSerializer();
- virtual std::string serializePayload(boost::shared_ptr<IBB>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<IBB>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/IdleSerializer.h b/Swiften/Serializer/PayloadSerializers/IdleSerializer.h
index b86ebd2..1a832a1 100644
--- a/Swiften/Serializer/PayloadSerializers/IdleSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/IdleSerializer.h
@@ -18,12 +18,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API IdleSerializer : public GenericPayloadSerializer<Idle> {
- public:
- IdleSerializer() : GenericPayloadSerializer<Idle>() {}
+ class SWIFTEN_API IdleSerializer : public GenericPayloadSerializer<Idle> {
+ public:
+ IdleSerializer() : GenericPayloadSerializer<Idle>() {}
- virtual std::string serializePayload(boost::shared_ptr<Idle> idle) const {
- return "<idle xmlns='urn:xmpp:idle:1' since='" + dateTimeToString(idle->getSince()) + "'/>";
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<Idle> idle) const {
+ return "<idle xmlns='urn:xmpp:idle:1' since='" + dateTimeToString(idle->getSince()) + "'/>";
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
index 45b8122..5f275f1 100644
--- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
@@ -19,95 +19,95 @@ namespace Swift {
InBandRegistrationPayloadSerializer::InBandRegistrationPayloadSerializer() {
}
-std::string InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr<InBandRegistrationPayload> registration) const {
- XMLElement registerElement("query", "jabber:iq:register");
+std::string InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr<InBandRegistrationPayload> registration) const {
+ XMLElement registerElement("query", "jabber:iq:register");
- if (registration->isRegistered()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("registered")));
- }
+ if (registration->isRegistered()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("registered")));
+ }
- if (registration->isRemove()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("remove")));
- }
+ if (registration->isRemove()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("remove")));
+ }
- if (registration->getInstructions()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("instructions", "", *registration->getInstructions())));
- }
+ if (registration->getInstructions()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("instructions", "", *registration->getInstructions())));
+ }
- if (registration->getUsername()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("username", "", *registration->getUsername())));
- }
+ if (registration->getUsername()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("username", "", *registration->getUsername())));
+ }
- if (registration->getNick()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("nick", "", *registration->getNick())));
- }
+ if (registration->getNick()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("nick", "", *registration->getNick())));
+ }
- if (registration->getPassword()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("password", "", *registration->getPassword())));
- }
+ if (registration->getPassword()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("password", "", *registration->getPassword())));
+ }
- if (registration->getName()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("name", "", *registration->getName())));
- }
+ if (registration->getName()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("name", "", *registration->getName())));
+ }
- if (registration->getFirst()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("first", "", *registration->getFirst())));
- }
+ if (registration->getFirst()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("first", "", *registration->getFirst())));
+ }
- if (registration->getLast()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("last", "", *registration->getLast())));
- }
+ if (registration->getLast()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("last", "", *registration->getLast())));
+ }
- if (registration->getEMail()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("email", "", *registration->getEMail())));
- }
+ if (registration->getEMail()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("email", "", *registration->getEMail())));
+ }
- if (registration->getAddress()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("address", "", *registration->getAddress())));
- }
+ if (registration->getAddress()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("address", "", *registration->getAddress())));
+ }
- if (registration->getCity()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("city", "", *registration->getCity())));
- }
+ if (registration->getCity()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("city", "", *registration->getCity())));
+ }
- if (registration->getState()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("state", "", *registration->getState())));
- }
+ if (registration->getState()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("state", "", *registration->getState())));
+ }
- if (registration->getZip()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("zip", "", *registration->getZip())));
- }
+ if (registration->getZip()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("zip", "", *registration->getZip())));
+ }
- if (registration->getPhone()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("phone", "", *registration->getPhone())));
- }
+ if (registration->getPhone()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("phone", "", *registration->getPhone())));
+ }
- if (registration->getURL()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("url", "", *registration->getURL())));
- }
+ if (registration->getURL()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("url", "", *registration->getURL())));
+ }
- if (registration->getDate()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("date", "", *registration->getDate())));
- }
+ if (registration->getDate()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("date", "", *registration->getDate())));
+ }
- if (registration->getMisc()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("misc", "", *registration->getMisc())));
- }
+ if (registration->getMisc()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("misc", "", *registration->getMisc())));
+ }
- if (registration->getText()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("text", "", *registration->getText())));
- }
+ if (registration->getText()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("text", "", *registration->getText())));
+ }
- if (registration->getKey()) {
- registerElement.addNode(XMLElement::ref(new XMLElement("key", "", *registration->getKey())));
- }
+ if (registration->getKey()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("key", "", *registration->getKey())));
+ }
- if (Form::ref form = registration->getForm()) {
- registerElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
- }
+ if (Form::ref form = registration->getForm()) {
+ registerElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
+ }
- return registerElement.serialize();
+ return registerElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h
index 6480749..45eb2f5 100644
--- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h
@@ -12,10 +12,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API InBandRegistrationPayloadSerializer : public GenericPayloadSerializer<InBandRegistrationPayload> {
- public:
- InBandRegistrationPayloadSerializer();
+ class SWIFTEN_API InBandRegistrationPayloadSerializer : public GenericPayloadSerializer<InBandRegistrationPayload> {
+ public:
+ InBandRegistrationPayloadSerializer();
- virtual std::string serializePayload(boost::shared_ptr<InBandRegistrationPayload>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<InBandRegistrationPayload>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.cpp
index 7d6c64e..243ebc0 100644
--- a/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.cpp
@@ -22,12 +22,12 @@ IsodeIQDelegationSerializer::~IsodeIQDelegationSerializer() {
}
std::string IsodeIQDelegationSerializer::serializePayload(boost::shared_ptr<IsodeIQDelegation> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("delegate", "http://isode.com/iq_delegation");
- element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(payload->getForward())->serialize(payload->getForward())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("delegate", "http://isode.com/iq_delegation");
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(payload->getForward())->serialize(payload->getForward())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h b/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h
index c505510..47a9ddc 100644
--- a/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API IsodeIQDelegationSerializer : public GenericPayloadSerializer<IsodeIQDelegation> {
- public:
- IsodeIQDelegationSerializer(PayloadSerializerCollection* serializers);
- virtual ~IsodeIQDelegationSerializer();
+ class SWIFTEN_API IsodeIQDelegationSerializer : public GenericPayloadSerializer<IsodeIQDelegation> {
+ public:
+ IsodeIQDelegationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~IsodeIQDelegationSerializer();
- virtual std::string serializePayload(boost::shared_ptr<IsodeIQDelegation>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<IsodeIQDelegation>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp
index 6e04db4..c006a93 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp
@@ -31,53 +31,53 @@ JingleContentPayloadSerializer::JingleContentPayloadSerializer() {
}
std::string JingleContentPayloadSerializer::serializePayload(boost::shared_ptr<JingleContentPayload> payload) const {
- XMLElement payloadXML("content");
- payloadXML.setAttribute("creator", creatorToString(payload->getCreator()));
- payloadXML.setAttribute("name", payload->getName());
-
- if (!payload->getDescriptions().empty()) {
- // JingleFileTransferDescription
- JingleFileTransferDescriptionSerializer ftSerializer;
- JingleFileTransferDescription::ref filetransfer;
-
- foreach(JingleDescription::ref desc, payload->getDescriptions()) {
- if ((filetransfer = boost::dynamic_pointer_cast<JingleFileTransferDescription>(desc))) {
- payloadXML.addNode(boost::make_shared<XMLRawTextNode>(ftSerializer.serializePayload(filetransfer)));
- }
- }
- }
-
- if (!payload->getTransports().empty()) {
- // JingleIBBTransportPayload
- JingleIBBTransportPayloadSerializer ibbSerializer;
- JingleIBBTransportPayload::ref ibb;
-
- // JingleS5BTransportPayload
- JingleS5BTransportPayloadSerializer s5bSerializer;
- JingleS5BTransportPayload::ref s5b;
+ XMLElement payloadXML("content");
+ payloadXML.setAttribute("creator", creatorToString(payload->getCreator()));
+ payloadXML.setAttribute("name", payload->getName());
- foreach(JingleTransportPayload::ref transport, payload->getTransports()) {
- if ((ibb = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) {
- payloadXML.addNode(boost::make_shared<XMLRawTextNode>(ibbSerializer.serializePayload(ibb)));
- } else if ((s5b = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transport))) {
- payloadXML.addNode(boost::make_shared<XMLRawTextNode>(s5bSerializer.serializePayload(s5b)));
- }
- }
- }
- return payloadXML.serialize();
+ if (!payload->getDescriptions().empty()) {
+ // JingleFileTransferDescription
+ JingleFileTransferDescriptionSerializer ftSerializer;
+ JingleFileTransferDescription::ref filetransfer;
+
+ foreach(JingleDescription::ref desc, payload->getDescriptions()) {
+ if ((filetransfer = boost::dynamic_pointer_cast<JingleFileTransferDescription>(desc))) {
+ payloadXML.addNode(boost::make_shared<XMLRawTextNode>(ftSerializer.serializePayload(filetransfer)));
+ }
+ }
+ }
+
+ if (!payload->getTransports().empty()) {
+ // JingleIBBTransportPayload
+ JingleIBBTransportPayloadSerializer ibbSerializer;
+ JingleIBBTransportPayload::ref ibb;
+
+ // JingleS5BTransportPayload
+ JingleS5BTransportPayloadSerializer s5bSerializer;
+ JingleS5BTransportPayload::ref s5b;
+
+ foreach(JingleTransportPayload::ref transport, payload->getTransports()) {
+ if ((ibb = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) {
+ payloadXML.addNode(boost::make_shared<XMLRawTextNode>(ibbSerializer.serializePayload(ibb)));
+ } else if ((s5b = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transport))) {
+ payloadXML.addNode(boost::make_shared<XMLRawTextNode>(s5bSerializer.serializePayload(s5b)));
+ }
+ }
+ }
+ return payloadXML.serialize();
}
std::string JingleContentPayloadSerializer::creatorToString(JingleContentPayload::Creator creator) const {
- switch(creator) {
- case JingleContentPayload::InitiatorCreator:
- return "initiator";
- case JingleContentPayload::ResponderCreator:
- return "responder";
- case JingleContentPayload::UnknownCreator:
- SWIFT_LOG(error) << "Serializing unknown creator value.";
- return "ERROR ERROR ERROR";
- }
- assert(false);
- return "";
+ switch(creator) {
+ case JingleContentPayload::InitiatorCreator:
+ return "initiator";
+ case JingleContentPayload::ResponderCreator:
+ return "responder";
+ case JingleContentPayload::UnknownCreator:
+ SWIFT_LOG(error) << "Serializing unknown creator value.";
+ return "ERROR ERROR ERROR";
+ }
+ assert(false);
+ return "";
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h
index 87a4162..ff0185e 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h
@@ -18,15 +18,15 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
-
- class SWIFTEN_API JingleContentPayloadSerializer : public GenericPayloadSerializer<JingleContentPayload> {
- public:
- JingleContentPayloadSerializer();
-
- virtual std::string serializePayload(boost::shared_ptr<JingleContentPayload>) const;
-
- private:
- std::string creatorToString(JingleContentPayload::Creator creator) const;
- };
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API JingleContentPayloadSerializer : public GenericPayloadSerializer<JingleContentPayload> {
+ public:
+ JingleContentPayloadSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<JingleContentPayload>) const;
+
+ private:
+ std::string creatorToString(JingleContentPayload::Creator creator) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp
index 28431ce..b0bb78d 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp
@@ -30,12 +30,12 @@ JingleFileTransferDescriptionSerializer::JingleFileTransferDescriptionSerializer
}
std::string JingleFileTransferDescriptionSerializer::serializePayload(boost::shared_ptr<JingleFileTransferDescription> payload) const {
- XMLElement description("description", "urn:xmpp:jingle:apps:file-transfer:4");
+ XMLElement description("description", "urn:xmpp:jingle:apps:file-transfer:4");
- JingleFileTransferFileInfoSerializer fileInfoSerializer;
- boost::shared_ptr<XMLRawTextNode> fileInfoXML = boost::make_shared<XMLRawTextNode>(fileInfoSerializer.serialize(boost::make_shared<JingleFileTransferFileInfo>(payload->getFileInfo())));
- description.addNode(fileInfoXML);
- return description.serialize();
+ JingleFileTransferFileInfoSerializer fileInfoSerializer;
+ boost::shared_ptr<XMLRawTextNode> fileInfoXML = boost::make_shared<XMLRawTextNode>(fileInfoSerializer.serialize(boost::make_shared<JingleFileTransferFileInfo>(payload->getFileInfo())));
+ description.addNode(fileInfoXML);
+ return description.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.h
index e731612..53199f6 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.h
@@ -18,13 +18,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class XMLElement;
-
- class SWIFTEN_API JingleFileTransferDescriptionSerializer : public GenericPayloadSerializer<JingleFileTransferDescription> {
- public:
- JingleFileTransferDescriptionSerializer();
-
- virtual std::string serializePayload(boost::shared_ptr<JingleFileTransferDescription>) const;
- };
+ class PayloadSerializerCollection;
+ class XMLElement;
+
+ class SWIFTEN_API JingleFileTransferDescriptionSerializer : public GenericPayloadSerializer<JingleFileTransferDescription> {
+ public:
+ JingleFileTransferDescriptionSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<JingleFileTransferDescription>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp
index 0c30b9d..7fcf452 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp
@@ -24,43 +24,43 @@ JingleFileTransferFileInfoSerializer::JingleFileTransferFileInfoSerializer() {
std::string JingleFileTransferFileInfoSerializer::serializePayload(boost::shared_ptr<JingleFileTransferFileInfo> fileInfo) const {
- XMLElement fileElement("file", "");
-
- if (fileInfo->getDate() != stringToDateTime("")) {
- fileElement.addNode(boost::make_shared<XMLElement>("date", "", dateTimeToString(fileInfo->getDate())));
- }
-
- if (!fileInfo->getDescription().empty()) {
- fileElement.addNode(boost::make_shared<XMLElement>("desc", "", fileInfo->getDescription()));
- }
-
- if (!fileInfo->getMediaType().empty()) {
- fileElement.addNode(boost::make_shared<XMLElement>("media-type", "", fileInfo->getMediaType()));
- }
-
- if (!fileInfo->getName().empty()) {
- fileElement.addNode(boost::make_shared<XMLElement>("name", "", fileInfo->getName()));
- }
-
- if (fileInfo->getSupportsRangeRequests()) {
- boost::shared_ptr<XMLElement> range = boost::make_shared<XMLElement>("range");
- if (fileInfo->getRangeOffset() != 0) {
- range->setAttribute("offset", boost::lexical_cast<std::string>(fileInfo->getRangeOffset()));
- }
- fileElement.addNode(range);
- }
-
- if (fileInfo->getSize() > 0) {
- fileElement.addNode(boost::make_shared<XMLElement>("size", "", boost::lexical_cast<std::string>(fileInfo->getSize())));
- }
-
- foreach (JingleFileTransferFileInfo::HashElementMap::value_type hashElement, fileInfo->getHashes()) {
- boost::shared_ptr<XMLElement> hash = boost::make_shared<XMLElement>("hash", "urn:xmpp:hashes:1", Base64::encode(hashElement.second));
- hash->setAttribute("algo", hashElement.first);
- fileElement.addNode(hash);
- }
-
- return fileElement.serialize();
+ XMLElement fileElement("file", "");
+
+ if (fileInfo->getDate() != stringToDateTime("")) {
+ fileElement.addNode(boost::make_shared<XMLElement>("date", "", dateTimeToString(fileInfo->getDate())));
+ }
+
+ if (!fileInfo->getDescription().empty()) {
+ fileElement.addNode(boost::make_shared<XMLElement>("desc", "", fileInfo->getDescription()));
+ }
+
+ if (!fileInfo->getMediaType().empty()) {
+ fileElement.addNode(boost::make_shared<XMLElement>("media-type", "", fileInfo->getMediaType()));
+ }
+
+ if (!fileInfo->getName().empty()) {
+ fileElement.addNode(boost::make_shared<XMLElement>("name", "", fileInfo->getName()));
+ }
+
+ if (fileInfo->getSupportsRangeRequests()) {
+ boost::shared_ptr<XMLElement> range = boost::make_shared<XMLElement>("range");
+ if (fileInfo->getRangeOffset() != 0) {
+ range->setAttribute("offset", boost::lexical_cast<std::string>(fileInfo->getRangeOffset()));
+ }
+ fileElement.addNode(range);
+ }
+
+ if (fileInfo->getSize() > 0) {
+ fileElement.addNode(boost::make_shared<XMLElement>("size", "", boost::lexical_cast<std::string>(fileInfo->getSize())));
+ }
+
+ foreach (JingleFileTransferFileInfo::HashElementMap::value_type hashElement, fileInfo->getHashes()) {
+ boost::shared_ptr<XMLElement> hash = boost::make_shared<XMLElement>("hash", "urn:xmpp:hashes:1", Base64::encode(hashElement.second));
+ hash->setAttribute("algo", hashElement.first);
+ fileElement.addNode(hash);
+ }
+
+ return fileElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.h
index c7b5233..bd4d8cd 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.h
@@ -12,12 +12,12 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API JingleFileTransferFileInfoSerializer : public GenericPayloadSerializer<JingleFileTransferFileInfo> {
- public:
- JingleFileTransferFileInfoSerializer();
+ class SWIFTEN_API JingleFileTransferFileInfoSerializer : public GenericPayloadSerializer<JingleFileTransferFileInfo> {
+ public:
+ JingleFileTransferFileInfoSerializer();
- virtual std::string serializePayload(boost::shared_ptr<JingleFileTransferFileInfo>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<JingleFileTransferFileInfo>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp
index 137e0c0..4db5f0c 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp
@@ -30,19 +30,19 @@ JingleFileTransferHashSerializer::JingleFileTransferHashSerializer() {
}
std::string JingleFileTransferHashSerializer::serializePayload(boost::shared_ptr<JingleFileTransferHash> payload) const {
- // code for version urn:xmpp:jingle:apps:file-transfer:2
- //XMLElement hash("hash", "urn:xmpp:jingle:apps:file-transfer:info:2", payload->getHash());
+ // code for version urn:xmpp:jingle:apps:file-transfer:2
+ //XMLElement hash("hash", "urn:xmpp:jingle:apps:file-transfer:info:2", payload->getHash());
- // code for version urn:xmpp:jingle:apps:file-transfer:4
- XMLElement checksum("checksum", "urn:xmpp:jingle:apps:file-transfer:4");
+ // code for version urn:xmpp:jingle:apps:file-transfer:4
+ XMLElement checksum("checksum", "urn:xmpp:jingle:apps:file-transfer:4");
- JingleFileTransferFileInfoSerializer fileSerializer;
+ JingleFileTransferFileInfoSerializer fileSerializer;
- boost::shared_ptr<XMLRawTextNode> file = boost::make_shared<XMLRawTextNode>(fileSerializer.serialize(boost::make_shared<JingleFileTransferFileInfo>(payload->getFileInfo())));
+ boost::shared_ptr<XMLRawTextNode> file = boost::make_shared<XMLRawTextNode>(fileSerializer.serialize(boost::make_shared<JingleFileTransferFileInfo>(payload->getFileInfo())));
- checksum.addNode(file);
+ checksum.addNode(file);
- return checksum.serialize();
+ return checksum.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.h b/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.h
index f63db33..5434c17 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.h
@@ -18,13 +18,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class XMLElement;
-
- class SWIFTEN_API JingleFileTransferHashSerializer : public GenericPayloadSerializer<JingleFileTransferHash> {
- public:
- JingleFileTransferHashSerializer();
-
- virtual std::string serializePayload(boost::shared_ptr<JingleFileTransferHash>) const;
- };
+ class PayloadSerializerCollection;
+ class XMLElement;
+
+ class SWIFTEN_API JingleFileTransferHashSerializer : public GenericPayloadSerializer<JingleFileTransferHash> {
+ public:
+ JingleFileTransferHashSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<JingleFileTransferHash>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp
index c165740..0574ea7 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp
@@ -27,13 +27,13 @@ JingleIBBTransportPayloadSerializer::JingleIBBTransportPayloadSerializer() {
}
std::string JingleIBBTransportPayloadSerializer::serializePayload(boost::shared_ptr<JingleIBBTransportPayload> payload) const {
- XMLElement payloadXML("transport", "urn:xmpp:jingle:transports:ibb:1");
- if (payload->getBlockSize()) {
- payloadXML.setAttribute("block-size", boost::lexical_cast<std::string>(*payload->getBlockSize()));
- }
- payloadXML.setAttribute("sid", payload->getSessionID());
+ XMLElement payloadXML("transport", "urn:xmpp:jingle:transports:ibb:1");
+ if (payload->getBlockSize()) {
+ payloadXML.setAttribute("block-size", boost::lexical_cast<std::string>(*payload->getBlockSize()));
+ }
+ payloadXML.setAttribute("sid", payload->getSessionID());
- return payloadXML.serialize();
+ return payloadXML.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.h
index 333c369..1b77666 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.h
@@ -18,13 +18,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class XMLElement;
-
- class SWIFTEN_API JingleIBBTransportPayloadSerializer : public GenericPayloadSerializer<JingleIBBTransportPayload> {
- public:
- JingleIBBTransportPayloadSerializer();
-
- virtual std::string serializePayload(boost::shared_ptr<JingleIBBTransportPayload>) const;
- };
+ class PayloadSerializerCollection;
+ class XMLElement;
+
+ class SWIFTEN_API JingleIBBTransportPayloadSerializer : public GenericPayloadSerializer<JingleIBBTransportPayload> {
+ public:
+ JingleIBBTransportPayloadSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<JingleIBBTransportPayload>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp
index cebf936..a5bd60a 100644
--- a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp
@@ -36,115 +36,115 @@ JinglePayloadSerializer::JinglePayloadSerializer(PayloadSerializerCollection* se
}
std::string JinglePayloadSerializer::serializePayload(boost::shared_ptr<JinglePayload> payload) const {
- XMLElement jinglePayload("jingle", "urn:xmpp:jingle:1");
- jinglePayload.setAttribute("action", actionToString(payload->getAction()));
- jinglePayload.setAttribute("initiator", payload->getInitiator());
- jinglePayload.setAttribute("sid", payload->getSessionID());
+ XMLElement jinglePayload("jingle", "urn:xmpp:jingle:1");
+ jinglePayload.setAttribute("action", actionToString(payload->getAction()));
+ jinglePayload.setAttribute("initiator", payload->getInitiator());
+ jinglePayload.setAttribute("sid", payload->getSessionID());
- std::vector<boost::shared_ptr<Payload> > payloads = payload->getPayloads();
- if (!payloads.empty()) {
- foreach(boost::shared_ptr<Payload> subPayload, payloads) {
- PayloadSerializer* serializer = serializers->getPayloadSerializer(subPayload);
- if (serializer) {
- jinglePayload.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(subPayload)));
- }
- }
- }
-
- if (payload->getReason().is_initialized()) {
- boost::shared_ptr<XMLElement> reason = boost::make_shared<XMLElement>("reason");
- reason->addNode(boost::make_shared<XMLElement>(reasonTypeToString(payload->getReason()->type)));
- if (!payload->getReason()->text.empty()) {
- reason->addNode(boost::make_shared<XMLElement>("desc", "", payload->getReason()->text));
- }
- jinglePayload.addNode(reason);
- }
-
- return jinglePayload.serialize();
+ std::vector<boost::shared_ptr<Payload> > payloads = payload->getPayloads();
+ if (!payloads.empty()) {
+ foreach(boost::shared_ptr<Payload> subPayload, payloads) {
+ PayloadSerializer* serializer = serializers->getPayloadSerializer(subPayload);
+ if (serializer) {
+ jinglePayload.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(subPayload)));
+ }
+ }
+ }
+
+ if (payload->getReason().is_initialized()) {
+ boost::shared_ptr<XMLElement> reason = boost::make_shared<XMLElement>("reason");
+ reason->addNode(boost::make_shared<XMLElement>(reasonTypeToString(payload->getReason()->type)));
+ if (!payload->getReason()->text.empty()) {
+ reason->addNode(boost::make_shared<XMLElement>("desc", "", payload->getReason()->text));
+ }
+ jinglePayload.addNode(reason);
+ }
+
+ return jinglePayload.serialize();
}
std::string JinglePayloadSerializer::actionToString(JinglePayload::Action action) const {
- switch(action) {
- case JinglePayload::ContentAccept:
- return "content-accept";
- case JinglePayload::ContentAdd:
- return "content-add";
- case JinglePayload::ContentModify:
- return "content-modify";
- case JinglePayload::ContentReject:
- return "content-reject";
- case JinglePayload::ContentRemove:
- return "content-remove";
- case JinglePayload::DescriptionInfo:
- return "description-info";
- case JinglePayload::SecurityInfo:
- return "security-info";
- case JinglePayload::SessionAccept:
- return "session-accept";
- case JinglePayload::SessionInfo:
- return "session-info";
- case JinglePayload::SessionInitiate:
- return "session-initiate";
- case JinglePayload::SessionTerminate:
- return "session-terminate";
- case JinglePayload::TransportAccept:
- return "transport-accept";
- case JinglePayload::TransportInfo:
- return "transport-info";
- case JinglePayload::TransportReject:
- return "transport-reject";
- case JinglePayload::TransportReplace:
- return "transport-replace";
- case JinglePayload::UnknownAction:
- SWIFT_LOG(warning) << "Serializing unknown action value." << std::endl;
- return "";
- }
- assert(false);
- return "";
+ switch(action) {
+ case JinglePayload::ContentAccept:
+ return "content-accept";
+ case JinglePayload::ContentAdd:
+ return "content-add";
+ case JinglePayload::ContentModify:
+ return "content-modify";
+ case JinglePayload::ContentReject:
+ return "content-reject";
+ case JinglePayload::ContentRemove:
+ return "content-remove";
+ case JinglePayload::DescriptionInfo:
+ return "description-info";
+ case JinglePayload::SecurityInfo:
+ return "security-info";
+ case JinglePayload::SessionAccept:
+ return "session-accept";
+ case JinglePayload::SessionInfo:
+ return "session-info";
+ case JinglePayload::SessionInitiate:
+ return "session-initiate";
+ case JinglePayload::SessionTerminate:
+ return "session-terminate";
+ case JinglePayload::TransportAccept:
+ return "transport-accept";
+ case JinglePayload::TransportInfo:
+ return "transport-info";
+ case JinglePayload::TransportReject:
+ return "transport-reject";
+ case JinglePayload::TransportReplace:
+ return "transport-replace";
+ case JinglePayload::UnknownAction:
+ SWIFT_LOG(warning) << "Serializing unknown action value." << std::endl;
+ return "";
+ }
+ assert(false);
+ return "";
}
std::string JinglePayloadSerializer::reasonTypeToString(JinglePayload::Reason::Type type) const {
- switch(type) {
- case JinglePayload::Reason::UnknownType:
- SWIFT_LOG(warning) << "Unknown jingle reason type!" << std::endl;
- return "";
- case JinglePayload::Reason::AlternativeSession:
- return "alternative-session";
- case JinglePayload::Reason::Busy:
- return "busy";
- case JinglePayload::Reason::Cancel:
- return "cancel";
- case JinglePayload::Reason::ConnectivityError:
- return "connectivity-error";
- case JinglePayload::Reason::Decline:
- return "decline";
- case JinglePayload::Reason::Expired:
- return "expired";
- case JinglePayload::Reason::FailedApplication:
- return "failed-application";
- case JinglePayload::Reason::FailedTransport:
- return "failed-transport";
- case JinglePayload::Reason::GeneralError:
- return "general-error";
- case JinglePayload::Reason::Gone:
- return "gone";
- case JinglePayload::Reason::IncompatibleParameters:
- return "incompatible-parameters";
- case JinglePayload::Reason::MediaError:
- return "media-error";
- case JinglePayload::Reason::SecurityError:
- return "security-error";
- case JinglePayload::Reason::Success:
- return "success";
- case JinglePayload::Reason::Timeout:
- return "timeout";
- case JinglePayload::Reason::UnsupportedApplications:
- return "unsupported-applications";
- case JinglePayload::Reason::UnsupportedTransports:
- return "unsupported-transports";
- }
- assert(false);
- return "";
+ switch(type) {
+ case JinglePayload::Reason::UnknownType:
+ SWIFT_LOG(warning) << "Unknown jingle reason type!" << std::endl;
+ return "";
+ case JinglePayload::Reason::AlternativeSession:
+ return "alternative-session";
+ case JinglePayload::Reason::Busy:
+ return "busy";
+ case JinglePayload::Reason::Cancel:
+ return "cancel";
+ case JinglePayload::Reason::ConnectivityError:
+ return "connectivity-error";
+ case JinglePayload::Reason::Decline:
+ return "decline";
+ case JinglePayload::Reason::Expired:
+ return "expired";
+ case JinglePayload::Reason::FailedApplication:
+ return "failed-application";
+ case JinglePayload::Reason::FailedTransport:
+ return "failed-transport";
+ case JinglePayload::Reason::GeneralError:
+ return "general-error";
+ case JinglePayload::Reason::Gone:
+ return "gone";
+ case JinglePayload::Reason::IncompatibleParameters:
+ return "incompatible-parameters";
+ case JinglePayload::Reason::MediaError:
+ return "media-error";
+ case JinglePayload::Reason::SecurityError:
+ return "security-error";
+ case JinglePayload::Reason::Success:
+ return "success";
+ case JinglePayload::Reason::Timeout:
+ return "timeout";
+ case JinglePayload::Reason::UnsupportedApplications:
+ return "unsupported-applications";
+ case JinglePayload::Reason::UnsupportedTransports:
+ return "unsupported-transports";
+ }
+ assert(false);
+ return "";
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h
index 97215ab..9b36626 100644
--- a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h
@@ -18,20 +18,20 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class XMLElement;
-
- class SWIFTEN_API JinglePayloadSerializer : public GenericPayloadSerializer<JinglePayload> {
- public:
- JinglePayloadSerializer(PayloadSerializerCollection*);
-
- virtual std::string serializePayload(boost::shared_ptr<JinglePayload>) const;
-
- private:
- std::string actionToString(JinglePayload::Action action) const;
- std::string reasonTypeToString(JinglePayload::Reason::Type type) const;
-
- private:
- PayloadSerializerCollection* serializers;
- };
+ class PayloadSerializerCollection;
+ class XMLElement;
+
+ class SWIFTEN_API JinglePayloadSerializer : public GenericPayloadSerializer<JinglePayload> {
+ public:
+ JinglePayloadSerializer(PayloadSerializerCollection*);
+
+ virtual std::string serializePayload(boost::shared_ptr<JinglePayload>) const;
+
+ private:
+ std::string actionToString(JinglePayload::Action action) const;
+ std::string reasonTypeToString(JinglePayload::Reason::Type type) const;
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp
index 69e2488..66e6515 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp
@@ -28,69 +28,69 @@ JingleS5BTransportPayloadSerializer::JingleS5BTransportPayloadSerializer() {
}
std::string JingleS5BTransportPayloadSerializer::serializePayload(boost::shared_ptr<JingleS5BTransportPayload> payload) const {
- XMLElement payloadXML("transport", "urn:xmpp:jingle:transports:s5b:1");
- payloadXML.setAttribute("sid", payload->getSessionID());
- payloadXML.setAttribute("mode", modeToString(payload->getMode()));
- if (!payload->getDstAddr().empty()) {
- payloadXML.setAttribute("dstaddr", payload->getDstAddr());
- }
-
- foreach(JingleS5BTransportPayload::Candidate candidate, payload->getCandidates()) {
- boost::shared_ptr<XMLElement> candidateXML = boost::make_shared<XMLElement>("candidate");
- candidateXML->setAttribute("cid", candidate.cid);
- candidateXML->setAttribute("host", candidate.hostPort.getAddress().toString());
- candidateXML->setAttribute("jid", candidate.jid.toString());
- candidateXML->setAttribute("port", boost::lexical_cast<std::string>(candidate.hostPort.getPort()));
- candidateXML->setAttribute("priority", boost::lexical_cast<std::string>(candidate.priority));
- candidateXML->setAttribute("type", typeToString(candidate.type));
- payloadXML.addNode(candidateXML);
- }
-
- if (payload->hasCandidateError()) {
- payloadXML.addNode(boost::make_shared<XMLElement>("candidate-error"));
- }
- if (payload->hasProxyError()) {
- payloadXML.addNode(boost::make_shared<XMLElement>("proxy-error"));
- }
-
- if (!payload->getActivated().empty()) {
- boost::shared_ptr<XMLElement> activatedXML = boost::make_shared<XMLElement>("activated");
- activatedXML->setAttribute("cid", payload->getActivated());
- payloadXML.addNode(activatedXML);
- }
- if (!payload->getCandidateUsed().empty()) {
- boost::shared_ptr<XMLElement> candusedXML = boost::make_shared<XMLElement>("candidate-used");
- candusedXML->setAttribute("cid", payload->getCandidateUsed());
- payloadXML.addNode(candusedXML);
- }
-
- return payloadXML.serialize();
+ XMLElement payloadXML("transport", "urn:xmpp:jingle:transports:s5b:1");
+ payloadXML.setAttribute("sid", payload->getSessionID());
+ payloadXML.setAttribute("mode", modeToString(payload->getMode()));
+ if (!payload->getDstAddr().empty()) {
+ payloadXML.setAttribute("dstaddr", payload->getDstAddr());
+ }
+
+ foreach(JingleS5BTransportPayload::Candidate candidate, payload->getCandidates()) {
+ boost::shared_ptr<XMLElement> candidateXML = boost::make_shared<XMLElement>("candidate");
+ candidateXML->setAttribute("cid", candidate.cid);
+ candidateXML->setAttribute("host", candidate.hostPort.getAddress().toString());
+ candidateXML->setAttribute("jid", candidate.jid.toString());
+ candidateXML->setAttribute("port", boost::lexical_cast<std::string>(candidate.hostPort.getPort()));
+ candidateXML->setAttribute("priority", boost::lexical_cast<std::string>(candidate.priority));
+ candidateXML->setAttribute("type", typeToString(candidate.type));
+ payloadXML.addNode(candidateXML);
+ }
+
+ if (payload->hasCandidateError()) {
+ payloadXML.addNode(boost::make_shared<XMLElement>("candidate-error"));
+ }
+ if (payload->hasProxyError()) {
+ payloadXML.addNode(boost::make_shared<XMLElement>("proxy-error"));
+ }
+
+ if (!payload->getActivated().empty()) {
+ boost::shared_ptr<XMLElement> activatedXML = boost::make_shared<XMLElement>("activated");
+ activatedXML->setAttribute("cid", payload->getActivated());
+ payloadXML.addNode(activatedXML);
+ }
+ if (!payload->getCandidateUsed().empty()) {
+ boost::shared_ptr<XMLElement> candusedXML = boost::make_shared<XMLElement>("candidate-used");
+ candusedXML->setAttribute("cid", payload->getCandidateUsed());
+ payloadXML.addNode(candusedXML);
+ }
+
+ return payloadXML.serialize();
}
std::string JingleS5BTransportPayloadSerializer::modeToString(JingleS5BTransportPayload::Mode mode) const {
- switch(mode) {
- case JingleS5BTransportPayload::TCPMode:
- return "tcp";
- case JingleS5BTransportPayload::UDPMode:
- return "udp";
- }
- assert(false);
- return "";
+ switch(mode) {
+ case JingleS5BTransportPayload::TCPMode:
+ return "tcp";
+ case JingleS5BTransportPayload::UDPMode:
+ return "udp";
+ }
+ assert(false);
+ return "";
}
std::string JingleS5BTransportPayloadSerializer::typeToString(JingleS5BTransportPayload::Candidate::Type type) const {
- switch(type) {
- case JingleS5BTransportPayload::Candidate::AssistedType:
- return "assisted";
- case JingleS5BTransportPayload::Candidate::DirectType:
- return "direct";
- case JingleS5BTransportPayload::Candidate::ProxyType:
- return "proxy";
- case JingleS5BTransportPayload::Candidate::TunnelType:
- return "tunnel";
- }
- assert(false);
- return "";
+ switch(type) {
+ case JingleS5BTransportPayload::Candidate::AssistedType:
+ return "assisted";
+ case JingleS5BTransportPayload::Candidate::DirectType:
+ return "direct";
+ case JingleS5BTransportPayload::Candidate::ProxyType:
+ return "proxy";
+ case JingleS5BTransportPayload::Candidate::TunnelType:
+ return "tunnel";
+ }
+ assert(false);
+ return "";
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.h
index 1d05969..684423e 100644
--- a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.h
@@ -18,17 +18,17 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class XMLElement;
-
- class SWIFTEN_API JingleS5BTransportPayloadSerializer : public GenericPayloadSerializer<JingleS5BTransportPayload> {
- public:
- JingleS5BTransportPayloadSerializer();
-
- virtual std::string serializePayload(boost::shared_ptr<JingleS5BTransportPayload>) const;
-
- private:
- std::string modeToString(JingleS5BTransportPayload::Mode) const;
- std::string typeToString(JingleS5BTransportPayload::Candidate::Type) const;
- };
+ class PayloadSerializerCollection;
+ class XMLElement;
+
+ class SWIFTEN_API JingleS5BTransportPayloadSerializer : public GenericPayloadSerializer<JingleS5BTransportPayload> {
+ public:
+ JingleS5BTransportPayloadSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<JingleS5BTransportPayload>) const;
+
+ private:
+ std::string modeToString(JingleS5BTransportPayload::Mode) const;
+ std::string typeToString(JingleS5BTransportPayload::Candidate::Type) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/LastSerializer.h b/Swiften/Serializer/PayloadSerializers/LastSerializer.h
index 18c5578..6c831eb 100644
--- a/Swiften/Serializer/PayloadSerializers/LastSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/LastSerializer.h
@@ -13,12 +13,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API LastSerializer : public GenericPayloadSerializer<Last> {
- public:
- LastSerializer() : GenericPayloadSerializer<Last>() {}
+ class SWIFTEN_API LastSerializer : public GenericPayloadSerializer<Last> {
+ public:
+ LastSerializer() : GenericPayloadSerializer<Last>() {}
- virtual std::string serializePayload(boost::shared_ptr<Last> last) const {
- return "<query xmlns='jabber:iq:last' seconds='" + boost::lexical_cast<std::string>(last->getSeconds()) + "'/>";
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<Last> last) const {
+ return "<query xmlns='jabber:iq:last' seconds='" + boost::lexical_cast<std::string>(last->getSeconds()) + "'/>";
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.cpp
index e17408f..d15038c 100644
--- a/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.cpp
@@ -23,27 +23,27 @@ MAMFinSerializer::~MAMFinSerializer() {
}
std::string MAMFinSerializer::serializePayload(boost::shared_ptr<MAMFin> payload) const {
- if (!payload) {
- return "";
- }
+ if (!payload) {
+ return "";
+ }
- XMLElement element("fin", "urn:xmpp:mam:0");
+ XMLElement element("fin", "urn:xmpp:mam:0");
- if (payload->isComplete()) {
- element.setAttribute("complete", "true");
- }
+ if (payload->isComplete()) {
+ element.setAttribute("complete", "true");
+ }
- if (!payload->isStable()) {
- element.setAttribute("stable", "false");
- }
+ if (!payload->isStable()) {
+ element.setAttribute("stable", "false");
+ }
- if (payload->getQueryID()) {
- element.setAttribute("queryid", *payload->getQueryID());
- }
+ if (payload->getQueryID()) {
+ element.setAttribute("queryid", *payload->getQueryID());
+ }
- if (payload->getResultSet()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(ResultSetSerializer().serialize(payload->getResultSet())));
- }
+ if (payload->getResultSet()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(ResultSetSerializer().serialize(payload->getResultSet())));
+ }
- return element.serialize();
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h b/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h
index b8ee1b1..2be6981 100644
--- a/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API MAMFinSerializer : public GenericPayloadSerializer<MAMFin> {
- public:
- MAMFinSerializer();
- virtual ~MAMFinSerializer();
+ class SWIFTEN_API MAMFinSerializer : public GenericPayloadSerializer<MAMFin> {
+ public:
+ MAMFinSerializer();
+ virtual ~MAMFinSerializer();
- virtual std::string serializePayload(boost::shared_ptr<MAMFin>) const SWIFTEN_OVERRIDE;
- };
+ virtual std::string serializePayload(boost::shared_ptr<MAMFin>) const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.cpp b/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.cpp
index 853bbf1..d503d0b 100644
--- a/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.cpp
@@ -25,27 +25,27 @@ MAMQuerySerializer::~MAMQuerySerializer() {
}
std::string MAMQuerySerializer::serializePayload(boost::shared_ptr<MAMQuery> payload) const {
- if (!payload) {
- return "";
- }
+ if (!payload) {
+ return "";
+ }
- XMLElement element("query", "urn:xmpp:mam:0");
+ XMLElement element("query", "urn:xmpp:mam:0");
- if (payload->getQueryID()) {
- element.setAttribute("queryid", *payload->getQueryID());
- }
+ if (payload->getQueryID()) {
+ element.setAttribute("queryid", *payload->getQueryID());
+ }
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
- if (payload->getForm()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getForm())));
- }
+ if (payload->getForm()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getForm())));
+ }
- if (payload->getResultSet()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(ResultSetSerializer().serialize(payload->getResultSet())));
- }
+ if (payload->getResultSet()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(ResultSetSerializer().serialize(payload->getResultSet())));
+ }
- return element.serialize();
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h b/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h
index e86663e..8b5e270 100644
--- a/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API MAMQuerySerializer : public GenericPayloadSerializer<MAMQuery> {
- public:
- MAMQuerySerializer();
- virtual ~MAMQuerySerializer();
+ class SWIFTEN_API MAMQuerySerializer : public GenericPayloadSerializer<MAMQuery> {
+ public:
+ MAMQuerySerializer();
+ virtual ~MAMQuerySerializer();
- virtual std::string serializePayload(boost::shared_ptr<MAMQuery>) const SWIFTEN_OVERRIDE;
- };
+ virtual std::string serializePayload(boost::shared_ptr<MAMQuery>) const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.cpp
index 4406e71..4bf25c6 100644
--- a/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.cpp
@@ -23,19 +23,19 @@ MAMResultSerializer::~MAMResultSerializer() {
}
std::string MAMResultSerializer::serializePayload(boost::shared_ptr<MAMResult> payload) const {
- if (!payload) {
- return "";
- }
+ if (!payload) {
+ return "";
+ }
- XMLElement element("result", "urn:xmpp:mam:0");
+ XMLElement element("result", "urn:xmpp:mam:0");
- element.setAttribute("id", payload->getID());
+ element.setAttribute("id", payload->getID());
- if (payload->getQueryID()) {
- element.setAttribute("queryid", *payload->getQueryID());
- }
+ if (payload->getQueryID()) {
+ element.setAttribute("queryid", *payload->getQueryID());
+ }
- element.addNode(boost::make_shared<XMLRawTextNode>(ForwardedSerializer(serializers_).serialize(payload->getPayload())));
+ element.addNode(boost::make_shared<XMLRawTextNode>(ForwardedSerializer(serializers_).serialize(payload->getPayload())));
- return element.serialize();
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h b/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h
index 3338080..4d8168c 100644
--- a/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h
@@ -14,16 +14,16 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API MAMResultSerializer : public GenericPayloadSerializer<MAMResult> {
- public:
- MAMResultSerializer(PayloadSerializerCollection* serializers);
- virtual ~MAMResultSerializer();
+ class SWIFTEN_API MAMResultSerializer : public GenericPayloadSerializer<MAMResult> {
+ public:
+ MAMResultSerializer(PayloadSerializerCollection* serializers);
+ virtual ~MAMResultSerializer();
- virtual std::string serializePayload(boost::shared_ptr<MAMResult>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<MAMResult>) const SWIFTEN_OVERRIDE;
- private:
- PayloadSerializerCollection* serializers_;
- };
+ private:
+ PayloadSerializerCollection* serializers_;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp
index 9f79c3e..5bd4b01 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp
@@ -22,11 +22,11 @@ MUCAdminPayloadSerializer::MUCAdminPayloadSerializer() : GenericPayloadSerialize
}
std::string MUCAdminPayloadSerializer::serializePayload(boost::shared_ptr<MUCAdminPayload> payload) const {
- XMLElement mucElement("query", "http://jabber.org/protocol/muc#admin");
- foreach (const MUCItem& item, payload->getItems()) {
- mucElement.addNode(MUCItemSerializer::itemToElement(item));
- }
- return mucElement.serialize();
+ XMLElement mucElement("query", "http://jabber.org/protocol/muc#admin");
+ foreach (const MUCItem& item, payload->getItems()) {
+ mucElement.addNode(MUCItemSerializer::itemToElement(item));
+ }
+ return mucElement.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h
index 3f763ae..b1e1ed1 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h
@@ -11,13 +11,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API MUCAdminPayloadSerializer : public GenericPayloadSerializer<MUCAdminPayload> {
- public:
- MUCAdminPayloadSerializer();
- std::string affiliationToString(MUCOccupant::Affiliation affiliation) const;
- std::string roleToString(MUCOccupant::Role role) const;
+ class SWIFTEN_API MUCAdminPayloadSerializer : public GenericPayloadSerializer<MUCAdminPayload> {
+ public:
+ MUCAdminPayloadSerializer();
+ std::string affiliationToString(MUCOccupant::Affiliation affiliation) const;
+ std::string roleToString(MUCOccupant::Role role) const;
- virtual std::string serializePayload(boost::shared_ptr<MUCAdminPayload> version) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<MUCAdminPayload> version) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp
index f6d8c8f..86d684e 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp
@@ -19,16 +19,16 @@ MUCDestroyPayloadSerializer::MUCDestroyPayloadSerializer() : GenericPayloadSeria
}
std::string MUCDestroyPayloadSerializer::serializePayload(boost::shared_ptr<MUCDestroyPayload> payload) const {
- XMLElement mucElement("destroy", "");
- if (!payload->getReason().empty()) {
- XMLElement::ref reason = boost::make_shared<XMLElement>("reason", "");
- reason->addNode(boost::make_shared<XMLTextNode>(payload->getReason()));
- mucElement.addNode(reason);
- }
- if (payload->getNewVenue().isValid()) {
- mucElement.setAttribute("jid", payload->getNewVenue().toString());
- }
- return mucElement.serialize();
+ XMLElement mucElement("destroy", "");
+ if (!payload->getReason().empty()) {
+ XMLElement::ref reason = boost::make_shared<XMLElement>("reason", "");
+ reason->addNode(boost::make_shared<XMLTextNode>(payload->getReason()));
+ mucElement.addNode(reason);
+ }
+ if (payload->getNewVenue().isValid()) {
+ mucElement.setAttribute("jid", payload->getNewVenue().toString());
+ }
+ return mucElement.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.h
index 75804ce..c6175fb 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.h
@@ -11,11 +11,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class SWIFTEN_API MUCDestroyPayloadSerializer : public GenericPayloadSerializer<MUCDestroyPayload> {
- public:
- MUCDestroyPayloadSerializer();
- virtual std::string serializePayload(boost::shared_ptr<MUCDestroyPayload> version) const;
- };
+ class PayloadSerializerCollection;
+ class SWIFTEN_API MUCDestroyPayloadSerializer : public GenericPayloadSerializer<MUCDestroyPayload> {
+ public:
+ MUCDestroyPayloadSerializer();
+ virtual std::string serializePayload(boost::shared_ptr<MUCDestroyPayload> version) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp
index ace52d5..4695f63 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp
@@ -20,26 +20,26 @@ MUCInvitationPayloadSerializer::MUCInvitationPayloadSerializer() : GenericPayloa
}
std::string MUCInvitationPayloadSerializer::serializePayload(boost::shared_ptr<MUCInvitationPayload> payload) const {
- XMLElement mucElement("x", "jabber:x:conference");
- if (payload->getIsContinuation()) {
- mucElement.setAttribute("continue", "true");
- }
- if (payload->getJID().isValid()) {
- mucElement.setAttribute("jid", payload->getJID().toString());
- }
- if (!payload->getPassword().empty()) {
- mucElement.setAttribute("password", payload->getPassword());
- }
- if (!payload->getReason().empty()) {
- mucElement.setAttribute("reason", payload->getReason());
- }
- if (!payload->getThread().empty()) {
- mucElement.setAttribute("thread", payload->getThread());
- }
- if (payload->getIsImpromptu()) {
- mucElement.addNode(boost::make_shared<XMLElement>("impromptu", "http://swift.im/impromptu"));
- }
- return mucElement.serialize();
+ XMLElement mucElement("x", "jabber:x:conference");
+ if (payload->getIsContinuation()) {
+ mucElement.setAttribute("continue", "true");
+ }
+ if (payload->getJID().isValid()) {
+ mucElement.setAttribute("jid", payload->getJID().toString());
+ }
+ if (!payload->getPassword().empty()) {
+ mucElement.setAttribute("password", payload->getPassword());
+ }
+ if (!payload->getReason().empty()) {
+ mucElement.setAttribute("reason", payload->getReason());
+ }
+ if (!payload->getThread().empty()) {
+ mucElement.setAttribute("thread", payload->getThread());
+ }
+ if (payload->getIsImpromptu()) {
+ mucElement.addNode(boost::make_shared<XMLElement>("impromptu", "http://swift.im/impromptu"));
+ }
+ return mucElement.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h
index 6872520..a2d27b0 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h
@@ -11,11 +11,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API MUCInvitationPayloadSerializer : public GenericPayloadSerializer<MUCInvitationPayload> {
- public:
- MUCInvitationPayloadSerializer();
+ class SWIFTEN_API MUCInvitationPayloadSerializer : public GenericPayloadSerializer<MUCInvitationPayload> {
+ public:
+ MUCInvitationPayloadSerializer();
- virtual std::string serializePayload(boost::shared_ptr<MUCInvitationPayload> version) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<MUCInvitationPayload> version) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h
index 7906888..016caf4 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h
@@ -14,57 +14,57 @@
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
- class MUCItemSerializer {
- public:
- static std::string affiliationToString(MUCOccupant::Affiliation affiliation) {
- std::string result;
- switch (affiliation) {
- case MUCOccupant::Owner: result = "owner"; break;
- case MUCOccupant::Admin: result = "admin"; break;
- case MUCOccupant::Member: result = "member"; break;
- case MUCOccupant::Outcast: result = "outcast"; break;
- case MUCOccupant::NoAffiliation: result = "none"; break;
- }
- return result;
- }
+ class MUCItemSerializer {
+ public:
+ static std::string affiliationToString(MUCOccupant::Affiliation affiliation) {
+ std::string result;
+ switch (affiliation) {
+ case MUCOccupant::Owner: result = "owner"; break;
+ case MUCOccupant::Admin: result = "admin"; break;
+ case MUCOccupant::Member: result = "member"; break;
+ case MUCOccupant::Outcast: result = "outcast"; break;
+ case MUCOccupant::NoAffiliation: result = "none"; break;
+ }
+ return result;
+ }
- static std::string roleToString(MUCOccupant::Role role) {
- std::string result;
- switch (role) {
- case MUCOccupant::Moderator: result = "moderator"; break;
- case MUCOccupant::NoRole: result = "none"; break;
- case MUCOccupant::Participant: result = "participant"; break;
- case MUCOccupant::Visitor: result = "visitor"; break;
- }
- return result;
+ static std::string roleToString(MUCOccupant::Role role) {
+ std::string result;
+ switch (role) {
+ case MUCOccupant::Moderator: result = "moderator"; break;
+ case MUCOccupant::NoRole: result = "none"; break;
+ case MUCOccupant::Participant: result = "participant"; break;
+ case MUCOccupant::Visitor: result = "visitor"; break;
+ }
+ return result;
- }
+ }
- static boost::shared_ptr<XMLElement> itemToElement(const MUCItem& item) {
- boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
- if (item.affiliation) {
- itemElement->setAttribute("affiliation", affiliationToString(item.affiliation.get()));
- }
- if (item.role) {
- itemElement->setAttribute("role", roleToString(item.role.get()));
- }
- if (item.realJID) {
- itemElement->setAttribute("jid", item.realJID.get());
- }
- if (item.nick) {
- itemElement->setAttribute("nick", item.nick.get());
- }
- if (item.actor) {
- boost::shared_ptr<XMLElement> actorElement(new XMLElement("actor"));
- actorElement->setAttribute("jid", item.actor->toString());
- itemElement->addNode(actorElement);
- }
- if (item.reason) {
- boost::shared_ptr<XMLElement> reasonElement(new XMLElement("reason"));
- reasonElement->addNode(boost::make_shared<XMLTextNode>(*item.reason));
- itemElement->addNode(reasonElement);
- }
- return itemElement;
- }
- };
+ static boost::shared_ptr<XMLElement> itemToElement(const MUCItem& item) {
+ boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
+ if (item.affiliation) {
+ itemElement->setAttribute("affiliation", affiliationToString(item.affiliation.get()));
+ }
+ if (item.role) {
+ itemElement->setAttribute("role", roleToString(item.role.get()));
+ }
+ if (item.realJID) {
+ itemElement->setAttribute("jid", item.realJID.get());
+ }
+ if (item.nick) {
+ itemElement->setAttribute("nick", item.nick.get());
+ }
+ if (item.actor) {
+ boost::shared_ptr<XMLElement> actorElement(new XMLElement("actor"));
+ actorElement->setAttribute("jid", item.actor->toString());
+ itemElement->addNode(actorElement);
+ }
+ if (item.reason) {
+ boost::shared_ptr<XMLElement> reasonElement(new XMLElement("reason"));
+ reasonElement->addNode(boost::make_shared<XMLTextNode>(*item.reason));
+ itemElement->addNode(reasonElement);
+ }
+ return itemElement;
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp
index 7597d8f..348f9f5 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp
@@ -18,15 +18,15 @@ MUCOwnerPayloadSerializer::MUCOwnerPayloadSerializer(PayloadSerializerCollection
}
std::string MUCOwnerPayloadSerializer::serializePayload(boost::shared_ptr<MUCOwnerPayload> mucOwner) const {
- XMLElement mucElement("query", "http://jabber.org/protocol/muc#owner");
- boost::shared_ptr<Payload> payload = mucOwner->getPayload();
- if (payload) {
- PayloadSerializer* serializer = serializers->getPayloadSerializer(payload);
- if (serializer) {
- mucElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(payload)));
- }
- }
- return mucElement.serialize();
+ XMLElement mucElement("query", "http://jabber.org/protocol/muc#owner");
+ boost::shared_ptr<Payload> payload = mucOwner->getPayload();
+ if (payload) {
+ PayloadSerializer* serializer = serializers->getPayloadSerializer(payload);
+ if (serializer) {
+ mucElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(payload)));
+ }
+ }
+ return mucElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h
index ffce898..bbe919a 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h
@@ -11,13 +11,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class SWIFTEN_API MUCOwnerPayloadSerializer : public GenericPayloadSerializer<MUCOwnerPayload> {
- public:
- MUCOwnerPayloadSerializer(PayloadSerializerCollection* serializers);
- virtual std::string serializePayload(boost::shared_ptr<MUCOwnerPayload> version) const;
- private:
- PayloadSerializerCollection* serializers;
- };
+ class PayloadSerializerCollection;
+ class SWIFTEN_API MUCOwnerPayloadSerializer : public GenericPayloadSerializer<MUCOwnerPayload> {
+ public:
+ MUCOwnerPayloadSerializer(PayloadSerializerCollection* serializers);
+ virtual std::string serializePayload(boost::shared_ptr<MUCOwnerPayload> version) const;
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp
index 30421dd..9af2f15 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp
@@ -20,38 +20,38 @@ MUCPayloadSerializer::MUCPayloadSerializer() : GenericPayloadSerializer<MUCPaylo
}
std::string MUCPayloadSerializer::serializePayload(boost::shared_ptr<MUCPayload> muc) const {
- XMLElement mucElement("x", "http://jabber.org/protocol/muc");
- boost::shared_ptr<XMLElement> historyElement(new XMLElement("history"));
- bool history = false;
- if (muc->getMaxChars() >= 0) {
- historyElement->setAttribute("maxchars", boost::lexical_cast<std::string>(muc->getMaxChars()));
- history = true;
- }
- if (muc->getMaxStanzas() >= 0) {
- historyElement->setAttribute("maxstanzas", boost::lexical_cast<std::string>(muc->getMaxStanzas()));
- history = true;
- }
- if (muc->getSeconds() >= 0) {
- historyElement->setAttribute("seconds", boost::lexical_cast<std::string>(muc->getSeconds()));
- history = true;
- }
- if (muc->getSince() != boost::posix_time::not_a_date_time) {
- std::string sinceString = std::string(boost::posix_time::to_iso_extended_string(muc->getSince()));
- String::replaceAll(sinceString, ',', ".");
- sinceString += "Z";
- historyElement->setAttribute("since", sinceString);
- history = true;
- }
- if (muc->getPassword()) {
- std::string password = *muc->getPassword();
- boost::shared_ptr<XMLElement> passwordElement(new XMLElement("password"));
- passwordElement->addNode(boost::make_shared<XMLTextNode>(password));
- mucElement.addNode(passwordElement);
- }
- if (history) {
- mucElement.addNode(historyElement);
- }
- return mucElement.serialize();
+ XMLElement mucElement("x", "http://jabber.org/protocol/muc");
+ boost::shared_ptr<XMLElement> historyElement(new XMLElement("history"));
+ bool history = false;
+ if (muc->getMaxChars() >= 0) {
+ historyElement->setAttribute("maxchars", boost::lexical_cast<std::string>(muc->getMaxChars()));
+ history = true;
+ }
+ if (muc->getMaxStanzas() >= 0) {
+ historyElement->setAttribute("maxstanzas", boost::lexical_cast<std::string>(muc->getMaxStanzas()));
+ history = true;
+ }
+ if (muc->getSeconds() >= 0) {
+ historyElement->setAttribute("seconds", boost::lexical_cast<std::string>(muc->getSeconds()));
+ history = true;
+ }
+ if (muc->getSince() != boost::posix_time::not_a_date_time) {
+ std::string sinceString = std::string(boost::posix_time::to_iso_extended_string(muc->getSince()));
+ String::replaceAll(sinceString, ',', ".");
+ sinceString += "Z";
+ historyElement->setAttribute("since", sinceString);
+ history = true;
+ }
+ if (muc->getPassword()) {
+ std::string password = *muc->getPassword();
+ boost::shared_ptr<XMLElement> passwordElement(new XMLElement("password"));
+ passwordElement->addNode(boost::make_shared<XMLTextNode>(password));
+ mucElement.addNode(passwordElement);
+ }
+ if (history) {
+ mucElement.addNode(historyElement);
+ }
+ return mucElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h
index 84f38d2..fa3a11c 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API MUCPayloadSerializer : public GenericPayloadSerializer<MUCPayload> {
- public:
- MUCPayloadSerializer();
- virtual std::string serializePayload(boost::shared_ptr<MUCPayload> version) const;
- };
+ class SWIFTEN_API MUCPayloadSerializer : public GenericPayloadSerializer<MUCPayload> {
+ public:
+ MUCPayloadSerializer();
+ virtual std::string serializePayload(boost::shared_ptr<MUCPayload> version) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp
index 0e560a2..d0c3b2b 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp
@@ -24,47 +24,47 @@ MUCUserPayloadSerializer::MUCUserPayloadSerializer(PayloadSerializerCollection*
}
std::string MUCUserPayloadSerializer::serializePayload(boost::shared_ptr<MUCUserPayload> payload) const {
- XMLElement mucElement("x", "http://jabber.org/protocol/muc#user");
- foreach (const MUCUserPayload::StatusCode statusCode, payload->getStatusCodes()) {
- boost::shared_ptr<XMLElement> statusElement(new XMLElement("status"));
- std::ostringstream code;
- code << statusCode.code;
- statusElement->setAttribute("code", code.str());
- mucElement.addNode(statusElement);
- }
- foreach (const MUCItem& item, payload->getItems()) {
- mucElement.addNode(MUCItemSerializer::itemToElement(item));
- }
+ XMLElement mucElement("x", "http://jabber.org/protocol/muc#user");
+ foreach (const MUCUserPayload::StatusCode statusCode, payload->getStatusCodes()) {
+ boost::shared_ptr<XMLElement> statusElement(new XMLElement("status"));
+ std::ostringstream code;
+ code << statusCode.code;
+ statusElement->setAttribute("code", code.str());
+ mucElement.addNode(statusElement);
+ }
+ foreach (const MUCItem& item, payload->getItems()) {
+ mucElement.addNode(MUCItemSerializer::itemToElement(item));
+ }
- if (payload->getPassword()) {
- boost::shared_ptr<XMLElement> passwordElement = boost::make_shared<XMLElement>("password");
- passwordElement->addNode(boost::make_shared<XMLTextNode>(*payload->getPassword()));
- }
+ if (payload->getPassword()) {
+ boost::shared_ptr<XMLElement> passwordElement = boost::make_shared<XMLElement>("password");
+ passwordElement->addNode(boost::make_shared<XMLTextNode>(*payload->getPassword()));
+ }
- if (payload->getInvite()) {
- MUCUserPayload::Invite invite = *payload->getInvite();
- boost::shared_ptr<XMLElement> inviteElement = boost::make_shared<XMLElement>("invite");
- if (invite.to.isValid()) {
- inviteElement->setAttribute("to", invite.to.toString());
- }
- if (invite.from.isValid()) {
- inviteElement->setAttribute("from", invite.from.toString());
- }
- if (!invite.reason.empty()) {
- boost::shared_ptr<XMLElement> reasonElement = boost::make_shared<XMLElement>("reason");
- reasonElement->addNode(boost::make_shared<XMLTextNode>(invite.reason));
- }
- mucElement.addNode(inviteElement);
- }
+ if (payload->getInvite()) {
+ MUCUserPayload::Invite invite = *payload->getInvite();
+ boost::shared_ptr<XMLElement> inviteElement = boost::make_shared<XMLElement>("invite");
+ if (invite.to.isValid()) {
+ inviteElement->setAttribute("to", invite.to.toString());
+ }
+ if (invite.from.isValid()) {
+ inviteElement->setAttribute("from", invite.from.toString());
+ }
+ if (!invite.reason.empty()) {
+ boost::shared_ptr<XMLElement> reasonElement = boost::make_shared<XMLElement>("reason");
+ reasonElement->addNode(boost::make_shared<XMLTextNode>(invite.reason));
+ }
+ mucElement.addNode(inviteElement);
+ }
- boost::shared_ptr<Payload> childPayload = payload->getPayload();
- if (childPayload) {
- PayloadSerializer* serializer = serializers->getPayloadSerializer(childPayload);
- if (serializer) {
- mucElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(childPayload)));
- }
- }
- return mucElement.serialize();
+ boost::shared_ptr<Payload> childPayload = payload->getPayload();
+ if (childPayload) {
+ PayloadSerializer* serializer = serializers->getPayloadSerializer(childPayload);
+ if (serializer) {
+ mucElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(childPayload)));
+ }
+ }
+ return mucElement.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h
index b1ace20..91b2ae6 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h
@@ -11,14 +11,14 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class SWIFTEN_API MUCUserPayloadSerializer : public GenericPayloadSerializer<MUCUserPayload> {
- public:
- MUCUserPayloadSerializer(PayloadSerializerCollection* serializers);
+ class PayloadSerializerCollection;
+ class SWIFTEN_API MUCUserPayloadSerializer : public GenericPayloadSerializer<MUCUserPayload> {
+ public:
+ MUCUserPayloadSerializer(PayloadSerializerCollection* serializers);
- virtual std::string serializePayload(boost::shared_ptr<MUCUserPayload> version) const;
- private:
- PayloadSerializerCollection* serializers;
- };
+ virtual std::string serializePayload(boost::shared_ptr<MUCUserPayload> version) const;
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
index 303ef9a..3b927f4 100644
--- a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
@@ -18,9 +18,9 @@ NicknameSerializer::NicknameSerializer() : GenericPayloadSerializer<Nickname>()
}
std::string NicknameSerializer::serializePayload(boost::shared_ptr<Nickname> nick) const {
- XMLElement nickElement("nick", "http://jabber.org/protocol/nick");
- nickElement.addNode(boost::make_shared<XMLTextNode>(nick->getNickname()));
- return nickElement.serialize();
+ XMLElement nickElement("nick", "http://jabber.org/protocol/nick");
+ nickElement.addNode(boost::make_shared<XMLTextNode>(nick->getNickname()));
+ return nickElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h
index e694624..d1b6e81 100644
--- a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h
@@ -11,12 +11,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API NicknameSerializer : public GenericPayloadSerializer<Nickname> {
- public:
- NicknameSerializer();
+ class SWIFTEN_API NicknameSerializer : public GenericPayloadSerializer<Nickname> {
+ public:
+ NicknameSerializer();
- virtual std::string serializePayload(boost::shared_ptr<Nickname>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<Nickname>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h
index 406f527..d7f0957 100644
--- a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h
@@ -13,12 +13,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API PrioritySerializer : public GenericPayloadSerializer<Priority> {
- public:
- PrioritySerializer() : GenericPayloadSerializer<Priority>() {}
+ class SWIFTEN_API PrioritySerializer : public GenericPayloadSerializer<Priority> {
+ public:
+ PrioritySerializer() : GenericPayloadSerializer<Priority>() {}
- virtual std::string serializePayload(boost::shared_ptr<Priority> priority) const {
- return "<priority>" + boost::lexical_cast<std::string>(priority->getPriority()) + "</priority>";
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<Priority> priority) const {
+ return "<priority>" + boost::lexical_cast<std::string>(priority->getPriority()) + "</priority>";
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
index bc916aa..2d03e1b 100644
--- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
@@ -20,16 +20,16 @@ namespace Swift {
PrivateStorageSerializer::PrivateStorageSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
}
-std::string PrivateStorageSerializer::serializePayload(boost::shared_ptr<PrivateStorage> storage) const {
- XMLElement storageElement("query", "jabber:iq:private");
- boost::shared_ptr<Payload> payload = storage->getPayload();
- if (payload) {
- PayloadSerializer* serializer = serializers->getPayloadSerializer(payload);
- if (serializer) {
- storageElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(payload)));
- }
- }
- return storageElement.serialize();
+std::string PrivateStorageSerializer::serializePayload(boost::shared_ptr<PrivateStorage> storage) const {
+ XMLElement storageElement("query", "jabber:iq:private");
+ boost::shared_ptr<Payload> payload = storage->getPayload();
+ if (payload) {
+ PayloadSerializer* serializer = serializers->getPayloadSerializer(payload);
+ if (serializer) {
+ storageElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(payload)));
+ }
+ }
+ return storageElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h
index 0a88193..a014e52 100644
--- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h
@@ -11,15 +11,15 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PrivateStorageSerializer : public GenericPayloadSerializer<PrivateStorage> {
- public:
- PrivateStorageSerializer(PayloadSerializerCollection* serializers);
+ class SWIFTEN_API PrivateStorageSerializer : public GenericPayloadSerializer<PrivateStorage> {
+ public:
+ PrivateStorageSerializer(PayloadSerializerCollection* serializers);
- virtual std::string serializePayload(boost::shared_ptr<PrivateStorage>) const;
+ virtual std::string serializePayload(boost::shared_ptr<PrivateStorage>) const;
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp
index 0e02e2b..8e58ff5 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp
@@ -22,24 +22,24 @@ PubSubAffiliationSerializer::~PubSubAffiliationSerializer() {
}
std::string PubSubAffiliationSerializer::serializePayload(boost::shared_ptr<PubSubAffiliation> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("affiliation", "http://jabber.org/protocol/pubsub");
- element.setAttribute("node", payload->getNode());
- element.setAttribute("affiliation", serializeType(payload->getType()));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliation", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ element.setAttribute("affiliation", serializeType(payload->getType()));
+ return element.serialize();
}
std::string PubSubAffiliationSerializer::serializeType(PubSubAffiliation::Type value) {
- switch (value) {
- case PubSubAffiliation::None: return "none";
- case PubSubAffiliation::Member: return "member";
- case PubSubAffiliation::Outcast: return "outcast";
- case PubSubAffiliation::Owner: return "owner";
- case PubSubAffiliation::Publisher: return "publisher";
- case PubSubAffiliation::PublishOnly: return "publish-only";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubAffiliation::None: return "none";
+ case PubSubAffiliation::Member: return "member";
+ case PubSubAffiliation::Outcast: return "outcast";
+ case PubSubAffiliation::Owner: return "owner";
+ case PubSubAffiliation::Publisher: return "publisher";
+ case PubSubAffiliation::PublishOnly: return "publish-only";
+ }
+ assert(false);
+ return "";
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h
index dfa235f..d451745 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubAffiliationSerializer : public GenericPayloadSerializer<PubSubAffiliation> {
- public:
- PubSubAffiliationSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubAffiliationSerializer();
+ class SWIFTEN_API PubSubAffiliationSerializer : public GenericPayloadSerializer<PubSubAffiliation> {
+ public:
+ PubSubAffiliationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubAffiliationSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubAffiliation>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubAffiliation>) const SWIFTEN_OVERRIDE;
- private:
- static std::string serializeType(PubSubAffiliation::Type);
+ private:
+ static std::string serializeType(PubSubAffiliation::Type);
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp
index 4003b6c..eba96aa 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp
@@ -24,17 +24,17 @@ PubSubAffiliationsSerializer::~PubSubAffiliationsSerializer() {
}
std::string PubSubAffiliationsSerializer::serializePayload(boost::shared_ptr<PubSubAffiliations> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("affiliations", "http://jabber.org/protocol/pubsub");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- foreach(boost::shared_ptr<PubSubAffiliation> item, payload->getAffiliations()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubAffiliationSerializer(serializers).serialize(item)));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliations", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ foreach(boost::shared_ptr<PubSubAffiliation> item, payload->getAffiliations()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubAffiliationSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h
index 25e12b8..211d957 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubAffiliationsSerializer : public GenericPayloadSerializer<PubSubAffiliations> {
- public:
- PubSubAffiliationsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubAffiliationsSerializer();
+ class SWIFTEN_API PubSubAffiliationsSerializer : public GenericPayloadSerializer<PubSubAffiliations> {
+ public:
+ PubSubAffiliationsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubAffiliationsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubAffiliations>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubAffiliations>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp
index 887e6e9..1853c1c 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp
@@ -23,12 +23,12 @@ PubSubConfigureSerializer::~PubSubConfigureSerializer() {
}
std::string PubSubConfigureSerializer::serializePayload(boost::shared_ptr<PubSubConfigure> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("configure", "http://jabber.org/protocol/pubsub");
- element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("configure", "http://jabber.org/protocol/pubsub");
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h
index 9fe3680..3d800d8 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubConfigureSerializer : public GenericPayloadSerializer<PubSubConfigure> {
- public:
- PubSubConfigureSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubConfigureSerializer();
+ class SWIFTEN_API PubSubConfigureSerializer : public GenericPayloadSerializer<PubSubConfigure> {
+ public:
+ PubSubConfigureSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubConfigureSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubConfigure>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubConfigure>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp
index 0f9094d..8b38fc1 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp
@@ -22,12 +22,12 @@ PubSubCreateSerializer::~PubSubCreateSerializer() {
}
std::string PubSubCreateSerializer::serializePayload(boost::shared_ptr<PubSubCreate> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("create", "http://jabber.org/protocol/pubsub");
- element.setAttribute("node", payload->getNode());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("create", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h
index c9bb95a..67b19bf 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubCreateSerializer : public GenericPayloadSerializer<PubSubCreate> {
- public:
- PubSubCreateSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubCreateSerializer();
+ class SWIFTEN_API PubSubCreateSerializer : public GenericPayloadSerializer<PubSubCreate> {
+ public:
+ PubSubCreateSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubCreateSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubCreate>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubCreate>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp
index c101623..aba1cae 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp
@@ -22,23 +22,23 @@ PubSubDefaultSerializer::~PubSubDefaultSerializer() {
}
std::string PubSubDefaultSerializer::serializePayload(boost::shared_ptr<PubSubDefault> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("default", "http://jabber.org/protocol/pubsub");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- element.setAttribute("type", serializeType(payload->getType()));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("default", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.setAttribute("type", serializeType(payload->getType()));
+ return element.serialize();
}
std::string PubSubDefaultSerializer::serializeType(PubSubDefault::Type value) {
- switch (value) {
- case PubSubDefault::None: return "none";
- case PubSubDefault::Collection: return "collection";
- case PubSubDefault::Leaf: return "leaf";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubDefault::None: return "none";
+ case PubSubDefault::Collection: return "collection";
+ case PubSubDefault::Leaf: return "leaf";
+ }
+ assert(false);
+ return "";
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h
index 344a8c7..5dc774f 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubDefaultSerializer : public GenericPayloadSerializer<PubSubDefault> {
- public:
- PubSubDefaultSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubDefaultSerializer();
+ class SWIFTEN_API PubSubDefaultSerializer : public GenericPayloadSerializer<PubSubDefault> {
+ public:
+ PubSubDefaultSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubDefaultSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubDefault>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubDefault>) const SWIFTEN_OVERRIDE;
- private:
- static std::string serializeType(PubSubDefault::Type);
+ private:
+ static std::string serializeType(PubSubDefault::Type);
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp
index 8235746..d14db49 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp
@@ -18,94 +18,94 @@ PubSubErrorSerializer::~PubSubErrorSerializer() {
}
std::string PubSubErrorSerializer::serializePayload(boost::shared_ptr<PubSubError> payload) const {
- if (payload->getType() == PubSubError::UnknownType) {
- return "";
- }
- XMLElement element(serializeType(payload->getType()), "http://jabber.org/protocol/pubsub#errors");
- if (payload->getType() == PubSubError::Unsupported) {
- if (payload->getUnsupportedFeatureType() != PubSubError::UnknownUnsupportedFeatureType) {
- element.setAttribute("feature", serializeUnsupportedFeatureType(payload->getUnsupportedFeatureType()));
- }
- }
- return element.serialize();
+ if (payload->getType() == PubSubError::UnknownType) {
+ return "";
+ }
+ XMLElement element(serializeType(payload->getType()), "http://jabber.org/protocol/pubsub#errors");
+ if (payload->getType() == PubSubError::Unsupported) {
+ if (payload->getUnsupportedFeatureType() != PubSubError::UnknownUnsupportedFeatureType) {
+ element.setAttribute("feature", serializeUnsupportedFeatureType(payload->getUnsupportedFeatureType()));
+ }
+ }
+ return element.serialize();
}
std::string PubSubErrorSerializer::serializeType(PubSubError::Type value) {
- switch (value) {
- case PubSubError::UnknownType: assert(false); return "";
- case PubSubError::ClosedNode: return "closed-node";
- case PubSubError::ConfigurationRequired: return "configuration-required";
- case PubSubError::InvalidJID: return "invalid-jid";
- case PubSubError::InvalidOptions: return "invalid-options";
- case PubSubError::InvalidPayload: return "invalid-payload";
- case PubSubError::InvalidSubscriptionID: return "invalid-subid";
- case PubSubError::ItemForbidden: return "item-forbidden";
- case PubSubError::ItemRequired: return "item-required";
- case PubSubError::JIDRequired: return "jid-required";
- case PubSubError::MaximumItemsExceeded: return "max-items-exceeded";
- case PubSubError::MaximumNodesExceeded: return "max-nodes-exceeded";
- case PubSubError::NodeIDRequired: return "nodeid-required";
- case PubSubError::NotInRosterGroup: return "not-in-roster-group";
- case PubSubError::NotSubscribed: return "not-subscribed";
- case PubSubError::PayloadTooBig: return "payload-too-big";
- case PubSubError::PayloadRequired: return "payload-required";
- case PubSubError::PendingSubscription: return "pending-subscription";
- case PubSubError::PresenceSubscriptionRequired: return "presence-subscription-required";
- case PubSubError::SubscriptionIDRequired: return "subid-required";
- case PubSubError::TooManySubscriptions: return "too-many-subscriptions";
- case PubSubError::Unsupported: return "unsupported";
- case PubSubError::UnsupportedAccessModel: return "unsupported-access-model";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubError::UnknownType: assert(false); return "";
+ case PubSubError::ClosedNode: return "closed-node";
+ case PubSubError::ConfigurationRequired: return "configuration-required";
+ case PubSubError::InvalidJID: return "invalid-jid";
+ case PubSubError::InvalidOptions: return "invalid-options";
+ case PubSubError::InvalidPayload: return "invalid-payload";
+ case PubSubError::InvalidSubscriptionID: return "invalid-subid";
+ case PubSubError::ItemForbidden: return "item-forbidden";
+ case PubSubError::ItemRequired: return "item-required";
+ case PubSubError::JIDRequired: return "jid-required";
+ case PubSubError::MaximumItemsExceeded: return "max-items-exceeded";
+ case PubSubError::MaximumNodesExceeded: return "max-nodes-exceeded";
+ case PubSubError::NodeIDRequired: return "nodeid-required";
+ case PubSubError::NotInRosterGroup: return "not-in-roster-group";
+ case PubSubError::NotSubscribed: return "not-subscribed";
+ case PubSubError::PayloadTooBig: return "payload-too-big";
+ case PubSubError::PayloadRequired: return "payload-required";
+ case PubSubError::PendingSubscription: return "pending-subscription";
+ case PubSubError::PresenceSubscriptionRequired: return "presence-subscription-required";
+ case PubSubError::SubscriptionIDRequired: return "subid-required";
+ case PubSubError::TooManySubscriptions: return "too-many-subscriptions";
+ case PubSubError::Unsupported: return "unsupported";
+ case PubSubError::UnsupportedAccessModel: return "unsupported-access-model";
+ }
+ assert(false);
+ return "";
}
std::string PubSubErrorSerializer::serializeUnsupportedFeatureType(PubSubError::UnsupportedFeatureType value) {
- switch (value) {
- case PubSubError::UnknownUnsupportedFeatureType: assert(false); return "";
- case PubSubError::AccessAuthorize: return "access-authorize";
- case PubSubError::AccessOpen: return "access-open";
- case PubSubError::AccessPresence: return "access-presence";
- case PubSubError::AccessRoster: return "access-roster";
- case PubSubError::AccessWhitelist: return "access-whitelist";
- case PubSubError::AutoCreate: return "auto-create";
- case PubSubError::AutoSubscribe: return "auto-subscribe";
- case PubSubError::Collections: return "collections";
- case PubSubError::ConfigNode: return "config-node";
- case PubSubError::CreateAndConfigure: return "create-and-configure";
- case PubSubError::CreateNodes: return "create-nodes";
- case PubSubError::DeleteItems: return "delete-items";
- case PubSubError::DeleteNodes: return "delete-nodes";
- case PubSubError::FilteredNotifications: return "filtered-notifications";
- case PubSubError::GetPending: return "get-pending";
- case PubSubError::InstantNodes: return "instant-nodes";
- case PubSubError::ItemIDs: return "item-ids";
- case PubSubError::LastPublished: return "last-published";
- case PubSubError::LeasedSubscription: return "leased-subscription";
- case PubSubError::ManageSubscriptions: return "manage-subscriptions";
- case PubSubError::MemberAffiliation: return "member-affiliation";
- case PubSubError::MetaData: return "meta-data";
- case PubSubError::ModifyAffiliations: return "modify-affiliations";
- case PubSubError::MultiCollection: return "multi-collection";
- case PubSubError::MultiSubscribe: return "multi-subscribe";
- case PubSubError::OutcastAffiliation: return "outcast-affiliation";
- case PubSubError::PersistentItems: return "persistent-items";
- case PubSubError::PresenceNotifications: return "presence-notifications";
- case PubSubError::PresenceSubscribe: return "presence-subscribe";
- case PubSubError::Publish: return "publish";
- case PubSubError::PublishOptions: return "publish-options";
- case PubSubError::PublishOnlyAffiliation: return "publish-only-affiliation";
- case PubSubError::PublisherAffiliation: return "publisher-affiliation";
- case PubSubError::PurgeNodes: return "purge-nodes";
- case PubSubError::RetractItems: return "retract-items";
- case PubSubError::RetrieveAffiliations: return "retrieve-affiliations";
- case PubSubError::RetrieveDefault: return "retrieve-default";
- case PubSubError::RetrieveItems: return "retrieve-items";
- case PubSubError::RetrieveSubscriptions: return "retrieve-subscriptions";
- case PubSubError::Subscribe: return "subscribe";
- case PubSubError::SubscriptionOptions: return "subscription-options";
- case PubSubError::SubscriptionNotifications: return "subscription-notifications";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubError::UnknownUnsupportedFeatureType: assert(false); return "";
+ case PubSubError::AccessAuthorize: return "access-authorize";
+ case PubSubError::AccessOpen: return "access-open";
+ case PubSubError::AccessPresence: return "access-presence";
+ case PubSubError::AccessRoster: return "access-roster";
+ case PubSubError::AccessWhitelist: return "access-whitelist";
+ case PubSubError::AutoCreate: return "auto-create";
+ case PubSubError::AutoSubscribe: return "auto-subscribe";
+ case PubSubError::Collections: return "collections";
+ case PubSubError::ConfigNode: return "config-node";
+ case PubSubError::CreateAndConfigure: return "create-and-configure";
+ case PubSubError::CreateNodes: return "create-nodes";
+ case PubSubError::DeleteItems: return "delete-items";
+ case PubSubError::DeleteNodes: return "delete-nodes";
+ case PubSubError::FilteredNotifications: return "filtered-notifications";
+ case PubSubError::GetPending: return "get-pending";
+ case PubSubError::InstantNodes: return "instant-nodes";
+ case PubSubError::ItemIDs: return "item-ids";
+ case PubSubError::LastPublished: return "last-published";
+ case PubSubError::LeasedSubscription: return "leased-subscription";
+ case PubSubError::ManageSubscriptions: return "manage-subscriptions";
+ case PubSubError::MemberAffiliation: return "member-affiliation";
+ case PubSubError::MetaData: return "meta-data";
+ case PubSubError::ModifyAffiliations: return "modify-affiliations";
+ case PubSubError::MultiCollection: return "multi-collection";
+ case PubSubError::MultiSubscribe: return "multi-subscribe";
+ case PubSubError::OutcastAffiliation: return "outcast-affiliation";
+ case PubSubError::PersistentItems: return "persistent-items";
+ case PubSubError::PresenceNotifications: return "presence-notifications";
+ case PubSubError::PresenceSubscribe: return "presence-subscribe";
+ case PubSubError::Publish: return "publish";
+ case PubSubError::PublishOptions: return "publish-options";
+ case PubSubError::PublishOnlyAffiliation: return "publish-only-affiliation";
+ case PubSubError::PublisherAffiliation: return "publisher-affiliation";
+ case PubSubError::PurgeNodes: return "purge-nodes";
+ case PubSubError::RetractItems: return "retract-items";
+ case PubSubError::RetrieveAffiliations: return "retrieve-affiliations";
+ case PubSubError::RetrieveDefault: return "retrieve-default";
+ case PubSubError::RetrieveItems: return "retrieve-items";
+ case PubSubError::RetrieveSubscriptions: return "retrieve-subscriptions";
+ case PubSubError::Subscribe: return "subscribe";
+ case PubSubError::SubscriptionOptions: return "subscription-options";
+ case PubSubError::SubscriptionNotifications: return "subscription-notifications";
+ }
+ assert(false);
+ return "";
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h
index 068c89e..b6750e9 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h
@@ -12,17 +12,17 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubErrorSerializer : public GenericPayloadSerializer<PubSubError> {
- public:
- PubSubErrorSerializer();
- virtual ~PubSubErrorSerializer();
+ class SWIFTEN_API PubSubErrorSerializer : public GenericPayloadSerializer<PubSubError> {
+ public:
+ PubSubErrorSerializer();
+ virtual ~PubSubErrorSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubError>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubError>) const SWIFTEN_OVERRIDE;
- private:
- static std::string serializeType(PubSubError::Type);
- static std::string serializeUnsupportedFeatureType(PubSubError::UnsupportedFeatureType);
- };
+ private:
+ static std::string serializeType(PubSubError::Type);
+ static std::string serializeUnsupportedFeatureType(PubSubError::UnsupportedFeatureType);
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp
index 4537d8c..c855977 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp
@@ -22,12 +22,12 @@ PubSubEventAssociateSerializer::~PubSubEventAssociateSerializer() {
}
std::string PubSubEventAssociateSerializer::serializePayload(boost::shared_ptr<PubSubEventAssociate> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("associate", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("node", payload->getNode());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("associate", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h
index 4ca1b06..03025fb 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventAssociateSerializer : public GenericPayloadSerializer<PubSubEventAssociate> {
- public:
- PubSubEventAssociateSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventAssociateSerializer();
+ class SWIFTEN_API PubSubEventAssociateSerializer : public GenericPayloadSerializer<PubSubEventAssociate> {
+ public:
+ PubSubEventAssociateSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventAssociateSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventAssociate>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventAssociate>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp
index 96462d3..df255d2 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp
@@ -24,16 +24,16 @@ PubSubEventCollectionSerializer::~PubSubEventCollectionSerializer() {
}
std::string PubSubEventCollectionSerializer::serializePayload(boost::shared_ptr<PubSubEventCollection> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("collection", "http://jabber.org/protocol/pubsub#event");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventDisassociateSerializer(serializers).serialize(payload->getDisassociate())));
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventAssociateSerializer(serializers).serialize(payload->getAssociate())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("collection", "http://jabber.org/protocol/pubsub#event");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventDisassociateSerializer(serializers).serialize(payload->getDisassociate())));
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventAssociateSerializer(serializers).serialize(payload->getAssociate())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h
index 8e515a6..6e6817d 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventCollectionSerializer : public GenericPayloadSerializer<PubSubEventCollection> {
- public:
- PubSubEventCollectionSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventCollectionSerializer();
+ class SWIFTEN_API PubSubEventCollectionSerializer : public GenericPayloadSerializer<PubSubEventCollection> {
+ public:
+ PubSubEventCollectionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventCollectionSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventCollection>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventCollection>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp
index 68b498f..3e2d18b 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp
@@ -23,13 +23,13 @@ PubSubEventConfigurationSerializer::~PubSubEventConfigurationSerializer() {
}
std::string PubSubEventConfigurationSerializer::serializePayload(boost::shared_ptr<PubSubEventConfiguration> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("configuration", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("node", payload->getNode());
- element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("configuration", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h
index 872fbab..6309e04 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventConfigurationSerializer : public GenericPayloadSerializer<PubSubEventConfiguration> {
- public:
- PubSubEventConfigurationSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventConfigurationSerializer();
+ class SWIFTEN_API PubSubEventConfigurationSerializer : public GenericPayloadSerializer<PubSubEventConfiguration> {
+ public:
+ PubSubEventConfigurationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventConfigurationSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventConfiguration>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventConfiguration>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp
index 5d9a6b4..4dcd734 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp
@@ -23,13 +23,13 @@ PubSubEventDeleteSerializer::~PubSubEventDeleteSerializer() {
}
std::string PubSubEventDeleteSerializer::serializePayload(boost::shared_ptr<PubSubEventDelete> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("delete", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("node", payload->getNode());
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventRedirectSerializer(serializers).serialize(payload->getRedirects())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("delete", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventRedirectSerializer(serializers).serialize(payload->getRedirects())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h
index a4746fc..6d937aa 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventDeleteSerializer : public GenericPayloadSerializer<PubSubEventDelete> {
- public:
- PubSubEventDeleteSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventDeleteSerializer();
+ class SWIFTEN_API PubSubEventDeleteSerializer : public GenericPayloadSerializer<PubSubEventDelete> {
+ public:
+ PubSubEventDeleteSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventDeleteSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventDelete>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventDelete>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp
index b3dc1da..0818dee 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp
@@ -22,12 +22,12 @@ PubSubEventDisassociateSerializer::~PubSubEventDisassociateSerializer() {
}
std::string PubSubEventDisassociateSerializer::serializePayload(boost::shared_ptr<PubSubEventDisassociate> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("disassociate", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("node", payload->getNode());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("disassociate", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h
index ddebdd2..9313ab2 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventDisassociateSerializer : public GenericPayloadSerializer<PubSubEventDisassociate> {
- public:
- PubSubEventDisassociateSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventDisassociateSerializer();
+ class SWIFTEN_API PubSubEventDisassociateSerializer : public GenericPayloadSerializer<PubSubEventDisassociate> {
+ public:
+ PubSubEventDisassociateSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventDisassociateSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventDisassociate>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventDisassociate>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp
index 01a58e3..4bc8815 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp
@@ -23,23 +23,23 @@ PubSubEventItemSerializer::~PubSubEventItemSerializer() {
}
std::string PubSubEventItemSerializer::serializePayload(boost::shared_ptr<PubSubEventItem> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("item", "http://jabber.org/protocol/pubsub#event");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- if (payload->getPublisher()) {
- element.setAttribute("publisher", *payload->getPublisher());
- }
- foreach(boost::shared_ptr<Payload> item, payload->getData()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item)));
- }
- if (payload->getID()) {
- element.setAttribute("id", *payload->getID());
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("item", "http://jabber.org/protocol/pubsub#event");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ if (payload->getPublisher()) {
+ element.setAttribute("publisher", *payload->getPublisher());
+ }
+ foreach(boost::shared_ptr<Payload> item, payload->getData()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item)));
+ }
+ if (payload->getID()) {
+ element.setAttribute("id", *payload->getID());
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h
index bd164fe..6666c6b 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventItemSerializer : public GenericPayloadSerializer<PubSubEventItem> {
- public:
- PubSubEventItemSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventItemSerializer();
+ class SWIFTEN_API PubSubEventItemSerializer : public GenericPayloadSerializer<PubSubEventItem> {
+ public:
+ PubSubEventItemSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventItemSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventItem>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventItem>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp
index 7faac5f..7128314 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp
@@ -25,18 +25,18 @@ PubSubEventItemsSerializer::~PubSubEventItemsSerializer() {
}
std::string PubSubEventItemsSerializer::serializePayload(boost::shared_ptr<PubSubEventItems> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("items", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("node", payload->getNode());
- foreach(boost::shared_ptr<PubSubEventItem> item, payload->getItems()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventItemSerializer(serializers).serialize(item)));
- }
- foreach(boost::shared_ptr<PubSubEventRetract> item, payload->getRetracts()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventRetractSerializer(serializers).serialize(item)));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("items", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubEventItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventItemSerializer(serializers).serialize(item)));
+ }
+ foreach(boost::shared_ptr<PubSubEventRetract> item, payload->getRetracts()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventRetractSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h
index a1f4633..d174f30 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventItemsSerializer : public GenericPayloadSerializer<PubSubEventItems> {
- public:
- PubSubEventItemsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventItemsSerializer();
+ class SWIFTEN_API PubSubEventItemsSerializer : public GenericPayloadSerializer<PubSubEventItems> {
+ public:
+ PubSubEventItemsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventItemsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventItems>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventItems>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp
index 9541ece..86c7635 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp
@@ -22,12 +22,12 @@ PubSubEventPurgeSerializer::~PubSubEventPurgeSerializer() {
}
std::string PubSubEventPurgeSerializer::serializePayload(boost::shared_ptr<PubSubEventPurge> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("purge", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("node", payload->getNode());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("purge", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h
index 47648d4..c80c703 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventPurgeSerializer : public GenericPayloadSerializer<PubSubEventPurge> {
- public:
- PubSubEventPurgeSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventPurgeSerializer();
+ class SWIFTEN_API PubSubEventPurgeSerializer : public GenericPayloadSerializer<PubSubEventPurge> {
+ public:
+ PubSubEventPurgeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventPurgeSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventPurge>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventPurge>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp
index 80b4d94..a7fcd20 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp
@@ -22,12 +22,12 @@ PubSubEventRedirectSerializer::~PubSubEventRedirectSerializer() {
}
std::string PubSubEventRedirectSerializer::serializePayload(boost::shared_ptr<PubSubEventRedirect> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("redirect", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("uri", payload->getURI());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("redirect", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("uri", payload->getURI());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h
index 79d4f56..fe0f16e 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventRedirectSerializer : public GenericPayloadSerializer<PubSubEventRedirect> {
- public:
- PubSubEventRedirectSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventRedirectSerializer();
+ class SWIFTEN_API PubSubEventRedirectSerializer : public GenericPayloadSerializer<PubSubEventRedirect> {
+ public:
+ PubSubEventRedirectSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventRedirectSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventRedirect>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventRedirect>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp
index 197c087..6a132cc 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp
@@ -22,12 +22,12 @@ PubSubEventRetractSerializer::~PubSubEventRetractSerializer() {
}
std::string PubSubEventRetractSerializer::serializePayload(boost::shared_ptr<PubSubEventRetract> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("retract", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("id", payload->getID());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("retract", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("id", payload->getID());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h
index a7fd987..2c393c2 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventRetractSerializer : public GenericPayloadSerializer<PubSubEventRetract> {
- public:
- PubSubEventRetractSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventRetractSerializer();
+ class SWIFTEN_API PubSubEventRetractSerializer : public GenericPayloadSerializer<PubSubEventRetract> {
+ public:
+ PubSubEventRetractSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventRetractSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventRetract>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventRetract>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp
index 8a7b881..7305d29 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp
@@ -23,29 +23,29 @@
using namespace Swift;
PubSubEventSerializer::PubSubEventSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
- pubsubSerializers.push_back(boost::make_shared<PubSubEventSubscriptionSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubEventPurgeSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubEventCollectionSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubEventDeleteSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubEventItemsSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubEventConfigurationSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventSubscriptionSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventPurgeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventCollectionSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventDeleteSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventItemsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventConfigurationSerializer>(serializers));
}
PubSubEventSerializer::~PubSubEventSerializer() {
}
std::string PubSubEventSerializer::serializePayload(boost::shared_ptr<PubSubEvent> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("event", "http://jabber.org/protocol/pubsub#event");
- boost::shared_ptr<PubSubEventPayload> p = payload->getPayload();
- foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
- if (serializer->canSerialize(p)) {
- element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
- }
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("event", "http://jabber.org/protocol/pubsub#event");
+ boost::shared_ptr<PubSubEventPayload> p = payload->getPayload();
+ foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
+ if (serializer->canSerialize(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
+ }
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h
index 9dae673..2b50e95 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h
@@ -16,20 +16,20 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventSerializer : public GenericPayloadSerializer<PubSubEvent> {
- public:
- PubSubEventSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventSerializer();
+ class SWIFTEN_API PubSubEventSerializer : public GenericPayloadSerializer<PubSubEvent> {
+ public:
+ PubSubEventSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEvent>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEvent>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp
index a7240c8..322b482 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp
@@ -22,27 +22,27 @@ PubSubEventSubscriptionSerializer::~PubSubEventSubscriptionSerializer() {
}
std::string PubSubEventSubscriptionSerializer::serializePayload(boost::shared_ptr<PubSubEventSubscription> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("subscription", "http://jabber.org/protocol/pubsub#event");
- element.setAttribute("node", payload->getNode());
- element.setAttribute("jid", payload->getJID());
- element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
- if (payload->getSubscriptionID()) {
- element.setAttribute("subid", *payload->getSubscriptionID());
- }
- element.setAttribute("expiry", dateTimeToString(payload->getExpiry()));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscription", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ element.setAttribute("jid", payload->getJID());
+ element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ element.setAttribute("expiry", dateTimeToString(payload->getExpiry()));
+ return element.serialize();
}
std::string PubSubEventSubscriptionSerializer::serializeSubscriptionType(PubSubEventSubscription::SubscriptionType value) {
- switch (value) {
- case PubSubEventSubscription::None: return "none";
- case PubSubEventSubscription::Pending: return "pending";
- case PubSubEventSubscription::Subscribed: return "subscribed";
- case PubSubEventSubscription::Unconfigured: return "unconfigured";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubEventSubscription::None: return "none";
+ case PubSubEventSubscription::Pending: return "pending";
+ case PubSubEventSubscription::Subscribed: return "subscribed";
+ case PubSubEventSubscription::Unconfigured: return "unconfigured";
+ }
+ assert(false);
+ return "";
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h
index 1329ca6..74e3062 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubEventSubscriptionSerializer : public GenericPayloadSerializer<PubSubEventSubscription> {
- public:
- PubSubEventSubscriptionSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubEventSubscriptionSerializer();
+ class SWIFTEN_API PubSubEventSubscriptionSerializer : public GenericPayloadSerializer<PubSubEventSubscription> {
+ public:
+ PubSubEventSubscriptionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventSubscriptionSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubEventSubscription>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventSubscription>) const SWIFTEN_OVERRIDE;
- private:
- static std::string serializeSubscriptionType(PubSubEventSubscription::SubscriptionType);
+ private:
+ static std::string serializeSubscriptionType(PubSubEventSubscription::SubscriptionType);
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp
index 93fa8e2..e32f17a 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp
@@ -23,17 +23,17 @@ PubSubItemSerializer::~PubSubItemSerializer() {
}
std::string PubSubItemSerializer::serializePayload(boost::shared_ptr<PubSubItem> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("item", "http://jabber.org/protocol/pubsub");
- foreach(boost::shared_ptr<Payload> item, payload->getData()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item)));
- }
- if (!payload->getID().empty()) {
- element.setAttribute("id", payload->getID());
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("item", "http://jabber.org/protocol/pubsub");
+ foreach(boost::shared_ptr<Payload> item, payload->getData()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item)));
+ }
+ if (!payload->getID().empty()) {
+ element.setAttribute("id", payload->getID());
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h
index 4f9a97e..e6dbb83 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubItemSerializer : public GenericPayloadSerializer<PubSubItem> {
- public:
- PubSubItemSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubItemSerializer();
+ class SWIFTEN_API PubSubItemSerializer : public GenericPayloadSerializer<PubSubItem> {
+ public:
+ PubSubItemSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubItemSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubItem>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubItem>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp
index f09fba1..75d32f5 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp
@@ -26,24 +26,24 @@ PubSubItemsSerializer::~PubSubItemsSerializer() {
}
std::string PubSubItemsSerializer::serializePayload(boost::shared_ptr<PubSubItems> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("items", "http://jabber.org/protocol/pubsub");
- if (payload->getNode().empty()) {
- SWIFT_LOG(warning) << "Serializing PubSubItems with empty node attribute";
- }
- element.setAttribute("node", payload->getNode());
- foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
- }
- if (payload->getMaximumItems()) {
- element.setAttribute("max_items", boost::lexical_cast<std::string>(*payload->getMaximumItems()));
- }
- if (payload->getSubscriptionID()) {
- element.setAttribute("subid", *payload->getSubscriptionID());
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("items", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode().empty()) {
+ SWIFT_LOG(warning) << "Serializing PubSubItems with empty node attribute";
+ }
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
+ }
+ if (payload->getMaximumItems()) {
+ element.setAttribute("max_items", boost::lexical_cast<std::string>(*payload->getMaximumItems()));
+ }
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h
index bd608d7..28b923f 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubItemsSerializer : public GenericPayloadSerializer<PubSubItems> {
- public:
- PubSubItemsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubItemsSerializer();
+ class SWIFTEN_API PubSubItemsSerializer : public GenericPayloadSerializer<PubSubItems> {
+ public:
+ PubSubItemsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubItemsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubItems>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubItems>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp
index 4117041..09f72ef 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp
@@ -23,17 +23,17 @@ PubSubOptionsSerializer::~PubSubOptionsSerializer() {
}
std::string PubSubOptionsSerializer::serializePayload(boost::shared_ptr<PubSubOptions> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("options", "http://jabber.org/protocol/pubsub");
- element.setAttribute("node", payload->getNode());
- element.setAttribute("jid", payload->getJID());
- element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
- if (payload->getSubscriptionID()) {
- element.setAttribute("subid", *payload->getSubscriptionID());
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("options", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ element.setAttribute("jid", payload->getJID());
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h
index 44a0f17..91dabab 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOptionsSerializer : public GenericPayloadSerializer<PubSubOptions> {
- public:
- PubSubOptionsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOptionsSerializer();
+ class SWIFTEN_API PubSubOptionsSerializer : public GenericPayloadSerializer<PubSubOptions> {
+ public:
+ PubSubOptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOptionsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOptions>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOptions>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp
index efc9eef..82980ff 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp
@@ -22,24 +22,24 @@ PubSubOwnerAffiliationSerializer::~PubSubOwnerAffiliationSerializer() {
}
std::string PubSubOwnerAffiliationSerializer::serializePayload(boost::shared_ptr<PubSubOwnerAffiliation> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("affiliation", "http://jabber.org/protocol/pubsub#owner");
- element.setAttribute("jid", payload->getJID());
- element.setAttribute("affiliation", serializeType(payload->getType()));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliation", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("jid", payload->getJID());
+ element.setAttribute("affiliation", serializeType(payload->getType()));
+ return element.serialize();
}
std::string PubSubOwnerAffiliationSerializer::serializeType(PubSubOwnerAffiliation::Type value) {
- switch (value) {
- case PubSubOwnerAffiliation::None: return "none";
- case PubSubOwnerAffiliation::Member: return "member";
- case PubSubOwnerAffiliation::Outcast: return "outcast";
- case PubSubOwnerAffiliation::Owner: return "owner";
- case PubSubOwnerAffiliation::Publisher: return "publisher";
- case PubSubOwnerAffiliation::PublishOnly: return "publish-only";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubOwnerAffiliation::None: return "none";
+ case PubSubOwnerAffiliation::Member: return "member";
+ case PubSubOwnerAffiliation::Outcast: return "outcast";
+ case PubSubOwnerAffiliation::Owner: return "owner";
+ case PubSubOwnerAffiliation::Publisher: return "publisher";
+ case PubSubOwnerAffiliation::PublishOnly: return "publish-only";
+ }
+ assert(false);
+ return "";
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h
index 9883ab9..ef0decf 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerAffiliationSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliation> {
- public:
- PubSubOwnerAffiliationSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerAffiliationSerializer();
+ class SWIFTEN_API PubSubOwnerAffiliationSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliation> {
+ public:
+ PubSubOwnerAffiliationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerAffiliationSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerAffiliation>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerAffiliation>) const SWIFTEN_OVERRIDE;
- private:
- static std::string serializeType(PubSubOwnerAffiliation::Type);
+ private:
+ static std::string serializeType(PubSubOwnerAffiliation::Type);
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp
index 5e80747..12873e5 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp
@@ -24,15 +24,15 @@ PubSubOwnerAffiliationsSerializer::~PubSubOwnerAffiliationsSerializer() {
}
std::string PubSubOwnerAffiliationsSerializer::serializePayload(boost::shared_ptr<PubSubOwnerAffiliations> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("affiliations", "http://jabber.org/protocol/pubsub#owner");
- element.setAttribute("node", payload->getNode());
- foreach(boost::shared_ptr<PubSubOwnerAffiliation> item, payload->getAffiliations()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerAffiliationSerializer(serializers).serialize(item)));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliations", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubOwnerAffiliation> item, payload->getAffiliations()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerAffiliationSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h
index a2ee181..70ba66f 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerAffiliationsSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliations> {
- public:
- PubSubOwnerAffiliationsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerAffiliationsSerializer();
+ class SWIFTEN_API PubSubOwnerAffiliationsSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliations> {
+ public:
+ PubSubOwnerAffiliationsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerAffiliationsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerAffiliations>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerAffiliations>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp
index d493e63..94e6860 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp
@@ -23,15 +23,15 @@ PubSubOwnerConfigureSerializer::~PubSubOwnerConfigureSerializer() {
}
std::string PubSubOwnerConfigureSerializer::serializePayload(boost::shared_ptr<PubSubOwnerConfigure> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("configure", "http://jabber.org/protocol/pubsub#owner");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("configure", "http://jabber.org/protocol/pubsub#owner");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h
index 8881ea5..be75a00 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerConfigureSerializer : public GenericPayloadSerializer<PubSubOwnerConfigure> {
- public:
- PubSubOwnerConfigureSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerConfigureSerializer();
+ class SWIFTEN_API PubSubOwnerConfigureSerializer : public GenericPayloadSerializer<PubSubOwnerConfigure> {
+ public:
+ PubSubOwnerConfigureSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerConfigureSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerConfigure>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerConfigure>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp
index 934f877..4b91a81 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp
@@ -23,12 +23,12 @@ PubSubOwnerDefaultSerializer::~PubSubOwnerDefaultSerializer() {
}
std::string PubSubOwnerDefaultSerializer::serializePayload(boost::shared_ptr<PubSubOwnerDefault> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("default", "http://jabber.org/protocol/pubsub#owner");
- element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("default", "http://jabber.org/protocol/pubsub#owner");
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h
index ab8487a..9d2916f 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerDefaultSerializer : public GenericPayloadSerializer<PubSubOwnerDefault> {
- public:
- PubSubOwnerDefaultSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerDefaultSerializer();
+ class SWIFTEN_API PubSubOwnerDefaultSerializer : public GenericPayloadSerializer<PubSubOwnerDefault> {
+ public:
+ PubSubOwnerDefaultSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerDefaultSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerDefault>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerDefault>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp
index 1594643..fbf9a24 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp
@@ -23,13 +23,13 @@ PubSubOwnerDeleteSerializer::~PubSubOwnerDeleteSerializer() {
}
std::string PubSubOwnerDeleteSerializer::serializePayload(boost::shared_ptr<PubSubOwnerDelete> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("delete", "http://jabber.org/protocol/pubsub#owner");
- element.setAttribute("node", payload->getNode());
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerRedirectSerializer(serializers).serialize(payload->getRedirect())));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("delete", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerRedirectSerializer(serializers).serialize(payload->getRedirect())));
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h
index 28bb090..3a96e80 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerDeleteSerializer : public GenericPayloadSerializer<PubSubOwnerDelete> {
- public:
- PubSubOwnerDeleteSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerDeleteSerializer();
+ class SWIFTEN_API PubSubOwnerDeleteSerializer : public GenericPayloadSerializer<PubSubOwnerDelete> {
+ public:
+ PubSubOwnerDeleteSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerDeleteSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerDelete>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerDelete>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp
index 39161f0..25b38d0 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp
@@ -23,29 +23,29 @@
using namespace Swift;
PubSubOwnerPubSubSerializer::PubSubOwnerPubSubSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
- pubsubSerializers.push_back(boost::make_shared<PubSubOwnerConfigureSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubOwnerSubscriptionsSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubOwnerDefaultSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubOwnerPurgeSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubOwnerAffiliationsSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubOwnerDeleteSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerConfigureSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerSubscriptionsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerDefaultSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerPurgeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerAffiliationsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerDeleteSerializer>(serializers));
}
PubSubOwnerPubSubSerializer::~PubSubOwnerPubSubSerializer() {
}
std::string PubSubOwnerPubSubSerializer::serializePayload(boost::shared_ptr<PubSubOwnerPubSub> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("pubsub", "http://jabber.org/protocol/pubsub#owner");
- boost::shared_ptr<PubSubOwnerPayload> p = payload->getPayload();
- foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
- if (serializer->canSerialize(p)) {
- element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
- }
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("pubsub", "http://jabber.org/protocol/pubsub#owner");
+ boost::shared_ptr<PubSubOwnerPayload> p = payload->getPayload();
+ foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
+ if (serializer->canSerialize(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
+ }
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h
index 398c084..2dd8400 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h
@@ -16,20 +16,20 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerPubSubSerializer : public GenericPayloadSerializer<PubSubOwnerPubSub> {
- public:
- PubSubOwnerPubSubSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerPubSubSerializer();
+ class SWIFTEN_API PubSubOwnerPubSubSerializer : public GenericPayloadSerializer<PubSubOwnerPubSub> {
+ public:
+ PubSubOwnerPubSubSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerPubSubSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerPubSub>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerPubSub>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp
index 9d2f0c1..f934c4e 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp
@@ -22,12 +22,12 @@ PubSubOwnerPurgeSerializer::~PubSubOwnerPurgeSerializer() {
}
std::string PubSubOwnerPurgeSerializer::serializePayload(boost::shared_ptr<PubSubOwnerPurge> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("purge", "http://jabber.org/protocol/pubsub#owner");
- element.setAttribute("node", payload->getNode());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("purge", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h
index 3ee1460..64be235 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerPurgeSerializer : public GenericPayloadSerializer<PubSubOwnerPurge> {
- public:
- PubSubOwnerPurgeSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerPurgeSerializer();
+ class SWIFTEN_API PubSubOwnerPurgeSerializer : public GenericPayloadSerializer<PubSubOwnerPurge> {
+ public:
+ PubSubOwnerPurgeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerPurgeSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerPurge>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerPurge>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp
index 7628379..f933a06 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp
@@ -22,12 +22,12 @@ PubSubOwnerRedirectSerializer::~PubSubOwnerRedirectSerializer() {
}
std::string PubSubOwnerRedirectSerializer::serializePayload(boost::shared_ptr<PubSubOwnerRedirect> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("redirect", "http://jabber.org/protocol/pubsub#owner");
- element.setAttribute("uri", payload->getURI());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("redirect", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("uri", payload->getURI());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h
index 71d6f48..b183f46 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerRedirectSerializer : public GenericPayloadSerializer<PubSubOwnerRedirect> {
- public:
- PubSubOwnerRedirectSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerRedirectSerializer();
+ class SWIFTEN_API PubSubOwnerRedirectSerializer : public GenericPayloadSerializer<PubSubOwnerRedirect> {
+ public:
+ PubSubOwnerRedirectSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerRedirectSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerRedirect>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerRedirect>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp
index a639716..923c160 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp
@@ -22,22 +22,22 @@ PubSubOwnerSubscriptionSerializer::~PubSubOwnerSubscriptionSerializer() {
}
std::string PubSubOwnerSubscriptionSerializer::serializePayload(boost::shared_ptr<PubSubOwnerSubscription> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("subscription", "http://jabber.org/protocol/pubsub#owner");
- element.setAttribute("jid", payload->getJID());
- element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscription", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("jid", payload->getJID());
+ element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
+ return element.serialize();
}
std::string PubSubOwnerSubscriptionSerializer::serializeSubscriptionType(PubSubOwnerSubscription::SubscriptionType value) {
- switch (value) {
- case PubSubOwnerSubscription::None: return "none";
- case PubSubOwnerSubscription::Pending: return "pending";
- case PubSubOwnerSubscription::Subscribed: return "subscribed";
- case PubSubOwnerSubscription::Unconfigured: return "unconfigured";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubOwnerSubscription::None: return "none";
+ case PubSubOwnerSubscription::Pending: return "pending";
+ case PubSubOwnerSubscription::Subscribed: return "subscribed";
+ case PubSubOwnerSubscription::Unconfigured: return "unconfigured";
+ }
+ assert(false);
+ return "";
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h
index 2f02be4..1bba67f 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerSubscriptionSerializer : public GenericPayloadSerializer<PubSubOwnerSubscription> {
- public:
- PubSubOwnerSubscriptionSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerSubscriptionSerializer();
+ class SWIFTEN_API PubSubOwnerSubscriptionSerializer : public GenericPayloadSerializer<PubSubOwnerSubscription> {
+ public:
+ PubSubOwnerSubscriptionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerSubscriptionSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerSubscription>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerSubscription>) const SWIFTEN_OVERRIDE;
- private:
- static std::string serializeSubscriptionType(PubSubOwnerSubscription::SubscriptionType);
+ private:
+ static std::string serializeSubscriptionType(PubSubOwnerSubscription::SubscriptionType);
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp
index 3b49329..088f6c2 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp
@@ -24,15 +24,15 @@ PubSubOwnerSubscriptionsSerializer::~PubSubOwnerSubscriptionsSerializer() {
}
std::string PubSubOwnerSubscriptionsSerializer::serializePayload(boost::shared_ptr<PubSubOwnerSubscriptions> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("subscriptions", "http://jabber.org/protocol/pubsub#owner");
- element.setAttribute("node", payload->getNode());
- foreach(boost::shared_ptr<PubSubOwnerSubscription> item, payload->getSubscriptions()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerSubscriptionSerializer(serializers).serialize(item)));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscriptions", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubOwnerSubscription> item, payload->getSubscriptions()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerSubscriptionSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h
index ec011f8..70ea7b2 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubOwnerSubscriptionsSerializer : public GenericPayloadSerializer<PubSubOwnerSubscriptions> {
- public:
- PubSubOwnerSubscriptionsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubOwnerSubscriptionsSerializer();
+ class SWIFTEN_API PubSubOwnerSubscriptionsSerializer : public GenericPayloadSerializer<PubSubOwnerSubscriptions> {
+ public:
+ PubSubOwnerSubscriptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerSubscriptionsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerSubscriptions>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerSubscriptions>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp
index f9044fd..efae018 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp
@@ -24,15 +24,15 @@ PubSubPublishSerializer::~PubSubPublishSerializer() {
}
std::string PubSubPublishSerializer::serializePayload(boost::shared_ptr<PubSubPublish> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("publish", "http://jabber.org/protocol/pubsub");
- element.setAttribute("node", payload->getNode());
- foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("publish", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h
index f834484..c576225 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubPublishSerializer : public GenericPayloadSerializer<PubSubPublish> {
- public:
- PubSubPublishSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubPublishSerializer();
+ class SWIFTEN_API PubSubPublishSerializer : public GenericPayloadSerializer<PubSubPublish> {
+ public:
+ PubSubPublishSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubPublishSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubPublish>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubPublish>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp
index 2d5af7a..9a84959 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp
@@ -24,16 +24,16 @@ PubSubRetractSerializer::~PubSubRetractSerializer() {
}
std::string PubSubRetractSerializer::serializePayload(boost::shared_ptr<PubSubRetract> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("retract", "http://jabber.org/protocol/pubsub");
- element.setAttribute("node", payload->getNode());
- foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
- }
- element.setAttribute("notify", payload->isNotify() ? "true" : "false");
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("retract", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
+ }
+ element.setAttribute("notify", payload->isNotify() ? "true" : "false");
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h
index 6f0d041..60acb6e 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubRetractSerializer : public GenericPayloadSerializer<PubSubRetract> {
- public:
- PubSubRetractSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubRetractSerializer();
+ class SWIFTEN_API PubSubRetractSerializer : public GenericPayloadSerializer<PubSubRetract> {
+ public:
+ PubSubRetractSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubRetractSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubRetract>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubRetract>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp
index 2e75ecb..9562edb 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp
@@ -30,40 +30,40 @@
using namespace Swift;
PubSubSerializer::PubSubSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
- pubsubSerializers.push_back(boost::make_shared<PubSubItemsSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubCreateSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubPublishSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubOptionsSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubAffiliationsSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubRetractSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubDefaultSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubSubscriptionsSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubSubscribeSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubUnsubscribeSerializer>(serializers));
- pubsubSerializers.push_back(boost::make_shared<PubSubSubscriptionSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubItemsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubCreateSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubPublishSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOptionsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubAffiliationsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubRetractSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubDefaultSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubSubscriptionsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubSubscribeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubUnsubscribeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubSubscriptionSerializer>(serializers));
}
PubSubSerializer::~PubSubSerializer() {
}
std::string PubSubSerializer::serializePayload(boost::shared_ptr<PubSub> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("pubsub", "http://jabber.org/protocol/pubsub");
- boost::shared_ptr<PubSubPayload> p = payload->getPayload();
- foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
- if (serializer->canSerialize(p)) {
- element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
- if (boost::shared_ptr<PubSubCreate> create = boost::dynamic_pointer_cast<PubSubCreate>(p)) {
- element.addNode(boost::make_shared<XMLRawTextNode>(boost::make_shared<PubSubConfigureSerializer>(serializers)->serialize(create->getConfigure())));
- }
- if (boost::shared_ptr<PubSubSubscribe> subscribe = boost::dynamic_pointer_cast<PubSubSubscribe>(p)) {
- element.addNode(boost::make_shared<XMLRawTextNode>(boost::make_shared<PubSubConfigureSerializer>(serializers)->serialize(subscribe->getOptions())));
- }
- }
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("pubsub", "http://jabber.org/protocol/pubsub");
+ boost::shared_ptr<PubSubPayload> p = payload->getPayload();
+ foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
+ if (serializer->canSerialize(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
+ if (boost::shared_ptr<PubSubCreate> create = boost::dynamic_pointer_cast<PubSubCreate>(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(boost::make_shared<PubSubConfigureSerializer>(serializers)->serialize(create->getConfigure())));
+ }
+ if (boost::shared_ptr<PubSubSubscribe> subscribe = boost::dynamic_pointer_cast<PubSubSubscribe>(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(boost::make_shared<PubSubConfigureSerializer>(serializers)->serialize(subscribe->getOptions())));
+ }
+ }
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h
index e257e26..0721d13 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h
@@ -14,17 +14,17 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubSerializer : public GenericPayloadSerializer<PubSub> {
- public:
- PubSubSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubSerializer();
+ class SWIFTEN_API PubSubSerializer : public GenericPayloadSerializer<PubSub> {
+ public:
+ PubSubSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSub>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSub>) const SWIFTEN_OVERRIDE;
- private:
- std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
- PayloadSerializerCollection* serializers;
- };
+ private:
+ std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp
index 692158f..2e3987e 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp
@@ -22,12 +22,12 @@ PubSubSubscribeOptionsSerializer::~PubSubSubscribeOptionsSerializer() {
}
std::string PubSubSubscribeOptionsSerializer::serializePayload(boost::shared_ptr<PubSubSubscribeOptions> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("subscribe-options", "http://jabber.org/protocol/pubsub");
- element.addNode(payload->isRequired() ? boost::make_shared<XMLElement>("required", "") : boost::shared_ptr<XMLElement>());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscribe-options", "http://jabber.org/protocol/pubsub");
+ element.addNode(payload->isRequired() ? boost::make_shared<XMLElement>("required", "") : boost::shared_ptr<XMLElement>());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h
index 399047d..663d91b 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubSubscribeOptionsSerializer : public GenericPayloadSerializer<PubSubSubscribeOptions> {
- public:
- PubSubSubscribeOptionsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubSubscribeOptionsSerializer();
+ class SWIFTEN_API PubSubSubscribeOptionsSerializer : public GenericPayloadSerializer<PubSubSubscribeOptions> {
+ public:
+ PubSubSubscribeOptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscribeOptionsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubSubscribeOptions>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscribeOptions>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp
index f761531..dcc7ab1 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp
@@ -22,15 +22,15 @@ PubSubSubscribeSerializer::~PubSubSubscribeSerializer() {
}
std::string PubSubSubscribeSerializer::serializePayload(boost::shared_ptr<PubSubSubscribe> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("subscribe", "http://jabber.org/protocol/pubsub");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- element.setAttribute("jid", payload->getJID());
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscribe", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.setAttribute("jid", payload->getJID());
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h
index 8618e27..c655464 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubSubscribeSerializer : public GenericPayloadSerializer<PubSubSubscribe> {
- public:
- PubSubSubscribeSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubSubscribeSerializer();
+ class SWIFTEN_API PubSubSubscribeSerializer : public GenericPayloadSerializer<PubSubSubscribe> {
+ public:
+ PubSubSubscribeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscribeSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubSubscribe>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscribe>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp
index a856f75..cadfce9 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp
@@ -23,29 +23,29 @@ PubSubSubscriptionSerializer::~PubSubSubscriptionSerializer() {
}
std::string PubSubSubscriptionSerializer::serializePayload(boost::shared_ptr<PubSubSubscription> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("subscription", "http://jabber.org/protocol/pubsub");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- if (payload->getSubscriptionID()) {
- element.setAttribute("subid", *payload->getSubscriptionID());
- }
- element.setAttribute("jid", payload->getJID());
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubSubscribeOptionsSerializer(serializers).serialize(payload->getOptions())));
- element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscription", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ element.setAttribute("jid", payload->getJID());
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubSubscribeOptionsSerializer(serializers).serialize(payload->getOptions())));
+ element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
+ return element.serialize();
}
std::string PubSubSubscriptionSerializer::serializeSubscriptionType(PubSubSubscription::SubscriptionType value) {
- switch (value) {
- case PubSubSubscription::None: return "none";
- case PubSubSubscription::Pending: return "pending";
- case PubSubSubscription::Subscribed: return "subscribed";
- case PubSubSubscription::Unconfigured: return "unconfigured";
- }
- assert(false);
- return "";
+ switch (value) {
+ case PubSubSubscription::None: return "none";
+ case PubSubSubscription::Pending: return "pending";
+ case PubSubSubscription::Subscribed: return "subscribed";
+ case PubSubSubscription::Unconfigured: return "unconfigured";
+ }
+ assert(false);
+ return "";
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h
index 1b061ee..7d96a06 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubSubscriptionSerializer : public GenericPayloadSerializer<PubSubSubscription> {
- public:
- PubSubSubscriptionSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubSubscriptionSerializer();
+ class SWIFTEN_API PubSubSubscriptionSerializer : public GenericPayloadSerializer<PubSubSubscription> {
+ public:
+ PubSubSubscriptionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscriptionSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubSubscription>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscription>) const SWIFTEN_OVERRIDE;
- private:
- static std::string serializeSubscriptionType(PubSubSubscription::SubscriptionType);
+ private:
+ static std::string serializeSubscriptionType(PubSubSubscription::SubscriptionType);
- private:
- PayloadSerializerCollection* serializers;
- };
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp
index 5e8c337..3347187 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp
@@ -24,17 +24,17 @@ PubSubSubscriptionsSerializer::~PubSubSubscriptionsSerializer() {
}
std::string PubSubSubscriptionsSerializer::serializePayload(boost::shared_ptr<PubSubSubscriptions> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("subscriptions", "http://jabber.org/protocol/pubsub");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- foreach(boost::shared_ptr<PubSubSubscription> item, payload->getSubscriptions()) {
- element.addNode(boost::make_shared<XMLRawTextNode>(PubSubSubscriptionSerializer(serializers).serialize(item)));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscriptions", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ foreach(boost::shared_ptr<PubSubSubscription> item, payload->getSubscriptions()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubSubscriptionSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h
index 82245fb..cc64483 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubSubscriptionsSerializer : public GenericPayloadSerializer<PubSubSubscriptions> {
- public:
- PubSubSubscriptionsSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubSubscriptionsSerializer();
+ class SWIFTEN_API PubSubSubscriptionsSerializer : public GenericPayloadSerializer<PubSubSubscriptions> {
+ public:
+ PubSubSubscriptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscriptionsSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubSubscriptions>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscriptions>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp
index 8a71583..e9a16d6 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp
@@ -22,18 +22,18 @@ PubSubUnsubscribeSerializer::~PubSubUnsubscribeSerializer() {
}
std::string PubSubUnsubscribeSerializer::serializePayload(boost::shared_ptr<PubSubUnsubscribe> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("unsubscribe", "http://jabber.org/protocol/pubsub");
- if (payload->getNode()) {
- element.setAttribute("node", *payload->getNode());
- }
- element.setAttribute("jid", payload->getJID());
- if (payload->getSubscriptionID()) {
- element.setAttribute("subid", *payload->getSubscriptionID());
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("unsubscribe", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.setAttribute("jid", payload->getJID());
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h
index 3341422..ab9a053 100644
--- a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API PubSubUnsubscribeSerializer : public GenericPayloadSerializer<PubSubUnsubscribe> {
- public:
- PubSubUnsubscribeSerializer(PayloadSerializerCollection* serializers);
- virtual ~PubSubUnsubscribeSerializer();
+ class SWIFTEN_API PubSubUnsubscribeSerializer : public GenericPayloadSerializer<PubSubUnsubscribe> {
+ public:
+ PubSubUnsubscribeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubUnsubscribeSerializer();
- virtual std::string serializePayload(boost::shared_ptr<PubSubUnsubscribe>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<PubSubUnsubscribe>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h
index f6aaec9..21ca59f 100644
--- a/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h
@@ -11,12 +11,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API RawXMLPayloadSerializer : public GenericPayloadSerializer<RawXMLPayload> {
- public:
- RawXMLPayloadSerializer() : GenericPayloadSerializer<RawXMLPayload>() {}
+ class SWIFTEN_API RawXMLPayloadSerializer : public GenericPayloadSerializer<RawXMLPayload> {
+ public:
+ RawXMLPayloadSerializer() : GenericPayloadSerializer<RawXMLPayload>() {}
- virtual std::string serializePayload(boost::shared_ptr<RawXMLPayload> p) const {
- return p->getRawXML();
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<RawXMLPayload> p) const {
+ return p->getRawXML();
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h b/Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h
index b61547e..a16f52b 100644
--- a/Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h
@@ -18,12 +18,12 @@
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
- class SWIFTEN_API ReplaceSerializer : public GenericPayloadSerializer<Replace> {
- public:
- ReplaceSerializer() : GenericPayloadSerializer<Replace>() {}
+ class SWIFTEN_API ReplaceSerializer : public GenericPayloadSerializer<Replace> {
+ public:
+ ReplaceSerializer() : GenericPayloadSerializer<Replace>() {}
- virtual std::string serializePayload(boost::shared_ptr<Replace> replace) const {
- return "<replace id = '" + replace->getID() + "' xmlns='urn:xmpp:message-correct:0'/>";
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<Replace> replace) const {
+ return "<replace id = '" + replace->getID() + "' xmlns='urn:xmpp:message-correct:0'/>";
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp
index 87614cd..c737102 100644
--- a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp
@@ -18,18 +18,18 @@ ResourceBindSerializer::ResourceBindSerializer() : GenericPayloadSerializer<Reso
}
std::string ResourceBindSerializer::serializePayload(boost::shared_ptr<ResourceBind> resourceBind) const {
- XMLElement bindElement("bind", "urn:ietf:params:xml:ns:xmpp-bind");
- if (resourceBind->getJID().isValid()) {
- boost::shared_ptr<XMLElement> jidNode(new XMLElement("jid"));
- jidNode->addNode(boost::make_shared<XMLTextNode>(resourceBind->getJID().toString()));
- bindElement.addNode(jidNode);
- }
- else if (!resourceBind->getResource().empty()) {
- boost::shared_ptr<XMLElement> resourceNode(new XMLElement("resource"));
- resourceNode->addNode(boost::make_shared<XMLTextNode>(resourceBind->getResource()));
- bindElement.addNode(resourceNode);
- }
- return bindElement.serialize();
+ XMLElement bindElement("bind", "urn:ietf:params:xml:ns:xmpp-bind");
+ if (resourceBind->getJID().isValid()) {
+ boost::shared_ptr<XMLElement> jidNode(new XMLElement("jid"));
+ jidNode->addNode(boost::make_shared<XMLTextNode>(resourceBind->getJID().toString()));
+ bindElement.addNode(jidNode);
+ }
+ else if (!resourceBind->getResource().empty()) {
+ boost::shared_ptr<XMLElement> resourceNode(new XMLElement("resource"));
+ resourceNode->addNode(boost::make_shared<XMLTextNode>(resourceBind->getResource()));
+ bindElement.addNode(resourceNode);
+ }
+ return bindElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h
index 4f60b71..2878c34 100644
--- a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API ResourceBindSerializer : public GenericPayloadSerializer<ResourceBind> {
- public:
- ResourceBindSerializer();
+ class SWIFTEN_API ResourceBindSerializer : public GenericPayloadSerializer<ResourceBind> {
+ public:
+ ResourceBindSerializer();
- virtual std::string serializePayload(boost::shared_ptr<ResourceBind>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<ResourceBind>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp
index 479d6be..205d9e0 100644
--- a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp
@@ -21,43 +21,43 @@ ResultSetSerializer::~ResultSetSerializer() {
}
std::string ResultSetSerializer::serializePayload(boost::shared_ptr<ResultSet> payload) const {
- if (!payload) {
- return "";
- }
+ if (!payload) {
+ return "";
+ }
- XMLElement element("set", "http://jabber.org/protocol/rsm");
+ XMLElement element("set", "http://jabber.org/protocol/rsm");
- if (payload->getMaxItems()) {
- element.addNode(boost::make_shared<XMLElement>("max", "", boost::lexical_cast<std::string>(*payload->getMaxItems())));
- }
+ if (payload->getMaxItems()) {
+ element.addNode(boost::make_shared<XMLElement>("max", "", boost::lexical_cast<std::string>(*payload->getMaxItems())));
+ }
- if (payload->getCount()) {
- element.addNode(boost::make_shared<XMLElement>("count", "", boost::lexical_cast<std::string>(*payload->getCount())));
- }
+ if (payload->getCount()) {
+ element.addNode(boost::make_shared<XMLElement>("count", "", boost::lexical_cast<std::string>(*payload->getCount())));
+ }
- if (payload->getIndex()) {
- element.addNode(boost::make_shared<XMLElement>("index", "", boost::lexical_cast<std::string>(*payload->getIndex())));
- }
+ if (payload->getIndex()) {
+ element.addNode(boost::make_shared<XMLElement>("index", "", boost::lexical_cast<std::string>(*payload->getIndex())));
+ }
- if (payload->getFirstID()) {
- boost::shared_ptr<XMLElement> firstElement = boost::make_shared<XMLElement>("first", "", *payload->getFirstID());
- if (payload->getFirstIDIndex()) {
- firstElement->setAttribute("index", boost::lexical_cast<std::string>(*payload->getFirstIDIndex()));
- }
- element.addNode(firstElement);
- }
+ if (payload->getFirstID()) {
+ boost::shared_ptr<XMLElement> firstElement = boost::make_shared<XMLElement>("first", "", *payload->getFirstID());
+ if (payload->getFirstIDIndex()) {
+ firstElement->setAttribute("index", boost::lexical_cast<std::string>(*payload->getFirstIDIndex()));
+ }
+ element.addNode(firstElement);
+ }
- if (payload->getLastID()) {
- element.addNode(boost::make_shared<XMLElement>("last", "", *payload->getLastID()));
- }
+ if (payload->getLastID()) {
+ element.addNode(boost::make_shared<XMLElement>("last", "", *payload->getLastID()));
+ }
- if (payload->getBefore()) {
- element.addNode(boost::make_shared<XMLElement>("before", "", *payload->getBefore()));
- }
+ if (payload->getBefore()) {
+ element.addNode(boost::make_shared<XMLElement>("before", "", *payload->getBefore()));
+ }
- if (payload->getAfter()) {
- element.addNode(boost::make_shared<XMLElement>("after", "", *payload->getAfter()));
- }
+ if (payload->getAfter()) {
+ element.addNode(boost::make_shared<XMLElement>("after", "", *payload->getAfter()));
+ }
- return element.serialize();
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h
index 7c4a0c9..9d8e24d 100644
--- a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API ResultSetSerializer : public GenericPayloadSerializer<ResultSet> {
- public:
- ResultSetSerializer();
- virtual ~ResultSetSerializer();
+ class SWIFTEN_API ResultSetSerializer : public GenericPayloadSerializer<ResultSet> {
+ public:
+ ResultSetSerializer();
+ virtual ~ResultSetSerializer();
- virtual std::string serializePayload(boost::shared_ptr<ResultSet>) const SWIFTEN_OVERRIDE;
- };
+ virtual std::string serializePayload(boost::shared_ptr<ResultSet>) const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp
index 54c31bd..f0b19e1 100644
--- a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp
@@ -26,28 +26,28 @@ RosterItemExchangeSerializer::RosterItemExchangeSerializer() : GenericPayloadSer
}
std::string RosterItemExchangeSerializer::serializePayload(boost::shared_ptr<RosterItemExchangePayload> roster) const {
- XMLElement queryElement("x", "http://jabber.org/protocol/rosterx");
- foreach(const RosterItemExchangePayload::Item& item, roster->getItems()) {
- boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
- itemElement->setAttribute("jid", item.getJID());
- itemElement->setAttribute("name", item.getName());
-
- switch (item.getAction()) {
- case RosterItemExchangePayload::Item::Add: itemElement->setAttribute("action", "add"); break;
- case RosterItemExchangePayload::Item::Modify: itemElement->setAttribute("action", "modify"); break;
- case RosterItemExchangePayload::Item::Delete: itemElement->setAttribute("action", "delete"); break;
- }
-
- foreach(const std::string& group, item.getGroups()) {
- boost::shared_ptr<XMLElement> groupElement(new XMLElement("group"));
- groupElement->addNode(boost::make_shared<XMLTextNode>(group));
- itemElement->addNode(groupElement);
- }
-
- queryElement.addNode(itemElement);
- }
-
- return queryElement.serialize();
+ XMLElement queryElement("x", "http://jabber.org/protocol/rosterx");
+ foreach(const RosterItemExchangePayload::Item& item, roster->getItems()) {
+ boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
+ itemElement->setAttribute("jid", item.getJID());
+ itemElement->setAttribute("name", item.getName());
+
+ switch (item.getAction()) {
+ case RosterItemExchangePayload::Item::Add: itemElement->setAttribute("action", "add"); break;
+ case RosterItemExchangePayload::Item::Modify: itemElement->setAttribute("action", "modify"); break;
+ case RosterItemExchangePayload::Item::Delete: itemElement->setAttribute("action", "delete"); break;
+ }
+
+ foreach(const std::string& group, item.getGroups()) {
+ boost::shared_ptr<XMLElement> groupElement(new XMLElement("group"));
+ groupElement->addNode(boost::make_shared<XMLTextNode>(group));
+ itemElement->addNode(groupElement);
+ }
+
+ queryElement.addNode(itemElement);
+ }
+
+ return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.h b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.h
index 8fbc202..ec4e81e 100644
--- a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.h
@@ -17,10 +17,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API RosterItemExchangeSerializer : public GenericPayloadSerializer<RosterItemExchangePayload> {
- public:
- RosterItemExchangeSerializer();
+ class SWIFTEN_API RosterItemExchangeSerializer : public GenericPayloadSerializer<RosterItemExchangePayload> {
+ public:
+ RosterItemExchangeSerializer();
- virtual std::string serializePayload(boost::shared_ptr<RosterItemExchangePayload>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<RosterItemExchangePayload>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp
index b90e859..1094f2d 100644
--- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp
@@ -20,42 +20,42 @@ RosterSerializer::RosterSerializer() : GenericPayloadSerializer<RosterPayload>()
}
std::string RosterSerializer::serializePayload(boost::shared_ptr<RosterPayload> roster) const {
- XMLElement queryElement("query", "jabber:iq:roster");
- if (roster->getVersion()) {
- queryElement.setAttribute("ver", *roster->getVersion());
- }
- foreach(const RosterItemPayload& item, roster->getItems()) {
- boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
- itemElement->setAttribute("jid", item.getJID());
- itemElement->setAttribute("name", item.getName());
-
- switch (item.getSubscription()) {
- case RosterItemPayload::To: itemElement->setAttribute("subscription", "to"); break;
- case RosterItemPayload::From: itemElement->setAttribute("subscription", "from"); break;
- case RosterItemPayload::Both: itemElement->setAttribute("subscription", "both"); break;
- case RosterItemPayload::Remove: itemElement->setAttribute("subscription", "remove"); break;
- case RosterItemPayload::None: itemElement->setAttribute("subscription", "none"); break;
- }
-
- if (item.getSubscriptionRequested()) {
- itemElement->setAttribute("ask", "subscribe");
- }
-
- foreach(const std::string& group, item.getGroups()) {
- boost::shared_ptr<XMLElement> groupElement(new XMLElement("group"));
- groupElement->addNode(boost::make_shared<XMLTextNode>(group));
- itemElement->addNode(groupElement);
- }
-
- if (!item.getUnknownContent().empty()) {
- itemElement->addNode(boost::make_shared<XMLRawTextNode>(item.getUnknownContent()));
- }
-
-
- queryElement.addNode(itemElement);
- }
-
- return queryElement.serialize();
+ XMLElement queryElement("query", "jabber:iq:roster");
+ if (roster->getVersion()) {
+ queryElement.setAttribute("ver", *roster->getVersion());
+ }
+ foreach(const RosterItemPayload& item, roster->getItems()) {
+ boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
+ itemElement->setAttribute("jid", item.getJID());
+ itemElement->setAttribute("name", item.getName());
+
+ switch (item.getSubscription()) {
+ case RosterItemPayload::To: itemElement->setAttribute("subscription", "to"); break;
+ case RosterItemPayload::From: itemElement->setAttribute("subscription", "from"); break;
+ case RosterItemPayload::Both: itemElement->setAttribute("subscription", "both"); break;
+ case RosterItemPayload::Remove: itemElement->setAttribute("subscription", "remove"); break;
+ case RosterItemPayload::None: itemElement->setAttribute("subscription", "none"); break;
+ }
+
+ if (item.getSubscriptionRequested()) {
+ itemElement->setAttribute("ask", "subscribe");
+ }
+
+ foreach(const std::string& group, item.getGroups()) {
+ boost::shared_ptr<XMLElement> groupElement(new XMLElement("group"));
+ groupElement->addNode(boost::make_shared<XMLTextNode>(group));
+ itemElement->addNode(groupElement);
+ }
+
+ if (!item.getUnknownContent().empty()) {
+ itemElement->addNode(boost::make_shared<XMLRawTextNode>(item.getUnknownContent()));
+ }
+
+
+ queryElement.addNode(itemElement);
+ }
+
+ return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.h b/Swiften/Serializer/PayloadSerializers/RosterSerializer.h
index 1788d7b..799d88f 100644
--- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API RosterSerializer : public GenericPayloadSerializer<RosterPayload> {
- public:
- RosterSerializer();
+ class SWIFTEN_API RosterSerializer : public GenericPayloadSerializer<RosterPayload> {
+ public:
+ RosterSerializer();
- virtual std::string serializePayload(boost::shared_ptr<RosterPayload>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<RosterPayload>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h b/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h
index 062e7c6..f10bcfc 100644
--- a/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h
@@ -21,24 +21,24 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API S5BProxyRequestSerializer : public GenericPayloadSerializer<S5BProxyRequest> {
- public:
- virtual std::string serializePayload(boost::shared_ptr<S5BProxyRequest> s5bProxyRequest) const {
- XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams");
- if (s5bProxyRequest && s5bProxyRequest->getStreamHost()) {
- boost::shared_ptr<XMLElement> streamHost = boost::make_shared<XMLElement>("streamhost");
- streamHost->setAttribute("host", s5bProxyRequest->getStreamHost().get().host);
- streamHost->setAttribute("port", boost::lexical_cast<std::string>(s5bProxyRequest->getStreamHost().get().port));
- streamHost->setAttribute("jid", s5bProxyRequest->getStreamHost().get().jid.toString());
- queryElement.addNode(streamHost);
- } else if (s5bProxyRequest && s5bProxyRequest->getActivate()) {
- queryElement.setAttribute("sid", s5bProxyRequest->getSID());
- boost::shared_ptr<XMLElement> activate = boost::make_shared<XMLElement>("activate", "", s5bProxyRequest->getActivate().get().toString());
- queryElement.addNode(activate);
- }
- return queryElement.serialize();
- }
- };
+ class SWIFTEN_API S5BProxyRequestSerializer : public GenericPayloadSerializer<S5BProxyRequest> {
+ public:
+ virtual std::string serializePayload(boost::shared_ptr<S5BProxyRequest> s5bProxyRequest) const {
+ XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams");
+ if (s5bProxyRequest && s5bProxyRequest->getStreamHost()) {
+ boost::shared_ptr<XMLElement> streamHost = boost::make_shared<XMLElement>("streamhost");
+ streamHost->setAttribute("host", s5bProxyRequest->getStreamHost().get().host);
+ streamHost->setAttribute("port", boost::lexical_cast<std::string>(s5bProxyRequest->getStreamHost().get().port));
+ streamHost->setAttribute("jid", s5bProxyRequest->getStreamHost().get().jid.toString());
+ queryElement.addNode(streamHost);
+ } else if (s5bProxyRequest && s5bProxyRequest->getActivate()) {
+ queryElement.setAttribute("sid", s5bProxyRequest->getSID());
+ boost::shared_ptr<XMLElement> activate = boost::make_shared<XMLElement>("activate", "", s5bProxyRequest->getActivate().get().toString());
+ queryElement.addNode(activate);
+ }
+ return queryElement.serialize();
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp
index e2cb766..de036df 100644
--- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp
@@ -19,45 +19,45 @@ namespace Swift {
SearchPayloadSerializer::SearchPayloadSerializer() {
}
-std::string SearchPayloadSerializer::serializePayload(boost::shared_ptr<SearchPayload> searchPayload) const {
- XMLElement searchElement("query", "jabber:iq:search");
+std::string SearchPayloadSerializer::serializePayload(boost::shared_ptr<SearchPayload> searchPayload) const {
+ XMLElement searchElement("query", "jabber:iq:search");
- if (searchPayload->getInstructions()) {
- searchElement.addNode(XMLElement::ref(new XMLElement("instructions", "", *searchPayload->getInstructions())));
- }
+ if (searchPayload->getInstructions()) {
+ searchElement.addNode(XMLElement::ref(new XMLElement("instructions", "", *searchPayload->getInstructions())));
+ }
- if (searchPayload->getNick()) {
- searchElement.addNode(XMLElement::ref(new XMLElement("nick", "", *searchPayload->getNick())));
- }
+ if (searchPayload->getNick()) {
+ searchElement.addNode(XMLElement::ref(new XMLElement("nick", "", *searchPayload->getNick())));
+ }
- if (searchPayload->getFirst()) {
- searchElement.addNode(XMLElement::ref(new XMLElement("first", "", *searchPayload->getFirst())));
- }
+ if (searchPayload->getFirst()) {
+ searchElement.addNode(XMLElement::ref(new XMLElement("first", "", *searchPayload->getFirst())));
+ }
- if (searchPayload->getLast()) {
- searchElement.addNode(XMLElement::ref(new XMLElement("last", "", *searchPayload->getLast())));
- }
+ if (searchPayload->getLast()) {
+ searchElement.addNode(XMLElement::ref(new XMLElement("last", "", *searchPayload->getLast())));
+ }
- if (searchPayload->getEMail()) {
- searchElement.addNode(XMLElement::ref(new XMLElement("email", "", *searchPayload->getEMail())));
- }
+ if (searchPayload->getEMail()) {
+ searchElement.addNode(XMLElement::ref(new XMLElement("email", "", *searchPayload->getEMail())));
+ }
- foreach(const SearchPayload::Item& item, searchPayload->getItems()) {
- XMLElement::ref itemElement(new XMLElement("item"));
- itemElement->setAttribute("jid", item.jid);
- itemElement->addNode(XMLElement::ref(new XMLElement("first", "", item.first)));
- itemElement->addNode(XMLElement::ref(new XMLElement("last", "", item.last)));
- itemElement->addNode(XMLElement::ref(new XMLElement("nick", "", item.nick)));
- itemElement->addNode(XMLElement::ref(new XMLElement("email", "", item.email)));
+ foreach(const SearchPayload::Item& item, searchPayload->getItems()) {
+ XMLElement::ref itemElement(new XMLElement("item"));
+ itemElement->setAttribute("jid", item.jid);
+ itemElement->addNode(XMLElement::ref(new XMLElement("first", "", item.first)));
+ itemElement->addNode(XMLElement::ref(new XMLElement("last", "", item.last)));
+ itemElement->addNode(XMLElement::ref(new XMLElement("nick", "", item.nick)));
+ itemElement->addNode(XMLElement::ref(new XMLElement("email", "", item.email)));
- searchElement.addNode(itemElement);
- }
+ searchElement.addNode(itemElement);
+ }
- if (Form::ref form = searchPayload->getForm()) {
- searchElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
- }
+ if (Form::ref form = searchPayload->getForm()) {
+ searchElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
+ }
- return searchElement.serialize();
+ return searchElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h
index ff5e2cc..594e5d7 100644
--- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h
@@ -12,12 +12,12 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API SearchPayloadSerializer : public GenericPayloadSerializer<SearchPayload> {
- public:
- SearchPayloadSerializer();
+ class SWIFTEN_API SearchPayloadSerializer : public GenericPayloadSerializer<SearchPayload> {
+ public:
+ SearchPayloadSerializer();
- virtual std::string serializePayload(boost::shared_ptr<SearchPayload>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<SearchPayload>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
index fb7092c..9b35952 100644
--- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
@@ -19,29 +19,29 @@ SecurityLabelSerializer::SecurityLabelSerializer() : GenericPayloadSerializer<Se
}
std::string SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel> label) const {
- XMLElement element("securitylabel", "urn:xmpp:sec-label:0");
- if (!label->getDisplayMarking().empty()) {
- boost::shared_ptr<XMLElement> displayMarking(new XMLElement("displaymarking"));
- if (!label->getForegroundColor().empty()) {
- displayMarking->setAttribute("fgcolor", label->getForegroundColor());
- }
- if (!label->getBackgroundColor().empty()) {
- displayMarking->setAttribute("bgcolor", label->getBackgroundColor());
- }
- displayMarking->addNode(boost::make_shared<XMLTextNode>(label->getDisplayMarking()));
- element.addNode(displayMarking);
- }
-
- boost::shared_ptr<XMLElement> labelElement(new XMLElement("label"));
- labelElement->addNode(boost::make_shared<XMLRawTextNode>(label->getLabel()));
- element.addNode(labelElement);
-
- foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) {
- boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel"));
- equivalentLabelElement->addNode(boost::make_shared<XMLRawTextNode>(equivalentLabel));
- element.addNode(equivalentLabelElement);
- }
- return element.serialize();
+ XMLElement element("securitylabel", "urn:xmpp:sec-label:0");
+ if (!label->getDisplayMarking().empty()) {
+ boost::shared_ptr<XMLElement> displayMarking(new XMLElement("displaymarking"));
+ if (!label->getForegroundColor().empty()) {
+ displayMarking->setAttribute("fgcolor", label->getForegroundColor());
+ }
+ if (!label->getBackgroundColor().empty()) {
+ displayMarking->setAttribute("bgcolor", label->getBackgroundColor());
+ }
+ displayMarking->addNode(boost::make_shared<XMLTextNode>(label->getDisplayMarking()));
+ element.addNode(displayMarking);
+ }
+
+ boost::shared_ptr<XMLElement> labelElement(new XMLElement("label"));
+ labelElement->addNode(boost::make_shared<XMLRawTextNode>(label->getLabel()));
+ element.addNode(labelElement);
+
+ foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) {
+ boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel"));
+ equivalentLabelElement->addNode(boost::make_shared<XMLRawTextNode>(equivalentLabel));
+ element.addNode(equivalentLabelElement);
+ }
+ return element.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h
index cf95243..23f50f4 100644
--- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API SecurityLabelSerializer : public GenericPayloadSerializer<SecurityLabel> {
- public:
- SecurityLabelSerializer();
+ class SWIFTEN_API SecurityLabelSerializer : public GenericPayloadSerializer<SecurityLabel> {
+ public:
+ SecurityLabelSerializer();
- virtual std::string serializePayload(boost::shared_ptr<SecurityLabel> version) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<SecurityLabel> version) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp
index 1aeae06..2bf6bbb 100644
--- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp
@@ -19,29 +19,29 @@ SecurityLabelsCatalogSerializer::SecurityLabelsCatalogSerializer() : GenericPayl
}
std::string SecurityLabelsCatalogSerializer::serializePayload(boost::shared_ptr<SecurityLabelsCatalog> catalog) const {
- XMLElement element("catalog", "urn:xmpp:sec-label:catalog:2");
- if (!catalog->getName().empty()) {
- element.setAttribute("name", catalog->getName());
- }
- if (catalog->getTo().isValid()) {
- element.setAttribute("to", catalog->getTo());
- }
- if (!catalog->getDescription().empty()) {
- element.setAttribute("desc", catalog->getDescription());
- }
- foreach (const SecurityLabelsCatalog::Item& item, catalog->getItems()) {
- boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
- itemElement->setAttribute("selector", item.getSelector());
- if (item.getIsDefault()) {
- itemElement->setAttribute("default", "true");
- }
- if (item.getLabel()) {
- std::string serializedLabel = SecurityLabelSerializer().serialize(item.getLabel());
- itemElement->addNode(boost::make_shared<XMLRawTextNode>(serializedLabel));
- }
- element.addNode(itemElement);
- }
- return element.serialize();
+ XMLElement element("catalog", "urn:xmpp:sec-label:catalog:2");
+ if (!catalog->getName().empty()) {
+ element.setAttribute("name", catalog->getName());
+ }
+ if (catalog->getTo().isValid()) {
+ element.setAttribute("to", catalog->getTo());
+ }
+ if (!catalog->getDescription().empty()) {
+ element.setAttribute("desc", catalog->getDescription());
+ }
+ foreach (const SecurityLabelsCatalog::Item& item, catalog->getItems()) {
+ boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
+ itemElement->setAttribute("selector", item.getSelector());
+ if (item.getIsDefault()) {
+ itemElement->setAttribute("default", "true");
+ }
+ if (item.getLabel()) {
+ std::string serializedLabel = SecurityLabelSerializer().serialize(item.getLabel());
+ itemElement->addNode(boost::make_shared<XMLRawTextNode>(serializedLabel));
+ }
+ element.addNode(itemElement);
+ }
+ return element.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h
index 3829995..da3b7f3 100644
--- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API SecurityLabelsCatalogSerializer : public GenericPayloadSerializer<SecurityLabelsCatalog> {
- public:
- SecurityLabelsCatalogSerializer();
+ class SWIFTEN_API SecurityLabelsCatalogSerializer : public GenericPayloadSerializer<SecurityLabelsCatalog> {
+ public:
+ SecurityLabelsCatalogSerializer();
- virtual std::string serializePayload(boost::shared_ptr<SecurityLabelsCatalog> version) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<SecurityLabelsCatalog> version) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp
index 8c0c605..05beaae 100644
--- a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp
@@ -12,18 +12,18 @@ SoftwareVersionSerializer::SoftwareVersionSerializer() : GenericPayloadSerialize
}
std::string SoftwareVersionSerializer::serializePayload(boost::shared_ptr<SoftwareVersion> version) const {
- std::string result("<query xmlns=\"jabber:iq:version\">");
- if (!version->getName().empty()) {
- result += "<name>" + version->getName() + "</name>";
- }
- if (!version->getVersion().empty()) {
- result += "<version>" + version->getVersion() + "</version>";
- }
- if (!version->getOS().empty()) {
- result += "<os>" + version->getOS() + "</os>";
- }
- result += "</query>";
- return result;
+ std::string result("<query xmlns=\"jabber:iq:version\">");
+ if (!version->getName().empty()) {
+ result += "<name>" + version->getName() + "</name>";
+ }
+ if (!version->getVersion().empty()) {
+ result += "<version>" + version->getVersion() + "</version>";
+ }
+ if (!version->getOS().empty()) {
+ result += "<os>" + version->getOS() + "</os>";
+ }
+ result += "</query>";
+ return result;
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h
index d514df0..6c03c84 100644
--- a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API SoftwareVersionSerializer : public GenericPayloadSerializer<SoftwareVersion> {
- public:
- SoftwareVersionSerializer();
+ class SWIFTEN_API SoftwareVersionSerializer : public GenericPayloadSerializer<SoftwareVersion> {
+ public:
+ SoftwareVersionSerializer();
- virtual std::string serializePayload(boost::shared_ptr<SoftwareVersion> version) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<SoftwareVersion> version) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h b/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h
index 1815955..086652f 100644
--- a/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h
@@ -14,12 +14,12 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API StartSessionSerializer : public GenericPayloadSerializer<StartSession> {
- public:
- StartSessionSerializer() : GenericPayloadSerializer<StartSession>() {}
+ class SWIFTEN_API StartSessionSerializer : public GenericPayloadSerializer<StartSession> {
+ public:
+ StartSessionSerializer() : GenericPayloadSerializer<StartSession>() {}
- virtual std::string serializePayload(boost::shared_ptr<StartSession>) const {
- return XMLElement("session", "urn:ietf:params:xml:ns:xmpp-session").serialize();
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<StartSession>) const {
+ return XMLElement("session", "urn:ietf:params:xml:ns:xmpp-session").serialize();
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h
index fb30744..8247e28 100644
--- a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h
@@ -15,14 +15,14 @@
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
- class SWIFTEN_API StatusSerializer : public GenericPayloadSerializer<Status> {
- public:
- StatusSerializer() : GenericPayloadSerializer<Status>() {}
+ class SWIFTEN_API StatusSerializer : public GenericPayloadSerializer<Status> {
+ public:
+ StatusSerializer() : GenericPayloadSerializer<Status>() {}
- virtual std::string serializePayload(boost::shared_ptr<Status> status) const {
- XMLElement element("status");
- element.addNode(boost::make_shared<XMLTextNode>(status->getText()));
- return element.serialize();
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<Status> status) const {
+ XMLElement element("status");
+ element.addNode(boost::make_shared<XMLTextNode>(status->getText()));
+ return element.serialize();
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h b/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h
index 13462f3..24fbe1b 100644
--- a/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h
@@ -11,27 +11,27 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API StatusShowSerializer : public GenericPayloadSerializer<StatusShow> {
- public:
- StatusShowSerializer() : GenericPayloadSerializer<StatusShow>() {}
+ class SWIFTEN_API StatusShowSerializer : public GenericPayloadSerializer<StatusShow> {
+ public:
+ StatusShowSerializer() : GenericPayloadSerializer<StatusShow>() {}
- virtual std::string serializePayload(boost::shared_ptr<StatusShow> statusShow) const {
- if (statusShow->getType () == StatusShow::Online || statusShow->getType() == StatusShow::None) {
- return "";
- }
- else {
- std::string result("<show>");
- switch (statusShow->getType()) {
- case StatusShow::Away: result += "away"; break;
- case StatusShow::XA: result += "xa"; break;
- case StatusShow::FFC: result += "chat"; break;
- case StatusShow::DND: result += "dnd"; break;
- case StatusShow::Online: assert(false); break;
- case StatusShow::None: assert(false); break;
- }
- result += "</show>";
- return result;
- }
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<StatusShow> statusShow) const {
+ if (statusShow->getType () == StatusShow::Online || statusShow->getType() == StatusShow::None) {
+ return "";
+ }
+ else {
+ std::string result("<show>");
+ switch (statusShow->getType()) {
+ case StatusShow::Away: result += "away"; break;
+ case StatusShow::XA: result += "xa"; break;
+ case StatusShow::FFC: result += "chat"; break;
+ case StatusShow::DND: result += "dnd"; break;
+ case StatusShow::Online: assert(false); break;
+ case StatusShow::None: assert(false); break;
+ }
+ result += "</show>";
+ return result;
+ }
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
index 45d8f8e..64ea62c 100644
--- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
@@ -18,35 +18,35 @@ namespace Swift {
StorageSerializer::StorageSerializer() : GenericPayloadSerializer<Storage>() {
}
-std::string StorageSerializer::serializePayload(boost::shared_ptr<Storage> storage) const {
- XMLElement storageElement("storage", "storage:bookmarks");
-
- foreach(const Storage::Room& room, storage->getRooms()) {
- boost::shared_ptr<XMLElement> conferenceElement(new XMLElement("conference"));
- conferenceElement->setAttribute("name", room.name);
- conferenceElement->setAttribute("jid", room.jid);
- conferenceElement->setAttribute("autojoin", room.autoJoin ? "1" : "0");
- if (!room.nick.empty()) {
- boost::shared_ptr<XMLElement> nickElement(new XMLElement("nick"));
- nickElement->addNode(boost::make_shared<XMLTextNode>(room.nick));
- conferenceElement->addNode(nickElement);
- }
- if (room.password) {
- boost::shared_ptr<XMLElement> passwordElement(new XMLElement("password"));
- passwordElement->addNode(boost::make_shared<XMLTextNode>(*room.password));
- conferenceElement->addNode(passwordElement);
- }
- storageElement.addNode(conferenceElement);
- }
-
- foreach(const Storage::URL& url, storage->getURLs()) {
- boost::shared_ptr<XMLElement> urlElement(new XMLElement("url"));
- urlElement->setAttribute("name", url.name);
- urlElement->setAttribute("url", url.url);
- storageElement.addNode(urlElement);
- }
-
- return storageElement.serialize();
+std::string StorageSerializer::serializePayload(boost::shared_ptr<Storage> storage) const {
+ XMLElement storageElement("storage", "storage:bookmarks");
+
+ foreach(const Storage::Room& room, storage->getRooms()) {
+ boost::shared_ptr<XMLElement> conferenceElement(new XMLElement("conference"));
+ conferenceElement->setAttribute("name", room.name);
+ conferenceElement->setAttribute("jid", room.jid);
+ conferenceElement->setAttribute("autojoin", room.autoJoin ? "1" : "0");
+ if (!room.nick.empty()) {
+ boost::shared_ptr<XMLElement> nickElement(new XMLElement("nick"));
+ nickElement->addNode(boost::make_shared<XMLTextNode>(room.nick));
+ conferenceElement->addNode(nickElement);
+ }
+ if (room.password) {
+ boost::shared_ptr<XMLElement> passwordElement(new XMLElement("password"));
+ passwordElement->addNode(boost::make_shared<XMLTextNode>(*room.password));
+ conferenceElement->addNode(passwordElement);
+ }
+ storageElement.addNode(conferenceElement);
+ }
+
+ foreach(const Storage::URL& url, storage->getURLs()) {
+ boost::shared_ptr<XMLElement> urlElement(new XMLElement("url"));
+ urlElement->setAttribute("name", url.name);
+ urlElement->setAttribute("url", url.url);
+ storageElement.addNode(urlElement);
+ }
+
+ return storageElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.h b/Swiften/Serializer/PayloadSerializers/StorageSerializer.h
index 6d62f35..a3a55f4 100644
--- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API StorageSerializer : public GenericPayloadSerializer<Storage> {
- public:
- StorageSerializer();
+ class SWIFTEN_API StorageSerializer : public GenericPayloadSerializer<Storage> {
+ public:
+ StorageSerializer();
- virtual std::string serializePayload(boost::shared_ptr<Storage>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<Storage>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp
index 06e28d8..a64d7ae 100644
--- a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp
@@ -26,35 +26,35 @@ namespace Swift {
StreamInitiationFileInfoSerializer::StreamInitiationFileInfoSerializer() {
}
-
+
std::string StreamInitiationFileInfoSerializer::serializePayload(boost::shared_ptr<StreamInitiationFileInfo> fileInfo) const {
- XMLElement fileElement("file", "http://jabber.org/protocol/si/profile/file-transfer");
-
- if (fileInfo->getDate() != stringToDateTime("")) {
- fileElement.setAttribute("date", dateTimeToString(fileInfo->getDate()));
- }
- fileElement.setAttribute("hash", fileInfo->getHash());
- if (fileInfo->getAlgo() != "md5") {
- fileElement.setAttribute("algo", fileInfo->getAlgo());
- }
- if (!fileInfo->getName().empty()) {
- fileElement.setAttribute("name", fileInfo->getName());
- }
- if (fileInfo->getSize() != 0) {
- fileElement.setAttribute("size", boost::lexical_cast<std::string>(fileInfo->getSize()));
- }
- if (!fileInfo->getDescription().empty()) {
- boost::shared_ptr<XMLElement> desc = boost::make_shared<XMLElement>("desc", "", fileInfo->getDescription());
- fileElement.addNode(desc);
- }
- if (fileInfo->getSupportsRangeRequests()) {
- boost::shared_ptr<XMLElement> range = boost::make_shared<XMLElement>("range");
- if (fileInfo->getRangeOffset() != 0) {
- range->setAttribute("offset", boost::lexical_cast<std::string>(fileInfo->getRangeOffset()));
- }
- fileElement.addNode(range);
- }
- return fileElement.serialize();
+ XMLElement fileElement("file", "http://jabber.org/protocol/si/profile/file-transfer");
+
+ if (fileInfo->getDate() != stringToDateTime("")) {
+ fileElement.setAttribute("date", dateTimeToString(fileInfo->getDate()));
+ }
+ fileElement.setAttribute("hash", fileInfo->getHash());
+ if (fileInfo->getAlgo() != "md5") {
+ fileElement.setAttribute("algo", fileInfo->getAlgo());
+ }
+ if (!fileInfo->getName().empty()) {
+ fileElement.setAttribute("name", fileInfo->getName());
+ }
+ if (fileInfo->getSize() != 0) {
+ fileElement.setAttribute("size", boost::lexical_cast<std::string>(fileInfo->getSize()));
+ }
+ if (!fileInfo->getDescription().empty()) {
+ boost::shared_ptr<XMLElement> desc = boost::make_shared<XMLElement>("desc", "", fileInfo->getDescription());
+ fileElement.addNode(desc);
+ }
+ if (fileInfo->getSupportsRangeRequests()) {
+ boost::shared_ptr<XMLElement> range = boost::make_shared<XMLElement>("range");
+ if (fileInfo->getRangeOffset() != 0) {
+ range->setAttribute("offset", boost::lexical_cast<std::string>(fileInfo->getRangeOffset()));
+ }
+ fileElement.addNode(range);
+ }
+ return fileElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.h
index 50268c5..e7714f0 100644
--- a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.h
@@ -19,12 +19,12 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API StreamInitiationFileInfoSerializer : public GenericPayloadSerializer<StreamInitiationFileInfo> {
- public:
- StreamInitiationFileInfoSerializer();
+ class SWIFTEN_API StreamInitiationFileInfoSerializer : public GenericPayloadSerializer<StreamInitiationFileInfo> {
+ public:
+ StreamInitiationFileInfoSerializer();
- virtual std::string serializePayload(boost::shared_ptr<StreamInitiationFileInfo>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<StreamInitiationFileInfo>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
index bd44040..824569a 100644
--- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
@@ -25,51 +25,51 @@ namespace Swift {
StreamInitiationSerializer::StreamInitiationSerializer() {
}
-std::string StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInitiation> streamInitiation) const {
- assert(streamInitiation->getIsFileTransfer());
+std::string StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInitiation> streamInitiation) const {
+ assert(streamInitiation->getIsFileTransfer());
- XMLElement siElement("si", "http://jabber.org/protocol/si");
- if (!streamInitiation->getID().empty()) {
- siElement.setAttribute("id", streamInitiation->getID());
- }
- siElement.setAttribute("profile", FILE_TRANSFER_NS);
+ XMLElement siElement("si", "http://jabber.org/protocol/si");
+ if (!streamInitiation->getID().empty()) {
+ siElement.setAttribute("id", streamInitiation->getID());
+ }
+ siElement.setAttribute("profile", FILE_TRANSFER_NS);
- if (streamInitiation->getFileInfo()) {
- StreamInitiationFileInfo file = *streamInitiation->getFileInfo();
- boost::shared_ptr<XMLElement> fileElement(new XMLElement("file", "http://jabber.org/protocol/si/profile/file-transfer"));
- fileElement->setAttribute("name", file.getName());
- if (file.getSize() != 0) {
- fileElement->setAttribute("size", boost::lexical_cast<std::string>(file.getSize()));
- }
- if (!file.getDescription().empty()) {
- boost::shared_ptr<XMLElement> descElement(new XMLElement("desc"));
- descElement->addNode(boost::make_shared<XMLTextNode>(file.getDescription()));
- fileElement->addNode(descElement);
- }
- siElement.addNode(fileElement);
- }
+ if (streamInitiation->getFileInfo()) {
+ StreamInitiationFileInfo file = *streamInitiation->getFileInfo();
+ boost::shared_ptr<XMLElement> fileElement(new XMLElement("file", "http://jabber.org/protocol/si/profile/file-transfer"));
+ fileElement->setAttribute("name", file.getName());
+ if (file.getSize() != 0) {
+ fileElement->setAttribute("size", boost::lexical_cast<std::string>(file.getSize()));
+ }
+ if (!file.getDescription().empty()) {
+ boost::shared_ptr<XMLElement> descElement(new XMLElement("desc"));
+ descElement->addNode(boost::make_shared<XMLTextNode>(file.getDescription()));
+ fileElement->addNode(descElement);
+ }
+ siElement.addNode(fileElement);
+ }
- boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature", FEATURE_NEG_NS));
- if (streamInitiation->getProvidedMethods().size() > 0) {
- Form::ref form(new Form(Form::FormType));
- FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
- field->setName("stream-method");
- foreach(const std::string& method, streamInitiation->getProvidedMethods()) {
- field->addOption(FormField::Option("", method));
- }
- form->addField(field);
- featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
- }
- else if (!streamInitiation->getRequestedMethod().empty()) {
- Form::ref form(new Form(Form::SubmitType));
- FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
- field->addValue(streamInitiation->getRequestedMethod());
- field->setName("stream-method");
- form->addField(field);
- featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
- }
- siElement.addNode(featureElement);
- return siElement.serialize();
+ boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature", FEATURE_NEG_NS));
+ if (streamInitiation->getProvidedMethods().size() > 0) {
+ Form::ref form(new Form(Form::FormType));
+ FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
+ field->setName("stream-method");
+ foreach(const std::string& method, streamInitiation->getProvidedMethods()) {
+ field->addOption(FormField::Option("", method));
+ }
+ form->addField(field);
+ featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
+ }
+ else if (!streamInitiation->getRequestedMethod().empty()) {
+ Form::ref form(new Form(Form::SubmitType));
+ FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
+ field->addValue(streamInitiation->getRequestedMethod());
+ field->setName("stream-method");
+ form->addField(field);
+ featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
+ }
+ siElement.addNode(featureElement);
+ return siElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h
index f83b2b8..056806e 100644
--- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API StreamInitiationSerializer : public GenericPayloadSerializer<StreamInitiation> {
- public:
- StreamInitiationSerializer();
+ class SWIFTEN_API StreamInitiationSerializer : public GenericPayloadSerializer<StreamInitiation> {
+ public:
+ StreamInitiationSerializer();
- virtual std::string serializePayload(boost::shared_ptr<StreamInitiation>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<StreamInitiation>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h b/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h
index 7e113c5..9f90ce0 100644
--- a/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h
@@ -12,13 +12,13 @@
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
- class SWIFTEN_API SubjectSerializer : public GenericPayloadSerializer<Subject> {
- public:
- SubjectSerializer() : GenericPayloadSerializer<Subject>() {}
+ class SWIFTEN_API SubjectSerializer : public GenericPayloadSerializer<Subject> {
+ public:
+ SubjectSerializer() : GenericPayloadSerializer<Subject>() {}
- virtual std::string serializePayload(boost::shared_ptr<Subject> subject) const {
- XMLTextNode textNode(subject->getText());
- return "<subject>" + textNode.serialize() + "</subject>";
- }
- };
+ virtual std::string serializePayload(boost::shared_ptr<Subject> subject) const {
+ XMLTextNode textNode(subject->getText());
+ return "<subject>" + textNode.serialize() + "</subject>";
+ }
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/ThreadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ThreadSerializer.cpp
index cc4d573..61b91ae 100644
--- a/Swiften/Serializer/PayloadSerializers/ThreadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ThreadSerializer.cpp
@@ -9,17 +9,17 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- ThreadSerializer::ThreadSerializer() : GenericPayloadSerializer<Thread>() {
- }
+ ThreadSerializer::ThreadSerializer() : GenericPayloadSerializer<Thread>() {
+ }
- ThreadSerializer::~ThreadSerializer() {
- }
+ ThreadSerializer::~ThreadSerializer() {
+ }
- std::string ThreadSerializer::serializePayload(boost::shared_ptr<Thread> thread) const {
- XMLElement threadNode("thread", "", thread->getText());
- if (!thread->getParent().empty()) {
- threadNode.setAttribute("parent", thread->getParent());
- }
- return threadNode.serialize();
- }
+ std::string ThreadSerializer::serializePayload(boost::shared_ptr<Thread> thread) const {
+ XMLElement threadNode("thread", "", thread->getText());
+ if (!thread->getParent().empty()) {
+ threadNode.setAttribute("parent", thread->getParent());
+ }
+ return threadNode.serialize();
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/ThreadSerializer.h b/Swiften/Serializer/PayloadSerializers/ThreadSerializer.h
index e54c39a..264faba 100644
--- a/Swiften/Serializer/PayloadSerializers/ThreadSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/ThreadSerializer.h
@@ -12,11 +12,11 @@
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
- class SWIFTEN_API ThreadSerializer : public GenericPayloadSerializer<Thread> {
- public:
- ThreadSerializer();
- virtual ~ThreadSerializer();
+ class SWIFTEN_API ThreadSerializer : public GenericPayloadSerializer<Thread> {
+ public:
+ ThreadSerializer();
+ virtual ~ThreadSerializer();
- virtual std::string serializePayload(boost::shared_ptr<Thread> thread) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<Thread> thread) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/BlockSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/BlockSerializerTest.cpp
index d130577..1dc97f8 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/BlockSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/BlockSerializerTest.cpp
@@ -23,39 +23,39 @@ using namespace Swift;
class BlockSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(BlockSerializerTest);
- CPPUNIT_TEST(testExample4);
- CPPUNIT_TEST(testExample6);
- CPPUNIT_TEST(testExample10);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- BlockSerializerTest() {}
-
- void testExample4() {
- BlockSerializer<BlockListPayload> testling("blocklist");
- boost::shared_ptr<BlockListPayload> blocklist = boost::make_shared<BlockListPayload>();
- blocklist->addItem(JID("romeo@montague.net"));
- blocklist->addItem(JID("iago@shakespeare.lit"));
-
- CPPUNIT_ASSERT_EQUAL(std::string("<blocklist xmlns=\"urn:xmpp:blocking\"><item jid=\"romeo@montague.net\"/><item jid=\"iago@shakespeare.lit\"/></blocklist>"), testling.serialize(blocklist));
- }
-
- void testExample6() {
- BlockSerializer<BlockPayload> testling("block");
- boost::shared_ptr<BlockPayload> block = boost::make_shared<BlockPayload>();
- block->addItem(JID("romeo@montague.net"));
-
- CPPUNIT_ASSERT_EQUAL(std::string("<block xmlns=\"urn:xmpp:blocking\"><item jid=\"romeo@montague.net\"/></block>"), testling.serialize(block));
- }
-
- void testExample10() {
- BlockSerializer<UnblockPayload> testling("unblock");
- boost::shared_ptr<UnblockPayload> unblock = boost::make_shared<UnblockPayload>();
- unblock->addItem(JID("romeo@montague.net"));
-
- CPPUNIT_ASSERT_EQUAL(std::string("<unblock xmlns=\"urn:xmpp:blocking\"><item jid=\"romeo@montague.net\"/></unblock>"), testling.serialize(unblock));
- }
+ CPPUNIT_TEST_SUITE(BlockSerializerTest);
+ CPPUNIT_TEST(testExample4);
+ CPPUNIT_TEST(testExample6);
+ CPPUNIT_TEST(testExample10);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ BlockSerializerTest() {}
+
+ void testExample4() {
+ BlockSerializer<BlockListPayload> testling("blocklist");
+ boost::shared_ptr<BlockListPayload> blocklist = boost::make_shared<BlockListPayload>();
+ blocklist->addItem(JID("romeo@montague.net"));
+ blocklist->addItem(JID("iago@shakespeare.lit"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<blocklist xmlns=\"urn:xmpp:blocking\"><item jid=\"romeo@montague.net\"/><item jid=\"iago@shakespeare.lit\"/></blocklist>"), testling.serialize(blocklist));
+ }
+
+ void testExample6() {
+ BlockSerializer<BlockPayload> testling("block");
+ boost::shared_ptr<BlockPayload> block = boost::make_shared<BlockPayload>();
+ block->addItem(JID("romeo@montague.net"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<block xmlns=\"urn:xmpp:blocking\"><item jid=\"romeo@montague.net\"/></block>"), testling.serialize(block));
+ }
+
+ void testExample10() {
+ BlockSerializer<UnblockPayload> testling("unblock");
+ boost::shared_ptr<UnblockPayload> unblock = boost::make_shared<UnblockPayload>();
+ unblock->addItem(JID("romeo@montague.net"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<unblock xmlns=\"urn:xmpp:blocking\"><item jid=\"romeo@montague.net\"/></unblock>"), testling.serialize(unblock));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(BlockSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp
index bdf5cbc..517e98b 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp
@@ -13,19 +13,19 @@ using namespace Swift;
class CapsInfoSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(CapsInfoSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(CapsInfoSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- CapsInfoSerializerTest() {}
+ public:
+ CapsInfoSerializerTest() {}
- void testSerialize() {
- CapsInfoSerializer testling;
- boost::shared_ptr<CapsInfo> priority(new CapsInfo("http://swift.im", "myversion", "sha-1"));
+ void testSerialize() {
+ CapsInfoSerializer testling;
+ boost::shared_ptr<CapsInfo> priority(new CapsInfo("http://swift.im", "myversion", "sha-1"));
- CPPUNIT_ASSERT_EQUAL(std::string("<c hash=\"sha-1\" node=\"http://swift.im\" ver=\"myversion\" xmlns=\"http://jabber.org/protocol/caps\"/>"), testling.serialize(priority));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<c hash=\"sha-1\" node=\"http://swift.im\" ver=\"myversion\" xmlns=\"http://jabber.org/protocol/caps\"/>"), testling.serialize(priority));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(CapsInfoSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/CarbonsSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/CarbonsSerializerTest.cpp
index b4dadf8..a0c49a6 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/CarbonsSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/CarbonsSerializerTest.cpp
@@ -20,117 +20,117 @@
#include <Swiften/Serializer/PayloadSerializers/CarbonsEnableSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/CarbonsPrivateSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/CarbonsReceivedSerializer.h>
-#include <Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/CarbonsSentSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
using namespace Swift;
class CarbonsSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(CarbonsSerializerTest);
- CPPUNIT_TEST(testSerializeExample3);
- CPPUNIT_TEST(testSerializeExample6);
- CPPUNIT_TEST(testSerializeExample12);
- CPPUNIT_TEST(testSerializeExample14);
- CPPUNIT_TEST(testSerializeExample15);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- CarbonsSerializerTest() {}
-
- /*
- * Test serializing of example 3 in XEP-0280.
- */
- void testSerializeExample3() {
- CarbonsEnableSerializer testling;
-
- CPPUNIT_ASSERT_EQUAL(std::string("<enable xmlns=\"urn:xmpp:carbons:2\"/>"), testling.serialize(boost::make_shared<CarbonsEnable>()));
- }
-
- /*
- * Test serializing of example 6 in XEP-0280.
- */
- void testSerializeExample6() {
- CarbonsDisableSerializer testling;
-
- CPPUNIT_ASSERT_EQUAL(std::string("<disable xmlns=\"urn:xmpp:carbons:2\"/>"), testling.serialize(boost::make_shared<CarbonsDisable>()));
- }
-
- /*
- * Test serializing of example 12 in XEP-0280.
- */
- void testSerializeExample12() {
- CarbonsReceivedSerializer testling(&serializers);
-
- CarbonsReceived::ref received = boost::make_shared<CarbonsReceived>();
-
- boost::shared_ptr<Forwarded> forwarded = boost::make_shared<Forwarded>();
-
- Message::ref message = boost::make_shared<Message>();
- message->setFrom(JID("juliet@capulet.example/balcony"));
- message->setTo(JID("romeo@montague.example/garden"));
- message->setBody("What man art thou that, thus bescreen'd in night, so stumblest on my counsel?");
- message->addPayload(boost::make_shared<Thread>("0e3141cd80894871a68e6fe6b1ec56fa"));
-
- forwarded->setStanza(message);
- received->setForwarded(forwarded);
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<received xmlns=\"urn:xmpp:carbons:2\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<message from=\"juliet@capulet.example/balcony\""
- " to=\"romeo@montague.example/garden\""
- " type=\"chat\""
- " xmlns=\"jabber:client\">"
- "<body>What man art thou that, thus bescreen'd in night, so stumblest on my counsel?</body>"
- "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
- "</message>"
- "</forwarded>"
- "</received>"), testling.serialize(received));
- }
-
- /*
- * Test serializing of example 14 in XEP-0280.
- */
- void testSerializeExample14() {
- CarbonsSentSerializer testling(&serializers);
-
- CarbonsSent::ref sent = boost::make_shared<CarbonsSent>();
-
- boost::shared_ptr<Forwarded> forwarded = boost::make_shared<Forwarded>();
-
- Message::ref message = boost::make_shared<Message>();
- message->setTo(JID("juliet@capulet.example/balcony"));
- message->setFrom(JID("romeo@montague.example/home"));
- message->setBody("Neither, fair saint, if either thee dislike.");
- message->addPayload(boost::make_shared<Thread>("0e3141cd80894871a68e6fe6b1ec56fa"));
-
- forwarded->setStanza(message);
- sent->setForwarded(forwarded);
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<sent xmlns=\"urn:xmpp:carbons:2\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<message from=\"romeo@montague.example/home\""
- " to=\"juliet@capulet.example/balcony\""
- " type=\"chat\""
- " xmlns=\"jabber:client\">"
- "<body>Neither, fair saint, if either thee dislike.</body>"
- "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
- "</message>"
- "</forwarded>"
- "</sent>"), testling.serialize(sent));
- }
-
- /*
- * Test serializing of example 15 in XEP-0280.
- */
- void testSerializeExample15() {
- CarbonsPrivateSerializer testling;
-
- CPPUNIT_ASSERT_EQUAL(std::string("<private xmlns=\"urn:xmpp:carbons:2\"/>"), testling.serialize(boost::make_shared<CarbonsPrivate>()));
- }
- private:
- FullPayloadSerializerCollection serializers;
+ CPPUNIT_TEST_SUITE(CarbonsSerializerTest);
+ CPPUNIT_TEST(testSerializeExample3);
+ CPPUNIT_TEST(testSerializeExample6);
+ CPPUNIT_TEST(testSerializeExample12);
+ CPPUNIT_TEST(testSerializeExample14);
+ CPPUNIT_TEST(testSerializeExample15);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ CarbonsSerializerTest() {}
+
+ /*
+ * Test serializing of example 3 in XEP-0280.
+ */
+ void testSerializeExample3() {
+ CarbonsEnableSerializer testling;
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<enable xmlns=\"urn:xmpp:carbons:2\"/>"), testling.serialize(boost::make_shared<CarbonsEnable>()));
+ }
+
+ /*
+ * Test serializing of example 6 in XEP-0280.
+ */
+ void testSerializeExample6() {
+ CarbonsDisableSerializer testling;
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<disable xmlns=\"urn:xmpp:carbons:2\"/>"), testling.serialize(boost::make_shared<CarbonsDisable>()));
+ }
+
+ /*
+ * Test serializing of example 12 in XEP-0280.
+ */
+ void testSerializeExample12() {
+ CarbonsReceivedSerializer testling(&serializers);
+
+ CarbonsReceived::ref received = boost::make_shared<CarbonsReceived>();
+
+ boost::shared_ptr<Forwarded> forwarded = boost::make_shared<Forwarded>();
+
+ Message::ref message = boost::make_shared<Message>();
+ message->setFrom(JID("juliet@capulet.example/balcony"));
+ message->setTo(JID("romeo@montague.example/garden"));
+ message->setBody("What man art thou that, thus bescreen'd in night, so stumblest on my counsel?");
+ message->addPayload(boost::make_shared<Thread>("0e3141cd80894871a68e6fe6b1ec56fa"));
+
+ forwarded->setStanza(message);
+ received->setForwarded(forwarded);
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<received xmlns=\"urn:xmpp:carbons:2\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<message from=\"juliet@capulet.example/balcony\""
+ " to=\"romeo@montague.example/garden\""
+ " type=\"chat\""
+ " xmlns=\"jabber:client\">"
+ "<body>What man art thou that, thus bescreen'd in night, so stumblest on my counsel?</body>"
+ "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
+ "</message>"
+ "</forwarded>"
+ "</received>"), testling.serialize(received));
+ }
+
+ /*
+ * Test serializing of example 14 in XEP-0280.
+ */
+ void testSerializeExample14() {
+ CarbonsSentSerializer testling(&serializers);
+
+ CarbonsSent::ref sent = boost::make_shared<CarbonsSent>();
+
+ boost::shared_ptr<Forwarded> forwarded = boost::make_shared<Forwarded>();
+
+ Message::ref message = boost::make_shared<Message>();
+ message->setTo(JID("juliet@capulet.example/balcony"));
+ message->setFrom(JID("romeo@montague.example/home"));
+ message->setBody("Neither, fair saint, if either thee dislike.");
+ message->addPayload(boost::make_shared<Thread>("0e3141cd80894871a68e6fe6b1ec56fa"));
+
+ forwarded->setStanza(message);
+ sent->setForwarded(forwarded);
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<sent xmlns=\"urn:xmpp:carbons:2\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<message from=\"romeo@montague.example/home\""
+ " to=\"juliet@capulet.example/balcony\""
+ " type=\"chat\""
+ " xmlns=\"jabber:client\">"
+ "<body>Neither, fair saint, if either thee dislike.</body>"
+ "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
+ "</message>"
+ "</forwarded>"
+ "</sent>"), testling.serialize(sent));
+ }
+
+ /*
+ * Test serializing of example 15 in XEP-0280.
+ */
+ void testSerializeExample15() {
+ CarbonsPrivateSerializer testling;
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<private xmlns=\"urn:xmpp:carbons:2\"/>"), testling.serialize(boost::make_shared<CarbonsPrivate>()));
+ }
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(CarbonsSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ChatStateSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ChatStateSerializerTest.cpp
index 36a01d3..85b067f 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/ChatStateSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ChatStateSerializerTest.cpp
@@ -13,42 +13,42 @@ using namespace Swift;
class ChatStateSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(ChatStateSerializerTest);
- CPPUNIT_TEST(testSerialize_ActiveState);
- CPPUNIT_TEST(testSerialize_GoneState);
- CPPUNIT_TEST(testSerialize_ComposingState);
- CPPUNIT_TEST(testSerialize_PausedState);
- CPPUNIT_TEST(testSerialize_InacativeState);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- ChatStateSerializerTest() {}
- ChatStateSerializer testling;
-
- void testSerialize_ActiveState() {
- boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Active));
- CPPUNIT_ASSERT_EQUAL(std::string("<active xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
- }
-
- void testSerialize_GoneState() {
- boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Gone));
- CPPUNIT_ASSERT_EQUAL(std::string("<gone xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
- }
-
- void testSerialize_ComposingState() {
- boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Composing));
- CPPUNIT_ASSERT_EQUAL(std::string("<composing xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
- }
-
- void testSerialize_PausedState() {
- boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Paused));
- CPPUNIT_ASSERT_EQUAL(std::string("<paused xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
- }
-
- void testSerialize_InacativeState() {
- boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Inactive));
- CPPUNIT_ASSERT_EQUAL(std::string("<inactive xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
- }
+ CPPUNIT_TEST_SUITE(ChatStateSerializerTest);
+ CPPUNIT_TEST(testSerialize_ActiveState);
+ CPPUNIT_TEST(testSerialize_GoneState);
+ CPPUNIT_TEST(testSerialize_ComposingState);
+ CPPUNIT_TEST(testSerialize_PausedState);
+ CPPUNIT_TEST(testSerialize_InacativeState);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ ChatStateSerializerTest() {}
+ ChatStateSerializer testling;
+
+ void testSerialize_ActiveState() {
+ boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Active));
+ CPPUNIT_ASSERT_EQUAL(std::string("<active xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
+ }
+
+ void testSerialize_GoneState() {
+ boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Gone));
+ CPPUNIT_ASSERT_EQUAL(std::string("<gone xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
+ }
+
+ void testSerialize_ComposingState() {
+ boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Composing));
+ CPPUNIT_ASSERT_EQUAL(std::string("<composing xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
+ }
+
+ void testSerialize_PausedState() {
+ boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Paused));
+ CPPUNIT_ASSERT_EQUAL(std::string("<paused xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
+ }
+
+ void testSerialize_InacativeState() {
+ boost::shared_ptr<ChatState> priority(new ChatState(ChatState::Inactive));
+ CPPUNIT_ASSERT_EQUAL(std::string("<inactive xmlns=\"http://jabber.org/protocol/chatstates\"/>"), testling.serialize(priority));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ChatStateSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/DeliveryReceiptSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/DeliveryReceiptSerializerTest.cpp
index 0c39e14..bda9ab7 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/DeliveryReceiptSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/DeliveryReceiptSerializerTest.cpp
@@ -22,29 +22,29 @@
using namespace Swift;
class DeliveryReceiptSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DeliveryReceiptSerializerTest);
- CPPUNIT_TEST(testSerialize_XEP0184Example3);
- CPPUNIT_TEST(testSerialize_XEP0184Example4);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(DeliveryReceiptSerializerTest);
+ CPPUNIT_TEST(testSerialize_XEP0184Example3);
+ CPPUNIT_TEST(testSerialize_XEP0184Example4);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize_XEP0184Example3() {
- std::string expected = "<request xmlns=\"urn:xmpp:receipts\"/>";
+ public:
+ void testSerialize_XEP0184Example3() {
+ std::string expected = "<request xmlns=\"urn:xmpp:receipts\"/>";
- DeliveryReceiptRequest::ref receipt = boost::make_shared<DeliveryReceiptRequest>();
+ DeliveryReceiptRequest::ref receipt = boost::make_shared<DeliveryReceiptRequest>();
- boost::shared_ptr<DeliveryReceiptRequestSerializer> serializer = boost::make_shared<DeliveryReceiptRequestSerializer>();
- CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(receipt));
- }
+ boost::shared_ptr<DeliveryReceiptRequestSerializer> serializer = boost::make_shared<DeliveryReceiptRequestSerializer>();
+ CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(receipt));
+ }
- void testSerialize_XEP0184Example4() {
- std::string expected = "<received id=\"richard2-4.1.247\" xmlns=\"urn:xmpp:receipts\"/>";
+ void testSerialize_XEP0184Example4() {
+ std::string expected = "<received id=\"richard2-4.1.247\" xmlns=\"urn:xmpp:receipts\"/>";
- DeliveryReceipt::ref receipt = boost::make_shared<DeliveryReceipt>("richard2-4.1.247");
+ DeliveryReceipt::ref receipt = boost::make_shared<DeliveryReceipt>("richard2-4.1.247");
- boost::shared_ptr<DeliveryReceiptSerializer> serializer = boost::make_shared<DeliveryReceiptSerializer>();
- CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(receipt));
- }
+ boost::shared_ptr<DeliveryReceiptSerializer> serializer = boost::make_shared<DeliveryReceiptSerializer>();
+ CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(receipt));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(DeliveryReceiptSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp
index 9aff6d2..14b1a34 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp
@@ -13,54 +13,54 @@ using namespace Swift;
class DiscoInfoSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(DiscoInfoSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_Form);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(DiscoInfoSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_Form);
+ CPPUNIT_TEST_SUITE_END();
- public:
- DiscoInfoSerializerTest() {}
+ public:
+ DiscoInfoSerializerTest() {}
- void testSerialize() {
- DiscoInfoSerializer testling;
- boost::shared_ptr<DiscoInfo> discoInfo(new DiscoInfo());
- discoInfo->addIdentity(DiscoInfo::Identity("Swift", "client", "pc"));
- discoInfo->addIdentity(DiscoInfo::Identity("Vlug", "client", "pc", "nl"));
- discoInfo->addFeature("http://jabber.org/protocol/caps");
- discoInfo->addFeature("http://jabber.org/protocol/disco#info");
- discoInfo->setNode("http://swift.im#bla");
+ void testSerialize() {
+ DiscoInfoSerializer testling;
+ boost::shared_ptr<DiscoInfo> discoInfo(new DiscoInfo());
+ discoInfo->addIdentity(DiscoInfo::Identity("Swift", "client", "pc"));
+ discoInfo->addIdentity(DiscoInfo::Identity("Vlug", "client", "pc", "nl"));
+ discoInfo->addFeature("http://jabber.org/protocol/caps");
+ discoInfo->addFeature("http://jabber.org/protocol/disco#info");
+ discoInfo->setNode("http://swift.im#bla");
- std::string expectedResult =
- "<query node=\"http://swift.im#bla\" xmlns=\"http://jabber.org/protocol/disco#info\">"
- "<identity category=\"client\" name=\"Swift\" type=\"pc\"/>"
- "<identity category=\"client\" name=\"Vlug\" type=\"pc\" xml:lang=\"nl\"/>"
- "<feature var=\"http://jabber.org/protocol/caps\"/>"
- "<feature var=\"http://jabber.org/protocol/disco#info\"/>"
- "</query>";
+ std::string expectedResult =
+ "<query node=\"http://swift.im#bla\" xmlns=\"http://jabber.org/protocol/disco#info\">"
+ "<identity category=\"client\" name=\"Swift\" type=\"pc\"/>"
+ "<identity category=\"client\" name=\"Vlug\" type=\"pc\" xml:lang=\"nl\"/>"
+ "<feature var=\"http://jabber.org/protocol/caps\"/>"
+ "<feature var=\"http://jabber.org/protocol/disco#info\"/>"
+ "</query>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(discoInfo));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(discoInfo));
+ }
- void testSerialize_Form() {
- DiscoInfoSerializer testling;
- boost::shared_ptr<DiscoInfo> discoInfo(new DiscoInfo());
- discoInfo->addFeature("http://jabber.org/protocol/caps");
- discoInfo->addFeature("http://jabber.org/protocol/disco#info");
- boost::shared_ptr<Form> form(new Form(Form::FormType));
- form->setTitle("Bot Configuration");
- discoInfo->addExtension(form);
+ void testSerialize_Form() {
+ DiscoInfoSerializer testling;
+ boost::shared_ptr<DiscoInfo> discoInfo(new DiscoInfo());
+ discoInfo->addFeature("http://jabber.org/protocol/caps");
+ discoInfo->addFeature("http://jabber.org/protocol/disco#info");
+ boost::shared_ptr<Form> form(new Form(Form::FormType));
+ form->setTitle("Bot Configuration");
+ discoInfo->addExtension(form);
- std::string expectedResult =
- "<query xmlns=\"http://jabber.org/protocol/disco#info\">"
- "<feature var=\"http://jabber.org/protocol/caps\"/>"
- "<feature var=\"http://jabber.org/protocol/disco#info\"/>"
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<title>Bot Configuration</title>"
- "</x>"
- "</query>";
+ std::string expectedResult =
+ "<query xmlns=\"http://jabber.org/protocol/disco#info\">"
+ "<feature var=\"http://jabber.org/protocol/caps\"/>"
+ "<feature var=\"http://jabber.org/protocol/disco#info\"/>"
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<title>Bot Configuration</title>"
+ "</x>"
+ "</query>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(discoInfo));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(discoInfo));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp
index c4d3e29..13d9e3c 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp
@@ -16,31 +16,31 @@
using namespace Swift;
class ErrorSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ErrorSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_Payload);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- ErrorSerializer testling(&serializers);
- boost::shared_ptr<ErrorPayload> error(new ErrorPayload(ErrorPayload::BadRequest, ErrorPayload::Cancel, "My Error"));
-
- CPPUNIT_ASSERT_EQUAL(std::string("<error type=\"cancel\"><bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">My Error</text></error>"), testling.serialize(error));
- }
-
- void testSerialize_Payload() {
- ErrorSerializer testling(&serializers);
- boost::shared_ptr<ErrorPayload> error = boost::make_shared<ErrorPayload>();
- error->setPayload(boost::make_shared<Delay>());
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<error type=\"cancel\"><undefined-condition xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><delay stamp=\"not-a-date-timeZ\" xmlns=\"urn:xmpp:delay\"/></error>"
- ), testling.serialize(error));
- }
-
- private:
- FullPayloadSerializerCollection serializers;
+ CPPUNIT_TEST_SUITE(ErrorSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_Payload);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ ErrorSerializer testling(&serializers);
+ boost::shared_ptr<ErrorPayload> error(new ErrorPayload(ErrorPayload::BadRequest, ErrorPayload::Cancel, "My Error"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<error type=\"cancel\"><bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">My Error</text></error>"), testling.serialize(error));
+ }
+
+ void testSerialize_Payload() {
+ ErrorSerializer testling(&serializers);
+ boost::shared_ptr<ErrorPayload> error = boost::make_shared<ErrorPayload>();
+ error->setPayload(boost::make_shared<Delay>());
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<error type=\"cancel\"><undefined-condition xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><delay stamp=\"not-a-date-timeZ\" xmlns=\"urn:xmpp:delay\"/></error>"
+ ), testling.serialize(error));
+ }
+
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ErrorSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp
index 967bc0e..8bd16cd 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp
@@ -12,287 +12,287 @@
using namespace Swift;
class FormSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(FormSerializerTest);
- CPPUNIT_TEST(testSerializeFormInformation);
- CPPUNIT_TEST(testSerializeLayout);
- CPPUNIT_TEST(testSerializeFields);
- CPPUNIT_TEST(testSerializeFormItems);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerializeFormInformation() {
- FormSerializer testling;
- boost::shared_ptr<Form> form(new Form(Form::FormType));
- form->setTitle("Bot Configuration");
- form->setInstructions("Hello!\nFill out this form to configure your new bot!");
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<title>Bot Configuration</title>"
- "<instructions>Hello!</instructions>"
- "<instructions>Fill out this form to configure your new bot!</instructions>"
- "</x>"), testling.serialize(form));
- }
-
- void testSerializeLayout() {
- FormSerializer testling;
- boost::shared_ptr<Form> form(new Form(Form::FormType));
-
- FormPage::page page = boost::make_shared<FormPage>();
- page->setLabel("P1");
- FormReportedRef::ref reportedRef = boost::make_shared<FormReportedRef>();
- page->addReportedRef(reportedRef);
- FormText::text formText = boost::make_shared<FormText>();
- formText->setTextString("P1T1");
- page->addTextElement(formText);
- FormField::ref field = boost::make_shared<FormField>(FormField::TextSingleType);
- field->setName("P1F1");
- field->setLabel("field one");
- page->addField(field);
-
- FormSection::section section = boost::make_shared<FormSection>();
- section->setLabel("P1S1");
- formText = boost::make_shared<FormText>();
- formText->setTextString("P1S1T1");
- section->addTextElement(formText);
- field = boost::make_shared<FormField>(FormField::TextSingleType);
- field->setName("P1S1F1");
- field->setLabel("field two");
- section->addField(field);
- page->addChildSection(section);
- form->addPage(page);
-
- page = boost::make_shared<FormPage>();
- page->setLabel("P2");
- section = boost::make_shared<FormSection>();
- section->setLabel("P2S1");
- FormSection::section subSection = boost::make_shared<FormSection>();
- subSection->setLabel("P2S2");
- FormSection::section subSection2 = boost::make_shared<FormSection>();
- subSection2->setLabel("P2S3");
- subSection->addChildSection(subSection2);
- section->addChildSection(subSection);
- page->addChildSection(section);
- form->addPage(page);
-
- // P1 = page one, S1 = section one, F1 = field one, T1 = text one
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<page label=\"P1\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
- "<text>P1T1</text>"
- "<fieldref var=\"P1F1\"/>"
- "<reportedref/>"
- "<section label=\"P1S1\">"
- "<text>P1S1T1</text>"
- "<fieldref var=\"P1S1F1\"/>"
- "</section>"
- "</page>"
- "<page label=\"P2\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
- "<section label=\"P2S1\">"
- "<section label=\"P2S2\">"
- "<section label=\"P2S3\"/>"
- "</section>"
- "</section>"
- "</page>"
- "<field label=\"field one\" type=\"text-single\" var=\"P1F1\"/>"
- "<field label=\"field two\" type=\"text-single\" var=\"P1S1F1\"/>"
- "</x>"), testling.serialize(form));
- }
-
- void testSerializeFields() {
- FormSerializer testling;
- boost::shared_ptr<Form> form(new Form(Form::FormType));
-
- FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:bot");
- field->setName("FORM_TYPE");
- form->addField(field);
-
- form->addField(boost::make_shared<FormField>(FormField::FixedType, "Section 1: Bot Info"));
-
- field = boost::make_shared<FormField>(FormField::TextSingleType);
- field->setName("botname");
- field->setLabel("The name of your bot");
- form->addField(field);
-
- field = boost::make_shared<FormField>(FormField::TextMultiType);
- field->setTextMultiValue("This is a bot.\nA quite good one actually");
- field->setName("description");
- field->setLabel("Helpful description of your bot");
- form->addField(field);
-
- field = boost::make_shared<FormField>(FormField::BooleanType, "1");
- field->setName("public");
- field->setLabel("Public bot?");
- field->setRequired(true);
- form->addField(field);
-
- field = boost::make_shared<FormField>(FormField::TextPrivateType);
- field->setName("password");
- field->setLabel("Password for special access");
- form->addField(field);
-
- field = boost::make_shared<FormField>(FormField::ListMultiType);
- field->addValue("news");
- field->addValue("search");
- field->setName("features");
- field->setLabel("What features will the bot support?");
- field->addOption(FormField::Option("Contests", "contests"));
- field->addOption(FormField::Option("News", "news"));
- field->addOption(FormField::Option("Polls", "polls"));
- field->addOption(FormField::Option("Reminders", "reminders"));
- field->addOption(FormField::Option("Search", "search"));
- form->addField(field);
-
- field = boost::make_shared<FormField>(FormField::ListSingleType, "20");
- field->setName("maxsubs");
- field->setLabel("Maximum number of subscribers");
- field->addOption(FormField::Option("10", "10"));
- field->addOption(FormField::Option("20", "20"));
- field->addOption(FormField::Option("30", "30"));
- field->addOption(FormField::Option("50", "50"));
- field->addOption(FormField::Option("100", "100"));
- field->addOption(FormField::Option("", "none"));
- form->addField(field);
-
- std::vector<JID> jids;
- field = boost::make_shared<FormField>(FormField::JIDMultiType);
- field->addValue("foo@bar.com");
- field->addValue("baz@fum.org");
- field->setName("invitelist");
- field->setLabel("People to invite");
- field->setDescription("Tell all your friends about your new bot!");
- form->addField(field);
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>jabber:bot</value>"
- "</field>"
- "<field type=\"fixed\"><value>Section 1: Bot Info</value></field>"
- "<field label=\"The name of your bot\" type=\"text-single\" var=\"botname\"/>"
- "<field label=\"Helpful description of your bot\" type=\"text-multi\" var=\"description\"><value>This is a bot.</value><value>A quite good one actually</value></field>"
- "<field label=\"Public bot?\" type=\"boolean\" var=\"public\">"
- "<required/>"
- "<value>1</value>"
- "</field>"
- "<field label=\"Password for special access\" type=\"text-private\" var=\"password\"/>"
- "<field label=\"What features will the bot support?\" type=\"list-multi\" var=\"features\">"
- "<value>news</value>"
- "<value>search</value>"
- "<option label=\"Contests\"><value>contests</value></option>"
- "<option label=\"News\"><value>news</value></option>"
- "<option label=\"Polls\"><value>polls</value></option>"
- "<option label=\"Reminders\"><value>reminders</value></option>"
- "<option label=\"Search\"><value>search</value></option>"
- "</field>"
- "<field label=\"Maximum number of subscribers\" type=\"list-single\" var=\"maxsubs\">"
- "<value>20</value>"
- "<option label=\"10\"><value>10</value></option>"
- "<option label=\"20\"><value>20</value></option>"
- "<option label=\"30\"><value>30</value></option>"
- "<option label=\"50\"><value>50</value></option>"
- "<option label=\"100\"><value>100</value></option>"
- "<option><value>none</value></option>"
- "</field>"
- "<field label=\"People to invite\" type=\"jid-multi\" var=\"invitelist\">"
- "<desc>Tell all your friends about your new bot!</desc>"
- "<value>foo@bar.com</value>"
- "<value>baz@fum.org</value>"
- "</field>"
- "</x>"), testling.serialize(form));
- }
-
- void testSerializeFormItems() {
- FormSerializer testling;
- boost::shared_ptr<Form> form(new Form(Form::ResultType));
-
- FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:iq:search");
- field->setName("FORM_TYPE");
- form->addField(field);
-
- // reported fields
- field = boost::make_shared<FormField>(FormField::TextSingleType);
- field->setName("first");
- field->setLabel("Given Name");
- form->addReportedField(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType);
- field->setName("last");
- field->setLabel("Family Name");
- form->addReportedField(field);
-
- field = boost::make_shared<FormField>(FormField::JIDSingleType);
- field->setName("jid");
- field->setLabel("Jabber ID");
- form->addReportedField(field);
-
- field = boost::make_shared<FormField>(FormField::ListSingleType);
- field->setName("x-gender");
- field->setLabel("Gender");
- form->addReportedField(field);
-
- Form::FormItem firstItem;
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Benvolio");
- field->setName("first");
- firstItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
- field->setName("last");
- firstItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::JIDSingleType, JID("benvolio@montague.net"));
- field->setName("jid");
- firstItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
- field->setName("x-gender");
- firstItem.push_back(field);
-
- Form::FormItem secondItem;
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Romeo");
- field->setName("first");
- secondItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
- field->setName("last");
- secondItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::JIDSingleType, JID("romeo@montague.net"));
- field->setName("jid");
- secondItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
- field->setName("x-gender");
- secondItem.push_back(field);
-
- form->addItem(firstItem);
- form->addItem(secondItem);
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<x type=\"result\" xmlns=\"jabber:x:data\">"
- "<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>jabber:iq:search</value>"
- "</field>"
- "<reported>"
- "<field label=\"Given Name\" type=\"text-single\" var=\"first\"/>"
- "<field label=\"Family Name\" type=\"text-single\" var=\"last\"/>"
- "<field label=\"Jabber ID\" type=\"jid-single\" var=\"jid\"/>"
- "<field label=\"Gender\" type=\"list-single\" var=\"x-gender\"/>"
- "</reported>"
- "<item>"
- "<field var=\"first\"><value>Benvolio</value></field>"
- "<field var=\"last\"><value>Montague</value></field>"
- "<field var=\"jid\"><value>benvolio@montague.net</value></field>"
- "<field var=\"x-gender\"><value>male</value></field>"
- "</item>"
- "<item>"
- "<field var=\"first\"><value>Romeo</value></field>"
- "<field var=\"last\"><value>Montague</value></field>"
- "<field var=\"jid\"><value>romeo@montague.net</value></field>"
- "<field var=\"x-gender\"><value>male</value></field>"
- "</item>"
- "</x>"), testling.serialize(form));
- }
+ CPPUNIT_TEST_SUITE(FormSerializerTest);
+ CPPUNIT_TEST(testSerializeFormInformation);
+ CPPUNIT_TEST(testSerializeLayout);
+ CPPUNIT_TEST(testSerializeFields);
+ CPPUNIT_TEST(testSerializeFormItems);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerializeFormInformation() {
+ FormSerializer testling;
+ boost::shared_ptr<Form> form(new Form(Form::FormType));
+ form->setTitle("Bot Configuration");
+ form->setInstructions("Hello!\nFill out this form to configure your new bot!");
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<title>Bot Configuration</title>"
+ "<instructions>Hello!</instructions>"
+ "<instructions>Fill out this form to configure your new bot!</instructions>"
+ "</x>"), testling.serialize(form));
+ }
+
+ void testSerializeLayout() {
+ FormSerializer testling;
+ boost::shared_ptr<Form> form(new Form(Form::FormType));
+
+ FormPage::page page = boost::make_shared<FormPage>();
+ page->setLabel("P1");
+ FormReportedRef::ref reportedRef = boost::make_shared<FormReportedRef>();
+ page->addReportedRef(reportedRef);
+ FormText::text formText = boost::make_shared<FormText>();
+ formText->setTextString("P1T1");
+ page->addTextElement(formText);
+ FormField::ref field = boost::make_shared<FormField>(FormField::TextSingleType);
+ field->setName("P1F1");
+ field->setLabel("field one");
+ page->addField(field);
+
+ FormSection::section section = boost::make_shared<FormSection>();
+ section->setLabel("P1S1");
+ formText = boost::make_shared<FormText>();
+ formText->setTextString("P1S1T1");
+ section->addTextElement(formText);
+ field = boost::make_shared<FormField>(FormField::TextSingleType);
+ field->setName("P1S1F1");
+ field->setLabel("field two");
+ section->addField(field);
+ page->addChildSection(section);
+ form->addPage(page);
+
+ page = boost::make_shared<FormPage>();
+ page->setLabel("P2");
+ section = boost::make_shared<FormSection>();
+ section->setLabel("P2S1");
+ FormSection::section subSection = boost::make_shared<FormSection>();
+ subSection->setLabel("P2S2");
+ FormSection::section subSection2 = boost::make_shared<FormSection>();
+ subSection2->setLabel("P2S3");
+ subSection->addChildSection(subSection2);
+ section->addChildSection(subSection);
+ page->addChildSection(section);
+ form->addPage(page);
+
+ // P1 = page one, S1 = section one, F1 = field one, T1 = text one
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<page label=\"P1\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
+ "<text>P1T1</text>"
+ "<fieldref var=\"P1F1\"/>"
+ "<reportedref/>"
+ "<section label=\"P1S1\">"
+ "<text>P1S1T1</text>"
+ "<fieldref var=\"P1S1F1\"/>"
+ "</section>"
+ "</page>"
+ "<page label=\"P2\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
+ "<section label=\"P2S1\">"
+ "<section label=\"P2S2\">"
+ "<section label=\"P2S3\"/>"
+ "</section>"
+ "</section>"
+ "</page>"
+ "<field label=\"field one\" type=\"text-single\" var=\"P1F1\"/>"
+ "<field label=\"field two\" type=\"text-single\" var=\"P1S1F1\"/>"
+ "</x>"), testling.serialize(form));
+ }
+
+ void testSerializeFields() {
+ FormSerializer testling;
+ boost::shared_ptr<Form> form(new Form(Form::FormType));
+
+ FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:bot");
+ field->setName("FORM_TYPE");
+ form->addField(field);
+
+ form->addField(boost::make_shared<FormField>(FormField::FixedType, "Section 1: Bot Info"));
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType);
+ field->setName("botname");
+ field->setLabel("The name of your bot");
+ form->addField(field);
+
+ field = boost::make_shared<FormField>(FormField::TextMultiType);
+ field->setTextMultiValue("This is a bot.\nA quite good one actually");
+ field->setName("description");
+ field->setLabel("Helpful description of your bot");
+ form->addField(field);
+
+ field = boost::make_shared<FormField>(FormField::BooleanType, "1");
+ field->setName("public");
+ field->setLabel("Public bot?");
+ field->setRequired(true);
+ form->addField(field);
+
+ field = boost::make_shared<FormField>(FormField::TextPrivateType);
+ field->setName("password");
+ field->setLabel("Password for special access");
+ form->addField(field);
+
+ field = boost::make_shared<FormField>(FormField::ListMultiType);
+ field->addValue("news");
+ field->addValue("search");
+ field->setName("features");
+ field->setLabel("What features will the bot support?");
+ field->addOption(FormField::Option("Contests", "contests"));
+ field->addOption(FormField::Option("News", "news"));
+ field->addOption(FormField::Option("Polls", "polls"));
+ field->addOption(FormField::Option("Reminders", "reminders"));
+ field->addOption(FormField::Option("Search", "search"));
+ form->addField(field);
+
+ field = boost::make_shared<FormField>(FormField::ListSingleType, "20");
+ field->setName("maxsubs");
+ field->setLabel("Maximum number of subscribers");
+ field->addOption(FormField::Option("10", "10"));
+ field->addOption(FormField::Option("20", "20"));
+ field->addOption(FormField::Option("30", "30"));
+ field->addOption(FormField::Option("50", "50"));
+ field->addOption(FormField::Option("100", "100"));
+ field->addOption(FormField::Option("", "none"));
+ form->addField(field);
+
+ std::vector<JID> jids;
+ field = boost::make_shared<FormField>(FormField::JIDMultiType);
+ field->addValue("foo@bar.com");
+ field->addValue("baz@fum.org");
+ field->setName("invitelist");
+ field->setLabel("People to invite");
+ field->setDescription("Tell all your friends about your new bot!");
+ form->addField(field);
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<field type=\"hidden\" var=\"FORM_TYPE\">"
+ "<value>jabber:bot</value>"
+ "</field>"
+ "<field type=\"fixed\"><value>Section 1: Bot Info</value></field>"
+ "<field label=\"The name of your bot\" type=\"text-single\" var=\"botname\"/>"
+ "<field label=\"Helpful description of your bot\" type=\"text-multi\" var=\"description\"><value>This is a bot.</value><value>A quite good one actually</value></field>"
+ "<field label=\"Public bot?\" type=\"boolean\" var=\"public\">"
+ "<required/>"
+ "<value>1</value>"
+ "</field>"
+ "<field label=\"Password for special access\" type=\"text-private\" var=\"password\"/>"
+ "<field label=\"What features will the bot support?\" type=\"list-multi\" var=\"features\">"
+ "<value>news</value>"
+ "<value>search</value>"
+ "<option label=\"Contests\"><value>contests</value></option>"
+ "<option label=\"News\"><value>news</value></option>"
+ "<option label=\"Polls\"><value>polls</value></option>"
+ "<option label=\"Reminders\"><value>reminders</value></option>"
+ "<option label=\"Search\"><value>search</value></option>"
+ "</field>"
+ "<field label=\"Maximum number of subscribers\" type=\"list-single\" var=\"maxsubs\">"
+ "<value>20</value>"
+ "<option label=\"10\"><value>10</value></option>"
+ "<option label=\"20\"><value>20</value></option>"
+ "<option label=\"30\"><value>30</value></option>"
+ "<option label=\"50\"><value>50</value></option>"
+ "<option label=\"100\"><value>100</value></option>"
+ "<option><value>none</value></option>"
+ "</field>"
+ "<field label=\"People to invite\" type=\"jid-multi\" var=\"invitelist\">"
+ "<desc>Tell all your friends about your new bot!</desc>"
+ "<value>foo@bar.com</value>"
+ "<value>baz@fum.org</value>"
+ "</field>"
+ "</x>"), testling.serialize(form));
+ }
+
+ void testSerializeFormItems() {
+ FormSerializer testling;
+ boost::shared_ptr<Form> form(new Form(Form::ResultType));
+
+ FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:iq:search");
+ field->setName("FORM_TYPE");
+ form->addField(field);
+
+ // reported fields
+ field = boost::make_shared<FormField>(FormField::TextSingleType);
+ field->setName("first");
+ field->setLabel("Given Name");
+ form->addReportedField(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType);
+ field->setName("last");
+ field->setLabel("Family Name");
+ form->addReportedField(field);
+
+ field = boost::make_shared<FormField>(FormField::JIDSingleType);
+ field->setName("jid");
+ field->setLabel("Jabber ID");
+ form->addReportedField(field);
+
+ field = boost::make_shared<FormField>(FormField::ListSingleType);
+ field->setName("x-gender");
+ field->setLabel("Gender");
+ form->addReportedField(field);
+
+ Form::FormItem firstItem;
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Benvolio");
+ field->setName("first");
+ firstItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
+ field->setName("last");
+ firstItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::JIDSingleType, JID("benvolio@montague.net"));
+ field->setName("jid");
+ firstItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
+ field->setName("x-gender");
+ firstItem.push_back(field);
+
+ Form::FormItem secondItem;
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Romeo");
+ field->setName("first");
+ secondItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
+ field->setName("last");
+ secondItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::JIDSingleType, JID("romeo@montague.net"));
+ field->setName("jid");
+ secondItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
+ field->setName("x-gender");
+ secondItem.push_back(field);
+
+ form->addItem(firstItem);
+ form->addItem(secondItem);
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<x type=\"result\" xmlns=\"jabber:x:data\">"
+ "<field type=\"hidden\" var=\"FORM_TYPE\">"
+ "<value>jabber:iq:search</value>"
+ "</field>"
+ "<reported>"
+ "<field label=\"Given Name\" type=\"text-single\" var=\"first\"/>"
+ "<field label=\"Family Name\" type=\"text-single\" var=\"last\"/>"
+ "<field label=\"Jabber ID\" type=\"jid-single\" var=\"jid\"/>"
+ "<field label=\"Gender\" type=\"list-single\" var=\"x-gender\"/>"
+ "</reported>"
+ "<item>"
+ "<field var=\"first\"><value>Benvolio</value></field>"
+ "<field var=\"last\"><value>Montague</value></field>"
+ "<field var=\"jid\"><value>benvolio@montague.net</value></field>"
+ "<field var=\"x-gender\"><value>male</value></field>"
+ "</item>"
+ "<item>"
+ "<field var=\"first\"><value>Romeo</value></field>"
+ "<field var=\"last\"><value>Montague</value></field>"
+ "<field var=\"jid\"><value>romeo@montague.net</value></field>"
+ "<field var=\"x-gender\"><value>male</value></field>"
+ "</item>"
+ "</x>"), testling.serialize(form));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(FormSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ForwardedSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ForwardedSerializerTest.cpp
index 9e986d3..d7aed26 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/ForwardedSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ForwardedSerializerTest.cpp
@@ -21,99 +21,99 @@
using namespace Swift;
class ForwardedSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ForwardedSerializerTest);
- CPPUNIT_TEST(testSerializeIQ);
- CPPUNIT_TEST(testSerializeMessage);
- CPPUNIT_TEST(testSerializeMessageNoDelay);
- CPPUNIT_TEST(testSerializePresence);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerializeIQ() {
- ForwardedSerializer serializer(&serializers);
-
- boost::shared_ptr<IQ> iq = IQ::createResult(JID("juliet@capulet.lit/balcony"), JID("romeo@montague.lit/orchard"), "id0");
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(iq);
- forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
-
- std::string expectedResult =
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<iq from=\"romeo@montague.lit/orchard\" id=\"id0\" to=\"juliet@capulet.lit/balcony\" type=\"result\" xmlns=\"jabber:client\"/>"
- "</forwarded>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
- }
-
- void testSerializeMessage() {
- ForwardedSerializer serializer(&serializers);
-
- boost::shared_ptr<Message> message(boost::make_shared<Message>());
- message->setType(Message::Chat);
- message->setTo(JID("juliet@capulet.lit/balcony"));
- message->setFrom(JID("romeo@montague.lit/orchard"));
- message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(message);
- forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
-
- std::string expectedResult =
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
- }
-
- void testSerializeMessageNoDelay() {
- ForwardedSerializer serializer(&serializers);
-
- boost::shared_ptr<Message> message(boost::make_shared<Message>());
- message->setType(Message::Chat);
- message->setTo(JID("juliet@capulet.lit/balcony"));
- message->setFrom(JID("romeo@montague.lit/orchard"));
- message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(message);
-
- std::string expectedResult =
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
- }
-
- void testSerializePresence() {
- ForwardedSerializer serializer(&serializers);
-
- boost::shared_ptr<Presence> presence(boost::make_shared<Presence>());
- presence->setType(Presence::Subscribe);
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(presence);
- forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
-
- std::string expectedResult =
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<presence type=\"subscribe\" xmlns=\"jabber:client\"/>"
- "</forwarded>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
- }
-
- private:
- FullPayloadSerializerCollection serializers;
+ CPPUNIT_TEST_SUITE(ForwardedSerializerTest);
+ CPPUNIT_TEST(testSerializeIQ);
+ CPPUNIT_TEST(testSerializeMessage);
+ CPPUNIT_TEST(testSerializeMessageNoDelay);
+ CPPUNIT_TEST(testSerializePresence);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerializeIQ() {
+ ForwardedSerializer serializer(&serializers);
+
+ boost::shared_ptr<IQ> iq = IQ::createResult(JID("juliet@capulet.lit/balcony"), JID("romeo@montague.lit/orchard"), "id0");
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(iq);
+ forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
+
+ std::string expectedResult =
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<iq from=\"romeo@montague.lit/orchard\" id=\"id0\" to=\"juliet@capulet.lit/balcony\" type=\"result\" xmlns=\"jabber:client\"/>"
+ "</forwarded>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
+ }
+
+ void testSerializeMessage() {
+ ForwardedSerializer serializer(&serializers);
+
+ boost::shared_ptr<Message> message(boost::make_shared<Message>());
+ message->setType(Message::Chat);
+ message->setTo(JID("juliet@capulet.lit/balcony"));
+ message->setFrom(JID("romeo@montague.lit/orchard"));
+ message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(message);
+ forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
+
+ std::string expectedResult =
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
+ }
+
+ void testSerializeMessageNoDelay() {
+ ForwardedSerializer serializer(&serializers);
+
+ boost::shared_ptr<Message> message(boost::make_shared<Message>());
+ message->setType(Message::Chat);
+ message->setTo(JID("juliet@capulet.lit/balcony"));
+ message->setFrom(JID("romeo@montague.lit/orchard"));
+ message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(message);
+
+ std::string expectedResult =
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
+ }
+
+ void testSerializePresence() {
+ ForwardedSerializer serializer(&serializers);
+
+ boost::shared_ptr<Presence> presence(boost::make_shared<Presence>());
+ presence->setType(Presence::Subscribe);
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(presence);
+ forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
+
+ std::string expectedResult =
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<presence type=\"subscribe\" xmlns=\"jabber:client\"/>"
+ "</forwarded>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(forwarded));
+ }
+
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ForwardedSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/IBBSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/IBBSerializerTest.cpp
index 311ade3..45badea 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/IBBSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/IBBSerializerTest.cpp
@@ -21,24 +21,24 @@ using namespace Swift;
class IBBSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(IBBSerializerTest);
- CPPUNIT_TEST(testSerialize_data);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- IBBSerializerTest() {}
-
- void testSerialize_data() {
- IBBSerializer testling;
- boost::shared_ptr<IBB> ibb = boost::make_shared<IBB>();
- ibb->setAction(IBB::Data);
- ibb->setData(createByteArray("abcdefgihjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\x0a"));
- ibb->setSequenceNumber(4);
- CPPUNIT_ASSERT_EQUAL(std::string("<data seq=\"4\" sid=\"\" xmlns=\"http://jabber.org/protocol/ibb\">"
- "YWJjZGVmZ2loamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1"
- "Njc4OTAK"
- "</data>"), testling.serialize(ibb));
- }
+ CPPUNIT_TEST_SUITE(IBBSerializerTest);
+ CPPUNIT_TEST(testSerialize_data);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ IBBSerializerTest() {}
+
+ void testSerialize_data() {
+ IBBSerializer testling;
+ boost::shared_ptr<IBB> ibb = boost::make_shared<IBB>();
+ ibb->setAction(IBB::Data);
+ ibb->setData(createByteArray("abcdefgihjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\x0a"));
+ ibb->setSequenceNumber(4);
+ CPPUNIT_ASSERT_EQUAL(std::string("<data seq=\"4\" sid=\"\" xmlns=\"http://jabber.org/protocol/ibb\">"
+ "YWJjZGVmZ2loamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1"
+ "Njc4OTAK"
+ "</data>"), testling.serialize(ibb));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(IBBSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/IdleSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/IdleSerializerTest.cpp
index e00a929..147c7be 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/IdleSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/IdleSerializerTest.cpp
@@ -20,19 +20,19 @@
using namespace Swift;
class IdleSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(IdleSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(IdleSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- IdleSerializerTest() {}
+ public:
+ IdleSerializerTest() {}
- void testSerialize() {
- IdleSerializer testling;
- Idle::ref idle = boost::make_shared<Idle>(stringToDateTime("1969-07-21T02:56:15Z"));
+ void testSerialize() {
+ IdleSerializer testling;
+ Idle::ref idle = boost::make_shared<Idle>(stringToDateTime("1969-07-21T02:56:15Z"));
- CPPUNIT_ASSERT_EQUAL(std::string("<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15Z'/>"), testling.serialize(idle));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15Z'/>"), testling.serialize(idle));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(IdleSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp
index 9320eff..b1b0c45 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp
@@ -14,50 +14,50 @@
using namespace Swift;
class InBandRegistrationPayloadSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(InBandRegistrationPayloadSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_Form);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- InBandRegistrationPayloadSerializer testling;
- boost::shared_ptr<InBandRegistrationPayload> registration(new InBandRegistrationPayload());
- registration->setRegistered(true);
-
- std::string expectedResult =
- "<query xmlns=\"jabber:iq:register\">"
- "<registered/>"
- "</query>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(registration));
- }
- void testSerialize_Form() {
- InBandRegistrationPayloadSerializer testling;
- boost::shared_ptr<InBandRegistrationPayload> registration(new InBandRegistrationPayload());
- registration->setInstructions("Use the enclosed form to register.");
-
- boost::shared_ptr<Form> form(new Form(Form::FormType));
- form->setTitle("Contest Registration");
-
- FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:iq:register");
- field->setName("FORM_TYPE");
- form->addField(field);
- registration->setForm(form);
-
- std::string expectedResult =
- "<query xmlns=\"jabber:iq:register\">"
- "<instructions>Use the enclosed form to register.</instructions>"
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<title>Contest Registration</title>"
- "<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>jabber:iq:register</value>"
- "</field>"
- "</x>"
- "</query>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(registration));
- }
+ CPPUNIT_TEST_SUITE(InBandRegistrationPayloadSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_Form);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ InBandRegistrationPayloadSerializer testling;
+ boost::shared_ptr<InBandRegistrationPayload> registration(new InBandRegistrationPayload());
+ registration->setRegistered(true);
+
+ std::string expectedResult =
+ "<query xmlns=\"jabber:iq:register\">"
+ "<registered/>"
+ "</query>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(registration));
+ }
+ void testSerialize_Form() {
+ InBandRegistrationPayloadSerializer testling;
+ boost::shared_ptr<InBandRegistrationPayload> registration(new InBandRegistrationPayload());
+ registration->setInstructions("Use the enclosed form to register.");
+
+ boost::shared_ptr<Form> form(new Form(Form::FormType));
+ form->setTitle("Contest Registration");
+
+ FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:iq:register");
+ field->setName("FORM_TYPE");
+ form->addField(field);
+ registration->setForm(form);
+
+ std::string expectedResult =
+ "<query xmlns=\"jabber:iq:register\">"
+ "<instructions>Use the enclosed form to register.</instructions>"
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<title>Contest Registration</title>"
+ "<field type=\"hidden\" var=\"FORM_TYPE\">"
+ "<value>jabber:iq:register</value>"
+ "</field>"
+ "</x>"
+ "</query>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(registration));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(InBandRegistrationPayloadSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/IsodeIQDelegationSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/IsodeIQDelegationSerializerTest.cpp
index 4e84648..8f46ca8 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/IsodeIQDelegationSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/IsodeIQDelegationSerializerTest.cpp
@@ -29,104 +29,104 @@ using namespace Swift;
class IsodeIQDelegationSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(IsodeIQDelegationSerializerTest);
- CPPUNIT_TEST(testSerialize_Forwarded_IQ);
- CPPUNIT_TEST(testSerialize_Forwarded_Message);
- CPPUNIT_TEST(testSerialize_Forwarded_MessageNoDelay);
- CPPUNIT_TEST(testSerialize_Forwarded_Presence);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- IsodeIQDelegationSerializerTest() {}
-
- void testSerialize_Forwarded_IQ() {
- IsodeIQDelegationSerializer testling(&serializers);
- boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
-
- boost::shared_ptr<IQ> iq = IQ::createResult(JID("juliet@capulet.lit/balcony"), JID("romeo@montague.lit/orchard"), "id0", boost::make_shared<Subject>("text"));
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(iq);
- forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
- isodeIQDelegation->setForward(forwarded);
-
- CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<iq from=\"romeo@montague.lit/orchard\" id=\"id0\" to=\"juliet@capulet.lit/balcony\" type=\"result\" xmlns=\"jabber:client\"><subject>text</subject></iq>"
- "</forwarded>"
- "</delegate>"), testling.serialize(isodeIQDelegation));
- }
-
- void testSerialize_Forwarded_Message() {
- IsodeIQDelegationSerializer testling(&serializers);
- boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
-
- boost::shared_ptr<Message> message(boost::make_shared<Message>());
- message->setType(Message::Chat);
- message->setTo(JID("juliet@capulet.lit/balcony"));
- message->setFrom(JID("romeo@montague.lit/orchard"));
- message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(message);
- forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
-
- isodeIQDelegation->setForward(forwarded);
- CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>"
- "</delegate>"), testling.serialize(isodeIQDelegation));
- }
-
- void testSerialize_Forwarded_MessageNoDelay() {
- IsodeIQDelegationSerializer testling(&serializers);
- boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
-
- boost::shared_ptr<Message> message(boost::make_shared<Message>());
- message->setType(Message::Chat);
- message->setTo(JID("juliet@capulet.lit/balcony"));
- message->setFrom(JID("romeo@montague.lit/orchard"));
- message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(message);
- isodeIQDelegation->setForward(forwarded);
-
- CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>"
- "</delegate>"), testling.serialize(isodeIQDelegation));
- }
-
- void testSerialize_Forwarded_Presence() {
- IsodeIQDelegationSerializer testling(&serializers);
- boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
-
- boost::shared_ptr<Presence> presence(boost::make_shared<Presence>());
- presence->setType(Presence::Subscribe);
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(presence);
- forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
- isodeIQDelegation->setForward(forwarded);
-
- CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<presence type=\"subscribe\" xmlns=\"jabber:client\"/>"
- "</forwarded>"
- "</delegate>"), testling.serialize(isodeIQDelegation));
- }
- private:
- FullPayloadSerializerCollection serializers;
+ CPPUNIT_TEST_SUITE(IsodeIQDelegationSerializerTest);
+ CPPUNIT_TEST(testSerialize_Forwarded_IQ);
+ CPPUNIT_TEST(testSerialize_Forwarded_Message);
+ CPPUNIT_TEST(testSerialize_Forwarded_MessageNoDelay);
+ CPPUNIT_TEST(testSerialize_Forwarded_Presence);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ IsodeIQDelegationSerializerTest() {}
+
+ void testSerialize_Forwarded_IQ() {
+ IsodeIQDelegationSerializer testling(&serializers);
+ boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
+
+ boost::shared_ptr<IQ> iq = IQ::createResult(JID("juliet@capulet.lit/balcony"), JID("romeo@montague.lit/orchard"), "id0", boost::make_shared<Subject>("text"));
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(iq);
+ forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
+ isodeIQDelegation->setForward(forwarded);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<iq from=\"romeo@montague.lit/orchard\" id=\"id0\" to=\"juliet@capulet.lit/balcony\" type=\"result\" xmlns=\"jabber:client\"><subject>text</subject></iq>"
+ "</forwarded>"
+ "</delegate>"), testling.serialize(isodeIQDelegation));
+ }
+
+ void testSerialize_Forwarded_Message() {
+ IsodeIQDelegationSerializer testling(&serializers);
+ boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
+
+ boost::shared_ptr<Message> message(boost::make_shared<Message>());
+ message->setType(Message::Chat);
+ message->setTo(JID("juliet@capulet.lit/balcony"));
+ message->setFrom(JID("romeo@montague.lit/orchard"));
+ message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(message);
+ forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
+
+ isodeIQDelegation->setForward(forwarded);
+ CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>"
+ "</delegate>"), testling.serialize(isodeIQDelegation));
+ }
+
+ void testSerialize_Forwarded_MessageNoDelay() {
+ IsodeIQDelegationSerializer testling(&serializers);
+ boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
+
+ boost::shared_ptr<Message> message(boost::make_shared<Message>());
+ message->setType(Message::Chat);
+ message->setTo(JID("juliet@capulet.lit/balcony"));
+ message->setFrom(JID("romeo@montague.lit/orchard"));
+ message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(message);
+ isodeIQDelegation->setForward(forwarded);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>"
+ "</delegate>"), testling.serialize(isodeIQDelegation));
+ }
+
+ void testSerialize_Forwarded_Presence() {
+ IsodeIQDelegationSerializer testling(&serializers);
+ boost::shared_ptr<IsodeIQDelegation> isodeIQDelegation = boost::make_shared<IsodeIQDelegation>();
+
+ boost::shared_ptr<Presence> presence(boost::make_shared<Presence>());
+ presence->setType(Presence::Subscribe);
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(presence);
+ forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
+ isodeIQDelegation->setForward(forwarded);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<delegate xmlns=\"http://isode.com/iq_delegation\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<presence type=\"subscribe\" xmlns=\"jabber:client\"/>"
+ "</forwarded>"
+ "</delegate>"), testling.serialize(isodeIQDelegation));
+ }
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(IsodeIQDelegationSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp
index d0e469f..ecb68cd 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp
@@ -32,377 +32,377 @@
using namespace Swift;
class JingleSerializersTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(JingleSerializersTest);
- CPPUNIT_TEST(testSerialize_StreamInitiationFileInfo);
- CPPUNIT_TEST(testSerialize_StreamInitiationFileInfoRange);
-
- CPPUNIT_TEST(testSerialize_Xep0261_Example1);
- CPPUNIT_TEST(testSerialize_Xep0261_Example9);
- CPPUNIT_TEST(testSerialize_Xep0261_Example13);
-
- CPPUNIT_TEST(testSerialize_Xep0234_Example1);
- CPPUNIT_TEST(testSerialize_Xep0234_Example3);
- CPPUNIT_TEST(testSerialize_Xep0234_Example5);
- CPPUNIT_TEST(testSerialize_Xep0234_Example8);
-
- CPPUNIT_TEST(testSerialize_Xep0260_Example1);
-
- CPPUNIT_TEST_SUITE_END();
-
- boost::shared_ptr<JinglePayloadSerializer> createTestling() {
- return boost::make_shared<JinglePayloadSerializer>(&collection);
- }
-
-
- public:
- void testSerialize_StreamInitiationFileInfo() {
- std::string expected = "<file"
- " date=\"1969-07-21T02:56:15Z\""
- " hash=\"552da749930852c69ae5d2141d3766b1\""
- " name=\"test.txt\""
- " size=\"1022\""
- " xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">"
- "<desc>This is a test. If this were a real file...</desc>"
- "<range/>"
- "</file>";
-
- StreamInitiationFileInfo::ref fileInfo = boost::make_shared<StreamInitiationFileInfo>();
- fileInfo->setDate(stringToDateTime("1969-07-21T02:56:15Z"));
- fileInfo->setHash("552da749930852c69ae5d2141d3766b1");
- fileInfo->setSize(1022);
- fileInfo->setName("test.txt");
- fileInfo->setDescription("This is a test. If this were a real file...");
- fileInfo->setSupportsRangeRequests(true);
-
- boost::shared_ptr<StreamInitiationFileInfoSerializer> serializer = boost::make_shared<StreamInitiationFileInfoSerializer>();
- CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(fileInfo));
- }
-
- void testSerialize_StreamInitiationFileInfoRange() {
- std::string expected = "<file hash=\"552da749930852c69ae5d2141d3766b1\""
- " xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">"
- "<range offset=\"270336\"/>"
- "</file>";
-
- StreamInitiationFileInfo::ref fileInfo = boost::make_shared<StreamInitiationFileInfo>();
- fileInfo->setHash("552da749930852c69ae5d2141d3766b1");
- fileInfo->setSupportsRangeRequests(true);
- fileInfo->setRangeOffset(270336);
-
- boost::shared_ptr<StreamInitiationFileInfoSerializer> serializer = boost::make_shared<StreamInitiationFileInfoSerializer>();
- CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(fileInfo));
- }
-
-
- // IBB Transport Method Examples
-
- // http://xmpp.org/extensions/xep-0261.html#example-1
- void testSerialize_Xep0261_Example1() {
- std::string expected =
- "<jingle action=\"session-initiate\""
- " initiator=\"romeo@montague.lit/orchard\""
- " sid=\"a73sjjvkla37jfea\""
- " xmlns=\"urn:xmpp:jingle:1\">"
- "<content creator=\"initiator\" name=\"ex\">"
- "<transport block-size=\"4096\""
- " sid=\"ch3d9s71\""
- " xmlns=\"urn:xmpp:jingle:transports:ibb:1\"/>"
- "</content>"
- "</jingle>";
-
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setAction(JinglePayload::SessionInitiate);
- payload->setSessionID("a73sjjvkla37jfea");
- payload->setInitiator(JID("romeo@montague.lit/orchard"));
-
- JingleIBBTransportPayload::ref transport = boost::make_shared<JingleIBBTransportPayload>();
- transport->setBlockSize(4096);
- transport->setSessionID("ch3d9s71");
-
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(JingleContentPayload::InitiatorCreator);
- content->setName("ex");
- content->addTransport(transport);
-
- payload->addPayload(content);
-
- CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
- }
-
- // http://xmpp.org/extensions/xep-0261.html#example-9
- void testSerialize_Xep0261_Example9() {
- std::string expected =
- "<jingle action=\"transport-info\""
- " initiator=\"romeo@montague.lit/orchard\""
- " sid=\"a73sjjvkla37jfea\""
- " xmlns=\"urn:xmpp:jingle:1\">"
- "<content creator=\"initiator\" name=\"ex\">"
- "<transport block-size=\"2048\""
- " sid=\"bt8a71h6\""
- " xmlns=\"urn:xmpp:jingle:transports:ibb:1\"/>"
- "</content>"
- "</jingle>";
-
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setAction(JinglePayload::TransportInfo);
- payload->setInitiator(JID("romeo@montague.lit/orchard"));
- payload->setSessionID("a73sjjvkla37jfea");
-
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(JingleContentPayload::InitiatorCreator);
- content->setName("ex");
-
- JingleIBBTransportPayload::ref transport = boost::make_shared<JingleIBBTransportPayload>();
- transport->setBlockSize(2048);
- transport->setSessionID("bt8a71h6");
-
- content->addTransport(transport);
- payload->addPayload(content);
-
- CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
- }
-
- // http://xmpp.org/extensions/xep-0261.html#example-13
- void testSerialize_Xep0261_Example13() {
- std::string expected =
- "<jingle action=\"session-terminate\""
- " initiator=\"romeo@montague.lit/orchard\""
- " sid=\"a73sjjvkla37jfea\""
- " xmlns=\"urn:xmpp:jingle:1\">"
- "<reason><success/></reason>"
- "</jingle>";
-
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setAction(JinglePayload::SessionTerminate);
- payload->setInitiator(JID("romeo@montague.lit/orchard"));
- payload->setSessionID("a73sjjvkla37jfea");
- payload->setReason(JinglePayload::Reason(JinglePayload::Reason::Success));
-
- CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-1
- void testSerialize_Xep0234_Example1() {
- std::string expected = "<description xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
- "<file>"
- "<date>1969-07-21T02:56:15Z</date>"
- "<desc>This is a test. If this were a real file...</desc>"
- "<name>test.txt</name>"
- "<range/>"
- "<size>1022</size>"
- "<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
- "</file>"
- "</description>";
- JingleFileTransferDescription::ref desc = boost::make_shared<JingleFileTransferDescription>();
- JingleFileTransferFileInfo fileInfo;
-
- fileInfo.setDate(stringToDateTime("1969-07-21T02:56:15Z"));
- fileInfo.addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
- fileInfo.setSize(1022);
- fileInfo.setName("test.txt");
- fileInfo.setDescription("This is a test. If this were a real file...");
- fileInfo.setSupportsRangeRequests(true);
-
- desc->setFileInfo(fileInfo);
-
- CPPUNIT_ASSERT_EQUAL(expected, boost::make_shared<JingleFileTransferDescriptionSerializer>()->serialize(desc));
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-3
- void testSerialize_Xep0234_Example3() {
- std::string expected =
- "<jingle action=\"session-accept\""
- " initiator=\"romeo@montague.lit/orchard\""
- " sid=\"851ba2\""
- " xmlns=\"urn:xmpp:jingle:1\">"
- "<content creator=\"initiator\" name=\"a-file-offer\">"
- "<description xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
- "<file>"
- "<date>1969-07-21T02:56:15Z</date>"
- "<desc>This is a test. If this were a real file...</desc>"
- "<name>test.txt</name>"
- "<range/>"
- "<size>1022</size>"
- "<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
- "</file>"
- "</description>"
- /*"<transport xmlns=\"urn:xmpp:jingle:transports:s5b:1\""
- " mode=\"tcp\""
- " sid=\"vj3hs98y\">"
- "<candidate cid=\"ht567dq\""
- " host=\"192.169.1.10\""
- " jid=\"juliet@capulet.lit/balcony\""
- " port=\"6539\""
- " priority=\"8257636\""
- " type=\"direct\"/>"
- "<candidate cid=\"hr65dqyd\""
- " host=\"134.102.201.180\""
- " jid=\"juliet@capulet.lit/balcony\""
- " port=\"16453\""
- " priority=\"7929856\""
- " type=\"assisted\"/>"
- "<candidate cid=\"grt654q2\""
- " host=\"2001:638:708:30c9:219:d1ff:fea4:a17d\""
- " jid=\"juliet@capulet.lit/balcony\""
- " port=\"6539\""
- " priority=\"8257606\""
- " type=\"direct\"/>"
- "</transport>"*/
- "</content>"
- "</jingle>";
-
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setAction(JinglePayload::SessionAccept);
- payload->setInitiator(JID("romeo@montague.lit/orchard"));
- payload->setSessionID("851ba2");
-
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(JingleContentPayload::InitiatorCreator);
- content->setName("a-file-offer");
-
- JingleFileTransferDescription::ref description = boost::make_shared<JingleFileTransferDescription>();
- JingleFileTransferFileInfo fileInfo;
- fileInfo.setName("test.txt");
- fileInfo.setSize(1022);
- fileInfo.addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
- fileInfo.setDate(stringToDateTime("1969-07-21T02:56:15Z"));
- fileInfo.setDescription("This is a test. If this were a real file...");
- fileInfo.setSupportsRangeRequests(true);
-
- description->setFileInfo(fileInfo);
- content->addDescription(description);
- payload->addPayload(content);
-
- CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-5
- void testSerialize_Xep0234_Example5() {
- std::string expected =
- "<jingle"
- " action=\"transport-info\""
- " initiator=\"romeo@montague.lit/orchard\""
- " sid=\"a73sjjvkla37jfea\""
- " xmlns=\"urn:xmpp:jingle:1\">"
- "<content creator=\"initiator\" name=\"ex\"/>"
- /*"<transport"
- " sid=\"vj3hs98y\""
- " xmlns=\"urn:xmpp:jingle:transports:s5b:1\">"
- "<candidate-used cid=\"hr65dqyd\"/>"
- "</transport>"*/
- //"</content>"
- "</jingle>";
-
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setAction(JinglePayload::TransportInfo);
- payload->setInitiator(JID("romeo@montague.lit/orchard"));
- payload->setSessionID("a73sjjvkla37jfea");
-
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(JingleContentPayload::InitiatorCreator);
- content->setName("ex");
- payload->addPayload(content);
-
- CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-8
- void testSerialize_Xep0234_Example8() {
- std::string expected =
- "<jingle"
- " action=\"session-info\""
- " initiator=\"romeo@montague.lit/orchard\""
- " sid=\"a73sjjvkla37jfea\""
- " xmlns=\"urn:xmpp:jingle:1\">"
- "<checksum xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
- "<file>"
- "<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
- "</file>"
- "</checksum>"
- "</jingle>";
-
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setAction(JinglePayload::SessionInfo);
- payload->setInitiator(JID("romeo@montague.lit/orchard"));
- payload->setSessionID("a73sjjvkla37jfea");
-
- JingleFileTransferHash::ref hash = boost::make_shared<JingleFileTransferHash>();
- hash->getFileInfo().addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
-
- payload->addPayload(hash);
-
- CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
- }
-
- // http://xmpp.org/extensions/xep-0260.html#example-1
- void testSerialize_Xep0260_Example1() {
- std::string expected =
- "<jingle"
- " action=\"session-initiate\""
- " initiator=\"romeo@montague.lit/orchard\""
- " sid=\"a73sjjvkla37jfea\""
- " xmlns=\"urn:xmpp:jingle:1\">"
- "<content creator=\"initiator\" name=\"ex\">"
- "<transport"
- " dstaddr=\"1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba\""
- " mode=\"tcp\""
- " sid=\"vj3hs98y\""
- " xmlns=\"urn:xmpp:jingle:transports:s5b:1\">"
- "<candidate cid=\"hft54dqy\""
- " host=\"192.168.4.1\""
- " jid=\"romeo@montague.lit/orchard\""
- " port=\"5086\""
- " priority=\"8257636\""
- " type=\"direct\"/>"
- "<candidate cid=\"hutr46fe\""
- " host=\"24.24.24.1\""
- " jid=\"romeo@montague.lit/orchard\""
- " port=\"5087\""
- " priority=\"8258636\""
- " type=\"direct\"/>"
- "</transport>"
- "</content>"
- "</jingle>";
-
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setAction(JinglePayload::SessionInitiate);
- payload->setInitiator(JID("romeo@montague.lit/orchard"));
- payload->setSessionID("a73sjjvkla37jfea");
-
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(JingleContentPayload::InitiatorCreator);
- content->setName("ex");
-
- JingleS5BTransportPayload::ref transport = boost::make_shared<JingleS5BTransportPayload>();
- transport->setMode(JingleS5BTransportPayload::TCPMode);
- transport->setDstAddr("1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba");
- transport->setSessionID("vj3hs98y");
-
- JingleS5BTransportPayload::Candidate candidate1;
- candidate1.cid = "hft54dqy";
- candidate1.hostPort = HostAddressPort(HostAddress("192.168.4.1"), 5086);
- candidate1.jid = JID("romeo@montague.lit/orchard");
- candidate1.priority = 8257636;
- candidate1.type = JingleS5BTransportPayload::Candidate::DirectType;
- transport->addCandidate(candidate1);
-
- JingleS5BTransportPayload::Candidate candidate2;
- candidate2.cid = "hutr46fe";
- candidate2.hostPort = HostAddressPort(HostAddress("24.24.24.1"), 5087);
- candidate2.jid = JID("romeo@montague.lit/orchard");
- candidate2.priority = 8258636;
- candidate2.type = JingleS5BTransportPayload::Candidate::DirectType;
- transport->addCandidate(candidate2);
-
- content->addTransport(transport);
-
- payload->addPayload(content);
-
- CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
- }
-
- private:
- FullPayloadSerializerCollection collection;
+ CPPUNIT_TEST_SUITE(JingleSerializersTest);
+ CPPUNIT_TEST(testSerialize_StreamInitiationFileInfo);
+ CPPUNIT_TEST(testSerialize_StreamInitiationFileInfoRange);
+
+ CPPUNIT_TEST(testSerialize_Xep0261_Example1);
+ CPPUNIT_TEST(testSerialize_Xep0261_Example9);
+ CPPUNIT_TEST(testSerialize_Xep0261_Example13);
+
+ CPPUNIT_TEST(testSerialize_Xep0234_Example1);
+ CPPUNIT_TEST(testSerialize_Xep0234_Example3);
+ CPPUNIT_TEST(testSerialize_Xep0234_Example5);
+ CPPUNIT_TEST(testSerialize_Xep0234_Example8);
+
+ CPPUNIT_TEST(testSerialize_Xep0260_Example1);
+
+ CPPUNIT_TEST_SUITE_END();
+
+ boost::shared_ptr<JinglePayloadSerializer> createTestling() {
+ return boost::make_shared<JinglePayloadSerializer>(&collection);
+ }
+
+
+ public:
+ void testSerialize_StreamInitiationFileInfo() {
+ std::string expected = "<file"
+ " date=\"1969-07-21T02:56:15Z\""
+ " hash=\"552da749930852c69ae5d2141d3766b1\""
+ " name=\"test.txt\""
+ " size=\"1022\""
+ " xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">"
+ "<desc>This is a test. If this were a real file...</desc>"
+ "<range/>"
+ "</file>";
+
+ StreamInitiationFileInfo::ref fileInfo = boost::make_shared<StreamInitiationFileInfo>();
+ fileInfo->setDate(stringToDateTime("1969-07-21T02:56:15Z"));
+ fileInfo->setHash("552da749930852c69ae5d2141d3766b1");
+ fileInfo->setSize(1022);
+ fileInfo->setName("test.txt");
+ fileInfo->setDescription("This is a test. If this were a real file...");
+ fileInfo->setSupportsRangeRequests(true);
+
+ boost::shared_ptr<StreamInitiationFileInfoSerializer> serializer = boost::make_shared<StreamInitiationFileInfoSerializer>();
+ CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(fileInfo));
+ }
+
+ void testSerialize_StreamInitiationFileInfoRange() {
+ std::string expected = "<file hash=\"552da749930852c69ae5d2141d3766b1\""
+ " xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">"
+ "<range offset=\"270336\"/>"
+ "</file>";
+
+ StreamInitiationFileInfo::ref fileInfo = boost::make_shared<StreamInitiationFileInfo>();
+ fileInfo->setHash("552da749930852c69ae5d2141d3766b1");
+ fileInfo->setSupportsRangeRequests(true);
+ fileInfo->setRangeOffset(270336);
+
+ boost::shared_ptr<StreamInitiationFileInfoSerializer> serializer = boost::make_shared<StreamInitiationFileInfoSerializer>();
+ CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(fileInfo));
+ }
+
+
+ // IBB Transport Method Examples
+
+ // http://xmpp.org/extensions/xep-0261.html#example-1
+ void testSerialize_Xep0261_Example1() {
+ std::string expected =
+ "<jingle action=\"session-initiate\""
+ " initiator=\"romeo@montague.lit/orchard\""
+ " sid=\"a73sjjvkla37jfea\""
+ " xmlns=\"urn:xmpp:jingle:1\">"
+ "<content creator=\"initiator\" name=\"ex\">"
+ "<transport block-size=\"4096\""
+ " sid=\"ch3d9s71\""
+ " xmlns=\"urn:xmpp:jingle:transports:ibb:1\"/>"
+ "</content>"
+ "</jingle>";
+
+ JinglePayload::ref payload = boost::make_shared<JinglePayload>();
+ payload->setAction(JinglePayload::SessionInitiate);
+ payload->setSessionID("a73sjjvkla37jfea");
+ payload->setInitiator(JID("romeo@montague.lit/orchard"));
+
+ JingleIBBTransportPayload::ref transport = boost::make_shared<JingleIBBTransportPayload>();
+ transport->setBlockSize(4096);
+ transport->setSessionID("ch3d9s71");
+
+ JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
+ content->setCreator(JingleContentPayload::InitiatorCreator);
+ content->setName("ex");
+ content->addTransport(transport);
+
+ payload->addPayload(content);
+
+ CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
+ }
+
+ // http://xmpp.org/extensions/xep-0261.html#example-9
+ void testSerialize_Xep0261_Example9() {
+ std::string expected =
+ "<jingle action=\"transport-info\""
+ " initiator=\"romeo@montague.lit/orchard\""
+ " sid=\"a73sjjvkla37jfea\""
+ " xmlns=\"urn:xmpp:jingle:1\">"
+ "<content creator=\"initiator\" name=\"ex\">"
+ "<transport block-size=\"2048\""
+ " sid=\"bt8a71h6\""
+ " xmlns=\"urn:xmpp:jingle:transports:ibb:1\"/>"
+ "</content>"
+ "</jingle>";
+
+ JinglePayload::ref payload = boost::make_shared<JinglePayload>();
+ payload->setAction(JinglePayload::TransportInfo);
+ payload->setInitiator(JID("romeo@montague.lit/orchard"));
+ payload->setSessionID("a73sjjvkla37jfea");
+
+ JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
+ content->setCreator(JingleContentPayload::InitiatorCreator);
+ content->setName("ex");
+
+ JingleIBBTransportPayload::ref transport = boost::make_shared<JingleIBBTransportPayload>();
+ transport->setBlockSize(2048);
+ transport->setSessionID("bt8a71h6");
+
+ content->addTransport(transport);
+ payload->addPayload(content);
+
+ CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
+ }
+
+ // http://xmpp.org/extensions/xep-0261.html#example-13
+ void testSerialize_Xep0261_Example13() {
+ std::string expected =
+ "<jingle action=\"session-terminate\""
+ " initiator=\"romeo@montague.lit/orchard\""
+ " sid=\"a73sjjvkla37jfea\""
+ " xmlns=\"urn:xmpp:jingle:1\">"
+ "<reason><success/></reason>"
+ "</jingle>";
+
+ JinglePayload::ref payload = boost::make_shared<JinglePayload>();
+ payload->setAction(JinglePayload::SessionTerminate);
+ payload->setInitiator(JID("romeo@montague.lit/orchard"));
+ payload->setSessionID("a73sjjvkla37jfea");
+ payload->setReason(JinglePayload::Reason(JinglePayload::Reason::Success));
+
+ CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-1
+ void testSerialize_Xep0234_Example1() {
+ std::string expected = "<description xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
+ "<file>"
+ "<date>1969-07-21T02:56:15Z</date>"
+ "<desc>This is a test. If this were a real file...</desc>"
+ "<name>test.txt</name>"
+ "<range/>"
+ "<size>1022</size>"
+ "<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
+ "</file>"
+ "</description>";
+ JingleFileTransferDescription::ref desc = boost::make_shared<JingleFileTransferDescription>();
+ JingleFileTransferFileInfo fileInfo;
+
+ fileInfo.setDate(stringToDateTime("1969-07-21T02:56:15Z"));
+ fileInfo.addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
+ fileInfo.setSize(1022);
+ fileInfo.setName("test.txt");
+ fileInfo.setDescription("This is a test. If this were a real file...");
+ fileInfo.setSupportsRangeRequests(true);
+
+ desc->setFileInfo(fileInfo);
+
+ CPPUNIT_ASSERT_EQUAL(expected, boost::make_shared<JingleFileTransferDescriptionSerializer>()->serialize(desc));
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-3
+ void testSerialize_Xep0234_Example3() {
+ std::string expected =
+ "<jingle action=\"session-accept\""
+ " initiator=\"romeo@montague.lit/orchard\""
+ " sid=\"851ba2\""
+ " xmlns=\"urn:xmpp:jingle:1\">"
+ "<content creator=\"initiator\" name=\"a-file-offer\">"
+ "<description xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
+ "<file>"
+ "<date>1969-07-21T02:56:15Z</date>"
+ "<desc>This is a test. If this were a real file...</desc>"
+ "<name>test.txt</name>"
+ "<range/>"
+ "<size>1022</size>"
+ "<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
+ "</file>"
+ "</description>"
+ /*"<transport xmlns=\"urn:xmpp:jingle:transports:s5b:1\""
+ " mode=\"tcp\""
+ " sid=\"vj3hs98y\">"
+ "<candidate cid=\"ht567dq\""
+ " host=\"192.169.1.10\""
+ " jid=\"juliet@capulet.lit/balcony\""
+ " port=\"6539\""
+ " priority=\"8257636\""
+ " type=\"direct\"/>"
+ "<candidate cid=\"hr65dqyd\""
+ " host=\"134.102.201.180\""
+ " jid=\"juliet@capulet.lit/balcony\""
+ " port=\"16453\""
+ " priority=\"7929856\""
+ " type=\"assisted\"/>"
+ "<candidate cid=\"grt654q2\""
+ " host=\"2001:638:708:30c9:219:d1ff:fea4:a17d\""
+ " jid=\"juliet@capulet.lit/balcony\""
+ " port=\"6539\""
+ " priority=\"8257606\""
+ " type=\"direct\"/>"
+ "</transport>"*/
+ "</content>"
+ "</jingle>";
+
+ JinglePayload::ref payload = boost::make_shared<JinglePayload>();
+ payload->setAction(JinglePayload::SessionAccept);
+ payload->setInitiator(JID("romeo@montague.lit/orchard"));
+ payload->setSessionID("851ba2");
+
+ JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
+ content->setCreator(JingleContentPayload::InitiatorCreator);
+ content->setName("a-file-offer");
+
+ JingleFileTransferDescription::ref description = boost::make_shared<JingleFileTransferDescription>();
+ JingleFileTransferFileInfo fileInfo;
+ fileInfo.setName("test.txt");
+ fileInfo.setSize(1022);
+ fileInfo.addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
+ fileInfo.setDate(stringToDateTime("1969-07-21T02:56:15Z"));
+ fileInfo.setDescription("This is a test. If this were a real file...");
+ fileInfo.setSupportsRangeRequests(true);
+
+ description->setFileInfo(fileInfo);
+ content->addDescription(description);
+ payload->addPayload(content);
+
+ CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-5
+ void testSerialize_Xep0234_Example5() {
+ std::string expected =
+ "<jingle"
+ " action=\"transport-info\""
+ " initiator=\"romeo@montague.lit/orchard\""
+ " sid=\"a73sjjvkla37jfea\""
+ " xmlns=\"urn:xmpp:jingle:1\">"
+ "<content creator=\"initiator\" name=\"ex\"/>"
+ /*"<transport"
+ " sid=\"vj3hs98y\""
+ " xmlns=\"urn:xmpp:jingle:transports:s5b:1\">"
+ "<candidate-used cid=\"hr65dqyd\"/>"
+ "</transport>"*/
+ //"</content>"
+ "</jingle>";
+
+ JinglePayload::ref payload = boost::make_shared<JinglePayload>();
+ payload->setAction(JinglePayload::TransportInfo);
+ payload->setInitiator(JID("romeo@montague.lit/orchard"));
+ payload->setSessionID("a73sjjvkla37jfea");
+
+ JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
+ content->setCreator(JingleContentPayload::InitiatorCreator);
+ content->setName("ex");
+ payload->addPayload(content);
+
+ CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-8
+ void testSerialize_Xep0234_Example8() {
+ std::string expected =
+ "<jingle"
+ " action=\"session-info\""
+ " initiator=\"romeo@montague.lit/orchard\""
+ " sid=\"a73sjjvkla37jfea\""
+ " xmlns=\"urn:xmpp:jingle:1\">"
+ "<checksum xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
+ "<file>"
+ "<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
+ "</file>"
+ "</checksum>"
+ "</jingle>";
+
+ JinglePayload::ref payload = boost::make_shared<JinglePayload>();
+ payload->setAction(JinglePayload::SessionInfo);
+ payload->setInitiator(JID("romeo@montague.lit/orchard"));
+ payload->setSessionID("a73sjjvkla37jfea");
+
+ JingleFileTransferHash::ref hash = boost::make_shared<JingleFileTransferHash>();
+ hash->getFileInfo().addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
+
+ payload->addPayload(hash);
+
+ CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
+ }
+
+ // http://xmpp.org/extensions/xep-0260.html#example-1
+ void testSerialize_Xep0260_Example1() {
+ std::string expected =
+ "<jingle"
+ " action=\"session-initiate\""
+ " initiator=\"romeo@montague.lit/orchard\""
+ " sid=\"a73sjjvkla37jfea\""
+ " xmlns=\"urn:xmpp:jingle:1\">"
+ "<content creator=\"initiator\" name=\"ex\">"
+ "<transport"
+ " dstaddr=\"1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba\""
+ " mode=\"tcp\""
+ " sid=\"vj3hs98y\""
+ " xmlns=\"urn:xmpp:jingle:transports:s5b:1\">"
+ "<candidate cid=\"hft54dqy\""
+ " host=\"192.168.4.1\""
+ " jid=\"romeo@montague.lit/orchard\""
+ " port=\"5086\""
+ " priority=\"8257636\""
+ " type=\"direct\"/>"
+ "<candidate cid=\"hutr46fe\""
+ " host=\"24.24.24.1\""
+ " jid=\"romeo@montague.lit/orchard\""
+ " port=\"5087\""
+ " priority=\"8258636\""
+ " type=\"direct\"/>"
+ "</transport>"
+ "</content>"
+ "</jingle>";
+
+ JinglePayload::ref payload = boost::make_shared<JinglePayload>();
+ payload->setAction(JinglePayload::SessionInitiate);
+ payload->setInitiator(JID("romeo@montague.lit/orchard"));
+ payload->setSessionID("a73sjjvkla37jfea");
+
+ JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
+ content->setCreator(JingleContentPayload::InitiatorCreator);
+ content->setName("ex");
+
+ JingleS5BTransportPayload::ref transport = boost::make_shared<JingleS5BTransportPayload>();
+ transport->setMode(JingleS5BTransportPayload::TCPMode);
+ transport->setDstAddr("1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba");
+ transport->setSessionID("vj3hs98y");
+
+ JingleS5BTransportPayload::Candidate candidate1;
+ candidate1.cid = "hft54dqy";
+ candidate1.hostPort = HostAddressPort(HostAddress("192.168.4.1"), 5086);
+ candidate1.jid = JID("romeo@montague.lit/orchard");
+ candidate1.priority = 8257636;
+ candidate1.type = JingleS5BTransportPayload::Candidate::DirectType;
+ transport->addCandidate(candidate1);
+
+ JingleS5BTransportPayload::Candidate candidate2;
+ candidate2.cid = "hutr46fe";
+ candidate2.hostPort = HostAddressPort(HostAddress("24.24.24.1"), 5087);
+ candidate2.jid = JID("romeo@montague.lit/orchard");
+ candidate2.priority = 8258636;
+ candidate2.type = JingleS5BTransportPayload::Candidate::DirectType;
+ transport->addCandidate(candidate2);
+
+ content->addTransport(transport);
+
+ payload->addPayload(content);
+
+ CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
+ }
+
+ private:
+ FullPayloadSerializerCollection collection;
};
CPPUNIT_TEST_SUITE_REGISTRATION(JingleSerializersTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp
index caa904e..0eda01c 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp
@@ -15,50 +15,50 @@
using namespace Swift;
class MAMFinSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(MAMFinSerializerTest);
- CPPUNIT_TEST(testSerialize_XEP0313_Exmaple1);
- CPPUNIT_TEST(testSerialize_XEP0313_Exmaple9);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(MAMFinSerializerTest);
+ CPPUNIT_TEST(testSerialize_XEP0313_Exmaple1);
+ CPPUNIT_TEST(testSerialize_XEP0313_Exmaple9);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize_XEP0313_Exmaple1() {
- MAMFinSerializer serializer;
+ public:
+ void testSerialize_XEP0313_Exmaple1() {
+ MAMFinSerializer serializer;
- boost::shared_ptr<MAMFin> fin = boost::make_shared<MAMFin>();
- fin->setQueryID("f27");
+ boost::shared_ptr<MAMFin> fin = boost::make_shared<MAMFin>();
+ fin->setQueryID("f27");
- std::string expectedResult =
- "<fin queryid=\"f27\" xmlns=\"urn:xmpp:mam:0\"/>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(fin));
- }
+ std::string expectedResult =
+ "<fin queryid=\"f27\" xmlns=\"urn:xmpp:mam:0\"/>";
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(fin));
+ }
- void testSerialize_XEP0313_Exmaple9() {
- MAMFinSerializer serializer;
+ void testSerialize_XEP0313_Exmaple9() {
+ MAMFinSerializer serializer;
- boost::shared_ptr<MAMFin> fin = boost::make_shared<MAMFin>();
- fin->setComplete(true);
+ boost::shared_ptr<MAMFin> fin = boost::make_shared<MAMFin>();
+ fin->setComplete(true);
- boost::shared_ptr<ResultSet> set = boost::make_shared<ResultSet>();
- set->setFirstID(std::string("23452-4534-1"));
- set->setFirstIDIndex(0);
- set->setLastID(std::string("390-2342-22"));
- set->setCount(16);
+ boost::shared_ptr<ResultSet> set = boost::make_shared<ResultSet>();
+ set->setFirstID(std::string("23452-4534-1"));
+ set->setFirstIDIndex(0);
+ set->setLastID(std::string("390-2342-22"));
+ set->setCount(16);
- fin->setResultSet(set);
+ fin->setResultSet(set);
- std::string expectedResult =
- "<fin complete=\"true\" xmlns=\"urn:xmpp:mam:0\">"
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<count>16</count>"
- "<first index=\"0\">23452-4534-1</first>"
- "<last>390-2342-22</last>"
- "</set>"
- "</fin>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(fin));
- }
+ std::string expectedResult =
+ "<fin complete=\"true\" xmlns=\"urn:xmpp:mam:0\">"
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<count>16</count>"
+ "<first index=\"0\">23452-4534-1</first>"
+ "<last>390-2342-22</last>"
+ "</set>"
+ "</fin>";
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(fin));
+ }
- private:
- FullPayloadSerializerCollection serializers;
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(MAMFinSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMQuerySerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMQuerySerializerTest.cpp
index d9f7f12..faf788d 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMQuerySerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMQuerySerializerTest.cpp
@@ -19,55 +19,55 @@
using namespace Swift;
class MAMQuerySerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(MAMQuerySerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(MAMQuerySerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize() {
- MAMQuerySerializer serializer;
+ public:
+ void testSerialize() {
+ MAMQuerySerializer serializer;
- boost::shared_ptr<Form> parameters(boost::make_shared<Form>());
+ boost::shared_ptr<Form> parameters(boost::make_shared<Form>());
- boost::shared_ptr<FormField> fieldType = boost::make_shared<FormField>(FormField::TextSingleType);
- fieldType->setName("FORM_TYPE");
- fieldType->addValue("urn:xmpp:mam:0");
- parameters->addField(fieldType);
+ boost::shared_ptr<FormField> fieldType = boost::make_shared<FormField>(FormField::TextSingleType);
+ fieldType->setName("FORM_TYPE");
+ fieldType->addValue("urn:xmpp:mam:0");
+ parameters->addField(fieldType);
- boost::shared_ptr<FormField> fieldStart = boost::make_shared<FormField>(FormField::TextSingleType);
- fieldStart->setName("start");
- fieldStart->addValue("2010-08-07T00:00:00Z");
- parameters->addField(fieldStart);
+ boost::shared_ptr<FormField> fieldStart = boost::make_shared<FormField>(FormField::TextSingleType);
+ fieldStart->setName("start");
+ fieldStart->addValue("2010-08-07T00:00:00Z");
+ parameters->addField(fieldStart);
- boost::shared_ptr<ResultSet> set = boost::make_shared<ResultSet>();
- set->setMaxItems(10);
+ boost::shared_ptr<ResultSet> set = boost::make_shared<ResultSet>();
+ set->setMaxItems(10);
- boost::shared_ptr<MAMQuery> query(boost::make_shared<MAMQuery>());
- query->setQueryID(std::string("id0"));
- query->setNode(std::string("node1"));
- query->setForm(parameters);
- query->setResultSet(set);
+ boost::shared_ptr<MAMQuery> query(boost::make_shared<MAMQuery>());
+ query->setQueryID(std::string("id0"));
+ query->setNode(std::string("node1"));
+ query->setForm(parameters);
+ query->setResultSet(set);
- std::string expectedResult =
- "<query node=\"node1\" queryid=\"id0\" xmlns=\"urn:xmpp:mam:0\">"
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<field type=\"text-single\" var=\"FORM_TYPE\">"
- "<value>urn:xmpp:mam:0</value>"
- "</field>"
- "<field type=\"text-single\" var=\"start\">"
- "<value>2010-08-07T00:00:00Z</value>"
- "</field>"
- "</x>"
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<max>10</max>"
- "</set>"
- "</query>";
+ std::string expectedResult =
+ "<query node=\"node1\" queryid=\"id0\" xmlns=\"urn:xmpp:mam:0\">"
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<field type=\"text-single\" var=\"FORM_TYPE\">"
+ "<value>urn:xmpp:mam:0</value>"
+ "</field>"
+ "<field type=\"text-single\" var=\"start\">"
+ "<value>2010-08-07T00:00:00Z</value>"
+ "</field>"
+ "</x>"
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<max>10</max>"
+ "</set>"
+ "</query>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(query));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(query));
+ }
- private:
- FullPayloadSerializerCollection serializers;
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(MAMQuerySerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMResultSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMResultSerializerTest.cpp
index c829f3d..40ca27d 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMResultSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMResultSerializerTest.cpp
@@ -19,44 +19,44 @@
using namespace Swift;
class MAMResultSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(MAMResultSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- MAMResultSerializer serializer(&serializers);
-
- boost::shared_ptr<Message> message(boost::make_shared<Message>());
- message->setType(Message::Chat);
- message->setTo(JID("juliet@capulet.lit/balcony"));
- message->setFrom(JID("romeo@montague.lit/orchard"));
- message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
-
- boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
- forwarded->setStanza(message);
- forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
-
- boost::shared_ptr<MAMResult> result(boost::make_shared<MAMResult>());
- result->setID("28482-98726-73623");
- result->setQueryID(std::string("f27"));
- result->setPayload(forwarded);
-
- std::string expectedResult =
- "<result id=\"28482-98726-73623\" queryid=\"f27\" xmlns=\"urn:xmpp:mam:0\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>"
- "</result>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(result));
- }
-
- private:
- FullPayloadSerializerCollection serializers;
+ CPPUNIT_TEST_SUITE(MAMResultSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ MAMResultSerializer serializer(&serializers);
+
+ boost::shared_ptr<Message> message(boost::make_shared<Message>());
+ message->setType(Message::Chat);
+ message->setTo(JID("juliet@capulet.lit/balcony"));
+ message->setFrom(JID("romeo@montague.lit/orchard"));
+ message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
+
+ boost::shared_ptr<Forwarded> forwarded(boost::make_shared<Forwarded>());
+ forwarded->setStanza(message);
+ forwarded->setDelay(boost::make_shared<Delay>(stringToDateTime(std::string("2010-07-10T23:08:25Z"))));
+
+ boost::shared_ptr<MAMResult> result(boost::make_shared<MAMResult>());
+ result->setID("28482-98726-73623");
+ result->setQueryID(std::string("f27"));
+ result->setPayload(forwarded);
+
+ std::string expectedResult =
+ "<result id=\"28482-98726-73623\" queryid=\"f27\" xmlns=\"urn:xmpp:mam:0\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<message from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\" xmlns=\"jabber:client\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>"
+ "</result>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(result));
+ }
+
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(MAMResultSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MUCAdminPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MUCAdminPayloadSerializerTest.cpp
index 2c0baff..fc6b346 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MUCAdminPayloadSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MUCAdminPayloadSerializerTest.cpp
@@ -15,25 +15,25 @@ using namespace Swift;
class MUCAdminPayloadSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(MUCAdminPayloadSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- MUCAdminPayloadSerializerTest() {}
-
- void testSerialize() {
- MUCAdminPayloadSerializer testling;
- boost::shared_ptr<MUCAdminPayload> admin = boost::make_shared<MUCAdminPayload>();
- MUCItem item;
- item.affiliation = MUCOccupant::Owner;
- item.role = MUCOccupant::Visitor;
- item.reason = "malice";
- item.actor = JID("kev@tester.lit");
- admin->addItem(item);
-
- CPPUNIT_ASSERT_EQUAL(std::string("<query xmlns=\"http://jabber.org/protocol/muc#admin\"><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item></query>"), testling.serialize(admin));
- }
+ CPPUNIT_TEST_SUITE(MUCAdminPayloadSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ MUCAdminPayloadSerializerTest() {}
+
+ void testSerialize() {
+ MUCAdminPayloadSerializer testling;
+ boost::shared_ptr<MUCAdminPayload> admin = boost::make_shared<MUCAdminPayload>();
+ MUCItem item;
+ item.affiliation = MUCOccupant::Owner;
+ item.role = MUCOccupant::Visitor;
+ item.reason = "malice";
+ item.actor = JID("kev@tester.lit");
+ admin->addItem(item);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<query xmlns=\"http://jabber.org/protocol/muc#admin\"><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item></query>"), testling.serialize(admin));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(MUCAdminPayloadSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp
index 7bd729d..223e7d9 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp
@@ -13,14 +13,14 @@
namespace Swift {
std::string PayloadsSerializer::serialize(boost::shared_ptr<Payload> payload) {
- PayloadSerializer* serializer = serializers.getPayloadSerializer(payload);
- if (serializer) {
- return serializer->serialize(payload);
- }
- else {
- CPPUNIT_ASSERT(false);
- return "";
- }
+ PayloadSerializer* serializer = serializers.getPayloadSerializer(payload);
+ if (serializer) {
+ return serializer->serialize(payload);
+ }
+ else {
+ CPPUNIT_ASSERT(false);
+ return "";
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h
index 6abe396..827e9da 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h
@@ -14,11 +14,11 @@
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
namespace Swift {
- class PayloadsSerializer {
- public:
- std::string serialize(boost::shared_ptr<Payload> payload);
+ class PayloadsSerializer {
+ public:
+ std::string serialize(boost::shared_ptr<Payload> payload);
- private:
- FullPayloadSerializerCollection serializers;
- };
+ private:
+ FullPayloadSerializerCollection serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp
index 272c25f..19971c2 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp
@@ -13,19 +13,19 @@ using namespace Swift;
class PrioritySerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(PrioritySerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(PrioritySerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- PrioritySerializerTest() {}
+ public:
+ PrioritySerializerTest() {}
- void testSerialize() {
- PrioritySerializer testling;
- boost::shared_ptr<Priority> priority(new Priority(-113));
+ void testSerialize() {
+ PrioritySerializer testling;
+ boost::shared_ptr<Priority> priority(new Priority(-113));
- CPPUNIT_ASSERT_EQUAL(std::string("<priority>-113</priority>"), testling.serialize(priority));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<priority>-113</priority>"), testling.serialize(priority));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(PrioritySerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp
index 5236821..3b115b3 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp
@@ -14,37 +14,37 @@
using namespace Swift;
class PrivateStorageSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PrivateStorageSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- PrivateStorageSerializerTest() {}
-
- void testSerialize() {
- PayloadsSerializer serializer;
-
- boost::shared_ptr<PrivateStorage> privateStorage(new PrivateStorage());
- boost::shared_ptr<Storage> storage(new Storage());
- Storage::Room room;
- room.name = "Swift";
- room.jid = JID("swift@rooms.swift.im");
- room.nick = "Alice";
- storage->addRoom(room);
- privateStorage->setPayload(storage);
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<query xmlns=\"jabber:iq:private\">"
- "<storage xmlns=\"storage:bookmarks\">"
- "<conference "
- "autojoin=\"0\" "
- "jid=\"swift@rooms.swift.im\" "
- "name=\"Swift\">"
- "<nick>Alice</nick>"
- "</conference>"
- "</storage>"
- "</query>"), serializer.serialize(privateStorage));
- }
+ CPPUNIT_TEST_SUITE(PrivateStorageSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ PrivateStorageSerializerTest() {}
+
+ void testSerialize() {
+ PayloadsSerializer serializer;
+
+ boost::shared_ptr<PrivateStorage> privateStorage(new PrivateStorage());
+ boost::shared_ptr<Storage> storage(new Storage());
+ Storage::Room room;
+ room.name = "Swift";
+ room.jid = JID("swift@rooms.swift.im");
+ room.nick = "Alice";
+ storage->addRoom(room);
+ privateStorage->setPayload(storage);
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<query xmlns=\"jabber:iq:private\">"
+ "<storage xmlns=\"storage:bookmarks\">"
+ "<conference "
+ "autojoin=\"0\" "
+ "jid=\"swift@rooms.swift.im\" "
+ "name=\"Swift\">"
+ "<nick>Alice</nick>"
+ "</conference>"
+ "</storage>"
+ "</query>"), serializer.serialize(privateStorage));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(PrivateStorageSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemSerializerTest.cpp
index c871a4e..b835421 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemSerializerTest.cpp
@@ -17,43 +17,43 @@
using namespace Swift;
class PubSubItemSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PubSubItemSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerializeEmptyID);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(PubSubItemSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerializeEmptyID);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize() {
- PubSubItemSerializer serializer(&serializers);
+ public:
+ void testSerialize() {
+ PubSubItemSerializer serializer(&serializers);
- boost::shared_ptr<RawXMLPayload> payload(boost::make_shared<RawXMLPayload>());
- payload->setRawXML("<payload xmlns=\"tmp\"/>");
+ boost::shared_ptr<RawXMLPayload> payload(boost::make_shared<RawXMLPayload>());
+ payload->setRawXML("<payload xmlns=\"tmp\"/>");
- boost::shared_ptr<PubSubItem> item(boost::make_shared<PubSubItem>());
- item->addData(payload);
- item->setID("pubsub-item-1");
+ boost::shared_ptr<PubSubItem> item(boost::make_shared<PubSubItem>());
+ item->addData(payload);
+ item->setID("pubsub-item-1");
- std::string expectedResult =
- "<item id=\"pubsub-item-1\" xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<payload xmlns=\"tmp\"/>"
- "</item>";
+ std::string expectedResult =
+ "<item id=\"pubsub-item-1\" xmlns=\"http://jabber.org/protocol/pubsub\">"
+ "<payload xmlns=\"tmp\"/>"
+ "</item>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(item));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(item));
+ }
- void testSerializeEmptyID() {
- PubSubItemSerializer serializer(&serializers);
+ void testSerializeEmptyID() {
+ PubSubItemSerializer serializer(&serializers);
- boost::shared_ptr<PubSubItem> item(boost::make_shared<PubSubItem>());
+ boost::shared_ptr<PubSubItem> item(boost::make_shared<PubSubItem>());
- std::string expectedResult =
- "<item xmlns=\"http://jabber.org/protocol/pubsub\"/>";
+ std::string expectedResult =
+ "<item xmlns=\"http://jabber.org/protocol/pubsub\"/>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(item));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(item));
+ }
- private:
- FullPayloadSerializerCollection serializers;
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(PubSubItemSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemsSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemsSerializerTest.cpp
index d557a89..fa99202 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemsSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PubSubItemsSerializerTest.cpp
@@ -17,61 +17,61 @@
using namespace Swift;
class PubSubItemsSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PubSubItemsSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerializeEmptyItems);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(PubSubItemsSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerializeEmptyItems);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize() {
- PubSubItemsSerializer serializer(&serializers);
+ public:
+ void testSerialize() {
+ PubSubItemsSerializer serializer(&serializers);
- boost::shared_ptr<RawXMLPayload> payload1(boost::make_shared<RawXMLPayload>());
- payload1->setRawXML("<payload xmlns=\"tmp\"/>");
+ boost::shared_ptr<RawXMLPayload> payload1(boost::make_shared<RawXMLPayload>());
+ payload1->setRawXML("<payload xmlns=\"tmp\"/>");
- boost::shared_ptr<PubSubItem> item1(boost::make_shared<PubSubItem>());
- item1->addData(payload1);
- item1->setID("pubsub-item-1");
+ boost::shared_ptr<PubSubItem> item1(boost::make_shared<PubSubItem>());
+ item1->addData(payload1);
+ item1->setID("pubsub-item-1");
- boost::shared_ptr<RawXMLPayload> payload2(boost::make_shared<RawXMLPayload>());
- payload2->setRawXML("<payload xmlns=\"other-tmp\"/>");
+ boost::shared_ptr<RawXMLPayload> payload2(boost::make_shared<RawXMLPayload>());
+ payload2->setRawXML("<payload xmlns=\"other-tmp\"/>");
- boost::shared_ptr<PubSubItem> item2(boost::make_shared<PubSubItem>());
- item2->addData(payload2);
- item2->setID("pubsub-item-2");
+ boost::shared_ptr<PubSubItem> item2(boost::make_shared<PubSubItem>());
+ item2->addData(payload2);
+ item2->setID("pubsub-item-2");
- boost::shared_ptr<PubSubItems> items(boost::make_shared<PubSubItems>());
- items->setNode("test-node");
- items->setSubscriptionID(std::string("sub-id"));
- items->addItem(item1);
- items->addItem(item2);
+ boost::shared_ptr<PubSubItems> items(boost::make_shared<PubSubItems>());
+ items->setNode("test-node");
+ items->setSubscriptionID(std::string("sub-id"));
+ items->addItem(item1);
+ items->addItem(item2);
- std::string expectedResult =
- "<items node=\"test-node\" subid=\"sub-id\" xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<item id=\"pubsub-item-1\" xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<payload xmlns=\"tmp\"/>"
- "</item>"
- "<item id=\"pubsub-item-2\" xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<payload xmlns=\"other-tmp\"/>"
- "</item>"
- "</items>";
+ std::string expectedResult =
+ "<items node=\"test-node\" subid=\"sub-id\" xmlns=\"http://jabber.org/protocol/pubsub\">"
+ "<item id=\"pubsub-item-1\" xmlns=\"http://jabber.org/protocol/pubsub\">"
+ "<payload xmlns=\"tmp\"/>"
+ "</item>"
+ "<item id=\"pubsub-item-2\" xmlns=\"http://jabber.org/protocol/pubsub\">"
+ "<payload xmlns=\"other-tmp\"/>"
+ "</item>"
+ "</items>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(items));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(items));
+ }
- void testSerializeEmptyItems() {
- PubSubItemsSerializer serializer(&serializers);
+ void testSerializeEmptyItems() {
+ PubSubItemsSerializer serializer(&serializers);
- boost::shared_ptr<PubSubItems> items(boost::make_shared<PubSubItems>());
+ boost::shared_ptr<PubSubItems> items(boost::make_shared<PubSubItems>());
- std::string expectedResult =
- "<items node=\"\" xmlns=\"http://jabber.org/protocol/pubsub\"/>";
+ std::string expectedResult =
+ "<items node=\"\" xmlns=\"http://jabber.org/protocol/pubsub\"/>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(items));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(items));
+ }
- private:
- FullPayloadSerializerCollection serializers;
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(PubSubItemsSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp
index 6a51182..1f40b26 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp
@@ -18,19 +18,19 @@
using namespace Swift;
class ReplaceSerializerTest: public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ReplaceSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- ReplaceSerializerTest() {}
-
- void testSerialize() {
- ReplaceSerializer testling;
- boost::shared_ptr<Replace> replace(new Replace());
- replace->setID("bad1");
- CPPUNIT_ASSERT_EQUAL(std::string("<replace id = 'bad1' xmlns='urn:xmpp:message-correct:0'/>"), testling.serialize(replace));
- }
+ CPPUNIT_TEST_SUITE(ReplaceSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ ReplaceSerializerTest() {}
+
+ void testSerialize() {
+ ReplaceSerializer testling;
+ boost::shared_ptr<Replace> replace(new Replace());
+ replace->setID("bad1");
+ CPPUNIT_ASSERT_EQUAL(std::string("<replace id = 'bad1' xmlns='urn:xmpp:message-correct:0'/>"), testling.serialize(replace));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ReplaceSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp
index 718370f..9bc637f 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp
@@ -13,43 +13,43 @@ using namespace Swift;
class ResourceBindSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(ResourceBindSerializerTest);
- CPPUNIT_TEST(testSerialize_JID);
- CPPUNIT_TEST(testSerialize_Resource);
- CPPUNIT_TEST(testSerialize_Empty);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- ResourceBindSerializerTest() {}
-
- void testSerialize_JID() {
- ResourceBindSerializer testling;
- boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
- resourceBind->setJID(JID("somenode@example.com/someresource"));
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">"
- "<jid>somenode@example.com/someresource</jid>"
- "</bind>"), testling.serialize(resourceBind));
- }
-
- void testSerialize_Resource() {
- ResourceBindSerializer testling;
- boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
- resourceBind->setResource("someresource");
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">"
- "<resource>someresource</resource>"
- "</bind>"), testling.serialize(resourceBind));
- }
-
- void testSerialize_Empty() {
- ResourceBindSerializer testling;
- boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
-
- CPPUNIT_ASSERT_EQUAL(std::string("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"), testling.serialize(resourceBind));
- }
+ CPPUNIT_TEST_SUITE(ResourceBindSerializerTest);
+ CPPUNIT_TEST(testSerialize_JID);
+ CPPUNIT_TEST(testSerialize_Resource);
+ CPPUNIT_TEST(testSerialize_Empty);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ ResourceBindSerializerTest() {}
+
+ void testSerialize_JID() {
+ ResourceBindSerializer testling;
+ boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
+ resourceBind->setJID(JID("somenode@example.com/someresource"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">"
+ "<jid>somenode@example.com/someresource</jid>"
+ "</bind>"), testling.serialize(resourceBind));
+ }
+
+ void testSerialize_Resource() {
+ ResourceBindSerializer testling;
+ boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
+ resourceBind->setResource("someresource");
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">"
+ "<resource>someresource</resource>"
+ "</bind>"), testling.serialize(resourceBind));
+ }
+
+ void testSerialize_Empty() {
+ ResourceBindSerializer testling;
+ boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"), testling.serialize(resourceBind));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ResourceBindSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp
index b44ac0b..0b0163e 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp
@@ -16,103 +16,103 @@
using namespace Swift;
class ResultSetSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ResultSetSerializerTest);
- CPPUNIT_TEST(testSerializeFull);
- CPPUNIT_TEST(testSerializeMaxItems);
- CPPUNIT_TEST(testSerializeEmptyBefore);
- CPPUNIT_TEST(testSerializeFirst);
- CPPUNIT_TEST(testSerializeFirstWithIndex);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(ResultSetSerializerTest);
+ CPPUNIT_TEST(testSerializeFull);
+ CPPUNIT_TEST(testSerializeMaxItems);
+ CPPUNIT_TEST(testSerializeEmptyBefore);
+ CPPUNIT_TEST(testSerializeFirst);
+ CPPUNIT_TEST(testSerializeFirstWithIndex);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerializeFull() {
- ResultSetSerializer serializer;
+ public:
+ void testSerializeFull() {
+ ResultSetSerializer serializer;
- boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
+ boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
- resultSet->setMaxItems(100);
- resultSet->setCount(800);
- resultSet->setIndex(0);
- resultSet->setFirstIDIndex(123);
- resultSet->setFirstID(std::string("stpeter@jabber.org"));
- resultSet->setLastID(std::string("peterpan@neverland.lit"));
- resultSet->setAfter(std::string("09af3-cc343-b409f"));
- resultSet->setBefore(std::string("decaf-badba-dbad1"));
+ resultSet->setMaxItems(100);
+ resultSet->setCount(800);
+ resultSet->setIndex(0);
+ resultSet->setFirstIDIndex(123);
+ resultSet->setFirstID(std::string("stpeter@jabber.org"));
+ resultSet->setLastID(std::string("peterpan@neverland.lit"));
+ resultSet->setAfter(std::string("09af3-cc343-b409f"));
+ resultSet->setBefore(std::string("decaf-badba-dbad1"));
- std::string expectedResult =
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<max>100</max>"
- "<count>800</count>"
- "<index>0</index>"
- "<first index=\"123\">stpeter@jabber.org</first>"
- "<last>peterpan@neverland.lit</last>"
- "<before>decaf-badba-dbad1</before>"
- "<after>09af3-cc343-b409f</after>"
- "</set>";
+ std::string expectedResult =
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<max>100</max>"
+ "<count>800</count>"
+ "<index>0</index>"
+ "<first index=\"123\">stpeter@jabber.org</first>"
+ "<last>peterpan@neverland.lit</last>"
+ "<before>decaf-badba-dbad1</before>"
+ "<after>09af3-cc343-b409f</after>"
+ "</set>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
+ }
- void testSerializeMaxItems() {
- ResultSetSerializer serializer;
+ void testSerializeMaxItems() {
+ ResultSetSerializer serializer;
- boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
+ boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
- resultSet->setMaxItems(100);
+ resultSet->setMaxItems(100);
- std::string expectedResult =
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<max>100</max>"
- "</set>";
+ std::string expectedResult =
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<max>100</max>"
+ "</set>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
+ }
- void testSerializeEmptyBefore() {
- ResultSetSerializer serializer;
+ void testSerializeEmptyBefore() {
+ ResultSetSerializer serializer;
- boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
+ boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
- resultSet->setBefore(std::string());
+ resultSet->setBefore(std::string());
- std::string expectedResult =
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<before/>"
- "</set>";
+ std::string expectedResult =
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<before/>"
+ "</set>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
+ }
- void testSerializeFirst() {
- ResultSetSerializer serializer;
+ void testSerializeFirst() {
+ ResultSetSerializer serializer;
- boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
+ boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
- resultSet->setFirstID(std::string("stpeter@jabber.org"));
+ resultSet->setFirstID(std::string("stpeter@jabber.org"));
- std::string expectedResult =
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<first>stpeter@jabber.org</first>"
- "</set>";
+ std::string expectedResult =
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<first>stpeter@jabber.org</first>"
+ "</set>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
+ }
- void testSerializeFirstWithIndex() {
- ResultSetSerializer serializer;
+ void testSerializeFirstWithIndex() {
+ ResultSetSerializer serializer;
- boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
+ boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
- resultSet->setFirstID(std::string("stpeter@jabber.org"));
- resultSet->setFirstIDIndex(123);
+ resultSet->setFirstID(std::string("stpeter@jabber.org"));
+ resultSet->setFirstIDIndex(123);
- std::string expectedResult =
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<first index=\"123\">stpeter@jabber.org</first>"
- "</set>";
+ std::string expectedResult =
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<first index=\"123\">stpeter@jabber.org</first>"
+ "</set>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ResultSetSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp
index b6a90d9..65922f7 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp
@@ -13,42 +13,42 @@ using namespace Swift;
class RosterItemExchangeSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(RosterItemExchangeSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- RosterItemExchangeSerializerTest() {}
-
- void testSerialize() {
- RosterItemExchangeSerializer testling;
- boost::shared_ptr<RosterItemExchangePayload> roster(new RosterItemExchangePayload());
-
- RosterItemExchangePayload::Item item1;
- item1.setJID("foo@bar.com");
- item1.setName("Foo @ Bar");
- item1.setAction(RosterItemExchangePayload::Item::Add);
- item1.addGroup("Group 1");
- item1.addGroup("Group 2");
- roster->addItem(item1);
-
- RosterItemExchangePayload::Item item2;
- item2.setJID("baz@blo.com");
- item2.setName("Baz");
- item2.setAction(RosterItemExchangePayload::Item::Modify);
- roster->addItem(item2);
-
- std::string expectedResult =
- "<x xmlns=\"http://jabber.org/protocol/rosterx\">"
- "<item action=\"add\" jid=\"foo@bar.com\" name=\"Foo @ Bar\">"
- "<group>Group 1</group>"
- "<group>Group 2</group>"
- "</item>"
- "<item action=\"modify\" jid=\"baz@blo.com\" name=\"Baz\"/>"
- "</x>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
- }
+ CPPUNIT_TEST_SUITE(RosterItemExchangeSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ RosterItemExchangeSerializerTest() {}
+
+ void testSerialize() {
+ RosterItemExchangeSerializer testling;
+ boost::shared_ptr<RosterItemExchangePayload> roster(new RosterItemExchangePayload());
+
+ RosterItemExchangePayload::Item item1;
+ item1.setJID("foo@bar.com");
+ item1.setName("Foo @ Bar");
+ item1.setAction(RosterItemExchangePayload::Item::Add);
+ item1.addGroup("Group 1");
+ item1.addGroup("Group 2");
+ roster->addItem(item1);
+
+ RosterItemExchangePayload::Item item2;
+ item2.setJID("baz@blo.com");
+ item2.setName("Baz");
+ item2.setAction(RosterItemExchangePayload::Item::Modify);
+ roster->addItem(item2);
+
+ std::string expectedResult =
+ "<x xmlns=\"http://jabber.org/protocol/rosterx\">"
+ "<item action=\"add\" jid=\"foo@bar.com\" name=\"Foo @ Bar\">"
+ "<group>Group 1</group>"
+ "<group>Group 2</group>"
+ "</item>"
+ "<item action=\"modify\" jid=\"baz@blo.com\" name=\"Baz\"/>"
+ "</x>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(RosterItemExchangeSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp
index b75b0a0..6670bb8 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp
@@ -12,90 +12,90 @@
using namespace Swift;
class RosterSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(RosterSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_ItemWithUnknownContent);
- CPPUNIT_TEST(testSerialize_WithVersion);
- CPPUNIT_TEST(testSerialize_WithEmptyVersion);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- RosterSerializer testling;
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
-
- RosterItemPayload item1;
- item1.setJID(JID("foo@bar.com"));
- item1.setName("Foo @ Bar");
- item1.setSubscription(RosterItemPayload::From);
- item1.addGroup("Group 1");
- item1.addGroup("Group 2");
- item1.setSubscriptionRequested();
- roster->addItem(item1);
-
- RosterItemPayload item2;
- item2.setJID(JID("baz@blo.com"));
- item2.setName("Baz");
- roster->addItem(item2);
-
- std::string expectedResult =
- "<query xmlns=\"jabber:iq:roster\">"
- "<item ask=\"subscribe\" jid=\"foo@bar.com\" name=\"Foo @ Bar\" subscription=\"from\">"
- "<group>Group 1</group>"
- "<group>Group 2</group>"
- "</item>"
- "<item jid=\"baz@blo.com\" name=\"Baz\" subscription=\"none\"/>"
- "</query>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
- }
-
- void testSerialize_ItemWithUnknownContent() {
- RosterSerializer testling;
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
-
- RosterItemPayload item;
- item.setJID(JID("baz@blo.com"));
- item.setName("Baz");
- item.addGroup("Group 1");
- item.addGroup("Group 2");
- item.addUnknownContent(std::string(
- "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>"
- "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>"));
- roster->addItem(item);
-
- std::string expectedResult =
- "<query xmlns=\"jabber:iq:roster\">"
- "<item jid=\"baz@blo.com\" name=\"Baz\" subscription=\"none\">"
- "<group>Group 1</group>"
- "<group>Group 2</group>"
- "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>"
- "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>"
- "</item>"
- "</query>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
- }
-
- void testSerialize_WithVersion() {
- RosterSerializer testling;
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
- roster->setVersion("ver20");
-
- std::string expectedResult = "<query ver=\"ver20\" xmlns=\"jabber:iq:roster\"/>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
- }
-
- void testSerialize_WithEmptyVersion() {
- RosterSerializer testling;
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
- roster->setVersion("");
-
- std::string expectedResult = "<query ver=\"\" xmlns=\"jabber:iq:roster\"/>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
- }
+ CPPUNIT_TEST_SUITE(RosterSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_ItemWithUnknownContent);
+ CPPUNIT_TEST(testSerialize_WithVersion);
+ CPPUNIT_TEST(testSerialize_WithEmptyVersion);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ RosterSerializer testling;
+ boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+
+ RosterItemPayload item1;
+ item1.setJID(JID("foo@bar.com"));
+ item1.setName("Foo @ Bar");
+ item1.setSubscription(RosterItemPayload::From);
+ item1.addGroup("Group 1");
+ item1.addGroup("Group 2");
+ item1.setSubscriptionRequested();
+ roster->addItem(item1);
+
+ RosterItemPayload item2;
+ item2.setJID(JID("baz@blo.com"));
+ item2.setName("Baz");
+ roster->addItem(item2);
+
+ std::string expectedResult =
+ "<query xmlns=\"jabber:iq:roster\">"
+ "<item ask=\"subscribe\" jid=\"foo@bar.com\" name=\"Foo @ Bar\" subscription=\"from\">"
+ "<group>Group 1</group>"
+ "<group>Group 2</group>"
+ "</item>"
+ "<item jid=\"baz@blo.com\" name=\"Baz\" subscription=\"none\"/>"
+ "</query>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
+ }
+
+ void testSerialize_ItemWithUnknownContent() {
+ RosterSerializer testling;
+ boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+
+ RosterItemPayload item;
+ item.setJID(JID("baz@blo.com"));
+ item.setName("Baz");
+ item.addGroup("Group 1");
+ item.addGroup("Group 2");
+ item.addUnknownContent(std::string(
+ "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>"
+ "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>"));
+ roster->addItem(item);
+
+ std::string expectedResult =
+ "<query xmlns=\"jabber:iq:roster\">"
+ "<item jid=\"baz@blo.com\" name=\"Baz\" subscription=\"none\">"
+ "<group>Group 1</group>"
+ "<group>Group 2</group>"
+ "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>"
+ "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>"
+ "</item>"
+ "</query>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
+ }
+
+ void testSerialize_WithVersion() {
+ RosterSerializer testling;
+ boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+ roster->setVersion("ver20");
+
+ std::string expectedResult = "<query ver=\"ver20\" xmlns=\"jabber:iq:roster\"/>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
+ }
+
+ void testSerialize_WithEmptyVersion() {
+ RosterSerializer testling;
+ boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+ roster->setVersion("");
+
+ std::string expectedResult = "<query ver=\"\" xmlns=\"jabber:iq:roster\"/>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(RosterSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp
index 54da0bc..0dfe0b0 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp
@@ -14,164 +14,164 @@
using namespace Swift;
class SearchPayloadSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(SearchPayloadSerializerTest);
- CPPUNIT_TEST(testSerialize_Request);
- CPPUNIT_TEST(testSerialize_Items);
- CPPUNIT_TEST(testSerialize_DataForm);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize_Request() {
- SearchPayloadSerializer testling;
-
- SearchPayload::ref payload(new SearchPayload());
- payload->setFirst("Juliet");
- payload->setLast("Capulet");
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<query xmlns=\"jabber:iq:search\">"
- "<first>Juliet</first>"
- "<last>Capulet</last>"
- "</query>"
- ), testling.serialize(payload));
- }
-
- void testSerialize_Items() {
- SearchPayloadSerializer testling;
-
- SearchPayload::ref payload(new SearchPayload());
- SearchPayload::Item item1;
- item1.jid = JID("juliet@capulet.com");
- item1.first = "Juliet";
- item1.last = "Capulet";
- item1.nick = "JuliC";
- item1.email = "juliet@shakespeare.lit";
- payload->addItem(item1);
-
- SearchPayload::Item item2;
- item2.jid = JID("tybalt@shakespeare.lit");
- item2.first = "Tybalt";
- item2.last = "Capulet";
- item2.nick = "ty";
- item2.email = "tybalt@shakespeare.lit";
- payload->addItem(item2);
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<query xmlns=\"jabber:iq:search\">"
- "<item jid=\"juliet@capulet.com\">"
- "<first>Juliet</first>"
- "<last>Capulet</last>"
- "<nick>JuliC</nick>"
- "<email>juliet@shakespeare.lit</email>"
- "</item>"
- "<item jid=\"tybalt@shakespeare.lit\">"
- "<first>Tybalt</first>"
- "<last>Capulet</last>"
- "<nick>ty</nick>"
- "<email>tybalt@shakespeare.lit</email>"
- "</item>"
- "</query>"
- ), testling.serialize(payload));
- }
-
- void testSerialize_DataForm() {
- SearchPayloadSerializer testling;
-
- SearchPayload::ref payload(new SearchPayload());
- boost::shared_ptr<Form> form(new Form(Form::ResultType));
-
- FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:iq:search");
- field->setName("FORM_TYPE");
- form->addField(field);
-
- // reported fields
- field = boost::make_shared<FormField>(FormField::TextSingleType);
- field->setName("first");
- field->setLabel("Given Name");
- form->addReportedField(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType);
- field->setName("last");
- field->setLabel("Family Name");
- form->addReportedField(field);
-
- field = boost::make_shared<FormField>(FormField::JIDSingleType);
- field->setName("jid");
- field->setLabel("Jabber ID");
- form->addReportedField(field);
-
- field = boost::make_shared<FormField>(FormField::ListSingleType);
- field->setName("x-gender");
- field->setLabel("Gender");
- form->addReportedField(field);
-
- Form::FormItem firstItem;
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Benvolio");
- field->setName("first");
- firstItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
- field->setName("last");
- firstItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType, "benvolio@montague.net");
- field->setName("jid");
- firstItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
- field->setName("x-gender");
- firstItem.push_back(field);
-
- Form::FormItem secondItem;
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Romeo");
- field->setName("first");
- secondItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
- field->setName("last");
- secondItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::TextSingleType, "romeo@montague.net");
- field->setName("jid");
- secondItem.push_back(field);
-
- field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
- field->setName("x-gender");
- secondItem.push_back(field);
-
- form->addItem(firstItem);
- form->addItem(secondItem);
-
- payload->setForm(form);
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<query xmlns=\"jabber:iq:search\">"
- "<x type=\"result\" xmlns=\"jabber:x:data\">"
- "<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>jabber:iq:search</value>"
- "</field>"
- "<reported>"
- "<field label=\"Given Name\" type=\"text-single\" var=\"first\"/>"
- "<field label=\"Family Name\" type=\"text-single\" var=\"last\"/>"
- "<field label=\"Jabber ID\" type=\"jid-single\" var=\"jid\"/>"
- "<field label=\"Gender\" type=\"list-single\" var=\"x-gender\"/>"
- "</reported>"
- "<item>"
- "<field var=\"first\"><value>Benvolio</value></field>"
- "<field var=\"last\"><value>Montague</value></field>"
- "<field var=\"jid\"><value>benvolio@montague.net</value></field>"
- "<field var=\"x-gender\"><value>male</value></field>"
- "</item>"
- "<item>"
- "<field var=\"first\"><value>Romeo</value></field>"
- "<field var=\"last\"><value>Montague</value></field>"
- "<field var=\"jid\"><value>romeo@montague.net</value></field>"
- "<field var=\"x-gender\"><value>male</value></field>"
- "</item>"
- "</x>"
- "</query>"), testling.serialize(payload));
-
- }
+ CPPUNIT_TEST_SUITE(SearchPayloadSerializerTest);
+ CPPUNIT_TEST(testSerialize_Request);
+ CPPUNIT_TEST(testSerialize_Items);
+ CPPUNIT_TEST(testSerialize_DataForm);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize_Request() {
+ SearchPayloadSerializer testling;
+
+ SearchPayload::ref payload(new SearchPayload());
+ payload->setFirst("Juliet");
+ payload->setLast("Capulet");
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<query xmlns=\"jabber:iq:search\">"
+ "<first>Juliet</first>"
+ "<last>Capulet</last>"
+ "</query>"
+ ), testling.serialize(payload));
+ }
+
+ void testSerialize_Items() {
+ SearchPayloadSerializer testling;
+
+ SearchPayload::ref payload(new SearchPayload());
+ SearchPayload::Item item1;
+ item1.jid = JID("juliet@capulet.com");
+ item1.first = "Juliet";
+ item1.last = "Capulet";
+ item1.nick = "JuliC";
+ item1.email = "juliet@shakespeare.lit";
+ payload->addItem(item1);
+
+ SearchPayload::Item item2;
+ item2.jid = JID("tybalt@shakespeare.lit");
+ item2.first = "Tybalt";
+ item2.last = "Capulet";
+ item2.nick = "ty";
+ item2.email = "tybalt@shakespeare.lit";
+ payload->addItem(item2);
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<query xmlns=\"jabber:iq:search\">"
+ "<item jid=\"juliet@capulet.com\">"
+ "<first>Juliet</first>"
+ "<last>Capulet</last>"
+ "<nick>JuliC</nick>"
+ "<email>juliet@shakespeare.lit</email>"
+ "</item>"
+ "<item jid=\"tybalt@shakespeare.lit\">"
+ "<first>Tybalt</first>"
+ "<last>Capulet</last>"
+ "<nick>ty</nick>"
+ "<email>tybalt@shakespeare.lit</email>"
+ "</item>"
+ "</query>"
+ ), testling.serialize(payload));
+ }
+
+ void testSerialize_DataForm() {
+ SearchPayloadSerializer testling;
+
+ SearchPayload::ref payload(new SearchPayload());
+ boost::shared_ptr<Form> form(new Form(Form::ResultType));
+
+ FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:iq:search");
+ field->setName("FORM_TYPE");
+ form->addField(field);
+
+ // reported fields
+ field = boost::make_shared<FormField>(FormField::TextSingleType);
+ field->setName("first");
+ field->setLabel("Given Name");
+ form->addReportedField(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType);
+ field->setName("last");
+ field->setLabel("Family Name");
+ form->addReportedField(field);
+
+ field = boost::make_shared<FormField>(FormField::JIDSingleType);
+ field->setName("jid");
+ field->setLabel("Jabber ID");
+ form->addReportedField(field);
+
+ field = boost::make_shared<FormField>(FormField::ListSingleType);
+ field->setName("x-gender");
+ field->setLabel("Gender");
+ form->addReportedField(field);
+
+ Form::FormItem firstItem;
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Benvolio");
+ field->setName("first");
+ firstItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
+ field->setName("last");
+ firstItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "benvolio@montague.net");
+ field->setName("jid");
+ firstItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
+ field->setName("x-gender");
+ firstItem.push_back(field);
+
+ Form::FormItem secondItem;
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Romeo");
+ field->setName("first");
+ secondItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Montague");
+ field->setName("last");
+ secondItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "romeo@montague.net");
+ field->setName("jid");
+ secondItem.push_back(field);
+
+ field = boost::make_shared<FormField>(FormField::ListSingleType, "male");
+ field->setName("x-gender");
+ secondItem.push_back(field);
+
+ form->addItem(firstItem);
+ form->addItem(secondItem);
+
+ payload->setForm(form);
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<query xmlns=\"jabber:iq:search\">"
+ "<x type=\"result\" xmlns=\"jabber:x:data\">"
+ "<field type=\"hidden\" var=\"FORM_TYPE\">"
+ "<value>jabber:iq:search</value>"
+ "</field>"
+ "<reported>"
+ "<field label=\"Given Name\" type=\"text-single\" var=\"first\"/>"
+ "<field label=\"Family Name\" type=\"text-single\" var=\"last\"/>"
+ "<field label=\"Jabber ID\" type=\"jid-single\" var=\"jid\"/>"
+ "<field label=\"Gender\" type=\"list-single\" var=\"x-gender\"/>"
+ "</reported>"
+ "<item>"
+ "<field var=\"first\"><value>Benvolio</value></field>"
+ "<field var=\"last\"><value>Montague</value></field>"
+ "<field var=\"jid\"><value>benvolio@montague.net</value></field>"
+ "<field var=\"x-gender\"><value>male</value></field>"
+ "</item>"
+ "<item>"
+ "<field var=\"first\"><value>Romeo</value></field>"
+ "<field var=\"last\"><value>Montague</value></field>"
+ "<field var=\"jid\"><value>romeo@montague.net</value></field>"
+ "<field var=\"x-gender\"><value>male</value></field>"
+ "</item>"
+ "</x>"
+ "</query>"), testling.serialize(payload));
+
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SearchPayloadSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp
index 9ad9ea6..db482ff 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp
@@ -12,49 +12,49 @@
using namespace Swift;
class SecurityLabelSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(SecurityLabelSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_EmptyLabel);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- SecurityLabelSerializer testling;
- boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel());
- securityLabel->setDisplayMarking("SECRET");
- securityLabel->setForegroundColor("black");
- securityLabel->setBackgroundColor("red");
- securityLabel->setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>");
- securityLabel->addEquivalentLabel("<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>");
- securityLabel->addEquivalentLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>");
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
- "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
- "<label>"
- "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"
- "</label>"
- "<equivalentlabel>"
- "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>"
- "</equivalentlabel>"
- "<equivalentlabel>"
- "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"
- "</equivalentlabel>"
- "</securitylabel>"), testling.serialize(securityLabel));
- }
-
- void testSerialize_EmptyLabel() {
- SecurityLabelSerializer testling;
- boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel());
- securityLabel->setDisplayMarking("SECRET");
- securityLabel->setLabel("");
-
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
- "<displaymarking>SECRET</displaymarking>"
- "<label></label>"
- "</securitylabel>"), testling.serialize(securityLabel));
- }
+ CPPUNIT_TEST_SUITE(SecurityLabelSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_EmptyLabel);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ SecurityLabelSerializer testling;
+ boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel());
+ securityLabel->setDisplayMarking("SECRET");
+ securityLabel->setForegroundColor("black");
+ securityLabel->setBackgroundColor("red");
+ securityLabel->setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>");
+ securityLabel->addEquivalentLabel("<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>");
+ securityLabel->addEquivalentLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>");
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
+ "<label>"
+ "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"
+ "</label>"
+ "<equivalentlabel>"
+ "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>"
+ "</equivalentlabel>"
+ "<equivalentlabel>"
+ "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"
+ "</equivalentlabel>"
+ "</securitylabel>"), testling.serialize(securityLabel));
+ }
+
+ void testSerialize_EmptyLabel() {
+ SecurityLabelSerializer testling;
+ boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel());
+ securityLabel->setDisplayMarking("SECRET");
+ securityLabel->setLabel("");
+
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking>SECRET</displaymarking>"
+ "<label></label>"
+ "</securitylabel>"), testling.serialize(securityLabel));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SecurityLabelSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp
index e18b4d7..51c98c1 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp
@@ -13,63 +13,63 @@ using namespace Swift;
class SecurityLabelsCatalogSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(SecurityLabelsCatalogSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(SecurityLabelsCatalogSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- SecurityLabelsCatalogSerializerTest() {}
+ public:
+ SecurityLabelsCatalogSerializerTest() {}
- void testSerialize() {
- SecurityLabelsCatalogSerializer testling;
- boost::shared_ptr<SecurityLabelsCatalog> catalog(new SecurityLabelsCatalog());
- catalog->setTo(JID("example.com"));
- catalog->setName("Default");
- catalog->setDescription("an example set of labels");
+ void testSerialize() {
+ SecurityLabelsCatalogSerializer testling;
+ boost::shared_ptr<SecurityLabelsCatalog> catalog(new SecurityLabelsCatalog());
+ catalog->setTo(JID("example.com"));
+ catalog->setName("Default");
+ catalog->setDescription("an example set of labels");
- SecurityLabelsCatalog::Item item1;
- boost::shared_ptr<SecurityLabel> securityLabel1(new SecurityLabel());
- item1.setLabel(securityLabel1);
- securityLabel1->setDisplayMarking("SECRET");
- securityLabel1->setForegroundColor("black");
- securityLabel1->setBackgroundColor("red");
- item1.setIsDefault(false);
- item1.setSelector("Classified|SECRET");
- securityLabel1->setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>");
- catalog->addItem(item1);
+ SecurityLabelsCatalog::Item item1;
+ boost::shared_ptr<SecurityLabel> securityLabel1(new SecurityLabel());
+ item1.setLabel(securityLabel1);
+ securityLabel1->setDisplayMarking("SECRET");
+ securityLabel1->setForegroundColor("black");
+ securityLabel1->setBackgroundColor("red");
+ item1.setIsDefault(false);
+ item1.setSelector("Classified|SECRET");
+ securityLabel1->setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>");
+ catalog->addItem(item1);
- SecurityLabelsCatalog::Item item2;
- boost::shared_ptr<SecurityLabel> securityLabel2(new SecurityLabel());
- item2.setLabel(securityLabel2);
- securityLabel2->setDisplayMarking("CONFIDENTIAL");
- securityLabel2->setForegroundColor("black");
- securityLabel2->setBackgroundColor("navy");
- item2.setIsDefault(true);
- item2.setSelector("Classified|CONFIDENTIAL");
- securityLabel2->setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>");
- catalog->addItem(item2);
+ SecurityLabelsCatalog::Item item2;
+ boost::shared_ptr<SecurityLabel> securityLabel2(new SecurityLabel());
+ item2.setLabel(securityLabel2);
+ securityLabel2->setDisplayMarking("CONFIDENTIAL");
+ securityLabel2->setForegroundColor("black");
+ securityLabel2->setBackgroundColor("navy");
+ item2.setIsDefault(true);
+ item2.setSelector("Classified|CONFIDENTIAL");
+ securityLabel2->setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>");
+ catalog->addItem(item2);
- SecurityLabelsCatalog::Item item3;
- item3.setSelector("Unclassified|UNCLASSIFIED");
- catalog->addItem(item3);
+ SecurityLabelsCatalog::Item item3;
+ item3.setSelector("Unclassified|UNCLASSIFIED");
+ catalog->addItem(item3);
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<catalog desc=\"an example set of labels\" name=\"Default\" to=\"example.com\" xmlns=\"urn:xmpp:sec-label:catalog:2\">"
- "<item selector=\"Classified|SECRET\">"
- "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
- "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
- "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel></label>"
- "</securitylabel>"
- "</item>"
- "<item default=\"true\" selector=\"Classified|CONFIDENTIAL\">"
- "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
- "<displaymarking bgcolor=\"navy\" fgcolor=\"black\">CONFIDENTIAL</displaymarking>"
- "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel></label>"
- "</securitylabel>"
- "</item>"
- "<item selector=\"Unclassified|UNCLASSIFIED\"/>"
- "</catalog>"), testling.serialize(catalog));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<catalog desc=\"an example set of labels\" name=\"Default\" to=\"example.com\" xmlns=\"urn:xmpp:sec-label:catalog:2\">"
+ "<item selector=\"Classified|SECRET\">"
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
+ "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel></label>"
+ "</securitylabel>"
+ "</item>"
+ "<item default=\"true\" selector=\"Classified|CONFIDENTIAL\">"
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking bgcolor=\"navy\" fgcolor=\"black\">CONFIDENTIAL</displaymarking>"
+ "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel></label>"
+ "</securitylabel>"
+ "</item>"
+ "<item selector=\"Unclassified|UNCLASSIFIED\"/>"
+ "</catalog>"), testling.serialize(catalog));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SecurityLabelsCatalogSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp
index 52e64b6..5643e1e 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp
@@ -13,19 +13,19 @@ using namespace Swift;
class SoftwareVersionSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(SoftwareVersionSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(SoftwareVersionSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- SoftwareVersionSerializerTest() {}
+ public:
+ SoftwareVersionSerializerTest() {}
- void testSerialize() {
- SoftwareVersionSerializer testling;
- boost::shared_ptr<SoftwareVersion> softwareVersion(new SoftwareVersion("Swift", "0.1", "Mac OS X"));
+ void testSerialize() {
+ SoftwareVersionSerializer testling;
+ boost::shared_ptr<SoftwareVersion> softwareVersion(new SoftwareVersion("Swift", "0.1", "Mac OS X"));
- CPPUNIT_ASSERT_EQUAL(std::string("<query xmlns=\"jabber:iq:version\"><name>Swift</name><version>0.1</version><os>Mac OS X</os></query>"), testling.serialize(softwareVersion));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<query xmlns=\"jabber:iq:version\"><name>Swift</name><version>0.1</version><os>Mac OS X</os></query>"), testling.serialize(softwareVersion));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SoftwareVersionSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp
index cb3ab7e..c8c2156 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp
@@ -13,19 +13,19 @@ using namespace Swift;
class StatusSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(StatusSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(StatusSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- StatusSerializerTest() {}
+ public:
+ StatusSerializerTest() {}
- void testSerialize() {
- StatusSerializer testling;
- boost::shared_ptr<Status> status(new Status("I am away"));
+ void testSerialize() {
+ StatusSerializer testling;
+ boost::shared_ptr<Status> status(new Status("I am away"));
- CPPUNIT_ASSERT_EQUAL(std::string("<status>I am away</status>"), testling.serialize(status));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<status>I am away</status>"), testling.serialize(status));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StatusSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp
index 272e61a..9fda49e 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp
@@ -13,52 +13,52 @@ using namespace Swift;
class StatusShowSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(StatusShowSerializerTest);
- CPPUNIT_TEST(testSerialize_Online);
- CPPUNIT_TEST(testSerialize_Away);
- CPPUNIT_TEST(testSerialize_FFC);
- CPPUNIT_TEST(testSerialize_XA);
- CPPUNIT_TEST(testSerialize_DND);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(StatusShowSerializerTest);
+ CPPUNIT_TEST(testSerialize_Online);
+ CPPUNIT_TEST(testSerialize_Away);
+ CPPUNIT_TEST(testSerialize_FFC);
+ CPPUNIT_TEST(testSerialize_XA);
+ CPPUNIT_TEST(testSerialize_DND);
+ CPPUNIT_TEST_SUITE_END();
- public:
- StatusShowSerializerTest() {}
+ public:
+ StatusShowSerializerTest() {}
- void testSerialize_Online() {
- StatusShowSerializer testling;
- boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::Online));
- CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(statusShow));
- }
+ void testSerialize_Online() {
+ StatusShowSerializer testling;
+ boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::Online));
+ CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(statusShow));
+ }
- void testSerialize_Away() {
- StatusShowSerializer testling;
- boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::Away));
- CPPUNIT_ASSERT_EQUAL(std::string("<show>away</show>"), testling.serialize(statusShow));
- }
+ void testSerialize_Away() {
+ StatusShowSerializer testling;
+ boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::Away));
+ CPPUNIT_ASSERT_EQUAL(std::string("<show>away</show>"), testling.serialize(statusShow));
+ }
- void testSerialize_FFC() {
- StatusShowSerializer testling;
- boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::FFC));
- CPPUNIT_ASSERT_EQUAL(std::string("<show>chat</show>"), testling.serialize(statusShow));
- }
+ void testSerialize_FFC() {
+ StatusShowSerializer testling;
+ boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::FFC));
+ CPPUNIT_ASSERT_EQUAL(std::string("<show>chat</show>"), testling.serialize(statusShow));
+ }
- void testSerialize_XA() {
- StatusShowSerializer testling;
- boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::XA));
- CPPUNIT_ASSERT_EQUAL(std::string("<show>xa</show>"), testling.serialize(statusShow));
- }
+ void testSerialize_XA() {
+ StatusShowSerializer testling;
+ boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::XA));
+ CPPUNIT_ASSERT_EQUAL(std::string("<show>xa</show>"), testling.serialize(statusShow));
+ }
- void testSerialize_DND() {
- StatusShowSerializer testling;
- boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::DND));
- CPPUNIT_ASSERT_EQUAL(std::string("<show>dnd</show>"), testling.serialize(statusShow));
- }
+ void testSerialize_DND() {
+ StatusShowSerializer testling;
+ boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::DND));
+ CPPUNIT_ASSERT_EQUAL(std::string("<show>dnd</show>"), testling.serialize(statusShow));
+ }
- void testSerialize_None() {
- StatusShowSerializer testling;
- boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::None));
- CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(statusShow));
- }
+ void testSerialize_None() {
+ StatusShowSerializer testling;
+ boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::None));
+ CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(statusShow));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StatusShowSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
index 3273e4b..e98ee3a 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
@@ -13,59 +13,59 @@
using namespace Swift;
class StorageSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(StorageSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_NoNickOrPassword);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(StorageSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoNickOrPassword);
+ CPPUNIT_TEST_SUITE_END();
- public:
- StorageSerializerTest() {}
+ public:
+ StorageSerializerTest() {}
- void testSerialize() {
- PayloadsSerializer serializer;
- boost::shared_ptr<Storage> storage(new Storage());
- Storage::Room room;
- room.name = "Council of Oberon";
- room.autoJoin = true;
- room.jid = JID("council@conference.underhill.org");
- room.nick = "Puck";
- room.password = "MyPass";
- storage->addRoom(room);
- Storage::URL url;
- url.name = "Complete Works of Shakespeare";
- url.url = "http://the-tech.mit.edu/Shakespeare/";
- storage->addURL(url);
+ void testSerialize() {
+ PayloadsSerializer serializer;
+ boost::shared_ptr<Storage> storage(new Storage());
+ Storage::Room room;
+ room.name = "Council of Oberon";
+ room.autoJoin = true;
+ room.jid = JID("council@conference.underhill.org");
+ room.nick = "Puck";
+ room.password = "MyPass";
+ storage->addRoom(room);
+ Storage::URL url;
+ url.name = "Complete Works of Shakespeare";
+ url.url = "http://the-tech.mit.edu/Shakespeare/";
+ storage->addURL(url);
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<storage xmlns=\"storage:bookmarks\">"
- "<conference "
- "autojoin=\"1\" "
- "jid=\"council@conference.underhill.org\" "
- "name=\"Council of Oberon\">"
- "<nick>Puck</nick>"
- "<password>MyPass</password>"
- "</conference>"
- "<url name=\"Complete Works of Shakespeare\" url=\"http://the-tech.mit.edu/Shakespeare/\"/>"
- "</storage>"), serializer.serialize(storage));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<storage xmlns=\"storage:bookmarks\">"
+ "<conference "
+ "autojoin=\"1\" "
+ "jid=\"council@conference.underhill.org\" "
+ "name=\"Council of Oberon\">"
+ "<nick>Puck</nick>"
+ "<password>MyPass</password>"
+ "</conference>"
+ "<url name=\"Complete Works of Shakespeare\" url=\"http://the-tech.mit.edu/Shakespeare/\"/>"
+ "</storage>"), serializer.serialize(storage));
+ }
- void testSerialize_NoNickOrPassword() {
- PayloadsSerializer serializer;
- boost::shared_ptr<Storage> storage(new Storage());
- Storage::Room room;
- room.name = "Council of Oberon";
- room.autoJoin = true;
- room.jid = JID("council@conference.underhill.org");
- storage->addRoom(room);
+ void testSerialize_NoNickOrPassword() {
+ PayloadsSerializer serializer;
+ boost::shared_ptr<Storage> storage(new Storage());
+ Storage::Room room;
+ room.name = "Council of Oberon";
+ room.autoJoin = true;
+ room.jid = JID("council@conference.underhill.org");
+ storage->addRoom(room);
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<storage xmlns=\"storage:bookmarks\">"
- "<conference "
- "autojoin=\"1\" "
- "jid=\"council@conference.underhill.org\" "
- "name=\"Council of Oberon\"/>"
- "</storage>"), serializer.serialize(storage));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<storage xmlns=\"storage:bookmarks\">"
+ "<conference "
+ "autojoin=\"1\" "
+ "jid=\"council@conference.underhill.org\" "
+ "name=\"Council of Oberon\"/>"
+ "</storage>"), serializer.serialize(storage));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StorageSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp
index 2d11dc4..ada65a9 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp
@@ -12,57 +12,57 @@
using namespace Swift;
class StreamInitiationSerializerTest : public CppUnit::TestFixture{
- CPPUNIT_TEST_SUITE(StreamInitiationSerializerTest);
- CPPUNIT_TEST(testSerialize_Request);
- CPPUNIT_TEST(testSerialize_Response);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(StreamInitiationSerializerTest);
+ CPPUNIT_TEST(testSerialize_Request);
+ CPPUNIT_TEST(testSerialize_Response);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize_Request() {
- StreamInitiationSerializer testling;
- boost::shared_ptr<StreamInitiation> streamInitiation(new StreamInitiation());
- StreamInitiationFileInfo fileInfo("test.txt", "This is info about the file.", 1022);
- streamInitiation->setID("a0");
- streamInitiation->setFileInfo(fileInfo);
- streamInitiation->addProvidedMethod("http://jabber.org/protocol/bytestreams");
- streamInitiation->addProvidedMethod("jabber:iq:oob");
- streamInitiation->addProvidedMethod("http://jabber.org/protocol/ibb");
+ public:
+ void testSerialize_Request() {
+ StreamInitiationSerializer testling;
+ boost::shared_ptr<StreamInitiation> streamInitiation(new StreamInitiation());
+ StreamInitiationFileInfo fileInfo("test.txt", "This is info about the file.", 1022);
+ streamInitiation->setID("a0");
+ streamInitiation->setFileInfo(fileInfo);
+ streamInitiation->addProvidedMethod("http://jabber.org/protocol/bytestreams");
+ streamInitiation->addProvidedMethod("jabber:iq:oob");
+ streamInitiation->addProvidedMethod("http://jabber.org/protocol/ibb");
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<si id=\"a0\" profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">"
- "<file name=\"test.txt\" size=\"1022\" xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">"
- "<desc>This is info about the file.</desc>"
- "</file>"
- "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">"
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<field type=\"list-single\" var=\"stream-method\">"
- "<option><value>http://jabber.org/protocol/bytestreams</value></option>"
- "<option><value>jabber:iq:oob</value></option>"
- "<option><value>http://jabber.org/protocol/ibb</value></option>"
- "</field>"
- "</x>"
- "</feature>"
- "</si>"
- ), testling.serialize(streamInitiation));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<si id=\"a0\" profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">"
+ "<file name=\"test.txt\" size=\"1022\" xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">"
+ "<desc>This is info about the file.</desc>"
+ "</file>"
+ "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">"
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<field type=\"list-single\" var=\"stream-method\">"
+ "<option><value>http://jabber.org/protocol/bytestreams</value></option>"
+ "<option><value>jabber:iq:oob</value></option>"
+ "<option><value>http://jabber.org/protocol/ibb</value></option>"
+ "</field>"
+ "</x>"
+ "</feature>"
+ "</si>"
+ ), testling.serialize(streamInitiation));
+ }
- void testSerialize_Response() {
- StreamInitiationSerializer testling;
- boost::shared_ptr<StreamInitiation> streamInitiation(new StreamInitiation());
- streamInitiation->setRequestedMethod("http://jabber.org/protocol/bytestreams");
+ void testSerialize_Response() {
+ StreamInitiationSerializer testling;
+ boost::shared_ptr<StreamInitiation> streamInitiation(new StreamInitiation());
+ streamInitiation->setRequestedMethod("http://jabber.org/protocol/bytestreams");
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<si profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">"
- "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">"
- "<x type=\"submit\" xmlns=\"jabber:x:data\">"
- "<field type=\"list-single\" var=\"stream-method\">"
- "<value>http://jabber.org/protocol/bytestreams</value>"
- "</field>"
- "</x>"
- "</feature>"
- "</si>"
- ), testling.serialize(streamInitiation));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<si profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">"
+ "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">"
+ "<x type=\"submit\" xmlns=\"jabber:x:data\">"
+ "<field type=\"list-single\" var=\"stream-method\">"
+ "<value>http://jabber.org/protocol/bytestreams</value>"
+ "</field>"
+ "</x>"
+ "</feature>"
+ "</si>"
+ ), testling.serialize(streamInitiation));
+ }
};
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp
index 565f61d..3aed450 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp
@@ -17,88 +17,88 @@
#include <Swiften/Base/DateTime.h>
#include <Swiften/Elements/UserLocation.h>
-#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
#include <Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h>
using namespace Swift;
class UserLocationSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(UserLocationSerializerTest);
- CPPUNIT_TEST(testSerialize_withAllVariablesSet);
- CPPUNIT_TEST(testSerialize_withSomeVariablesSet);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(UserLocationSerializerTest);
+ CPPUNIT_TEST(testSerialize_withAllVariablesSet);
+ CPPUNIT_TEST(testSerialize_withSomeVariablesSet);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize_withAllVariablesSet() {
- UserLocationSerializer testling(&serializers);
- boost::shared_ptr<UserLocation> userLocation(new UserLocation());
- userLocation->setArea(boost::optional<std::string>("Barbaric"));
- userLocation->setAltitude(5.75F);
- userLocation->setLocality(boost::optional<std::string>("Near"));
- userLocation->setLatitude(boost::optional<float>(5.75F));
- userLocation->setAccuracy(5.75F);
- userLocation->setDescription(boost::optional<std::string>("Nice"));
- userLocation->setCountryCode(boost::optional<std::string>("+91"));
- userLocation->setTimestamp(stringToDateTime("2015-06-11T20:55:50Z"));
- userLocation->setFloor(boost::optional<std::string>("3"));
- userLocation->setBuilding(boost::optional<std::string>("First"));
- userLocation->setRoom(boost::optional<std::string>("E315"));
- userLocation->setCountry(boost::optional<std::string>("USA"));
- userLocation->setRegion(boost::optional<std::string>("NewSode"));
- userLocation->setURI(boost::optional<std::string>("URIs"));
- userLocation->setLongitude(5.75F);
- userLocation->setError(5.75F);
- userLocation->setPostalCode(boost::optional<std::string>("67"));
- userLocation->setBearing(5.75F);
- userLocation->setText(boost::optional<std::string>("Hello"));
- userLocation->setDatum(boost::optional<std::string>("Datee"));
- userLocation->setStreet(boost::optional<std::string>("Highway"));
- userLocation->setSpeed(5.75F);
+ public:
+ void testSerialize_withAllVariablesSet() {
+ UserLocationSerializer testling(&serializers);
+ boost::shared_ptr<UserLocation> userLocation(new UserLocation());
+ userLocation->setArea(boost::optional<std::string>("Barbaric"));
+ userLocation->setAltitude(5.75F);
+ userLocation->setLocality(boost::optional<std::string>("Near"));
+ userLocation->setLatitude(boost::optional<float>(5.75F));
+ userLocation->setAccuracy(5.75F);
+ userLocation->setDescription(boost::optional<std::string>("Nice"));
+ userLocation->setCountryCode(boost::optional<std::string>("+91"));
+ userLocation->setTimestamp(stringToDateTime("2015-06-11T20:55:50Z"));
+ userLocation->setFloor(boost::optional<std::string>("3"));
+ userLocation->setBuilding(boost::optional<std::string>("First"));
+ userLocation->setRoom(boost::optional<std::string>("E315"));
+ userLocation->setCountry(boost::optional<std::string>("USA"));
+ userLocation->setRegion(boost::optional<std::string>("NewSode"));
+ userLocation->setURI(boost::optional<std::string>("URIs"));
+ userLocation->setLongitude(5.75F);
+ userLocation->setError(5.75F);
+ userLocation->setPostalCode(boost::optional<std::string>("67"));
+ userLocation->setBearing(5.75F);
+ userLocation->setText(boost::optional<std::string>("Hello"));
+ userLocation->setDatum(boost::optional<std::string>("Datee"));
+ userLocation->setStreet(boost::optional<std::string>("Highway"));
+ userLocation->setSpeed(5.75F);
- std::string expectedResult =
- "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
- "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
- "<lat>5.75</lat><accuracy>5.75</accuracy><description>Nice</description>"
- "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
- "<building>First</building><room>E315</room><country>USA</country>"
- "<region>NewSode</region><uri>URIs</uri><lon>5.75</lon><error>5.75</error>"
- "<postalcode>67</postalcode><bearing>5.75</bearing><text>Hello</text>"
- "<datum>Datee</datum><street>Highway</street><speed>5.75</speed></geoloc>";
+ std::string expectedResult =
+ "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
+ "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
+ "<lat>5.75</lat><accuracy>5.75</accuracy><description>Nice</description>"
+ "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
+ "<building>First</building><room>E315</room><country>USA</country>"
+ "<region>NewSode</region><uri>URIs</uri><lon>5.75</lon><error>5.75</error>"
+ "<postalcode>67</postalcode><bearing>5.75</bearing><text>Hello</text>"
+ "<datum>Datee</datum><street>Highway</street><speed>5.75</speed></geoloc>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userLocation));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userLocation));
+ }
- void testSerialize_withSomeVariablesSet() {
- UserLocationSerializer testling(&serializers);
- boost::shared_ptr<UserLocation> userLocation(new UserLocation());
- userLocation->setArea(boost::optional<std::string>("Barbaric"));
- userLocation->setAltitude(5.75F);
- userLocation->setLocality(boost::optional<std::string>("Near"));
- userLocation->setAccuracy(5.75F);
- userLocation->setDescription(boost::optional<std::string>("Nice"));
- userLocation->setCountryCode(boost::optional<std::string>("+91"));
- userLocation->setTimestamp(stringToDateTime("2015-06-11T20:55:50Z"));
- userLocation->setFloor(boost::optional<std::string>("3"));
- userLocation->setRegion(boost::optional<std::string>("NewSode"));
- userLocation->setURI(boost::optional<std::string>("URIs"));
- userLocation->setLongitude(5.75F);
- userLocation->setError(5.75F);
- userLocation->setPostalCode(boost::optional<std::string>("67"));
- userLocation->setBearing(5.75F);
- userLocation->setText(boost::optional<std::string>("Hello"));
+ void testSerialize_withSomeVariablesSet() {
+ UserLocationSerializer testling(&serializers);
+ boost::shared_ptr<UserLocation> userLocation(new UserLocation());
+ userLocation->setArea(boost::optional<std::string>("Barbaric"));
+ userLocation->setAltitude(5.75F);
+ userLocation->setLocality(boost::optional<std::string>("Near"));
+ userLocation->setAccuracy(5.75F);
+ userLocation->setDescription(boost::optional<std::string>("Nice"));
+ userLocation->setCountryCode(boost::optional<std::string>("+91"));
+ userLocation->setTimestamp(stringToDateTime("2015-06-11T20:55:50Z"));
+ userLocation->setFloor(boost::optional<std::string>("3"));
+ userLocation->setRegion(boost::optional<std::string>("NewSode"));
+ userLocation->setURI(boost::optional<std::string>("URIs"));
+ userLocation->setLongitude(5.75F);
+ userLocation->setError(5.75F);
+ userLocation->setPostalCode(boost::optional<std::string>("67"));
+ userLocation->setBearing(5.75F);
+ userLocation->setText(boost::optional<std::string>("Hello"));
- std::string expectedResult =
- "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
- "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
- "<accuracy>5.75</accuracy><description>Nice</description>"
- "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
- "<region>NewSode</region><uri>URIs</uri><lon>5.75</lon><error>5.75</error>"
- "<postalcode>67</postalcode><bearing>5.75</bearing><text>Hello</text></geoloc>";
+ std::string expectedResult =
+ "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
+ "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
+ "<accuracy>5.75</accuracy><description>Nice</description>"
+ "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
+ "<region>NewSode</region><uri>URIs</uri><lon>5.75</lon><error>5.75</error>"
+ "<postalcode>67</postalcode><bearing>5.75</bearing><text>Hello</text></geoloc>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userLocation));
- }
- private:
- FullPayloadSerializerCollection serializers;
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userLocation));
+ }
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(UserLocationSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/UserTuneSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/UserTuneSerializerTest.cpp
index 6e2fc8b..50f2a54 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/UserTuneSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/UserTuneSerializerTest.cpp
@@ -17,53 +17,53 @@
#include <Swiften/Base/DateTime.h>
#include <Swiften/Elements/UserTune.h>
-#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
#include <Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h>
using namespace Swift;
class UserTuneSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(UserTuneSerializerTest);
- CPPUNIT_TEST(testSerialize_withAllVariablesSet);
- CPPUNIT_TEST(testSerialize_withSomeVariablesSet);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(UserTuneSerializerTest);
+ CPPUNIT_TEST(testSerialize_withAllVariablesSet);
+ CPPUNIT_TEST(testSerialize_withSomeVariablesSet);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testSerialize_withAllVariablesSet() {
- UserTuneSerializer testling(&serializers);
- boost::shared_ptr<UserTune> userTune(new UserTune());
- userTune->setRating(5);
- userTune->setTitle(boost::optional<std::string>("Minion"));
- userTune->setTrack(boost::optional<std::string>("Yellow"));
- userTune->setArtist(boost::optional<std::string>("Ice"));
- userTune->setURI(boost::optional<std::string>("Fire"));
- userTune->setSource(boost::optional<std::string>("Origin"));
- userTune->setLength(226);
+ public:
+ void testSerialize_withAllVariablesSet() {
+ UserTuneSerializer testling(&serializers);
+ boost::shared_ptr<UserTune> userTune(new UserTune());
+ userTune->setRating(5);
+ userTune->setTitle(boost::optional<std::string>("Minion"));
+ userTune->setTrack(boost::optional<std::string>("Yellow"));
+ userTune->setArtist(boost::optional<std::string>("Ice"));
+ userTune->setURI(boost::optional<std::string>("Fire"));
+ userTune->setSource(boost::optional<std::string>("Origin"));
+ userTune->setLength(226);
- std::string expectedResult =
- "<tune xmlns=\"http://jabber.org/protocol/tune\">"
- "<rating>5</rating><title>Minion</title><track>Yellow</track><artist>Ice</artist><uri>Fire</uri><source>Origin</source><length>226</length></tune>";
+ std::string expectedResult =
+ "<tune xmlns=\"http://jabber.org/protocol/tune\">"
+ "<rating>5</rating><title>Minion</title><track>Yellow</track><artist>Ice</artist><uri>Fire</uri><source>Origin</source><length>226</length></tune>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userTune));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userTune));
+ }
- void testSerialize_withSomeVariablesSet() {
- UserTuneSerializer testling(&serializers);
- boost::shared_ptr<UserTune> userTune(new UserTune());
- userTune->setTitle(boost::optional<std::string>("Minion"));
- userTune->setTrack(boost::optional<std::string>("Yellow"));
- userTune->setArtist(boost::optional<std::string>("Ice"));
- userTune->setSource(boost::optional<std::string>("Origin"));
- userTune->setLength(226);
+ void testSerialize_withSomeVariablesSet() {
+ UserTuneSerializer testling(&serializers);
+ boost::shared_ptr<UserTune> userTune(new UserTune());
+ userTune->setTitle(boost::optional<std::string>("Minion"));
+ userTune->setTrack(boost::optional<std::string>("Yellow"));
+ userTune->setArtist(boost::optional<std::string>("Ice"));
+ userTune->setSource(boost::optional<std::string>("Origin"));
+ userTune->setLength(226);
- std::string expectedResult =
- "<tune xmlns=\"http://jabber.org/protocol/tune\">"
- "<title>Minion</title><track>Yellow</track><artist>Ice</artist><source>Origin</source><length>226</length></tune>";
+ std::string expectedResult =
+ "<tune xmlns=\"http://jabber.org/protocol/tune\">"
+ "<title>Minion</title><track>Yellow</track><artist>Ice</artist><source>Origin</source><length>226</length></tune>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userTune));
- }
- private:
- FullPayloadSerializerCollection serializers;
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(userTune));
+ }
+ private:
+ FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(UserTuneSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp
index d0385d3..c4a8156 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp
@@ -13,136 +13,136 @@ using namespace Swift;
class VCardSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(VCardSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- VCardSerializer testling;
- boost::shared_ptr<VCard> vcard(new VCard());
- vcard->setVersion("2.0");
- vcard->setFullName("Alice In Wonderland");
- vcard->setPrefix("Mrs");
- vcard->setGivenName("Alice");
- vcard->setMiddleName("In");
- vcard->setFamilyName("Wonderland");
- vcard->setSuffix("PhD");
- vcard->setNickname("DreamGirl");
- vcard->setPhoto(createByteArray("abcdef"));
- vcard->setPhotoType("image/png");
- vcard->setBirthday(boost::posix_time::ptime(boost::gregorian::date(1865, 5, 4)));
- vcard->addUnknownContent("<MAILER>mutt</MAILER>");
-
- VCard::EMailAddress emailAddress1;
- emailAddress1.address = "alice@wonderland.lit";
- emailAddress1.isHome = true;
- emailAddress1.isPreferred = true;
- emailAddress1.isInternet = true;
- vcard->addEMailAddress(emailAddress1);
-
- VCard::EMailAddress address2;
- address2.address = "alice@teaparty.lit";
- address2.isWork = true;
- address2.isX400 = true;
- vcard->addEMailAddress(address2);
-
- VCard::Telephone telephone1;
- telephone1.number = "555-6273";
- telephone1.isHome = true;
- telephone1.isVoice = true;
- vcard->addTelephone(telephone1);
-
- VCard::Address address1;
- address1.locality = "Any Town";
- address1.street = "Fake Street 123";
- address1.postalCode = "12345";
- address1.country = "USA";
- address1.isHome = true;
- vcard->addAddress(address1);
-
- VCard::AddressLabel label1;
- label1.lines.push_back("Fake Street 123");
- label1.lines.push_back("12345 Any Town");
- label1.lines.push_back("USA");
- label1.isHome = true;
- vcard->addAddressLabel(label1);
-
- vcard->addJID(JID("alice@teaparty.lit"));
- vcard->addJID(JID("alice@wonderland.lit"));
-
- vcard->setDescription("I once fell down a rabbit hole.");
-
- VCard::Organization org1;
- org1.name = "Alice In Wonderland Inc.";
- vcard->addOrganization(org1);
-
- vcard->addTitle("Some Title");
- vcard->addRole("Main Character");
- vcard->addURL("http://wonderland.lit/~alice");
- vcard->addURL("http://teaparty.lit/~alice2");
-
- std::string expectedResult =
- "<vCard xmlns=\"vcard-temp\">"
- "<VERSION>2.0</VERSION>"
- "<FN>Alice In Wonderland</FN>"
- "<N>"
- "<FAMILY>Wonderland</FAMILY>"
- "<GIVEN>Alice</GIVEN>"
- "<MIDDLE>In</MIDDLE>"
- "<PREFIX>Mrs</PREFIX>"
- "<SUFFIX>PhD</SUFFIX>"
- "</N>"
- "<EMAIL>"
- "<USERID>alice@wonderland.lit</USERID>"
- "<HOME/>"
- "<INTERNET/>"
- "<PREF/>"
- "</EMAIL>"
- "<EMAIL>"
- "<USERID>alice@teaparty.lit</USERID>"
- "<WORK/>"
- "<X400/>"
- "</EMAIL>"
- "<NICKNAME>DreamGirl</NICKNAME>"
- "<PHOTO>"
- "<TYPE>image/png</TYPE>"
- "<BINVAL>YWJjZGVm</BINVAL>"
- "</PHOTO>"
- "<BDAY>1865-05-04T00:00:00Z</BDAY>"
- "<TEL>"
- "<NUMBER>555-6273</NUMBER>"
- "<HOME/>"
- "<VOICE/>"
- "</TEL>"
- "<ADR>"
- "<STREET>Fake Street 123</STREET>"
- "<LOCALITY>Any Town</LOCALITY>"
- "<PCODE>12345</PCODE>"
- "<CTRY>USA</CTRY>"
- "<HOME/>"
- "</ADR>"
- "<LABEL>"
- "<LINE>Fake Street 123</LINE>"
- "<LINE>12345 Any Town</LINE>"
- "<LINE>USA</LINE>"
- "<HOME/>"
- "</LABEL>"
- "<JID>alice@teaparty.lit</JID>"
- "<JID>alice@wonderland.lit</JID>"
- "<DESC>I once fell down a rabbit hole.</DESC>"
- "<ORG>"
- "<ORGNAME>Alice In Wonderland Inc.</ORGNAME>"
- "</ORG>"
- "<TITLE>Some Title</TITLE>"
- "<ROLE>Main Character</ROLE>"
- "<URL>http://wonderland.lit/~alice</URL>"
- "<URL>http://teaparty.lit/~alice2</URL>"
- "<MAILER>mutt</MAILER>"
- "</vCard>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(vcard));
- }
+ CPPUNIT_TEST_SUITE(VCardSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ VCardSerializer testling;
+ boost::shared_ptr<VCard> vcard(new VCard());
+ vcard->setVersion("2.0");
+ vcard->setFullName("Alice In Wonderland");
+ vcard->setPrefix("Mrs");
+ vcard->setGivenName("Alice");
+ vcard->setMiddleName("In");
+ vcard->setFamilyName("Wonderland");
+ vcard->setSuffix("PhD");
+ vcard->setNickname("DreamGirl");
+ vcard->setPhoto(createByteArray("abcdef"));
+ vcard->setPhotoType("image/png");
+ vcard->setBirthday(boost::posix_time::ptime(boost::gregorian::date(1865, 5, 4)));
+ vcard->addUnknownContent("<MAILER>mutt</MAILER>");
+
+ VCard::EMailAddress emailAddress1;
+ emailAddress1.address = "alice@wonderland.lit";
+ emailAddress1.isHome = true;
+ emailAddress1.isPreferred = true;
+ emailAddress1.isInternet = true;
+ vcard->addEMailAddress(emailAddress1);
+
+ VCard::EMailAddress address2;
+ address2.address = "alice@teaparty.lit";
+ address2.isWork = true;
+ address2.isX400 = true;
+ vcard->addEMailAddress(address2);
+
+ VCard::Telephone telephone1;
+ telephone1.number = "555-6273";
+ telephone1.isHome = true;
+ telephone1.isVoice = true;
+ vcard->addTelephone(telephone1);
+
+ VCard::Address address1;
+ address1.locality = "Any Town";
+ address1.street = "Fake Street 123";
+ address1.postalCode = "12345";
+ address1.country = "USA";
+ address1.isHome = true;
+ vcard->addAddress(address1);
+
+ VCard::AddressLabel label1;
+ label1.lines.push_back("Fake Street 123");
+ label1.lines.push_back("12345 Any Town");
+ label1.lines.push_back("USA");
+ label1.isHome = true;
+ vcard->addAddressLabel(label1);
+
+ vcard->addJID(JID("alice@teaparty.lit"));
+ vcard->addJID(JID("alice@wonderland.lit"));
+
+ vcard->setDescription("I once fell down a rabbit hole.");
+
+ VCard::Organization org1;
+ org1.name = "Alice In Wonderland Inc.";
+ vcard->addOrganization(org1);
+
+ vcard->addTitle("Some Title");
+ vcard->addRole("Main Character");
+ vcard->addURL("http://wonderland.lit/~alice");
+ vcard->addURL("http://teaparty.lit/~alice2");
+
+ std::string expectedResult =
+ "<vCard xmlns=\"vcard-temp\">"
+ "<VERSION>2.0</VERSION>"
+ "<FN>Alice In Wonderland</FN>"
+ "<N>"
+ "<FAMILY>Wonderland</FAMILY>"
+ "<GIVEN>Alice</GIVEN>"
+ "<MIDDLE>In</MIDDLE>"
+ "<PREFIX>Mrs</PREFIX>"
+ "<SUFFIX>PhD</SUFFIX>"
+ "</N>"
+ "<EMAIL>"
+ "<USERID>alice@wonderland.lit</USERID>"
+ "<HOME/>"
+ "<INTERNET/>"
+ "<PREF/>"
+ "</EMAIL>"
+ "<EMAIL>"
+ "<USERID>alice@teaparty.lit</USERID>"
+ "<WORK/>"
+ "<X400/>"
+ "</EMAIL>"
+ "<NICKNAME>DreamGirl</NICKNAME>"
+ "<PHOTO>"
+ "<TYPE>image/png</TYPE>"
+ "<BINVAL>YWJjZGVm</BINVAL>"
+ "</PHOTO>"
+ "<BDAY>1865-05-04T00:00:00Z</BDAY>"
+ "<TEL>"
+ "<NUMBER>555-6273</NUMBER>"
+ "<HOME/>"
+ "<VOICE/>"
+ "</TEL>"
+ "<ADR>"
+ "<STREET>Fake Street 123</STREET>"
+ "<LOCALITY>Any Town</LOCALITY>"
+ "<PCODE>12345</PCODE>"
+ "<CTRY>USA</CTRY>"
+ "<HOME/>"
+ "</ADR>"
+ "<LABEL>"
+ "<LINE>Fake Street 123</LINE>"
+ "<LINE>12345 Any Town</LINE>"
+ "<LINE>USA</LINE>"
+ "<HOME/>"
+ "</LABEL>"
+ "<JID>alice@teaparty.lit</JID>"
+ "<JID>alice@wonderland.lit</JID>"
+ "<DESC>I once fell down a rabbit hole.</DESC>"
+ "<ORG>"
+ "<ORGNAME>Alice In Wonderland Inc.</ORGNAME>"
+ "</ORG>"
+ "<TITLE>Some Title</TITLE>"
+ "<ROLE>Main Character</ROLE>"
+ "<URL>http://wonderland.lit/~alice</URL>"
+ "<URL>http://teaparty.lit/~alice2</URL>"
+ "<MAILER>mutt</MAILER>"
+ "</vCard>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(vcard));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(VCardSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp
index fd2bb42..ed0500a 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp
@@ -13,25 +13,25 @@ using namespace Swift;
class VCardUpdateSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(VCardUpdateSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(VCardUpdateSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
- public:
- VCardUpdateSerializerTest() {}
+ public:
+ VCardUpdateSerializerTest() {}
- void testSerialize() {
- VCardUpdateSerializer testling;
- boost::shared_ptr<VCardUpdate> update(new VCardUpdate());
- update->setPhotoHash("sha1-hash-of-image");
+ void testSerialize() {
+ VCardUpdateSerializer testling;
+ boost::shared_ptr<VCardUpdate> update(new VCardUpdate());
+ update->setPhotoHash("sha1-hash-of-image");
- std::string expectedResult =
- "<x xmlns=\"vcard-temp:x:update\">"
- "<photo>sha1-hash-of-image</photo>"
- "</x>";
+ std::string expectedResult =
+ "<x xmlns=\"vcard-temp:x:update\">"
+ "<photo>sha1-hash-of-image</photo>"
+ "</x>";
- CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(update));
- }
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(update));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(VCardUpdateSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp
index 130e8a2..2383cc8 100644
--- a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp
@@ -24,77 +24,77 @@ UserLocationSerializer::~UserLocationSerializer() {
}
std::string UserLocationSerializer::serializePayload(boost::shared_ptr<UserLocation> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("geoloc", "http://jabber.org/protocol/geoloc");
- if (payload->getArea()) {
- element.addNode(boost::make_shared<XMLElement>("area", "", *payload->getArea()));
- }
- if (payload->getAltitude()) {
- element.addNode(boost::make_shared<XMLElement>("alt", "", boost::lexical_cast<std::string>(*payload->getAltitude())));
- }
- if (payload->getLocality()) {
- element.addNode(boost::make_shared<XMLElement>("locality", "", *payload->getLocality()));
- }
- if (payload->getLatitude()) {
- element.addNode(boost::make_shared<XMLElement>("lat", "", boost::lexical_cast<std::string>(*payload->getLatitude())));
- }
- if (payload->getAccuracy()) {
- element.addNode(boost::make_shared<XMLElement>("accuracy", "", boost::lexical_cast<std::string>(*payload->getAccuracy())));
- }
- if (payload->getDescription()) {
- element.addNode(boost::make_shared<XMLElement>("description", "", *payload->getDescription()));
- }
- if (payload->getCountryCode()) {
- element.addNode(boost::make_shared<XMLElement>("countrycode", "", *payload->getCountryCode()));
- }
- if (payload->getTimestamp()) {
- element.addNode(boost::make_shared<XMLElement>("timestamp", "", dateTimeToString(*payload->getTimestamp())));
- }
- if (payload->getFloor()) {
- element.addNode(boost::make_shared<XMLElement>("floor", "", *payload->getFloor()));
- }
- if (payload->getBuilding()) {
- element.addNode(boost::make_shared<XMLElement>("building", "", *payload->getBuilding()));
- }
- if (payload->getRoom()) {
- element.addNode(boost::make_shared<XMLElement>("room", "", *payload->getRoom()));
- }
- if (payload->getCountry()) {
- element.addNode(boost::make_shared<XMLElement>("country", "", *payload->getCountry()));
- }
- if (payload->getRegion()) {
- element.addNode(boost::make_shared<XMLElement>("region", "", *payload->getRegion()));
- }
- if (payload->getURI()) {
- element.addNode(boost::make_shared<XMLElement>("uri", "", *payload->getURI()));
- }
- if (payload->getLongitude()) {
- element.addNode(boost::make_shared<XMLElement>("lon", "", boost::lexical_cast<std::string>(*payload->getLongitude())));
- }
- if (payload->getError()) {
- element.addNode(boost::make_shared<XMLElement>("error", "", boost::lexical_cast<std::string>(*payload->getError())));
- }
- if (payload->getPostalCode()) {
- element.addNode(boost::make_shared<XMLElement>("postalcode", "", *payload->getPostalCode()));
- }
- if (payload->getBearing()) {
- element.addNode(boost::make_shared<XMLElement>("bearing", "", boost::lexical_cast<std::string>(*payload->getBearing())));
- }
- if (payload->getText()) {
- element.addNode(boost::make_shared<XMLElement>("text", "", *payload->getText()));
- }
- if (payload->getDatum()) {
- element.addNode(boost::make_shared<XMLElement>("datum", "", *payload->getDatum()));
- }
- if (payload->getStreet()) {
- element.addNode(boost::make_shared<XMLElement>("street", "", *payload->getStreet()));
- }
- if (payload->getSpeed()) {
- element.addNode(boost::make_shared<XMLElement>("speed", "", boost::lexical_cast<std::string>(*payload->getSpeed())));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("geoloc", "http://jabber.org/protocol/geoloc");
+ if (payload->getArea()) {
+ element.addNode(boost::make_shared<XMLElement>("area", "", *payload->getArea()));
+ }
+ if (payload->getAltitude()) {
+ element.addNode(boost::make_shared<XMLElement>("alt", "", boost::lexical_cast<std::string>(*payload->getAltitude())));
+ }
+ if (payload->getLocality()) {
+ element.addNode(boost::make_shared<XMLElement>("locality", "", *payload->getLocality()));
+ }
+ if (payload->getLatitude()) {
+ element.addNode(boost::make_shared<XMLElement>("lat", "", boost::lexical_cast<std::string>(*payload->getLatitude())));
+ }
+ if (payload->getAccuracy()) {
+ element.addNode(boost::make_shared<XMLElement>("accuracy", "", boost::lexical_cast<std::string>(*payload->getAccuracy())));
+ }
+ if (payload->getDescription()) {
+ element.addNode(boost::make_shared<XMLElement>("description", "", *payload->getDescription()));
+ }
+ if (payload->getCountryCode()) {
+ element.addNode(boost::make_shared<XMLElement>("countrycode", "", *payload->getCountryCode()));
+ }
+ if (payload->getTimestamp()) {
+ element.addNode(boost::make_shared<XMLElement>("timestamp", "", dateTimeToString(*payload->getTimestamp())));
+ }
+ if (payload->getFloor()) {
+ element.addNode(boost::make_shared<XMLElement>("floor", "", *payload->getFloor()));
+ }
+ if (payload->getBuilding()) {
+ element.addNode(boost::make_shared<XMLElement>("building", "", *payload->getBuilding()));
+ }
+ if (payload->getRoom()) {
+ element.addNode(boost::make_shared<XMLElement>("room", "", *payload->getRoom()));
+ }
+ if (payload->getCountry()) {
+ element.addNode(boost::make_shared<XMLElement>("country", "", *payload->getCountry()));
+ }
+ if (payload->getRegion()) {
+ element.addNode(boost::make_shared<XMLElement>("region", "", *payload->getRegion()));
+ }
+ if (payload->getURI()) {
+ element.addNode(boost::make_shared<XMLElement>("uri", "", *payload->getURI()));
+ }
+ if (payload->getLongitude()) {
+ element.addNode(boost::make_shared<XMLElement>("lon", "", boost::lexical_cast<std::string>(*payload->getLongitude())));
+ }
+ if (payload->getError()) {
+ element.addNode(boost::make_shared<XMLElement>("error", "", boost::lexical_cast<std::string>(*payload->getError())));
+ }
+ if (payload->getPostalCode()) {
+ element.addNode(boost::make_shared<XMLElement>("postalcode", "", *payload->getPostalCode()));
+ }
+ if (payload->getBearing()) {
+ element.addNode(boost::make_shared<XMLElement>("bearing", "", boost::lexical_cast<std::string>(*payload->getBearing())));
+ }
+ if (payload->getText()) {
+ element.addNode(boost::make_shared<XMLElement>("text", "", *payload->getText()));
+ }
+ if (payload->getDatum()) {
+ element.addNode(boost::make_shared<XMLElement>("datum", "", *payload->getDatum()));
+ }
+ if (payload->getStreet()) {
+ element.addNode(boost::make_shared<XMLElement>("street", "", *payload->getStreet()));
+ }
+ if (payload->getSpeed()) {
+ element.addNode(boost::make_shared<XMLElement>("speed", "", boost::lexical_cast<std::string>(*payload->getSpeed())));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h
index acfc16c..4b17628 100644
--- a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API UserLocationSerializer : public GenericPayloadSerializer<UserLocation> {
- public:
- UserLocationSerializer(PayloadSerializerCollection* serializers);
- virtual ~UserLocationSerializer();
+ class SWIFTEN_API UserLocationSerializer : public GenericPayloadSerializer<UserLocation> {
+ public:
+ UserLocationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~UserLocationSerializer();
- virtual std::string serializePayload(boost::shared_ptr<UserLocation>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<UserLocation>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp
index fd6eebd..eeab2b7 100644
--- a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp
@@ -23,32 +23,32 @@ UserTuneSerializer::~UserTuneSerializer() {
}
std::string UserTuneSerializer::serializePayload(boost::shared_ptr<UserTune> payload) const {
- if (!payload) {
- return "";
- }
- XMLElement element("tune", "http://jabber.org/protocol/tune");
- if (payload->getRating()) {
- element.addNode(boost::make_shared<XMLElement>("rating", "", boost::lexical_cast<std::string>(*payload->getRating())));
- }
- if (payload->getTitle()) {
- element.addNode(boost::make_shared<XMLElement>("title", "", *payload->getTitle()));
- }
- if (payload->getTrack()) {
- element.addNode(boost::make_shared<XMLElement>("track", "", *payload->getTrack()));
- }
- if (payload->getArtist()) {
- element.addNode(boost::make_shared<XMLElement>("artist", "", *payload->getArtist()));
- }
- if (payload->getURI()) {
- element.addNode(boost::make_shared<XMLElement>("uri", "", *payload->getURI()));
- }
- if (payload->getSource()) {
- element.addNode(boost::make_shared<XMLElement>("source", "", *payload->getSource()));
- }
- if (payload->getLength()) {
- element.addNode(boost::make_shared<XMLElement>("length", "", boost::lexical_cast<std::string>(*payload->getLength())));
- }
- return element.serialize();
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("tune", "http://jabber.org/protocol/tune");
+ if (payload->getRating()) {
+ element.addNode(boost::make_shared<XMLElement>("rating", "", boost::lexical_cast<std::string>(*payload->getRating())));
+ }
+ if (payload->getTitle()) {
+ element.addNode(boost::make_shared<XMLElement>("title", "", *payload->getTitle()));
+ }
+ if (payload->getTrack()) {
+ element.addNode(boost::make_shared<XMLElement>("track", "", *payload->getTrack()));
+ }
+ if (payload->getArtist()) {
+ element.addNode(boost::make_shared<XMLElement>("artist", "", *payload->getArtist()));
+ }
+ if (payload->getURI()) {
+ element.addNode(boost::make_shared<XMLElement>("uri", "", *payload->getURI()));
+ }
+ if (payload->getSource()) {
+ element.addNode(boost::make_shared<XMLElement>("source", "", *payload->getSource()));
+ }
+ if (payload->getLength()) {
+ element.addNode(boost::make_shared<XMLElement>("length", "", boost::lexical_cast<std::string>(*payload->getLength())));
+ }
+ return element.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h
index 13f56ae..1d3c76b 100644
--- a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h
@@ -14,19 +14,19 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
+ class PayloadSerializerCollection;
- class SWIFTEN_API UserTuneSerializer : public GenericPayloadSerializer<UserTune> {
- public:
- UserTuneSerializer(PayloadSerializerCollection* serializers);
- virtual ~UserTuneSerializer();
+ class SWIFTEN_API UserTuneSerializer : public GenericPayloadSerializer<UserTune> {
+ public:
+ UserTuneSerializer(PayloadSerializerCollection* serializers);
+ virtual ~UserTuneSerializer();
- virtual std::string serializePayload(boost::shared_ptr<UserTune>) const SWIFTEN_OVERRIDE;
+ virtual std::string serializePayload(boost::shared_ptr<UserTune>) const SWIFTEN_OVERRIDE;
- private:
-
+ private:
- private:
- PayloadSerializerCollection* serializers;
- };
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
index 2b1d179..98597e4 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
@@ -22,230 +22,230 @@ VCardSerializer::VCardSerializer() : GenericPayloadSerializer<VCard>() {
}
std::string VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const {
- XMLElement queryElement("vCard", "vcard-temp");
- if (!vcard->getVersion().empty()) {
- queryElement.addNode(boost::make_shared<XMLElement>("VERSION", "", vcard->getVersion()));
- }
- if (!vcard->getFullName().empty()) {
- queryElement.addNode(boost::make_shared<XMLElement>("FN", "", vcard->getFullName()));
- }
- if (!vcard->getGivenName().empty() || !vcard->getFamilyName().empty() || !vcard->getMiddleName().empty() || !vcard->getPrefix().empty() || !vcard->getSuffix().empty()) {
- boost::shared_ptr<XMLElement> nameElement(new XMLElement("N"));
- if (!vcard->getFamilyName().empty()) {
- nameElement->addNode(boost::make_shared<XMLElement>("FAMILY", "", vcard->getFamilyName()));
- }
- if (!vcard->getGivenName().empty()) {
- nameElement->addNode(boost::make_shared<XMLElement>("GIVEN", "", vcard->getGivenName()));
- }
- if (!vcard->getMiddleName().empty()) {
- nameElement->addNode(boost::make_shared<XMLElement>("MIDDLE", "", vcard->getMiddleName()));
- }
- if (!vcard->getPrefix().empty()) {
- nameElement->addNode(boost::make_shared<XMLElement>("PREFIX", "", vcard->getPrefix()));
- }
- if (!vcard->getSuffix().empty()) {
- nameElement->addNode(boost::make_shared<XMLElement>("SUFFIX", "", vcard->getSuffix()));
- }
- queryElement.addNode(nameElement);
- }
- foreach(const VCard::EMailAddress& emailAddress, vcard->getEMailAddresses()) {
- boost::shared_ptr<XMLElement> emailElement(new XMLElement("EMAIL"));
- emailElement->addNode(boost::make_shared<XMLElement>("USERID", "", emailAddress.address));
- if (emailAddress.isHome) {
- emailElement->addNode(boost::make_shared<XMLElement>("HOME"));
- }
- if (emailAddress.isWork) {
- emailElement->addNode(boost::make_shared<XMLElement>("WORK"));
- }
- if (emailAddress.isInternet) {
- emailElement->addNode(boost::make_shared<XMLElement>("INTERNET"));
- }
- if (emailAddress.isPreferred) {
- emailElement->addNode(boost::make_shared<XMLElement>("PREF"));
- }
- if (emailAddress.isX400) {
- emailElement->addNode(boost::make_shared<XMLElement>("X400"));
- }
- queryElement.addNode(emailElement);
- }
- if (!vcard->getNickname().empty()) {
- queryElement.addNode(boost::make_shared<XMLElement>("NICKNAME", "", vcard->getNickname()));
- }
- if (!vcard->getPhoto().empty() || !vcard->getPhotoType().empty()) {
- XMLElement::ref photoElement(new XMLElement("PHOTO"));
- if (!vcard->getPhotoType().empty()) {
- photoElement->addNode(boost::make_shared<XMLElement>("TYPE", "", vcard->getPhotoType()));
- }
- if (!vcard->getPhoto().empty()) {
- photoElement->addNode(boost::make_shared<XMLElement>("BINVAL", "", Base64::encode(vcard->getPhoto())));
- }
- queryElement.addNode(photoElement);
- }
- if (!vcard->getBirthday().is_not_a_date_time()) {
- queryElement.addNode(boost::make_shared<XMLElement>("BDAY", "", dateTimeToString(vcard->getBirthday())));
- }
-
- foreach(const VCard::Telephone& telephone, vcard->getTelephones()) {
- boost::shared_ptr<XMLElement> telElement(new XMLElement("TEL"));
- telElement->addNode(boost::make_shared<XMLElement>("NUMBER", "", telephone.number));
- if (telephone.isHome) {
- telElement->addNode(boost::make_shared<XMLElement>("HOME"));
- }
- if (telephone.isWork) {
- telElement->addNode(boost::make_shared<XMLElement>("WORK"));
- }
- if (telephone.isVoice) {
- telElement->addNode(boost::make_shared<XMLElement>("VOICE"));
- }
- if (telephone.isFax) {
- telElement->addNode(boost::make_shared<XMLElement>("FAX"));
- }
- if (telephone.isPager) {
- telElement->addNode(boost::make_shared<XMLElement>("PAGER"));
- }
- if (telephone.isMSG) {
- telElement->addNode(boost::make_shared<XMLElement>("MSG"));
- }
- if (telephone.isCell) {
- telElement->addNode(boost::make_shared<XMLElement>("CELL"));
- }
- if (telephone.isVideo) {
- telElement->addNode(boost::make_shared<XMLElement>("VIDEO"));
- }
- if (telephone.isBBS) {
- telElement->addNode(boost::make_shared<XMLElement>("BBS"));
- }
- if (telephone.isModem) {
- telElement->addNode(boost::make_shared<XMLElement>("MODEM"));
- }
- if (telephone.isISDN) {
- telElement->addNode(boost::make_shared<XMLElement>("ISDN"));
- }
- if (telephone.isPCS) {
- telElement->addNode(boost::make_shared<XMLElement>("PCS"));
- }
- if (telephone.isPreferred) {
- telElement->addNode(boost::make_shared<XMLElement>("PREF"));
- }
- queryElement.addNode(telElement);
- }
-
- foreach(const VCard::Address& address, vcard->getAddresses()) {
- boost::shared_ptr<XMLElement> adrElement = boost::make_shared<XMLElement>("ADR");
- if (!address.poBox.empty()) {
- adrElement->addNode(boost::make_shared<XMLElement>("POBOX", "", address.poBox));
- }
- if (!address.addressExtension.empty()) {
- adrElement->addNode(boost::make_shared<XMLElement>("EXTADD", "", address.addressExtension));
- }
- if (!address.street.empty()) {
- adrElement->addNode(boost::make_shared<XMLElement>("STREET", "", address.street));
- }
- if (!address.locality.empty()) {
- adrElement->addNode(boost::make_shared<XMLElement>("LOCALITY", "", address.locality));
- }
- if (!address.region.empty()) {
- adrElement->addNode(boost::make_shared<XMLElement>("REGION", "", address.region));
- }
- if (!address.postalCode.empty()) {
- adrElement->addNode(boost::make_shared<XMLElement>("PCODE", "", address.postalCode));
- }
- if (!address.country.empty()) {
- adrElement->addNode(boost::make_shared<XMLElement>("CTRY", "", address.country));
- }
-
- if (address.isHome) {
- adrElement->addNode(boost::make_shared<XMLElement>("HOME"));
- }
- if (address.isWork) {
- adrElement->addNode(boost::make_shared<XMLElement>("WORK"));
- }
- if (address.isPostal) {
- adrElement->addNode(boost::make_shared<XMLElement>("POSTAL"));
- }
- if (address.isParcel) {
- adrElement->addNode(boost::make_shared<XMLElement>("PARCEL"));
- }
- if (address.deliveryType == VCard::DomesticDelivery) {
- adrElement->addNode(boost::make_shared<XMLElement>("DOM"));
- }
- if (address.deliveryType == VCard::InternationalDelivery) {
- adrElement->addNode(boost::make_shared<XMLElement>("INTL"));
- }
- if (address.isPreferred) {
- adrElement->addNode(boost::make_shared<XMLElement>("PREF"));
- }
- queryElement.addNode(adrElement);
- }
-
- foreach(const VCard::AddressLabel& addressLabel, vcard->getAddressLabels()) {
- boost::shared_ptr<XMLElement> labelElement = boost::make_shared<XMLElement>("LABEL");
-
- foreach(const std::string& line, addressLabel.lines) {
- labelElement->addNode(boost::make_shared<XMLElement>("LINE", "", line));
- }
-
- if (addressLabel.isHome) {
- labelElement->addNode(boost::make_shared<XMLElement>("HOME"));
- }
- if (addressLabel.isWork) {
- labelElement->addNode(boost::make_shared<XMLElement>("WORK"));
- }
- if (addressLabel.isPostal) {
- labelElement->addNode(boost::make_shared<XMLElement>("POSTAL"));
- }
- if (addressLabel.isParcel) {
- labelElement->addNode(boost::make_shared<XMLElement>("PARCEL"));
- }
- if (addressLabel.deliveryType == VCard::DomesticDelivery) {
- labelElement->addNode(boost::make_shared<XMLElement>("DOM"));
- }
- if (addressLabel.deliveryType == VCard::InternationalDelivery) {
- labelElement->addNode(boost::make_shared<XMLElement>("INTL"));
- }
- if (addressLabel.isPreferred) {
- labelElement->addNode(boost::make_shared<XMLElement>("PREF"));
- }
- queryElement.addNode(labelElement);
- }
-
- foreach(const JID& jid, vcard->getJIDs()) {
- queryElement.addNode(boost::make_shared<XMLElement>("JID", "", jid.toString()));
- }
-
- if (!vcard->getDescription().empty()) {
- queryElement.addNode(boost::make_shared<XMLElement>("DESC", "", vcard->getDescription()));
- }
-
- foreach(const VCard::Organization& org, vcard->getOrganizations()) {
- boost::shared_ptr<XMLElement> orgElement = boost::make_shared<XMLElement>("ORG");
- if (!org.name.empty()) {
- orgElement->addNode(boost::make_shared<XMLElement>("ORGNAME", "", org.name));
- }
- if (!org.units.empty()) {
- foreach(const std::string& unit, org.units) {
- orgElement->addNode(boost::make_shared<XMLElement>("ORGUNIT", "", unit));
- }
- }
- queryElement.addNode(orgElement);
- }
-
- foreach(const std::string& title, vcard->getTitles()) {
- queryElement.addNode(boost::make_shared<XMLElement>("TITLE", "", title));
- }
-
- foreach(const std::string& role, vcard->getRoles()) {
- queryElement.addNode(boost::make_shared<XMLElement>("ROLE", "", role));
- }
-
- foreach(const std::string& url, vcard->getURLs()) {
- queryElement.addNode(boost::make_shared<XMLElement>("URL", "", url));
- }
-
- if (!vcard->getUnknownContent().empty()) {
- queryElement.addNode(boost::make_shared<XMLRawTextNode>(vcard->getUnknownContent()));
- }
- return queryElement.serialize();
+ XMLElement queryElement("vCard", "vcard-temp");
+ if (!vcard->getVersion().empty()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("VERSION", "", vcard->getVersion()));
+ }
+ if (!vcard->getFullName().empty()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("FN", "", vcard->getFullName()));
+ }
+ if (!vcard->getGivenName().empty() || !vcard->getFamilyName().empty() || !vcard->getMiddleName().empty() || !vcard->getPrefix().empty() || !vcard->getSuffix().empty()) {
+ boost::shared_ptr<XMLElement> nameElement(new XMLElement("N"));
+ if (!vcard->getFamilyName().empty()) {
+ nameElement->addNode(boost::make_shared<XMLElement>("FAMILY", "", vcard->getFamilyName()));
+ }
+ if (!vcard->getGivenName().empty()) {
+ nameElement->addNode(boost::make_shared<XMLElement>("GIVEN", "", vcard->getGivenName()));
+ }
+ if (!vcard->getMiddleName().empty()) {
+ nameElement->addNode(boost::make_shared<XMLElement>("MIDDLE", "", vcard->getMiddleName()));
+ }
+ if (!vcard->getPrefix().empty()) {
+ nameElement->addNode(boost::make_shared<XMLElement>("PREFIX", "", vcard->getPrefix()));
+ }
+ if (!vcard->getSuffix().empty()) {
+ nameElement->addNode(boost::make_shared<XMLElement>("SUFFIX", "", vcard->getSuffix()));
+ }
+ queryElement.addNode(nameElement);
+ }
+ foreach(const VCard::EMailAddress& emailAddress, vcard->getEMailAddresses()) {
+ boost::shared_ptr<XMLElement> emailElement(new XMLElement("EMAIL"));
+ emailElement->addNode(boost::make_shared<XMLElement>("USERID", "", emailAddress.address));
+ if (emailAddress.isHome) {
+ emailElement->addNode(boost::make_shared<XMLElement>("HOME"));
+ }
+ if (emailAddress.isWork) {
+ emailElement->addNode(boost::make_shared<XMLElement>("WORK"));
+ }
+ if (emailAddress.isInternet) {
+ emailElement->addNode(boost::make_shared<XMLElement>("INTERNET"));
+ }
+ if (emailAddress.isPreferred) {
+ emailElement->addNode(boost::make_shared<XMLElement>("PREF"));
+ }
+ if (emailAddress.isX400) {
+ emailElement->addNode(boost::make_shared<XMLElement>("X400"));
+ }
+ queryElement.addNode(emailElement);
+ }
+ if (!vcard->getNickname().empty()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("NICKNAME", "", vcard->getNickname()));
+ }
+ if (!vcard->getPhoto().empty() || !vcard->getPhotoType().empty()) {
+ XMLElement::ref photoElement(new XMLElement("PHOTO"));
+ if (!vcard->getPhotoType().empty()) {
+ photoElement->addNode(boost::make_shared<XMLElement>("TYPE", "", vcard->getPhotoType()));
+ }
+ if (!vcard->getPhoto().empty()) {
+ photoElement->addNode(boost::make_shared<XMLElement>("BINVAL", "", Base64::encode(vcard->getPhoto())));
+ }
+ queryElement.addNode(photoElement);
+ }
+ if (!vcard->getBirthday().is_not_a_date_time()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("BDAY", "", dateTimeToString(vcard->getBirthday())));
+ }
+
+ foreach(const VCard::Telephone& telephone, vcard->getTelephones()) {
+ boost::shared_ptr<XMLElement> telElement(new XMLElement("TEL"));
+ telElement->addNode(boost::make_shared<XMLElement>("NUMBER", "", telephone.number));
+ if (telephone.isHome) {
+ telElement->addNode(boost::make_shared<XMLElement>("HOME"));
+ }
+ if (telephone.isWork) {
+ telElement->addNode(boost::make_shared<XMLElement>("WORK"));
+ }
+ if (telephone.isVoice) {
+ telElement->addNode(boost::make_shared<XMLElement>("VOICE"));
+ }
+ if (telephone.isFax) {
+ telElement->addNode(boost::make_shared<XMLElement>("FAX"));
+ }
+ if (telephone.isPager) {
+ telElement->addNode(boost::make_shared<XMLElement>("PAGER"));
+ }
+ if (telephone.isMSG) {
+ telElement->addNode(boost::make_shared<XMLElement>("MSG"));
+ }
+ if (telephone.isCell) {
+ telElement->addNode(boost::make_shared<XMLElement>("CELL"));
+ }
+ if (telephone.isVideo) {
+ telElement->addNode(boost::make_shared<XMLElement>("VIDEO"));
+ }
+ if (telephone.isBBS) {
+ telElement->addNode(boost::make_shared<XMLElement>("BBS"));
+ }
+ if (telephone.isModem) {
+ telElement->addNode(boost::make_shared<XMLElement>("MODEM"));
+ }
+ if (telephone.isISDN) {
+ telElement->addNode(boost::make_shared<XMLElement>("ISDN"));
+ }
+ if (telephone.isPCS) {
+ telElement->addNode(boost::make_shared<XMLElement>("PCS"));
+ }
+ if (telephone.isPreferred) {
+ telElement->addNode(boost::make_shared<XMLElement>("PREF"));
+ }
+ queryElement.addNode(telElement);
+ }
+
+ foreach(const VCard::Address& address, vcard->getAddresses()) {
+ boost::shared_ptr<XMLElement> adrElement = boost::make_shared<XMLElement>("ADR");
+ if (!address.poBox.empty()) {
+ adrElement->addNode(boost::make_shared<XMLElement>("POBOX", "", address.poBox));
+ }
+ if (!address.addressExtension.empty()) {
+ adrElement->addNode(boost::make_shared<XMLElement>("EXTADD", "", address.addressExtension));
+ }
+ if (!address.street.empty()) {
+ adrElement->addNode(boost::make_shared<XMLElement>("STREET", "", address.street));
+ }
+ if (!address.locality.empty()) {
+ adrElement->addNode(boost::make_shared<XMLElement>("LOCALITY", "", address.locality));
+ }
+ if (!address.region.empty()) {
+ adrElement->addNode(boost::make_shared<XMLElement>("REGION", "", address.region));
+ }
+ if (!address.postalCode.empty()) {
+ adrElement->addNode(boost::make_shared<XMLElement>("PCODE", "", address.postalCode));
+ }
+ if (!address.country.empty()) {
+ adrElement->addNode(boost::make_shared<XMLElement>("CTRY", "", address.country));
+ }
+
+ if (address.isHome) {
+ adrElement->addNode(boost::make_shared<XMLElement>("HOME"));
+ }
+ if (address.isWork) {
+ adrElement->addNode(boost::make_shared<XMLElement>("WORK"));
+ }
+ if (address.isPostal) {
+ adrElement->addNode(boost::make_shared<XMLElement>("POSTAL"));
+ }
+ if (address.isParcel) {
+ adrElement->addNode(boost::make_shared<XMLElement>("PARCEL"));
+ }
+ if (address.deliveryType == VCard::DomesticDelivery) {
+ adrElement->addNode(boost::make_shared<XMLElement>("DOM"));
+ }
+ if (address.deliveryType == VCard::InternationalDelivery) {
+ adrElement->addNode(boost::make_shared<XMLElement>("INTL"));
+ }
+ if (address.isPreferred) {
+ adrElement->addNode(boost::make_shared<XMLElement>("PREF"));
+ }
+ queryElement.addNode(adrElement);
+ }
+
+ foreach(const VCard::AddressLabel& addressLabel, vcard->getAddressLabels()) {
+ boost::shared_ptr<XMLElement> labelElement = boost::make_shared<XMLElement>("LABEL");
+
+ foreach(const std::string& line, addressLabel.lines) {
+ labelElement->addNode(boost::make_shared<XMLElement>("LINE", "", line));
+ }
+
+ if (addressLabel.isHome) {
+ labelElement->addNode(boost::make_shared<XMLElement>("HOME"));
+ }
+ if (addressLabel.isWork) {
+ labelElement->addNode(boost::make_shared<XMLElement>("WORK"));
+ }
+ if (addressLabel.isPostal) {
+ labelElement->addNode(boost::make_shared<XMLElement>("POSTAL"));
+ }
+ if (addressLabel.isParcel) {
+ labelElement->addNode(boost::make_shared<XMLElement>("PARCEL"));
+ }
+ if (addressLabel.deliveryType == VCard::DomesticDelivery) {
+ labelElement->addNode(boost::make_shared<XMLElement>("DOM"));
+ }
+ if (addressLabel.deliveryType == VCard::InternationalDelivery) {
+ labelElement->addNode(boost::make_shared<XMLElement>("INTL"));
+ }
+ if (addressLabel.isPreferred) {
+ labelElement->addNode(boost::make_shared<XMLElement>("PREF"));
+ }
+ queryElement.addNode(labelElement);
+ }
+
+ foreach(const JID& jid, vcard->getJIDs()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("JID", "", jid.toString()));
+ }
+
+ if (!vcard->getDescription().empty()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("DESC", "", vcard->getDescription()));
+ }
+
+ foreach(const VCard::Organization& org, vcard->getOrganizations()) {
+ boost::shared_ptr<XMLElement> orgElement = boost::make_shared<XMLElement>("ORG");
+ if (!org.name.empty()) {
+ orgElement->addNode(boost::make_shared<XMLElement>("ORGNAME", "", org.name));
+ }
+ if (!org.units.empty()) {
+ foreach(const std::string& unit, org.units) {
+ orgElement->addNode(boost::make_shared<XMLElement>("ORGUNIT", "", unit));
+ }
+ }
+ queryElement.addNode(orgElement);
+ }
+
+ foreach(const std::string& title, vcard->getTitles()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("TITLE", "", title));
+ }
+
+ foreach(const std::string& role, vcard->getRoles()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("ROLE", "", role));
+ }
+
+ foreach(const std::string& url, vcard->getURLs()) {
+ queryElement.addNode(boost::make_shared<XMLElement>("URL", "", url));
+ }
+
+ if (!vcard->getUnknownContent().empty()) {
+ queryElement.addNode(boost::make_shared<XMLRawTextNode>(vcard->getUnknownContent()));
+ }
+ return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.h b/Swiften/Serializer/PayloadSerializers/VCardSerializer.h
index b4502f5..e84252d 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API VCardSerializer : public GenericPayloadSerializer<VCard> {
- public:
- VCardSerializer();
+ class SWIFTEN_API VCardSerializer : public GenericPayloadSerializer<VCard> {
+ public:
+ VCardSerializer();
- virtual std::string serializePayload(boost::shared_ptr<VCard>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<VCard>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
index 0edca0a..8fb1e3f 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
@@ -17,12 +17,12 @@ namespace Swift {
VCardUpdateSerializer::VCardUpdateSerializer() : GenericPayloadSerializer<VCardUpdate>() {
}
-std::string VCardUpdateSerializer::serializePayload(boost::shared_ptr<VCardUpdate> vcardUpdate) const {
- XMLElement updateElement("x", "vcard-temp:x:update");
- boost::shared_ptr<XMLElement> photoElement(new XMLElement("photo"));
- photoElement->addNode(boost::make_shared<XMLTextNode>(vcardUpdate->getPhotoHash()));
- updateElement.addNode(photoElement);
- return updateElement.serialize();
+std::string VCardUpdateSerializer::serializePayload(boost::shared_ptr<VCardUpdate> vcardUpdate) const {
+ XMLElement updateElement("x", "vcard-temp:x:update");
+ boost::shared_ptr<XMLElement> photoElement(new XMLElement("photo"));
+ photoElement->addNode(boost::make_shared<XMLTextNode>(vcardUpdate->getPhotoHash()));
+ updateElement.addNode(photoElement);
+ return updateElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h
index 87fb235..777da3e 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
namespace Swift {
- class SWIFTEN_API VCardUpdateSerializer : public GenericPayloadSerializer<VCardUpdate> {
- public:
- VCardUpdateSerializer();
+ class SWIFTEN_API VCardUpdateSerializer : public GenericPayloadSerializer<VCardUpdate> {
+ public:
+ VCardUpdateSerializer();
- virtual std::string serializePayload(boost::shared_ptr<VCardUpdate>) const;
- };
+ virtual std::string serializePayload(boost::shared_ptr<VCardUpdate>) const;
+ };
}
diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp
index b037e5a..27d3f57 100644
--- a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp
@@ -23,186 +23,186 @@
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
- void WhiteboardElementSerializingVisitor::visit(WhiteboardLineElement& line) {
- element = boost::make_shared<XMLElement>("line");
- try {
- element->setAttribute("x1", boost::lexical_cast<std::string>(line.x1()));
- element->setAttribute("y1", boost::lexical_cast<std::string>(line.y1()));
- element->setAttribute("x2", boost::lexical_cast<std::string>(line.x2()));
- element->setAttribute("y2", boost::lexical_cast<std::string>(line.y2()));
- element->setAttribute("id", line.getID());
- element->setAttribute("stroke", line.getColor().toHex());
- element->setAttribute("stroke-width", boost::lexical_cast<std::string>(line.getPenWidth()));
- element->setAttribute("opacity", alphaToOpacity(line.getColor().getAlpha()));
- } catch (boost::bad_lexical_cast&) {
- }
- }
-
- void WhiteboardElementSerializingVisitor::visit(WhiteboardFreehandPathElement& path) {
- element = boost::make_shared<XMLElement>("path");
- element->setAttribute("id", path.getID());
- element->setAttribute("stroke", path.getColor().toHex());
- try {
- element->setAttribute("stroke-width", boost::lexical_cast<std::string>(path.getPenWidth()));
- element->setAttribute("opacity", alphaToOpacity(path.getColor().getAlpha()));
- std::string pathData;
- if (path.getPoints().size() != 0) {
- std::vector<std::pair<int, int> >::const_iterator it = path.getPoints().begin();
- pathData = "M"+boost::lexical_cast<std::string>(it->first)+" "+boost::lexical_cast<std::string>(it->second)+"L";
- for (; it != path.getPoints().end(); ++it) {
- pathData += boost::lexical_cast<std::string>(it->first)+" "+boost::lexical_cast<std::string>(it->second)+" ";
- }
- }
- element->setAttribute("d", pathData);
- } catch (boost::bad_lexical_cast&) {
- }
- }
-
- void WhiteboardElementSerializingVisitor::visit(WhiteboardRectElement& rect) {
- element = boost::make_shared<XMLElement>("rect");
- try {
- element->setAttribute("x", boost::lexical_cast<std::string>(rect.getX()));
- element->setAttribute("y", boost::lexical_cast<std::string>(rect.getY()));
- element->setAttribute("width", boost::lexical_cast<std::string>(rect.getWidth()));
- element->setAttribute("height", boost::lexical_cast<std::string>(rect.getHeight()));
- element->setAttribute("id", rect.getID());
- element->setAttribute("stroke", rect.getPenColor().toHex());
- element->setAttribute("fill", rect.getBrushColor().toHex());;
- element->setAttribute("stroke-width", boost::lexical_cast<std::string>(rect.getPenWidth()));
- element->setAttribute("opacity", alphaToOpacity(rect.getPenColor().getAlpha()));
- element->setAttribute("fill-opacity", alphaToOpacity(rect.getBrushColor().getAlpha()));
- } catch (boost::bad_lexical_cast&) {
- }
- }
-
- void WhiteboardElementSerializingVisitor::visit(WhiteboardPolygonElement& polygon) {
- element = boost::make_shared<XMLElement>("polygon");
- try {
- element->setAttribute("id", polygon.getID());
- element->setAttribute("stroke", polygon.getPenColor().toHex());
- element->setAttribute("fill", polygon.getBrushColor().toHex());;
- element->setAttribute("stroke-width", boost::lexical_cast<std::string>(polygon.getPenWidth()));
- element->setAttribute("opacity", alphaToOpacity(polygon.getPenColor().getAlpha()));
- element->setAttribute("fill-opacity", alphaToOpacity(polygon.getBrushColor().getAlpha()));
- std::string points;
- std::vector<std::pair<int, int> >::const_iterator it = polygon.getPoints().begin();
- for (; it != polygon.getPoints().end(); ++it) {
- points += boost::lexical_cast<std::string>(it->first)+","+boost::lexical_cast<std::string>(it->second)+" ";
- }
- element->setAttribute("points", points);
- } catch (boost::bad_lexical_cast&) {
- }
- }
-
- void WhiteboardElementSerializingVisitor::visit(WhiteboardTextElement& text) {
- element = boost::make_shared<XMLElement>("text");
- try {
- element->setAttribute("x", boost::lexical_cast<std::string>(text.getX()));
- element->setAttribute("y", boost::lexical_cast<std::string>(text.getY()));
- element->setAttribute("font-size", boost::lexical_cast<std::string>(text.getSize()));
- element->setAttribute("id", text.getID());
- element->setAttribute("fill", text.getColor().toHex());
- element->setAttribute("opacity", alphaToOpacity(text.getColor().getAlpha()));
- element->addNode(boost::make_shared<XMLTextNode>(text.getText()));
- } catch (boost::bad_lexical_cast&) {
- }
- }
-
- void WhiteboardElementSerializingVisitor::visit(WhiteboardEllipseElement& ellipse) {
- element = boost::make_shared<XMLElement>("ellipse");
- try {
- element->setAttribute("cx", boost::lexical_cast<std::string>(ellipse.getCX()));
- element->setAttribute("cy", boost::lexical_cast<std::string>(ellipse.getCY()));
- element->setAttribute("rx", boost::lexical_cast<std::string>(ellipse.getRX()));
- element->setAttribute("ry", boost::lexical_cast<std::string>(ellipse.getRY()));
- element->setAttribute("id", ellipse.getID());
- element->setAttribute("stroke", ellipse.getPenColor().toHex());
- element->setAttribute("fill", ellipse.getBrushColor().toHex());;
- element->setAttribute("stroke-width", boost::lexical_cast<std::string>(ellipse.getPenWidth()));
- element->setAttribute("opacity", alphaToOpacity(ellipse.getPenColor().getAlpha()));
- element->setAttribute("fill-opacity", alphaToOpacity(ellipse.getBrushColor().getAlpha()));
- } catch (boost::bad_lexical_cast&) {
- }
- }
-
- XMLElement::ref WhiteboardElementSerializingVisitor::getResult() const {
- return element;
- }
-
- std::string WhiteboardElementSerializingVisitor::alphaToOpacity(int alpha) const {
- int opacity = 100*alpha/254;
- if (opacity == 100) {
- return "1";
- } else {
- return "."+boost::lexical_cast<std::string>(opacity);
- }
- }
-
- std::string WhiteboardSerializer::serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const {
- XMLElement element("wb", "http://swift.im/whiteboard");
- if (payload->getType() == WhiteboardPayload::Data) {
- XMLElement::ref operationNode = boost::make_shared<XMLElement>("operation");
- WhiteboardElementSerializingVisitor visitor;
-// payload->getElement()->accept(visitor);
- WhiteboardInsertOperation::ref insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(payload->getOperation());
- if (insertOp) {
- try {
- operationNode->setAttribute("type", "insert");
- operationNode->setAttribute("pos", boost::lexical_cast<std::string>(insertOp->getPos()));
- operationNode->setAttribute("id", insertOp->getID());
- operationNode->setAttribute("parentid", insertOp->getParentID());
- } catch (boost::bad_lexical_cast&) {
- }
- insertOp->getElement()->accept(visitor);
- operationNode->addNode(visitor.getResult());
- }
- WhiteboardUpdateOperation::ref updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(payload->getOperation());
- if (updateOp) {
- try {
- operationNode->setAttribute("type", "update");
- operationNode->setAttribute("pos", boost::lexical_cast<std::string>(updateOp->getPos()));
- operationNode->setAttribute("id", updateOp->getID());
- operationNode->setAttribute("parentid", updateOp->getParentID());
- operationNode->setAttribute("newpos", boost::lexical_cast<std::string>(updateOp->getNewPos()));
- } catch (boost::bad_lexical_cast&) {
- }
- updateOp->getElement()->accept(visitor);
- operationNode->addNode(visitor.getResult());
-
- }
-
- WhiteboardDeleteOperation::ref deleteOp = boost::dynamic_pointer_cast<WhiteboardDeleteOperation>(payload->getOperation());
- if (deleteOp) {
- try {
- operationNode->setAttribute("type", "delete");
- operationNode->setAttribute("pos", boost::lexical_cast<std::string>(deleteOp->getPos()));
- operationNode->setAttribute("id", deleteOp->getID());
- operationNode->setAttribute("parentid", deleteOp->getParentID());
- operationNode->setAttribute("elementid", deleteOp->getElementID());
- } catch (boost::bad_lexical_cast&) {
- }
- }
- element.addNode(operationNode);
- }
- element.setAttribute("type", typeToString(payload->getType()));
- return element.serialize();
- }
-
- std::string WhiteboardSerializer::typeToString(WhiteboardPayload::Type type) const {
- switch (type) {
- case WhiteboardPayload::Data:
- return "data";
- case WhiteboardPayload::SessionRequest:
- return "session-request";
- case WhiteboardPayload::SessionAccept:
- return "session-accept";
- case WhiteboardPayload::SessionTerminate:
- return "session-terminate";
- case WhiteboardPayload::UnknownType:
- std::cerr << "Warning: Serializing unknown action value." << std::endl;
- return "";
- }
- assert(false);
- return "";
- }
+ void WhiteboardElementSerializingVisitor::visit(WhiteboardLineElement& line) {
+ element = boost::make_shared<XMLElement>("line");
+ try {
+ element->setAttribute("x1", boost::lexical_cast<std::string>(line.x1()));
+ element->setAttribute("y1", boost::lexical_cast<std::string>(line.y1()));
+ element->setAttribute("x2", boost::lexical_cast<std::string>(line.x2()));
+ element->setAttribute("y2", boost::lexical_cast<std::string>(line.y2()));
+ element->setAttribute("id", line.getID());
+ element->setAttribute("stroke", line.getColor().toHex());
+ element->setAttribute("stroke-width", boost::lexical_cast<std::string>(line.getPenWidth()));
+ element->setAttribute("opacity", alphaToOpacity(line.getColor().getAlpha()));
+ } catch (boost::bad_lexical_cast&) {
+ }
+ }
+
+ void WhiteboardElementSerializingVisitor::visit(WhiteboardFreehandPathElement& path) {
+ element = boost::make_shared<XMLElement>("path");
+ element->setAttribute("id", path.getID());
+ element->setAttribute("stroke", path.getColor().toHex());
+ try {
+ element->setAttribute("stroke-width", boost::lexical_cast<std::string>(path.getPenWidth()));
+ element->setAttribute("opacity", alphaToOpacity(path.getColor().getAlpha()));
+ std::string pathData;
+ if (path.getPoints().size() != 0) {
+ std::vector<std::pair<int, int> >::const_iterator it = path.getPoints().begin();
+ pathData = "M"+boost::lexical_cast<std::string>(it->first)+" "+boost::lexical_cast<std::string>(it->second)+"L";
+ for (; it != path.getPoints().end(); ++it) {
+ pathData += boost::lexical_cast<std::string>(it->first)+" "+boost::lexical_cast<std::string>(it->second)+" ";
+ }
+ }
+ element->setAttribute("d", pathData);
+ } catch (boost::bad_lexical_cast&) {
+ }
+ }
+
+ void WhiteboardElementSerializingVisitor::visit(WhiteboardRectElement& rect) {
+ element = boost::make_shared<XMLElement>("rect");
+ try {
+ element->setAttribute("x", boost::lexical_cast<std::string>(rect.getX()));
+ element->setAttribute("y", boost::lexical_cast<std::string>(rect.getY()));
+ element->setAttribute("width", boost::lexical_cast<std::string>(rect.getWidth()));
+ element->setAttribute("height", boost::lexical_cast<std::string>(rect.getHeight()));
+ element->setAttribute("id", rect.getID());
+ element->setAttribute("stroke", rect.getPenColor().toHex());
+ element->setAttribute("fill", rect.getBrushColor().toHex());;
+ element->setAttribute("stroke-width", boost::lexical_cast<std::string>(rect.getPenWidth()));
+ element->setAttribute("opacity", alphaToOpacity(rect.getPenColor().getAlpha()));
+ element->setAttribute("fill-opacity", alphaToOpacity(rect.getBrushColor().getAlpha()));
+ } catch (boost::bad_lexical_cast&) {
+ }
+ }
+
+ void WhiteboardElementSerializingVisitor::visit(WhiteboardPolygonElement& polygon) {
+ element = boost::make_shared<XMLElement>("polygon");
+ try {
+ element->setAttribute("id", polygon.getID());
+ element->setAttribute("stroke", polygon.getPenColor().toHex());
+ element->setAttribute("fill", polygon.getBrushColor().toHex());;
+ element->setAttribute("stroke-width", boost::lexical_cast<std::string>(polygon.getPenWidth()));
+ element->setAttribute("opacity", alphaToOpacity(polygon.getPenColor().getAlpha()));
+ element->setAttribute("fill-opacity", alphaToOpacity(polygon.getBrushColor().getAlpha()));
+ std::string points;
+ std::vector<std::pair<int, int> >::const_iterator it = polygon.getPoints().begin();
+ for (; it != polygon.getPoints().end(); ++it) {
+ points += boost::lexical_cast<std::string>(it->first)+","+boost::lexical_cast<std::string>(it->second)+" ";
+ }
+ element->setAttribute("points", points);
+ } catch (boost::bad_lexical_cast&) {
+ }
+ }
+
+ void WhiteboardElementSerializingVisitor::visit(WhiteboardTextElement& text) {
+ element = boost::make_shared<XMLElement>("text");
+ try {
+ element->setAttribute("x", boost::lexical_cast<std::string>(text.getX()));
+ element->setAttribute("y", boost::lexical_cast<std::string>(text.getY()));
+ element->setAttribute("font-size", boost::lexical_cast<std::string>(text.getSize()));
+ element->setAttribute("id", text.getID());
+ element->setAttribute("fill", text.getColor().toHex());
+ element->setAttribute("opacity", alphaToOpacity(text.getColor().getAlpha()));
+ element->addNode(boost::make_shared<XMLTextNode>(text.getText()));
+ } catch (boost::bad_lexical_cast&) {
+ }
+ }
+
+ void WhiteboardElementSerializingVisitor::visit(WhiteboardEllipseElement& ellipse) {
+ element = boost::make_shared<XMLElement>("ellipse");
+ try {
+ element->setAttribute("cx", boost::lexical_cast<std::string>(ellipse.getCX()));
+ element->setAttribute("cy", boost::lexical_cast<std::string>(ellipse.getCY()));
+ element->setAttribute("rx", boost::lexical_cast<std::string>(ellipse.getRX()));
+ element->setAttribute("ry", boost::lexical_cast<std::string>(ellipse.getRY()));
+ element->setAttribute("id", ellipse.getID());
+ element->setAttribute("stroke", ellipse.getPenColor().toHex());
+ element->setAttribute("fill", ellipse.getBrushColor().toHex());;
+ element->setAttribute("stroke-width", boost::lexical_cast<std::string>(ellipse.getPenWidth()));
+ element->setAttribute("opacity", alphaToOpacity(ellipse.getPenColor().getAlpha()));
+ element->setAttribute("fill-opacity", alphaToOpacity(ellipse.getBrushColor().getAlpha()));
+ } catch (boost::bad_lexical_cast&) {
+ }
+ }
+
+ XMLElement::ref WhiteboardElementSerializingVisitor::getResult() const {
+ return element;
+ }
+
+ std::string WhiteboardElementSerializingVisitor::alphaToOpacity(int alpha) const {
+ int opacity = 100*alpha/254;
+ if (opacity == 100) {
+ return "1";
+ } else {
+ return "."+boost::lexical_cast<std::string>(opacity);
+ }
+ }
+
+ std::string WhiteboardSerializer::serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const {
+ XMLElement element("wb", "http://swift.im/whiteboard");
+ if (payload->getType() == WhiteboardPayload::Data) {
+ XMLElement::ref operationNode = boost::make_shared<XMLElement>("operation");
+ WhiteboardElementSerializingVisitor visitor;
+// payload->getElement()->accept(visitor);
+ WhiteboardInsertOperation::ref insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(payload->getOperation());
+ if (insertOp) {
+ try {
+ operationNode->setAttribute("type", "insert");
+ operationNode->setAttribute("pos", boost::lexical_cast<std::string>(insertOp->getPos()));
+ operationNode->setAttribute("id", insertOp->getID());
+ operationNode->setAttribute("parentid", insertOp->getParentID());
+ } catch (boost::bad_lexical_cast&) {
+ }
+ insertOp->getElement()->accept(visitor);
+ operationNode->addNode(visitor.getResult());
+ }
+ WhiteboardUpdateOperation::ref updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(payload->getOperation());
+ if (updateOp) {
+ try {
+ operationNode->setAttribute("type", "update");
+ operationNode->setAttribute("pos", boost::lexical_cast<std::string>(updateOp->getPos()));
+ operationNode->setAttribute("id", updateOp->getID());
+ operationNode->setAttribute("parentid", updateOp->getParentID());
+ operationNode->setAttribute("newpos", boost::lexical_cast<std::string>(updateOp->getNewPos()));
+ } catch (boost::bad_lexical_cast&) {
+ }
+ updateOp->getElement()->accept(visitor);
+ operationNode->addNode(visitor.getResult());
+
+ }
+
+ WhiteboardDeleteOperation::ref deleteOp = boost::dynamic_pointer_cast<WhiteboardDeleteOperation>(payload->getOperation());
+ if (deleteOp) {
+ try {
+ operationNode->setAttribute("type", "delete");
+ operationNode->setAttribute("pos", boost::lexical_cast<std::string>(deleteOp->getPos()));
+ operationNode->setAttribute("id", deleteOp->getID());
+ operationNode->setAttribute("parentid", deleteOp->getParentID());
+ operationNode->setAttribute("elementid", deleteOp->getElementID());
+ } catch (boost::bad_lexical_cast&) {
+ }
+ }
+ element.addNode(operationNode);
+ }
+ element.setAttribute("type", typeToString(payload->getType()));
+ return element.serialize();
+ }
+
+ std::string WhiteboardSerializer::typeToString(WhiteboardPayload::Type type) const {
+ switch (type) {
+ case WhiteboardPayload::Data:
+ return "data";
+ case WhiteboardPayload::SessionRequest:
+ return "session-request";
+ case WhiteboardPayload::SessionAccept:
+ return "session-accept";
+ case WhiteboardPayload::SessionTerminate:
+ return "session-terminate";
+ case WhiteboardPayload::UnknownType:
+ std::cerr << "Warning: Serializing unknown action value." << std::endl;
+ return "";
+ }
+ assert(false);
+ return "";
+ }
}
diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h
index cf93c8c..70aef1e 100644
--- a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h
@@ -25,27 +25,27 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API WhiteboardElementSerializingVisitor : public WhiteboardElementVisitor {
- public:
- void visit(WhiteboardLineElement& line);
- void visit(WhiteboardFreehandPathElement& path);
- void visit(WhiteboardRectElement& rect);
- void visit(WhiteboardPolygonElement& polygon);
- void visit(WhiteboardTextElement& text);
- void visit(WhiteboardEllipseElement& ellipse);
- XMLElement::ref getResult() const;
-
- private:
- std::string alphaToOpacity(int alpha) const;
-
- XMLElement::ref element;
- };
-
- class SWIFTEN_API WhiteboardSerializer : public GenericPayloadSerializer<WhiteboardPayload> {
- public:
- std::string serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const;
-
- private:
- std::string typeToString(WhiteboardPayload::Type type) const;
- };
+ class SWIFTEN_API WhiteboardElementSerializingVisitor : public WhiteboardElementVisitor {
+ public:
+ void visit(WhiteboardLineElement& line);
+ void visit(WhiteboardFreehandPathElement& path);
+ void visit(WhiteboardRectElement& rect);
+ void visit(WhiteboardPolygonElement& polygon);
+ void visit(WhiteboardTextElement& text);
+ void visit(WhiteboardEllipseElement& ellipse);
+ XMLElement::ref getResult() const;
+
+ private:
+ std::string alphaToOpacity(int alpha) const;
+
+ XMLElement::ref element;
+ };
+
+ class SWIFTEN_API WhiteboardSerializer : public GenericPayloadSerializer<WhiteboardPayload> {
+ public:
+ std::string serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const;
+
+ private:
+ std::string typeToString(WhiteboardPayload::Type type) const;
+ };
}
diff --git a/Swiften/Serializer/PresenceSerializer.cpp b/Swiften/Serializer/PresenceSerializer.cpp
index 71cf8eb..24c4365 100644
--- a/Swiften/Serializer/PresenceSerializer.cpp
+++ b/Swiften/Serializer/PresenceSerializer.cpp
@@ -14,23 +14,23 @@
namespace Swift {
PresenceSerializer::PresenceSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS) :
- GenericStanzaSerializer<Presence>("presence", payloadSerializers, explicitNS) {
+ GenericStanzaSerializer<Presence>("presence", payloadSerializers, explicitNS) {
}
void PresenceSerializer::setStanzaSpecificAttributesGeneric(
- boost::shared_ptr<Presence> presence,
- XMLElement& element) const {
- switch (presence->getType()) {
- case Presence::Unavailable: element.setAttribute("type","unavailable"); break;
- case Presence::Probe: element.setAttribute("type","probe"); break;
- case Presence::Subscribe: element.setAttribute("type","subscribe"); break;
- case Presence::Subscribed: element.setAttribute("type","subscribed"); break;
- case Presence::Unsubscribe: element.setAttribute("type","unsubscribe"); break;
- case Presence::Unsubscribed: element.setAttribute("type","unsubscribed"); break;
- case Presence::Error: element.setAttribute("type","error"); break;
- case Presence::Available: break;
- }
+ boost::shared_ptr<Presence> presence,
+ XMLElement& element) const {
+ switch (presence->getType()) {
+ case Presence::Unavailable: element.setAttribute("type","unavailable"); break;
+ case Presence::Probe: element.setAttribute("type","probe"); break;
+ case Presence::Subscribe: element.setAttribute("type","subscribe"); break;
+ case Presence::Subscribed: element.setAttribute("type","subscribed"); break;
+ case Presence::Unsubscribe: element.setAttribute("type","unsubscribe"); break;
+ case Presence::Unsubscribed: element.setAttribute("type","unsubscribed"); break;
+ case Presence::Error: element.setAttribute("type","error"); break;
+ case Presence::Available: break;
+ }
}
}
diff --git a/Swiften/Serializer/PresenceSerializer.h b/Swiften/Serializer/PresenceSerializer.h
index 1119f27..e40b9c2 100644
--- a/Swiften/Serializer/PresenceSerializer.h
+++ b/Swiften/Serializer/PresenceSerializer.h
@@ -13,14 +13,14 @@
#include <Swiften/Serializer/GenericStanzaSerializer.h>
namespace Swift {
- class SWIFTEN_API PresenceSerializer : public GenericStanzaSerializer<Presence> {
- public:
- PresenceSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>());
- ~PresenceSerializer() {}
+ class SWIFTEN_API PresenceSerializer : public GenericStanzaSerializer<Presence> {
+ public:
+ PresenceSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>());
+ ~PresenceSerializer() {}
- private:
- virtual void setStanzaSpecificAttributesGeneric(
- boost::shared_ptr<Presence> presence,
- XMLElement& element) const;
- };
+ private:
+ virtual void setStanzaSpecificAttributesGeneric(
+ boost::shared_ptr<Presence> presence,
+ XMLElement& element) const;
+ };
}
diff --git a/Swiften/Serializer/StanzaAckRequestSerializer.h b/Swiften/Serializer/StanzaAckRequestSerializer.h
index e8517b6..b178db1 100644
--- a/Swiften/Serializer/StanzaAckRequestSerializer.h
+++ b/Swiften/Serializer/StanzaAckRequestSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API StanzaAckRequestSerializer : public GenericElementSerializer<StanzaAckRequest> {
- public:
- StanzaAckRequestSerializer() : GenericElementSerializer<StanzaAckRequest>() {
- }
+ class SWIFTEN_API StanzaAckRequestSerializer : public GenericElementSerializer<StanzaAckRequest> {
+ public:
+ StanzaAckRequestSerializer() : GenericElementSerializer<StanzaAckRequest>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("r", "urn:xmpp:sm:2").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("r", "urn:xmpp:sm:2").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/StanzaAckSerializer.h b/Swiften/Serializer/StanzaAckSerializer.h
index 80e086b..7ca6ab8 100644
--- a/Swiften/Serializer/StanzaAckSerializer.h
+++ b/Swiften/Serializer/StanzaAckSerializer.h
@@ -15,17 +15,17 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API StanzaAckSerializer : public GenericElementSerializer<StanzaAck> {
- public:
- StanzaAckSerializer() : GenericElementSerializer<StanzaAck>() {
- }
+ class SWIFTEN_API StanzaAckSerializer : public GenericElementSerializer<StanzaAck> {
+ public:
+ StanzaAckSerializer() : GenericElementSerializer<StanzaAck>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const {
- StanzaAck::ref stanzaAck(boost::dynamic_pointer_cast<StanzaAck>(element));
- assert(stanzaAck->isValid());
- XMLElement result("a", "urn:xmpp:sm:2");
- result.setAttribute("h", std::string(boost::lexical_cast<std::string>(stanzaAck->getHandledStanzasCount())));
- return createSafeByteArray(result.serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const {
+ StanzaAck::ref stanzaAck(boost::dynamic_pointer_cast<StanzaAck>(element));
+ assert(stanzaAck->isValid());
+ XMLElement result("a", "urn:xmpp:sm:2");
+ result.setAttribute("h", std::string(boost::lexical_cast<std::string>(stanzaAck->getHandledStanzasCount())));
+ return createSafeByteArray(result.serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/StanzaSerializer.cpp b/Swiften/Serializer/StanzaSerializer.cpp
index d44dce4..002f2c3 100644
--- a/Swiften/Serializer/StanzaSerializer.cpp
+++ b/Swiften/Serializer/StanzaSerializer.cpp
@@ -23,44 +23,44 @@ StanzaSerializer::StanzaSerializer(const std::string& tag, PayloadSerializerColl
}
SafeByteArray StanzaSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- if (explicitDefaultNS_) {
- return serialize(element, explicitDefaultNS_.get());
- }
- else {
- return serialize(element, "");
- }
+ if (explicitDefaultNS_) {
+ return serialize(element, explicitDefaultNS_.get());
+ }
+ else {
+ return serialize(element, "");
+ }
}
SafeByteArray StanzaSerializer::serialize(boost::shared_ptr<ToplevelElement> element, const std::string& xmlns) const {
- boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element));
+ boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element));
- XMLElement stanzaElement(tag_, explicitDefaultNS_ ? explicitDefaultNS_.get() : xmlns);
- if (stanza->getFrom().isValid()) {
- stanzaElement.setAttribute("from", stanza->getFrom());
- }
- if (stanza->getTo().isValid()) {
- stanzaElement.setAttribute("to", stanza->getTo());
- }
- if (!stanza->getID().empty()) {
- stanzaElement.setAttribute("id", stanza->getID());
- }
- setStanzaSpecificAttributes(stanza, stanzaElement);
+ XMLElement stanzaElement(tag_, explicitDefaultNS_ ? explicitDefaultNS_.get() : xmlns);
+ if (stanza->getFrom().isValid()) {
+ stanzaElement.setAttribute("from", stanza->getFrom());
+ }
+ if (stanza->getTo().isValid()) {
+ stanzaElement.setAttribute("to", stanza->getTo());
+ }
+ if (!stanza->getID().empty()) {
+ stanzaElement.setAttribute("id", stanza->getID());
+ }
+ setStanzaSpecificAttributes(stanza, stanzaElement);
- std::string serializedPayloads;
- foreach (const boost::shared_ptr<Payload>& payload, stanza->getPayloads()) {
- PayloadSerializer* serializer = payloadSerializers_->getPayloadSerializer(payload);
- if (serializer) {
- serializedPayloads += serializer->serialize(payload);
- }
- else {
- std::cerr << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl;
- }
- }
- if (!serializedPayloads.empty()) {
- stanzaElement.addNode(boost::shared_ptr<XMLNode>(new XMLRawTextNode(serializedPayloads)));
- }
+ std::string serializedPayloads;
+ foreach (const boost::shared_ptr<Payload>& payload, stanza->getPayloads()) {
+ PayloadSerializer* serializer = payloadSerializers_->getPayloadSerializer(payload);
+ if (serializer) {
+ serializedPayloads += serializer->serialize(payload);
+ }
+ else {
+ std::cerr << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl;
+ }
+ }
+ if (!serializedPayloads.empty()) {
+ stanzaElement.addNode(boost::shared_ptr<XMLNode>(new XMLRawTextNode(serializedPayloads)));
+ }
- return createSafeByteArray(stanzaElement.serialize());
+ return createSafeByteArray(stanzaElement.serialize());
}
}
diff --git a/Swiften/Serializer/StanzaSerializer.h b/Swiften/Serializer/StanzaSerializer.h
index b8de056..34aab9e 100644
--- a/Swiften/Serializer/StanzaSerializer.h
+++ b/Swiften/Serializer/StanzaSerializer.h
@@ -15,20 +15,20 @@
#include <Swiften/Serializer/ElementSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class XMLElement;
-
- class SWIFTEN_API StanzaSerializer : public ElementSerializer {
- public:
- StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>());
-
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element, const std::string& xmlns) const;
- virtual void setStanzaSpecificAttributes(boost::shared_ptr<ToplevelElement>, XMLElement&) const = 0;
-
- private:
- std::string tag_;
- PayloadSerializerCollection* payloadSerializers_;
- boost::optional<std::string> explicitDefaultNS_;
- };
+ class PayloadSerializerCollection;
+ class XMLElement;
+
+ class SWIFTEN_API StanzaSerializer : public ElementSerializer {
+ public:
+ StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS = boost::optional<std::string>());
+
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element, const std::string& xmlns) const;
+ virtual void setStanzaSpecificAttributes(boost::shared_ptr<ToplevelElement>, XMLElement&) const = 0;
+
+ private:
+ std::string tag_;
+ PayloadSerializerCollection* payloadSerializers_;
+ boost::optional<std::string> explicitDefaultNS_;
+ };
}
diff --git a/Swiften/Serializer/StartTLSFailureSerializer.h b/Swiften/Serializer/StartTLSFailureSerializer.h
index b645953..f7f7296 100644
--- a/Swiften/Serializer/StartTLSFailureSerializer.h
+++ b/Swiften/Serializer/StartTLSFailureSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API StartTLSFailureSerializer : public GenericElementSerializer<StartTLSFailure> {
- public:
- StartTLSFailureSerializer() : GenericElementSerializer<StartTLSFailure>() {
- }
+ class SWIFTEN_API StartTLSFailureSerializer : public GenericElementSerializer<StartTLSFailure> {
+ public:
+ StartTLSFailureSerializer() : GenericElementSerializer<StartTLSFailure>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/StartTLSRequestSerializer.h b/Swiften/Serializer/StartTLSRequestSerializer.h
index 47dc1e7..cc8e3d5 100644
--- a/Swiften/Serializer/StartTLSRequestSerializer.h
+++ b/Swiften/Serializer/StartTLSRequestSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API StartTLSRequestSerializer : public GenericElementSerializer<StartTLSRequest> {
- public:
- StartTLSRequestSerializer() : GenericElementSerializer<StartTLSRequest>() {
- }
+ class SWIFTEN_API StartTLSRequestSerializer : public GenericElementSerializer<StartTLSRequest> {
+ public:
+ StartTLSRequestSerializer() : GenericElementSerializer<StartTLSRequest>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/StreamErrorSerializer.cpp b/Swiften/Serializer/StreamErrorSerializer.cpp
index 6ddaf4c..3cad478 100644
--- a/Swiften/Serializer/StreamErrorSerializer.cpp
+++ b/Swiften/Serializer/StreamErrorSerializer.cpp
@@ -16,44 +16,44 @@ StreamErrorSerializer::StreamErrorSerializer() : GenericElementSerializer<Stream
}
SafeByteArray StreamErrorSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- StreamError::ref error = boost::dynamic_pointer_cast<StreamError>(element);
- XMLElement errorElement("error", "http://etherx.jabber.org/streams");
-
- std::string typeTag;
- switch (error->getType()) {
- case StreamError::BadFormat: typeTag = "bad-format"; break;
- case StreamError::BadNamespacePrefix: typeTag = "bad-namespace-prefix"; break;
- case StreamError::Conflict: typeTag = "conflict"; break;
- case StreamError::ConnectionTimeout: typeTag = "connection-timeout"; break;
- case StreamError::HostGone: typeTag = "host-gone"; break;
- case StreamError::HostUnknown: typeTag = "host-unknown"; break;
- case StreamError::ImproperAddressing: typeTag = "improper-addressing"; break;
- case StreamError::InternalServerError: typeTag = "internal-server-error"; break;
- case StreamError::InvalidFrom: typeTag = "invalid-from"; break;
- case StreamError::InvalidID: typeTag = "invalid-id"; break;
- case StreamError::InvalidNamespace: typeTag = "invalid-namespace"; break;
- case StreamError::InvalidXML: typeTag = "invalid-xml"; break;
- case StreamError::NotAuthorized: typeTag = "not-authorized"; break;
- case StreamError::NotWellFormed: typeTag = "not-well-formed"; break;
- case StreamError::PolicyViolation: typeTag = "policy-violation"; break;
- case StreamError::RemoteConnectionFailed: typeTag = "remote-connection-failed"; break;
- case StreamError::Reset: typeTag = "reset"; break;
- case StreamError::ResourceConstraint: typeTag = "resource-constraint"; break;
- case StreamError::RestrictedXML: typeTag = "restricted-xml"; break;
- case StreamError::SeeOtherHost: typeTag = "see-other-host"; break;
- case StreamError::SystemShutdown: typeTag = "system-shutdown"; break;
- case StreamError::UndefinedCondition: typeTag = "undefined-condition"; break;
- case StreamError::UnsupportedEncoding: typeTag = "unsupported-encoding"; break;
- case StreamError::UnsupportedStanzaType: typeTag = "unsupported-stanza-type"; break;
- case StreamError::UnsupportedVersion: typeTag = "unsupported-version"; break;
- }
- errorElement.addNode(boost::make_shared<XMLElement>(typeTag, "urn:ietf:params:xml:ns:xmpp-streams"));
-
- if (!error->getText().empty()) {
- errorElement.addNode(boost::make_shared<XMLElement>("text", "urn:ietf:params:xml:ns:xmpp-streams", error->getText()));
- }
-
- return createSafeByteArray(errorElement.serialize());
+ StreamError::ref error = boost::dynamic_pointer_cast<StreamError>(element);
+ XMLElement errorElement("error", "http://etherx.jabber.org/streams");
+
+ std::string typeTag;
+ switch (error->getType()) {
+ case StreamError::BadFormat: typeTag = "bad-format"; break;
+ case StreamError::BadNamespacePrefix: typeTag = "bad-namespace-prefix"; break;
+ case StreamError::Conflict: typeTag = "conflict"; break;
+ case StreamError::ConnectionTimeout: typeTag = "connection-timeout"; break;
+ case StreamError::HostGone: typeTag = "host-gone"; break;
+ case StreamError::HostUnknown: typeTag = "host-unknown"; break;
+ case StreamError::ImproperAddressing: typeTag = "improper-addressing"; break;
+ case StreamError::InternalServerError: typeTag = "internal-server-error"; break;
+ case StreamError::InvalidFrom: typeTag = "invalid-from"; break;
+ case StreamError::InvalidID: typeTag = "invalid-id"; break;
+ case StreamError::InvalidNamespace: typeTag = "invalid-namespace"; break;
+ case StreamError::InvalidXML: typeTag = "invalid-xml"; break;
+ case StreamError::NotAuthorized: typeTag = "not-authorized"; break;
+ case StreamError::NotWellFormed: typeTag = "not-well-formed"; break;
+ case StreamError::PolicyViolation: typeTag = "policy-violation"; break;
+ case StreamError::RemoteConnectionFailed: typeTag = "remote-connection-failed"; break;
+ case StreamError::Reset: typeTag = "reset"; break;
+ case StreamError::ResourceConstraint: typeTag = "resource-constraint"; break;
+ case StreamError::RestrictedXML: typeTag = "restricted-xml"; break;
+ case StreamError::SeeOtherHost: typeTag = "see-other-host"; break;
+ case StreamError::SystemShutdown: typeTag = "system-shutdown"; break;
+ case StreamError::UndefinedCondition: typeTag = "undefined-condition"; break;
+ case StreamError::UnsupportedEncoding: typeTag = "unsupported-encoding"; break;
+ case StreamError::UnsupportedStanzaType: typeTag = "unsupported-stanza-type"; break;
+ case StreamError::UnsupportedVersion: typeTag = "unsupported-version"; break;
+ }
+ errorElement.addNode(boost::make_shared<XMLElement>(typeTag, "urn:ietf:params:xml:ns:xmpp-streams"));
+
+ if (!error->getText().empty()) {
+ errorElement.addNode(boost::make_shared<XMLElement>("text", "urn:ietf:params:xml:ns:xmpp-streams", error->getText()));
+ }
+
+ return createSafeByteArray(errorElement.serialize());
}
}
diff --git a/Swiften/Serializer/StreamErrorSerializer.h b/Swiften/Serializer/StreamErrorSerializer.h
index 35af764..f578005 100644
--- a/Swiften/Serializer/StreamErrorSerializer.h
+++ b/Swiften/Serializer/StreamErrorSerializer.h
@@ -11,10 +11,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API StreamErrorSerializer : public GenericElementSerializer<StreamError> {
- public:
- StreamErrorSerializer();
+ class SWIFTEN_API StreamErrorSerializer : public GenericElementSerializer<StreamError> {
+ public:
+ StreamErrorSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> error) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> error) const;
+ };
}
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.cpp b/Swiften/Serializer/StreamFeaturesSerializer.cpp
index 5908ec8..ed042ec 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.cpp
+++ b/Swiften/Serializer/StreamFeaturesSerializer.cpp
@@ -18,43 +18,43 @@ StreamFeaturesSerializer::StreamFeaturesSerializer() {
}
SafeByteArray StreamFeaturesSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const {
- boost::shared_ptr<StreamFeatures> streamFeatures(boost::dynamic_pointer_cast<StreamFeatures>(element));
-
- XMLElement streamFeaturesElement("stream:features");
- if (streamFeatures->hasStartTLS()) {
- streamFeaturesElement.addNode(boost::make_shared<XMLElement>("starttls", "urn:ietf:params:xml:ns:xmpp-tls"));
- }
- if (!streamFeatures->getCompressionMethods().empty()) {
- boost::shared_ptr<XMLElement> compressionElement(new XMLElement("compression", "http://jabber.org/features/compress"));
- foreach(const std::string& method, streamFeatures->getCompressionMethods()) {
- boost::shared_ptr<XMLElement> methodElement(new XMLElement("method"));
- methodElement->addNode(boost::make_shared<XMLTextNode>(method));
- compressionElement->addNode(methodElement);
- }
- streamFeaturesElement.addNode(compressionElement);
- }
- if (!streamFeatures->getAuthenticationMechanisms().empty()) {
- boost::shared_ptr<XMLElement> mechanismsElement(new XMLElement("mechanisms", "urn:ietf:params:xml:ns:xmpp-sasl"));
- foreach(const std::string& mechanism, streamFeatures->getAuthenticationMechanisms()) {
- boost::shared_ptr<XMLElement> mechanismElement(new XMLElement("mechanism"));
- mechanismElement->addNode(boost::make_shared<XMLTextNode>(mechanism));
- mechanismsElement->addNode(mechanismElement);
- }
- streamFeaturesElement.addNode(mechanismsElement);
- }
- if (streamFeatures->hasResourceBind()) {
- streamFeaturesElement.addNode(boost::make_shared<XMLElement>("bind", "urn:ietf:params:xml:ns:xmpp-bind"));
- }
- if (streamFeatures->hasSession()) {
- streamFeaturesElement.addNode(boost::make_shared<XMLElement>("session", "urn:ietf:params:xml:ns:xmpp-session"));
- }
- if (streamFeatures->hasStreamManagement()) {
- streamFeaturesElement.addNode(boost::make_shared<XMLElement>("sm", "urn:xmpp:sm:2"));
- }
- if (streamFeatures->hasRosterVersioning()) {
- streamFeaturesElement.addNode(boost::make_shared<XMLElement>("ver", "urn:xmpp:features:rosterver"));
- }
- return createSafeByteArray(streamFeaturesElement.serialize());
+ boost::shared_ptr<StreamFeatures> streamFeatures(boost::dynamic_pointer_cast<StreamFeatures>(element));
+
+ XMLElement streamFeaturesElement("stream:features");
+ if (streamFeatures->hasStartTLS()) {
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("starttls", "urn:ietf:params:xml:ns:xmpp-tls"));
+ }
+ if (!streamFeatures->getCompressionMethods().empty()) {
+ boost::shared_ptr<XMLElement> compressionElement(new XMLElement("compression", "http://jabber.org/features/compress"));
+ foreach(const std::string& method, streamFeatures->getCompressionMethods()) {
+ boost::shared_ptr<XMLElement> methodElement(new XMLElement("method"));
+ methodElement->addNode(boost::make_shared<XMLTextNode>(method));
+ compressionElement->addNode(methodElement);
+ }
+ streamFeaturesElement.addNode(compressionElement);
+ }
+ if (!streamFeatures->getAuthenticationMechanisms().empty()) {
+ boost::shared_ptr<XMLElement> mechanismsElement(new XMLElement("mechanisms", "urn:ietf:params:xml:ns:xmpp-sasl"));
+ foreach(const std::string& mechanism, streamFeatures->getAuthenticationMechanisms()) {
+ boost::shared_ptr<XMLElement> mechanismElement(new XMLElement("mechanism"));
+ mechanismElement->addNode(boost::make_shared<XMLTextNode>(mechanism));
+ mechanismsElement->addNode(mechanismElement);
+ }
+ streamFeaturesElement.addNode(mechanismsElement);
+ }
+ if (streamFeatures->hasResourceBind()) {
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("bind", "urn:ietf:params:xml:ns:xmpp-bind"));
+ }
+ if (streamFeatures->hasSession()) {
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("session", "urn:ietf:params:xml:ns:xmpp-session"));
+ }
+ if (streamFeatures->hasStreamManagement()) {
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("sm", "urn:xmpp:sm:2"));
+ }
+ if (streamFeatures->hasRosterVersioning()) {
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("ver", "urn:xmpp:features:rosterver"));
+ }
+ return createSafeByteArray(streamFeaturesElement.serialize());
}
}
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.h b/Swiften/Serializer/StreamFeaturesSerializer.h
index f98a86f..f2328a5 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.h
+++ b/Swiften/Serializer/StreamFeaturesSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API StreamFeaturesSerializer : public GenericElementSerializer<StreamFeatures> {
- public:
- StreamFeaturesSerializer();
+ class SWIFTEN_API StreamFeaturesSerializer : public GenericElementSerializer<StreamFeatures> {
+ public:
+ StreamFeaturesSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement> element) const;
+ };
}
diff --git a/Swiften/Serializer/StreamManagementEnabledSerializer.cpp b/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
index 3ee0772..b03196c 100644
--- a/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
+++ b/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
@@ -17,13 +17,13 @@ StreamManagementEnabledSerializer::StreamManagementEnabledSerializer() : Generic
}
SafeByteArray StreamManagementEnabledSerializer::serialize(boost::shared_ptr<ToplevelElement> el) const {
- boost::shared_ptr<StreamManagementEnabled> e(boost::dynamic_pointer_cast<StreamManagementEnabled>(el));
- XMLElement element("enabled", "urn:xmpp:sm:2");
- if (!e->getResumeID().empty()) {
- element.setAttribute("id", e->getResumeID());
- }
- if (e->getResumeSupported()) {
- element.setAttribute("resume", "true");
- }
- return createSafeByteArray(element.serialize());
+ boost::shared_ptr<StreamManagementEnabled> e(boost::dynamic_pointer_cast<StreamManagementEnabled>(el));
+ XMLElement element("enabled", "urn:xmpp:sm:2");
+ if (!e->getResumeID().empty()) {
+ element.setAttribute("id", e->getResumeID());
+ }
+ if (e->getResumeSupported()) {
+ element.setAttribute("resume", "true");
+ }
+ return createSafeByteArray(element.serialize());
}
diff --git a/Swiften/Serializer/StreamManagementEnabledSerializer.h b/Swiften/Serializer/StreamManagementEnabledSerializer.h
index fc44739..9ffe233 100644
--- a/Swiften/Serializer/StreamManagementEnabledSerializer.h
+++ b/Swiften/Serializer/StreamManagementEnabledSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API StreamManagementEnabledSerializer : public GenericElementSerializer<StreamManagementEnabled> {
- public:
- StreamManagementEnabledSerializer();
+ class SWIFTEN_API StreamManagementEnabledSerializer : public GenericElementSerializer<StreamManagementEnabled> {
+ public:
+ StreamManagementEnabledSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const;
+ };
}
diff --git a/Swiften/Serializer/StreamManagementFailedSerializer.h b/Swiften/Serializer/StreamManagementFailedSerializer.h
index 4489f97..b189bd8 100644
--- a/Swiften/Serializer/StreamManagementFailedSerializer.h
+++ b/Swiften/Serializer/StreamManagementFailedSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API StreamManagementFailedSerializer : public GenericElementSerializer<StreamManagementFailed> {
- public:
- StreamManagementFailedSerializer() : GenericElementSerializer<StreamManagementFailed>() {
- }
+ class SWIFTEN_API StreamManagementFailedSerializer : public GenericElementSerializer<StreamManagementFailed> {
+ public:
+ StreamManagementFailedSerializer() : GenericElementSerializer<StreamManagementFailed>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("failed", "urn:xmpp:sm:2").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("failed", "urn:xmpp:sm:2").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/StreamResumeSerializer.cpp b/Swiften/Serializer/StreamResumeSerializer.cpp
index 261956d..c660083 100644
--- a/Swiften/Serializer/StreamResumeSerializer.cpp
+++ b/Swiften/Serializer/StreamResumeSerializer.cpp
@@ -18,11 +18,11 @@ StreamResumeSerializer::StreamResumeSerializer() : GenericElementSerializer<Stre
}
SafeByteArray StreamResumeSerializer::serialize(boost::shared_ptr<ToplevelElement> el) const {
- boost::shared_ptr<StreamResume> e(boost::dynamic_pointer_cast<StreamResume>(el));
- XMLElement element("resume", "urn:xmpp:sm:2");
- element.setAttribute("previd", e->getResumeID());
- if (e->getHandledStanzasCount()) {
- element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get()));
- }
- return createSafeByteArray(element.serialize());
+ boost::shared_ptr<StreamResume> e(boost::dynamic_pointer_cast<StreamResume>(el));
+ XMLElement element("resume", "urn:xmpp:sm:2");
+ element.setAttribute("previd", e->getResumeID());
+ if (e->getHandledStanzasCount()) {
+ element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get()));
+ }
+ return createSafeByteArray(element.serialize());
}
diff --git a/Swiften/Serializer/StreamResumeSerializer.h b/Swiften/Serializer/StreamResumeSerializer.h
index f166ac3..5e7c58d 100644
--- a/Swiften/Serializer/StreamResumeSerializer.h
+++ b/Swiften/Serializer/StreamResumeSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API StreamResumeSerializer : public GenericElementSerializer<StreamResume> {
- public:
- StreamResumeSerializer();
+ class SWIFTEN_API StreamResumeSerializer : public GenericElementSerializer<StreamResume> {
+ public:
+ StreamResumeSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const;
+ };
}
diff --git a/Swiften/Serializer/StreamResumedSerializer.cpp b/Swiften/Serializer/StreamResumedSerializer.cpp
index 295096a..9778338 100644
--- a/Swiften/Serializer/StreamResumedSerializer.cpp
+++ b/Swiften/Serializer/StreamResumedSerializer.cpp
@@ -18,11 +18,11 @@ StreamResumedSerializer::StreamResumedSerializer() : GenericElementSerializer<St
}
SafeByteArray StreamResumedSerializer::serialize(boost::shared_ptr<ToplevelElement> el) const {
- boost::shared_ptr<StreamResumed> e(boost::dynamic_pointer_cast<StreamResumed>(el));
- XMLElement element("resumed", "urn:xmpp:sm:2");
- element.setAttribute("previd", e->getResumeID());
- if (e->getHandledStanzasCount()) {
- element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get()));
- }
- return createSafeByteArray(element.serialize());
+ boost::shared_ptr<StreamResumed> e(boost::dynamic_pointer_cast<StreamResumed>(el));
+ XMLElement element("resumed", "urn:xmpp:sm:2");
+ element.setAttribute("previd", e->getResumeID());
+ if (e->getHandledStanzasCount()) {
+ element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get()));
+ }
+ return createSafeByteArray(element.serialize());
}
diff --git a/Swiften/Serializer/StreamResumedSerializer.h b/Swiften/Serializer/StreamResumedSerializer.h
index a0c316e..82a66d7 100644
--- a/Swiften/Serializer/StreamResumedSerializer.h
+++ b/Swiften/Serializer/StreamResumedSerializer.h
@@ -13,10 +13,10 @@
#include <Swiften/Serializer/GenericElementSerializer.h>
namespace Swift {
- class SWIFTEN_API StreamResumedSerializer : public GenericElementSerializer<StreamResumed> {
- public:
- StreamResumedSerializer();
+ class SWIFTEN_API StreamResumedSerializer : public GenericElementSerializer<StreamResumed> {
+ public:
+ StreamResumedSerializer();
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const;
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const;
+ };
}
diff --git a/Swiften/Serializer/TLSProceedSerializer.h b/Swiften/Serializer/TLSProceedSerializer.h
index 7203042..e9af0a2 100644
--- a/Swiften/Serializer/TLSProceedSerializer.h
+++ b/Swiften/Serializer/TLSProceedSerializer.h
@@ -14,13 +14,13 @@
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
- class SWIFTEN_API TLSProceedSerializer : public GenericElementSerializer<TLSProceed> {
- public:
- TLSProceedSerializer() : GenericElementSerializer<TLSProceed>() {
- }
+ class SWIFTEN_API TLSProceedSerializer : public GenericElementSerializer<TLSProceed> {
+ public:
+ TLSProceedSerializer() : GenericElementSerializer<TLSProceed>() {
+ }
- virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
- return createSafeByteArray(XMLElement("proceed", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
- }
- };
+ virtual SafeByteArray serialize(boost::shared_ptr<ToplevelElement>) const {
+ return createSafeByteArray(XMLElement("proceed", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
+ }
+ };
}
diff --git a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
index 71da7e8..1d41e81 100644
--- a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
@@ -15,43 +15,43 @@
using namespace Swift;
class AuthChallengeSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(AuthChallengeSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_NoMessage);
- CPPUNIT_TEST(testSerialize_EmptyMessage);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- AuthChallengeSerializer testling;
- boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
- authChallenge->setValue(createByteArray("foo"));
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "Zm9v"
- "</challenge>"), testling.serialize(authChallenge));
- }
-
- void testSerialize_NoMessage() {
- AuthChallengeSerializer testling;
- boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "</challenge>"), testling.serialize(authChallenge));
- }
-
- void testSerialize_EmptyMessage() {
- AuthChallengeSerializer testling;
- boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
- authChallenge->setValue(std::vector<unsigned char>());
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "="
- "</challenge>"), testling.serialize(authChallenge));
- }
+ CPPUNIT_TEST_SUITE(AuthChallengeSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthChallengeSerializer testling;
+ boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
+ authChallenge->setValue(createByteArray("foo"));
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "Zm9v"
+ "</challenge>"), testling.serialize(authChallenge));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthChallengeSerializer testling;
+ boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "</challenge>"), testling.serialize(authChallenge));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthChallengeSerializer testling;
+ boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
+ authChallenge->setValue(std::vector<unsigned char>());
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "="
+ "</challenge>"), testling.serialize(authChallenge));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(AuthChallengeSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
index b27b736..95460b2 100644
--- a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
@@ -15,43 +15,43 @@
using namespace Swift;
class AuthRequestSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(AuthRequestSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_NoMessage);
- CPPUNIT_TEST(testSerialize_EmptyMessage);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- AuthRequestSerializer testling;
- boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
- authRequest->setMessage(createSafeByteArray("foo"));
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
- "Zm9v"
- "</auth>"), testling.serialize(authRequest));
- }
-
- void testSerialize_NoMessage() {
- AuthRequestSerializer testling;
- boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
- "</auth>"), testling.serialize(authRequest));
- }
-
- void testSerialize_EmptyMessage() {
- AuthRequestSerializer testling;
- boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
- authRequest->setMessage(SafeByteArray());
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
- "="
- "</auth>"), testling.serialize(authRequest));
- }
+ CPPUNIT_TEST_SUITE(AuthRequestSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthRequestSerializer testling;
+ boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
+ authRequest->setMessage(createSafeByteArray("foo"));
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
+ "Zm9v"
+ "</auth>"), testling.serialize(authRequest));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthRequestSerializer testling;
+ boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
+ "</auth>"), testling.serialize(authRequest));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthRequestSerializer testling;
+ boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
+ authRequest->setMessage(SafeByteArray());
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
+ "="
+ "</auth>"), testling.serialize(authRequest));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(AuthRequestSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
index fdff30b..67c6f16 100644
--- a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
@@ -15,43 +15,43 @@
using namespace Swift;
class AuthResponseSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(AuthResponseSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_NoMessage);
- CPPUNIT_TEST(testSerialize_EmptyMessage);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- AuthResponseSerializer testling;
- boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
- authResponse->setValue(createSafeByteArray("foo"));
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "Zm9v"
- "</response>"), testling.serialize(authResponse));
- }
-
- void testSerialize_NoMessage() {
- AuthResponseSerializer testling;
- boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "</response>"), testling.serialize(authResponse));
- }
-
- void testSerialize_EmptyMessage() {
- AuthResponseSerializer testling;
- boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
- authResponse->setValue(SafeByteArray());
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- ""
- "</response>"), testling.serialize(authResponse));
- }
+ CPPUNIT_TEST_SUITE(AuthResponseSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthResponseSerializer testling;
+ boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
+ authResponse->setValue(createSafeByteArray("foo"));
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "Zm9v"
+ "</response>"), testling.serialize(authResponse));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthResponseSerializer testling;
+ boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "</response>"), testling.serialize(authResponse));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthResponseSerializer testling;
+ boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
+ authResponse->setValue(SafeByteArray());
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ ""
+ "</response>"), testling.serialize(authResponse));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(AuthResponseSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
index 2d9b610..228bd9b 100644
--- a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
@@ -15,43 +15,43 @@
using namespace Swift;
class AuthSuccessSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(AuthSuccessSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_NoMessage);
- CPPUNIT_TEST(testSerialize_EmptyMessage);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testSerialize() {
- AuthSuccessSerializer testling;
- boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
- authSuccess->setValue(createByteArray("foo"));
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "Zm9v"
- "</success>"), testling.serialize(authSuccess));
- }
-
- void testSerialize_NoMessage() {
- AuthSuccessSerializer testling;
- boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "</success>"), testling.serialize(authSuccess));
- }
-
- void testSerialize_EmptyMessage() {
- AuthSuccessSerializer testling;
- boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
- authSuccess->setValue(std::vector<unsigned char>());
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "="
- "</success>"), testling.serialize(authSuccess));
- }
+ CPPUNIT_TEST_SUITE(AuthSuccessSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthSuccessSerializer testling;
+ boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
+ authSuccess->setValue(createByteArray("foo"));
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "Zm9v"
+ "</success>"), testling.serialize(authSuccess));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthSuccessSerializer testling;
+ boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "</success>"), testling.serialize(authSuccess));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthSuccessSerializer testling;
+ boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
+ authSuccess->setValue(std::vector<unsigned char>());
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "="
+ "</success>"), testling.serialize(authSuccess));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(AuthSuccessSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
index adfadbc..5f4f821 100644
--- a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
@@ -15,43 +15,43 @@ using namespace Swift;
class StreamFeaturesSerializerTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(StreamFeaturesSerializerTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- StreamFeaturesSerializerTest() {}
-
- void testSerialize() {
- StreamFeaturesSerializer testling;
- boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
- streamFeatures->setHasStartTLS();
- streamFeatures->addCompressionMethod("zlib");
- streamFeatures->addCompressionMethod("lzw");
- streamFeatures->addAuthenticationMechanism("DIGEST-MD5");
- streamFeatures->addAuthenticationMechanism("PLAIN");
- streamFeatures->setHasResourceBind();
- streamFeatures->setHasSession();
- streamFeatures->setHasStreamManagement();
- streamFeatures->setHasRosterVersioning();
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
- "<stream:features>"
- "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
- "<compression xmlns=\"http://jabber.org/features/compress\">"
- "<method>zlib</method>"
- "<method>lzw</method>"
- "</compression>"
- "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "<mechanism>DIGEST-MD5</mechanism>"
- "<mechanism>PLAIN</mechanism>"
- "</mechanisms>"
- "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
- "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
- "<sm xmlns=\"urn:xmpp:sm:2\"/>"
- "<ver xmlns=\"urn:xmpp:features:rosterver\"/>"
- "</stream:features>"), testling.serialize(streamFeatures));
- }
+ CPPUNIT_TEST_SUITE(StreamFeaturesSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ StreamFeaturesSerializerTest() {}
+
+ void testSerialize() {
+ StreamFeaturesSerializer testling;
+ boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
+ streamFeatures->setHasStartTLS();
+ streamFeatures->addCompressionMethod("zlib");
+ streamFeatures->addCompressionMethod("lzw");
+ streamFeatures->addAuthenticationMechanism("DIGEST-MD5");
+ streamFeatures->addAuthenticationMechanism("PLAIN");
+ streamFeatures->setHasResourceBind();
+ streamFeatures->setHasSession();
+ streamFeatures->setHasStreamManagement();
+ streamFeatures->setHasRosterVersioning();
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
+ "<stream:features>"
+ "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
+ "<compression xmlns=\"http://jabber.org/features/compress\">"
+ "<method>zlib</method>"
+ "<method>lzw</method>"
+ "</compression>"
+ "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "<mechanism>DIGEST-MD5</mechanism>"
+ "<mechanism>PLAIN</mechanism>"
+ "</mechanisms>"
+ "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
+ "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
+ "<sm xmlns=\"urn:xmpp:sm:2\"/>"
+ "<ver xmlns=\"urn:xmpp:features:rosterver\"/>"
+ "</stream:features>"), testling.serialize(streamFeatures));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StreamFeaturesSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp b/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp
index 83bb737..3eaeef0 100644
--- a/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp
@@ -15,61 +15,61 @@
using namespace Swift;
class XMPPSerializerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(XMPPSerializerTest);
- CPPUNIT_TEST(testSerializeHeader_Client);
- CPPUNIT_TEST(testSerializeHeader_Component);
- CPPUNIT_TEST(testSerializeHeader_Server);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(XMPPSerializerTest);
+ CPPUNIT_TEST(testSerializeHeader_Client);
+ CPPUNIT_TEST(testSerializeHeader_Component);
+ CPPUNIT_TEST(testSerializeHeader_Server);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void setUp() {
- payloadSerializerCollection = new PayloadSerializerCollection();
- }
+ public:
+ void setUp() {
+ payloadSerializerCollection = new PayloadSerializerCollection();
+ }
- void tearDown() {
- delete payloadSerializerCollection;
- }
+ void tearDown() {
+ delete payloadSerializerCollection;
+ }
- void testSerializeHeader_Client() {
- boost::shared_ptr<XMPPSerializer> testling(createSerializer(ClientStreamType));
- ProtocolHeader protocolHeader;
- protocolHeader.setFrom("bla@foo.com");
- protocolHeader.setTo("foo.com");
- protocolHeader.setID("myid");
- protocolHeader.setVersion("0.99");
+ void testSerializeHeader_Client() {
+ boost::shared_ptr<XMPPSerializer> testling(createSerializer(ClientStreamType));
+ ProtocolHeader protocolHeader;
+ protocolHeader.setFrom("bla@foo.com");
+ protocolHeader.setTo("foo.com");
+ protocolHeader.setID("myid");
+ protocolHeader.setVersion("0.99");
- CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader));
+ }
- void testSerializeHeader_Component() {
- boost::shared_ptr<XMPPSerializer> testling(createSerializer(ComponentStreamType));
- ProtocolHeader protocolHeader;
- protocolHeader.setFrom("bla@foo.com");
- protocolHeader.setTo("foo.com");
- protocolHeader.setID("myid");
- protocolHeader.setVersion("0.99");
+ void testSerializeHeader_Component() {
+ boost::shared_ptr<XMPPSerializer> testling(createSerializer(ComponentStreamType));
+ ProtocolHeader protocolHeader;
+ protocolHeader.setFrom("bla@foo.com");
+ protocolHeader.setTo("foo.com");
+ protocolHeader.setID("myid");
+ protocolHeader.setVersion("0.99");
- CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:component:accept\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:component:accept\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader));
+ }
- void testSerializeHeader_Server() {
- boost::shared_ptr<XMPPSerializer> testling(createSerializer(ServerStreamType));
- ProtocolHeader protocolHeader;
- protocolHeader.setFrom("bla@foo.com");
- protocolHeader.setTo("foo.com");
- protocolHeader.setID("myid");
- protocolHeader.setVersion("0.99");
+ void testSerializeHeader_Server() {
+ boost::shared_ptr<XMPPSerializer> testling(createSerializer(ServerStreamType));
+ ProtocolHeader protocolHeader;
+ protocolHeader.setFrom("bla@foo.com");
+ protocolHeader.setTo("foo.com");
+ protocolHeader.setID("myid");
+ protocolHeader.setVersion("0.99");
- CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:server\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:server\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader));
+ }
- private:
- XMPPSerializer* createSerializer(StreamType type) {
- return new XMPPSerializer(payloadSerializerCollection, type, false);
- }
+ private:
+ XMPPSerializer* createSerializer(StreamType type) {
+ return new XMPPSerializer(payloadSerializerCollection, type, false);
+ }
- private:
- PayloadSerializerCollection* payloadSerializerCollection;
+ private:
+ PayloadSerializerCollection* payloadSerializerCollection;
};
CPPUNIT_TEST_SUITE_REGISTRATION(XMPPSerializerTest);
diff --git a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp b/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
index f9a5e2a..edd1b0e 100644
--- a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
+++ b/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
@@ -16,55 +16,55 @@ using namespace Swift;
class XMLElementTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(XMLElementTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_NoChildren);
- CPPUNIT_TEST(testSerialize_SpecialAttributeCharacters);
- CPPUNIT_TEST(testSerialize_EmptyAttributeValue);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- XMLElementTest() {}
-
- void testSerialize() {
- XMLElement testling("foo", "http://example.com");
- testling.setAttribute("myatt", "myval");
- boost::shared_ptr<XMLElement> barElement(new XMLElement("bar"));
- barElement->addNode(boost::make_shared<XMLTextNode>("Blo"));
- testling.addNode(barElement);
- boost::shared_ptr<XMLElement> bazElement(new XMLElement("baz"));
- bazElement->addNode(boost::make_shared<XMLTextNode>("Bli&</stream>"));
- testling.addNode(bazElement);
-
- std::string result = testling.serialize();
- std::string expectedResult =
- "<foo myatt=\"myval\" xmlns=\"http://example.com\">"
- "<bar>Blo</bar>"
- "<baz>Bli&amp;&lt;/stream&gt;</baz>"
- "</foo>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, result);
- }
-
- void testSerialize_NoChildren() {
- XMLElement testling("foo", "http://example.com");
-
- CPPUNIT_ASSERT_EQUAL(std::string("<foo xmlns=\"http://example.com\"/>"), testling.serialize());
- }
-
- void testSerialize_SpecialAttributeCharacters() {
- XMLElement testling("foo");
- testling.setAttribute("myatt", "<\"'&>");
-
- CPPUNIT_ASSERT_EQUAL(std::string("<foo myatt=\"&lt;&quot;&apos;&amp;&gt;\"/>"), testling.serialize());
- }
-
- void testSerialize_EmptyAttributeValue() {
- XMLElement testling("foo");
- testling.setAttribute("myatt", "");
-
- CPPUNIT_ASSERT_EQUAL(std::string("<foo myatt=\"\"/>"), testling.serialize());
- }
+ CPPUNIT_TEST_SUITE(XMLElementTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoChildren);
+ CPPUNIT_TEST(testSerialize_SpecialAttributeCharacters);
+ CPPUNIT_TEST(testSerialize_EmptyAttributeValue);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ XMLElementTest() {}
+
+ void testSerialize() {
+ XMLElement testling("foo", "http://example.com");
+ testling.setAttribute("myatt", "myval");
+ boost::shared_ptr<XMLElement> barElement(new XMLElement("bar"));
+ barElement->addNode(boost::make_shared<XMLTextNode>("Blo"));
+ testling.addNode(barElement);
+ boost::shared_ptr<XMLElement> bazElement(new XMLElement("baz"));
+ bazElement->addNode(boost::make_shared<XMLTextNode>("Bli&</stream>"));
+ testling.addNode(bazElement);
+
+ std::string result = testling.serialize();
+ std::string expectedResult =
+ "<foo myatt=\"myval\" xmlns=\"http://example.com\">"
+ "<bar>Blo</bar>"
+ "<baz>Bli&amp;&lt;/stream&gt;</baz>"
+ "</foo>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, result);
+ }
+
+ void testSerialize_NoChildren() {
+ XMLElement testling("foo", "http://example.com");
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<foo xmlns=\"http://example.com\"/>"), testling.serialize());
+ }
+
+ void testSerialize_SpecialAttributeCharacters() {
+ XMLElement testling("foo");
+ testling.setAttribute("myatt", "<\"'&>");
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<foo myatt=\"&lt;&quot;&apos;&amp;&gt;\"/>"), testling.serialize());
+ }
+
+ void testSerialize_EmptyAttributeValue() {
+ XMLElement testling("foo");
+ testling.setAttribute("myatt", "");
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<foo myatt=\"\"/>"), testling.serialize());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(XMLElementTest);
diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp
index 01e89bc..fc5e470 100644
--- a/Swiften/Serializer/XML/XMLElement.cpp
+++ b/Swiften/Serializer/XML/XMLElement.cpp
@@ -12,49 +12,49 @@
namespace Swift {
XMLElement::XMLElement(const std::string& tag, const std::string& xmlns, const std::string& text) : tag_(tag) {
- if (!xmlns.empty()) {
- setAttribute("xmlns", xmlns);
- }
- if (!text.empty()) {
- addNode(XMLTextNode::ref(new XMLTextNode(text)));
- }
+ if (!xmlns.empty()) {
+ setAttribute("xmlns", xmlns);
+ }
+ if (!text.empty()) {
+ addNode(XMLTextNode::ref(new XMLTextNode(text)));
+ }
}
std::string XMLElement::serialize() {
- std::string result;
- result += "<" + tag_;
- typedef std::pair<std::string,std::string> Pair;
- foreach(const Pair& p, attributes_) {
- result += " " + p.first + "=\"" + p.second + "\"";
- }
-
- if (!childNodes_.empty()) {
- result += ">";
- foreach (boost::shared_ptr<XMLNode> node, childNodes_) {
- result += node->serialize();
- }
- result += "</" + tag_ + ">";
- }
- else {
- result += "/>";
- }
- return result;
+ std::string result;
+ result += "<" + tag_;
+ typedef std::pair<std::string,std::string> Pair;
+ foreach(const Pair& p, attributes_) {
+ result += " " + p.first + "=\"" + p.second + "\"";
+ }
+
+ if (!childNodes_.empty()) {
+ result += ">";
+ foreach (boost::shared_ptr<XMLNode> node, childNodes_) {
+ result += node->serialize();
+ }
+ result += "</" + tag_ + ">";
+ }
+ else {
+ result += "/>";
+ }
+ return result;
}
void XMLElement::setAttribute(const std::string& attribute, const std::string& value) {
- std::string escapedValue(value);
- String::replaceAll(escapedValue, '&', "&amp;");
- String::replaceAll(escapedValue, '<', "&lt;");
- String::replaceAll(escapedValue, '>', "&gt;");
- String::replaceAll(escapedValue, '\'', "&apos;");
- String::replaceAll(escapedValue, '"', "&quot;");
- attributes_[attribute] = escapedValue;
+ std::string escapedValue(value);
+ String::replaceAll(escapedValue, '&', "&amp;");
+ String::replaceAll(escapedValue, '<', "&lt;");
+ String::replaceAll(escapedValue, '>', "&gt;");
+ String::replaceAll(escapedValue, '\'', "&apos;");
+ String::replaceAll(escapedValue, '"', "&quot;");
+ attributes_[attribute] = escapedValue;
}
void XMLElement::addNode(boost::shared_ptr<XMLNode> node) {
- if (node) {
- childNodes_.push_back(node);
- }
+ if (node) {
+ childNodes_.push_back(node);
+ }
}
}
diff --git a/Swiften/Serializer/XML/XMLElement.h b/Swiften/Serializer/XML/XMLElement.h
index 66e0a77..e7507f2 100644
--- a/Swiften/Serializer/XML/XMLElement.h
+++ b/Swiften/Serializer/XML/XMLElement.h
@@ -16,20 +16,20 @@
#include <Swiften/Serializer/XML/XMLNode.h>
namespace Swift {
- class SWIFTEN_API XMLElement : public XMLNode {
- public:
- typedef boost::shared_ptr<XMLElement> ref;
+ class SWIFTEN_API XMLElement : public XMLNode {
+ public:
+ typedef boost::shared_ptr<XMLElement> ref;
- XMLElement(const std::string& tag, const std::string& xmlns = "", const std::string& text = "");
+ XMLElement(const std::string& tag, const std::string& xmlns = "", const std::string& text = "");
- void setAttribute(const std::string& attribute, const std::string& value);
- void addNode(boost::shared_ptr<XMLNode> node);
+ void setAttribute(const std::string& attribute, const std::string& value);
+ void addNode(boost::shared_ptr<XMLNode> node);
- virtual std::string serialize();
+ virtual std::string serialize();
- private:
- std::string tag_;
- std::map<std::string, std::string> attributes_;
- std::vector< boost::shared_ptr<XMLNode> > childNodes_;
- };
+ private:
+ std::string tag_;
+ std::map<std::string, std::string> attributes_;
+ std::vector< boost::shared_ptr<XMLNode> > childNodes_;
+ };
}
diff --git a/Swiften/Serializer/XML/XMLNode.h b/Swiften/Serializer/XML/XMLNode.h
index e3ac925..8417b5c 100644
--- a/Swiften/Serializer/XML/XMLNode.h
+++ b/Swiften/Serializer/XML/XMLNode.h
@@ -11,10 +11,10 @@
#include <Swiften/Base/API.h>
namespace Swift {
- class SWIFTEN_API XMLNode {
- public:
- virtual ~XMLNode();
+ class SWIFTEN_API XMLNode {
+ public:
+ virtual ~XMLNode();
- virtual std::string serialize() = 0;
- };
+ virtual std::string serialize() = 0;
+ };
}
diff --git a/Swiften/Serializer/XML/XMLRawTextNode.h b/Swiften/Serializer/XML/XMLRawTextNode.h
index f1e75e6..fbd7754 100644
--- a/Swiften/Serializer/XML/XMLRawTextNode.h
+++ b/Swiften/Serializer/XML/XMLRawTextNode.h
@@ -10,16 +10,16 @@
#include <Swiften/Serializer/XML/XMLNode.h>
namespace Swift {
- class SWIFTEN_API XMLRawTextNode : public XMLNode {
- public:
- XMLRawTextNode(const std::string& text) : text_(text) {
- }
+ class SWIFTEN_API XMLRawTextNode : public XMLNode {
+ public:
+ XMLRawTextNode(const std::string& text) : text_(text) {
+ }
- std::string serialize() {
- return text_;
- }
+ std::string serialize() {
+ return text_;
+ }
- private:
- std::string text_;
- };
+ private:
+ std::string text_;
+ };
}
diff --git a/Swiften/Serializer/XML/XMLTextNode.h b/Swiften/Serializer/XML/XMLTextNode.h
index 86efdf1..b0f8d01 100644
--- a/Swiften/Serializer/XML/XMLTextNode.h
+++ b/Swiften/Serializer/XML/XMLTextNode.h
@@ -13,25 +13,25 @@
#include <Swiften/Serializer/XML/XMLNode.h>
namespace Swift {
- class SWIFTEN_API XMLTextNode : public XMLNode {
- public:
- typedef boost::shared_ptr<XMLTextNode> ref;
-
- XMLTextNode(const std::string& text) : text_(text) {
- String::replaceAll(text_, '&', "&amp;"); // Should come first
- String::replaceAll(text_, '<', "&lt;");
- String::replaceAll(text_, '>', "&gt;");
- }
-
- std::string serialize() {
- return text_;
- }
-
- static ref create(const std::string& text) {
- return ref(new XMLTextNode(text));
- }
-
- private:
- std::string text_;
- };
+ class SWIFTEN_API XMLTextNode : public XMLNode {
+ public:
+ typedef boost::shared_ptr<XMLTextNode> ref;
+
+ XMLTextNode(const std::string& text) : text_(text) {
+ String::replaceAll(text_, '&', "&amp;"); // Should come first
+ String::replaceAll(text_, '<', "&lt;");
+ String::replaceAll(text_, '>', "&gt;");
+ }
+
+ std::string serialize() {
+ return text_;
+ }
+
+ static ref create(const std::string& text) {
+ return ref(new XMLTextNode(text));
+ }
+
+ private:
+ std::string text_;
+ };
}
diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp
index 7130e51..b17e31b 100644
--- a/Swiften/Serializer/XMPPSerializer.cpp
+++ b/Swiften/Serializer/XMPPSerializer.cpp
@@ -41,72 +41,72 @@
namespace Swift {
XMPPSerializer::XMPPSerializer(PayloadSerializerCollection* payloadSerializers, StreamType type, bool setExplictNSonTopLevelElements) : type_(type) {
- serializers_.push_back(boost::make_shared<PresenceSerializer>(payloadSerializers, setExplictNSonTopLevelElements ? getDefaultNamespace() : boost::optional<std::string>()));
- serializers_.push_back(boost::make_shared<IQSerializer>(payloadSerializers, setExplictNSonTopLevelElements ? getDefaultNamespace() : boost::optional<std::string>()));
- serializers_.push_back(boost::make_shared<MessageSerializer>(payloadSerializers, setExplictNSonTopLevelElements ? getDefaultNamespace() : boost::optional<std::string>()));
- serializers_.push_back(boost::make_shared<CompressRequestSerializer>());
- serializers_.push_back(boost::make_shared<CompressFailureSerializer>());
- serializers_.push_back(boost::make_shared<AuthRequestSerializer>());
- serializers_.push_back(boost::make_shared<AuthFailureSerializer>());
- serializers_.push_back(boost::make_shared<AuthSuccessSerializer>());
- serializers_.push_back(boost::make_shared<AuthChallengeSerializer>());
- serializers_.push_back(boost::make_shared<AuthResponseSerializer>());
- serializers_.push_back(boost::make_shared<StartTLSRequestSerializer>());
- serializers_.push_back(boost::make_shared<StartTLSFailureSerializer>());
- serializers_.push_back(boost::make_shared<TLSProceedSerializer>());
- serializers_.push_back(boost::make_shared<StreamFeaturesSerializer>());
- serializers_.push_back(boost::make_shared<StreamErrorSerializer>());
- serializers_.push_back(boost::make_shared<EnableStreamManagementSerializer>());
- serializers_.push_back(boost::make_shared<StreamManagementEnabledSerializer>());
- serializers_.push_back(boost::make_shared<StreamManagementFailedSerializer>());
- serializers_.push_back(boost::make_shared<StreamResumeSerializer>());
- serializers_.push_back(boost::make_shared<StreamResumedSerializer>());
- serializers_.push_back(boost::make_shared<StanzaAckSerializer>());
- serializers_.push_back(boost::make_shared<StanzaAckRequestSerializer>());
- serializers_.push_back(boost::make_shared<ComponentHandshakeSerializer>());
+ serializers_.push_back(boost::make_shared<PresenceSerializer>(payloadSerializers, setExplictNSonTopLevelElements ? getDefaultNamespace() : boost::optional<std::string>()));
+ serializers_.push_back(boost::make_shared<IQSerializer>(payloadSerializers, setExplictNSonTopLevelElements ? getDefaultNamespace() : boost::optional<std::string>()));
+ serializers_.push_back(boost::make_shared<MessageSerializer>(payloadSerializers, setExplictNSonTopLevelElements ? getDefaultNamespace() : boost::optional<std::string>()));
+ serializers_.push_back(boost::make_shared<CompressRequestSerializer>());
+ serializers_.push_back(boost::make_shared<CompressFailureSerializer>());
+ serializers_.push_back(boost::make_shared<AuthRequestSerializer>());
+ serializers_.push_back(boost::make_shared<AuthFailureSerializer>());
+ serializers_.push_back(boost::make_shared<AuthSuccessSerializer>());
+ serializers_.push_back(boost::make_shared<AuthChallengeSerializer>());
+ serializers_.push_back(boost::make_shared<AuthResponseSerializer>());
+ serializers_.push_back(boost::make_shared<StartTLSRequestSerializer>());
+ serializers_.push_back(boost::make_shared<StartTLSFailureSerializer>());
+ serializers_.push_back(boost::make_shared<TLSProceedSerializer>());
+ serializers_.push_back(boost::make_shared<StreamFeaturesSerializer>());
+ serializers_.push_back(boost::make_shared<StreamErrorSerializer>());
+ serializers_.push_back(boost::make_shared<EnableStreamManagementSerializer>());
+ serializers_.push_back(boost::make_shared<StreamManagementEnabledSerializer>());
+ serializers_.push_back(boost::make_shared<StreamManagementFailedSerializer>());
+ serializers_.push_back(boost::make_shared<StreamResumeSerializer>());
+ serializers_.push_back(boost::make_shared<StreamResumedSerializer>());
+ serializers_.push_back(boost::make_shared<StanzaAckSerializer>());
+ serializers_.push_back(boost::make_shared<StanzaAckRequestSerializer>());
+ serializers_.push_back(boost::make_shared<ComponentHandshakeSerializer>());
}
std::string XMPPSerializer::serializeHeader(const ProtocolHeader& header) const {
- std::string result = "<?xml version=\"1.0\"?><stream:stream xmlns=\"" + getDefaultNamespace() + "\" xmlns:stream=\"http://etherx.jabber.org/streams\"";
- if (!header.getFrom().empty()) {
- result += " from=\"" + header.getFrom() + "\"";
- }
- if (!header.getTo().empty()) {
- result += " to=\"" + header.getTo() + "\"";
- }
- if (!header.getID().empty()) {
- result += " id=\"" + header.getID() + "\"";
- }
- if (!header.getVersion().empty()) {
- result += " version=\"" + header.getVersion() + "\"";
- }
- result += ">";
- return result;
+ std::string result = "<?xml version=\"1.0\"?><stream:stream xmlns=\"" + getDefaultNamespace() + "\" xmlns:stream=\"http://etherx.jabber.org/streams\"";
+ if (!header.getFrom().empty()) {
+ result += " from=\"" + header.getFrom() + "\"";
+ }
+ if (!header.getTo().empty()) {
+ result += " to=\"" + header.getTo() + "\"";
+ }
+ if (!header.getID().empty()) {
+ result += " id=\"" + header.getID() + "\"";
+ }
+ if (!header.getVersion().empty()) {
+ result += " version=\"" + header.getVersion() + "\"";
+ }
+ result += ">";
+ return result;
}
SafeByteArray XMPPSerializer::serializeElement(boost::shared_ptr<ToplevelElement> element) const {
- std::vector< boost::shared_ptr<ElementSerializer> >::const_iterator i = std::find_if(serializers_.begin(), serializers_.end(), boost::bind(&ElementSerializer::canSerialize, _1, element));
- if (i != serializers_.end()) {
- return (*i)->serialize(element);
- }
- else {
- std::cerr << "Could not find serializer for " << typeid(*(element.get())).name() << std::endl;
- return createSafeByteArray("");
- }
+ std::vector< boost::shared_ptr<ElementSerializer> >::const_iterator i = std::find_if(serializers_.begin(), serializers_.end(), boost::bind(&ElementSerializer::canSerialize, _1, element));
+ if (i != serializers_.end()) {
+ return (*i)->serialize(element);
+ }
+ else {
+ std::cerr << "Could not find serializer for " << typeid(*(element.get())).name() << std::endl;
+ return createSafeByteArray("");
+ }
}
std::string XMPPSerializer::serializeFooter() const {
- return "</stream:stream>";
+ return "</stream:stream>";
}
std::string XMPPSerializer::getDefaultNamespace() const {
- switch (type_) {
- case ClientStreamType: return "jabber:client";
- case ServerStreamType: return "jabber:server";
- case ComponentStreamType: return "jabber:component:accept";
- }
- assert(false);
- return "";
+ switch (type_) {
+ case ClientStreamType: return "jabber:client";
+ case ServerStreamType: return "jabber:server";
+ case ComponentStreamType: return "jabber:component:accept";
+ }
+ assert(false);
+ return "";
}
}
diff --git a/Swiften/Serializer/XMPPSerializer.h b/Swiften/Serializer/XMPPSerializer.h
index 493a88d..a771fdd 100644
--- a/Swiften/Serializer/XMPPSerializer.h
+++ b/Swiften/Serializer/XMPPSerializer.h
@@ -17,23 +17,23 @@
#include <Swiften/Serializer/ElementSerializer.h>
namespace Swift {
- class PayloadSerializerCollection;
- class CompressRequestSerializer;
- class ProtocolHeader;
-
- class SWIFTEN_API XMPPSerializer {
- public:
- XMPPSerializer(PayloadSerializerCollection*, StreamType type, bool setExplictNSonTopLevelElements);
-
- std::string serializeHeader(const ProtocolHeader&) const;
- SafeByteArray serializeElement(boost::shared_ptr<ToplevelElement> stanza) const;
- std::string serializeFooter() const;
-
- private:
- std::string getDefaultNamespace() const;
-
- private:
- StreamType type_;
- std::vector< boost::shared_ptr<ElementSerializer> > serializers_;
- };
+ class PayloadSerializerCollection;
+ class CompressRequestSerializer;
+ class ProtocolHeader;
+
+ class SWIFTEN_API XMPPSerializer {
+ public:
+ XMPPSerializer(PayloadSerializerCollection*, StreamType type, bool setExplictNSonTopLevelElements);
+
+ std::string serializeHeader(const ProtocolHeader&) const;
+ SafeByteArray serializeElement(boost::shared_ptr<ToplevelElement> stanza) const;
+ std::string serializeFooter() const;
+
+ private:
+ std::string getDefaultNamespace() const;
+
+ private:
+ StreamType type_;
+ std::vector< boost::shared_ptr<ElementSerializer> > serializers_;
+ };
}