From d6c5f1d91e15bda83be5d0f56d25e9aa6363b48e Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Fri, 3 Feb 2012 09:05:51 +0100 Subject: [PATCH] Change -[XMPPMessage addBody:] to -[XMPPMessage setBody:]. --- src/XMPPMessage.h | 6 +++--- src/XMPPMessage.m | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/XMPPMessage.h b/src/XMPPMessage.h index 76537f2..34fd88e 100644 --- a/src/XMPPMessage.h +++ b/src/XMPPMessage.h @@ -94,9 +94,9 @@ ID: (OFString*)ID; /** - * Adds a body element to the XMPPMessage + * Sets the body element of the XMPPMessage. * - * \param body The text content of the body element + * \param body The text content of the body element or nil to remove the body */ -- (void)addBody: (OFString*)body; +- (void)setBody: (OFString*)body; @end diff --git a/src/XMPPMessage.m b/src/XMPPMessage.m index 900d549..485481f 100644 --- a/src/XMPPMessage.m +++ b/src/XMPPMessage.m @@ -77,10 +77,17 @@ ID: ID_]; } -- (void)addBody: (OFString*)body +- (void)setBody: (OFString*)body { - [self addChild: [OFXMLElement elementWithName: @"body" - namespace: XMPP_NS_CLIENT - stringValue: body]]; + OFXMLElement *oldBody = [self elementForName: @"body" + namespace: XMPP_NS_CLIENT]; + + if (oldBody != nil) + [self removeChild: oldBody]; + + if (body != nil) + [self addChild: [OFXMLElement elementWithName: @"body" + namespace: XMPP_NS_CLIENT + stringValue: body]]; } @end