ObjXMPP  Check-in [29d84637d6]

Overview
Comment:Improve +[XMPPStanza stanzaWithElement:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 29d84637d6994c3f5d3a5ebf277f0d07c815d22f2e8762d99de6256f1be781c5
User & Date: js on 2011-04-25 23:04:34
Other Links: manifest | tags
Context
2011-05-12
17:49
Fix namespace handling. check-in: 39a1c76b23 user: js tags: trunk
2011-04-25
23:04
Improve +[XMPPStanza stanzaWithElement:]. check-in: 29d84637d6 user: js tags: trunk
17:48
Move all roster handling code to XMPPRoster. check-in: 55e37a4da2 user: js tags: trunk
Changes

Modified src/XMPPStanza.h from [1377ddf174] to [eb4f4f5610].

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+ stanzaWithName: (OFString*)name
	    type: (OFString*)type
	      ID: (OFString*)ID;

/**
 * Creates a new autoreleased XMPPStanza from an OFXMLElement.
 *
 * \param elem The element to base the XMPPStanza on
 * \return A new autoreleased XMPPStanza
 */
+ stanzaWithElement: (OFXMLElement*)elem;

/**
 * Initializes an already allocated XMPPStanza with the specified name.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \return A initialized XMPPStanza
 */







|


|







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+ stanzaWithName: (OFString*)name
	    type: (OFString*)type
	      ID: (OFString*)ID;

/**
 * Creates a new autoreleased XMPPStanza from an OFXMLElement.
 *
 * \param element The element to base the XMPPStanza on
 * \return A new autoreleased XMPPStanza
 */
+ stanzaWithElement: (OFXMLElement*)element;

/**
 * Initializes an already allocated XMPPStanza with the specified name.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \return A initialized XMPPStanza
 */
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
- initWithName: (OFString*)name
	  type: (OFString*)type
	    ID: (OFString*)ID;

/**
 * Initializes an already allocated XMPPStanza based on a OFXMLElement
 *
 * \param elem The element to base the XMPPStanza on
 * \return A initialized XMPPStanza
 */
- initWithElement: (OFXMLElement*)elem;

- (void)setFrom: (XMPPJID*)from;
- (XMPPJID*)from;
- (void)setTo: (XMPPJID*)to;
- (XMPPJID*)to;
- (void)setType: (OFString*)type;
- (OFString*)type;
- (void)setID: (OFString*)ID;
- (OFString*)ID;
@end







|


|










135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
- initWithName: (OFString*)name
	  type: (OFString*)type
	    ID: (OFString*)ID;

/**
 * Initializes an already allocated XMPPStanza based on a OFXMLElement
 *
 * \param element The element to base the XMPPStanza on
 * \return A initialized XMPPStanza
 */
- initWithElement: (OFXMLElement*)element;

- (void)setFrom: (XMPPJID*)from;
- (XMPPJID*)from;
- (void)setTo: (XMPPJID*)to;
- (XMPPJID*)to;
- (void)setType: (OFString*)type;
- (OFString*)type;
- (void)setID: (OFString*)ID;
- (OFString*)ID;
@end

Modified src/XMPPStanza.m from [20dba48ed9] to [6749e640ea].

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
	      ID: (OFString*)ID_
{
	return [[[self alloc] initWithName: name
				      type: type_
					ID: ID_] autorelease];
}

+ stanzaWithElement: (OFXMLElement*)elem
{
	return [[[self alloc] initWithElement: elem] autorelease];
}

- initWithName: (OFString*)name_
{
	return [self initWithName: name_
			     type: nil
			       ID: nil];







|

|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
	      ID: (OFString*)ID_
{
	return [[[self alloc] initWithName: name
				      type: type_
					ID: ID_] autorelease];
}

+ stanzaWithElement: (OFXMLElement*)element
{
	return [[[self alloc] initWithElement: element] autorelease];
}

- initWithName: (OFString*)name_
{
	return [self initWithName: name_
			     type: nil
			       ID: nil];
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

145
146
147
148
149
150
151
152
153
		[self release];
		@throw e;
	}

	return self;
}

- initWithElement: (OFXMLElement*)elem
{
	self = [super initWithName: [elem name]
			 namespace: [elem namespace]];

	@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];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







|

|
<


<
|
<

<
<
|
|
<
<
|
|
|
|
<
|
<
<
|
|
<
<
|

<
>
|
<







107
108
109
110
111
112
113
114
115
116

117
118

119

120


121
122


123
124
125
126

127


128
129


130
131

132
133

134
135
136
137
138
139
140
		[self release];
		@throw e;
	}

	return self;
}

- initWithElement: (OFXMLElement*)element
{
	self = [super initWithElement: element];


	@try {

		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;
	}

	return self;
}