Index: src/XMPPStanza.h ================================================================== --- src/XMPPStanza.h +++ src/XMPPStanza.h @@ -88,14 +88,14 @@ ID: (OFString*)ID; /** * Creates a new autoreleased XMPPStanza from an OFXMLElement. * - * \param elem The element to base the XMPPStanza on + * \param element The element to base the XMPPStanza on * \return A new autoreleased XMPPStanza */ -+ stanzaWithElement: (OFXMLElement*)elem; ++ stanzaWithElement: (OFXMLElement*)element; /** * Initializes an already allocated XMPPStanza with the specified name. * * \param name The stanza's name (one of iq, message or presence) @@ -137,14 +137,14 @@ ID: (OFString*)ID; /** * Initializes an already allocated XMPPStanza based on a OFXMLElement * - * \param elem The element to base the XMPPStanza on + * \param element The element to base the XMPPStanza on * \return A initialized XMPPStanza */ -- initWithElement: (OFXMLElement*)elem; +- initWithElement: (OFXMLElement*)element; - (void)setFrom: (XMPPJID*)from; - (XMPPJID*)from; - (void)setTo: (XMPPJID*)to; - (XMPPJID*)to; Index: src/XMPPStanza.m ================================================================== --- src/XMPPStanza.m +++ src/XMPPStanza.m @@ -52,13 +52,13 @@ return [[[self alloc] initWithName: name type: type_ ID: ID_] autorelease]; } -+ stanzaWithElement: (OFXMLElement*)elem ++ stanzaWithElement: (OFXMLElement*)element { - return [[[self alloc] initWithElement: elem] autorelease]; + return [[[self alloc] initWithElement: element] autorelease]; } - initWithName: (OFString*)name_ { return [self initWithName: name_ @@ -109,43 +109,30 @@ } return self; } -- initWithElement: (OFXMLElement*)elem +- initWithElement: (OFXMLElement*)element { - self = [super initWithName: [elem name] - namespace: [elem namespace]]; + self = [super initWithElement: element]; @try { - OFEnumerator *enumerator; - OFXMLAttribute *attr; - OFXMLElement *el; - - enumerator = [[elem attributes] objectEnumerator]; - while ((attr = [enumerator nextObject]) != nil) { - if ([[attr name] isEqual: @"from"]) - [self setFrom: [XMPPJID JIDWithString: - [attr stringValue]]]; - else if ([[attr name] isEqual: @"to"]) - [self setTo: [XMPPJID JIDWithString: - [attr stringValue]]]; - else if ([[attr name] isEqual: @"type"]) - [self setType: [attr stringValue]]; - else if ([[attr name] isEqual: @"id"]) - [self setID: [attr stringValue]]; - else - [self addAttribute: attr]; - } - - enumerator = [[elem children] objectEnumerator]; - while ((el = [enumerator nextObject]) != nil) - [self addChild: el]; - - [self setDefaultNamespace: XMPP_NS_CLIENT]; - [self setPrefix: @"stream" - forNamespace: XMPP_NS_STREAM]; + OFXMLAttribute *attribute; + + if ((attribute = [element attributeForName: @"from"])) + [self setFrom: + [XMPPJID JIDWithString: [attribute stringValue]]]; + + if ((attribute = [element attributeForName: @"to"])) + [self setTo: + [XMPPJID JIDWithString: [attribute stringValue]]]; + + if ((attribute = [element attributeForName: @"type"])) + [self setType: [attribute stringValue]]; + + if ((attribute = [element attributeForName: @"id"])) + [self setID: [attribute stringValue]]; } @catch (id e) { [self release]; @throw e; }