Index: src/XMPPMessage.h ================================================================== --- src/XMPPMessage.h +++ src/XMPPMessage.h @@ -92,11 +92,11 @@ */ - initWithType: (OFString*)type 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 Index: src/XMPPMessage.m ================================================================== --- src/XMPPMessage.m +++ src/XMPPMessage.m @@ -75,12 +75,19 @@ return [super initWithName: @"message" type: type_ 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