ObjXMPP  Diff

Differences From Artifact [b2b145f65c]:

To Artifact [127836dc56]:


1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







/*
 * Copyright (c) 2011, 2012, 2013, Jonathan Schleifer <js@heap.zone>
 * Copyright (c) 2011, 2012, 2013, 2019, Jonathan Schleifer <js@heap.zone>
 * Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de>
 *
 * https://heap.zone/objxmpp/
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
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
154
155
156
157
158


159
160
161
162


163
164
165

166
167
168

169
170
171
172
173
174
175
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
154
155
156


157
158
159
160


161
162
163
164

165
166
167

168
169
170
171
172
173
174
175







-
+




-
+


-
+
















-
-
+
+


-
-
+
+


-
+


-
+







		       stringValue: nil];

	@try {
		if (![name isEqual: @"iq"] && ![name isEqual: @"message"] &&
		    ![name isEqual: @"presence"])
			@throw [OFInvalidArgumentException exception];

		[self setDefaultNamespace: XMPP_NS_CLIENT];
		self.defaultNamespace = XMPP_NS_CLIENT;
		[self setPrefix: @"stream"
		   forNamespace: XMPP_NS_STREAM];

		if (type != nil)
			[self setType: type];
			self.type = type;

		if (ID != nil)
			[self setID: ID];
			self.ID = ID;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

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

	@try {
		OFXMLAttribute *attribute;

		if ((attribute = [element attributeForName: @"from"]))
			[self setFrom:
			    [XMPPJID JIDWithString: [attribute stringValue]]];
			self.from =
			    [XMPPJID JIDWithString: attribute.stringValue];

		if ((attribute = [element attributeForName: @"to"]))
			[self setTo:
			    [XMPPJID JIDWithString: [attribute stringValue]]];
			self.to =
			    [XMPPJID JIDWithString: attribute.stringValue];

		if ((attribute = [element attributeForName: @"type"]))
			[self setType: [attribute stringValue]];
			self.type = attribute.stringValue;

		if ((attribute = [element attributeForName: @"id"]))
			[self setID: [attribute stringValue]];
			self.ID = attribute.stringValue;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
190
191
192
193
194
195
196
197

198
199
200
201
202
203
204
205
206
207
208
209
210

211
212
213
214
215
216
217
190
191
192
193
194
195
196

197
198
199
200
201
202
203
204
205
206
207
208
209

210
211
212
213
214
215
216
217







-
+












-
+







	_from = [from copy];
	[old release];

	[self removeAttributeForName: @"from"];

	if (from != nil)
		[self addAttributeWithName: @"from"
			       stringValue: [from fullJID]];
			       stringValue: from.fullJID];
}

- (void)setTo: (XMPPJID *)to
{
	XMPPJID *old = _to;
	_to = [to copy];
	[old release];

	[self removeAttributeForName: @"to"];

	if (to != nil)
		[self addAttributeWithName: @"to"
			       stringValue: [to fullJID]];
			       stringValue: to.fullJID];
}

- (void)setType: (OFString *)type
{
	OFString *old = _type;
	_type = [type copy];
	[old release];