ObjXMPP  Diff

Differences From Artifact [c9e6f90b6f]:

To Artifact [36a51c1323]:


77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92
93

94
95

96
97

98
99

100
101
102
103
104
105
106
107
77
78
79
80
81
82
83

84

85
86
87
88
89
90
91

92


93


94


95

96
97
98
99
100
101
102







-
+
-







-
+
-
-
+
-
-
+
-
-
+
-







	msg.to = [XMPPJID JIDWithString: @"jdev@conference.jabber.org"];
	msg.from = [XMPPJID JIDWithString: @"alice@example.com"];
	assert([msg.XMLString isEqual: @"<message type='chat' "
	    @"to='jdev@conference.jabber.org' "
	    @"from='alice@example.com'><body>Hello everyone</body>"
	    @"</message>"]);

	XMPPIQ *IQ = [XMPPIQ IQWithType: @"set"
	XMPPIQ *IQ = [XMPPIQ IQWithType: @"set" ID: @"128"];
				     ID: @"128"];
	IQ.to = [XMPPJID JIDWithString: @"juliet@capulet.lit"];
	IQ.from = [XMPPJID JIDWithString: @"romeo@montague.lit"];
	assert([IQ.XMLString isEqual: @"<iq type='set' id='128' "
	    @"to='juliet@capulet.lit' "
	    @"from='romeo@montague.lit'/>"]);

	OFXMLElement *elem = [OFXMLElement elementWithName: @"iq"];
	[elem addAttributeWithName: @"from"
	[elem addAttributeWithName: @"from" stringValue: @"bob@localhost"];
		       stringValue: @"bob@localhost"];
	[elem addAttributeWithName: @"to"
	[elem addAttributeWithName: @"to" stringValue: @"alice@localhost"];
		       stringValue: @"alice@localhost"];
	[elem addAttributeWithName: @"type"
	[elem addAttributeWithName: @"type" stringValue: @"get"];
		       stringValue: @"get"];
	[elem addAttributeWithName: @"id"
	[elem addAttributeWithName: @"id" stringValue: @"42"];
		       stringValue: @"42"];
	XMPPStanza *stanza = [XMPPStanza stanzaWithElement: elem];
	assert([elem.XMLString isEqual: [stanza XMLString]]);
	assert(([[OFString stringWithFormat: @"%@, %@, %@, %@",
	    stanza.from.fullJID, stanza.to.fullJID, stanza.type, stanza.ID]
	    isEqual: @"bob@localhost, alice@localhost, get, 42"]));


143
144
145
146
147
148
149
150

151
152
153
154
155
156
157
158
138
139
140
141
142
143
144

145

146
147
148
149
150
151
152







-
+
-







}

- (void)connectionWasAuthenticated: (XMPPConnection *)conn
{
	OFLog(@"Auth successful");
}

- (void)connection: (XMPPConnection *)conn_
- (void)connection: (XMPPConnection *)conn_ wasBoundToJID: (XMPPJID *)JID
     wasBoundToJID: (XMPPJID *)JID
{
	OFLog(@"Bound to JID: %@", JID.fullJID);
	OFLog(@"Supports SM: %@",
	    conn_.supportsStreamManagement ? @"true" : @"false");

	XMPPDiscoEntity *discoEntity =
	    [[XMPPDiscoEntity alloc] initWithConnection: conn];
208
209
210
211
212
213
214
215

216
217
218
219
220

221
222
223
224
225
226
227
202
203
204
205
206
207
208

209

210
211


212
213
214
215
216
217
218
219







-
+
-


-
-
+







	pres = [XMPPPresence presence];
	pres.priority = [OFNumber numberWithChar: 10];
	pres.status = @"ObjXMPP test is working!";

	[conn sendStanza: pres];

#ifdef OF_HAVE_BLOCKS
	XMPPIQ *IQ = [XMPPIQ IQWithType: @"get"
	XMPPIQ *IQ = [XMPPIQ IQWithType: @"get" ID: [conn generateStanzaID]];
				     ID: [conn generateStanzaID]];
	[IQ addChild: [OFXMLElement elementWithName: @"ping"
					  namespace: @"urn:xmpp:ping"]];
	[conn	   sendIQ: IQ
	    callbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) {
	[conn sendIQ: IQ callbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) {
		OFLog(@"Ping response: %@", resp);
	}];
#endif
}

- (void)connectionDidUpgradeToTLS: (XMPPConnection *)conn_
{
239
240
241
242
243
244
245
246

247
248
249
250
251
252
253
254

255
256
257
258
259
260
261
262
263
264
265
266

267
268
269
270
271
272

273
274
275
276
277
231
232
233
234
235
236
237

238

239
240
241
242
243
244

245

246
247
248
249
250
251
252
253
254
255

256

257
258
259
260

261

262
263
264
265







-
+
-






-
+
-










-
+
-




-
+
-





-         (void)roster: (XMPPRoster *)roster_
  didReceiveRosterItem: (XMPPRosterItem *)rosterItem
{
	OFLog(@"Got roster push: %@", rosterItem);
}

- (bool)connection: (XMPPConnection *)conn
- (bool)connection: (XMPPConnection *)conn didReceiveIQ: (XMPPIQ *)iq
      didReceiveIQ: (XMPPIQ *)iq
{
	OFLog(@"IQ: %@", iq);

	return NO;
}

-  (void)connection: (XMPPConnection *)conn
- (void)connection: (XMPPConnection *)conn didReceiveMessage: (XMPPMessage *)msg
  didReceiveMessage: (XMPPMessage *)msg
{
	OFLog(@"Message: %@", msg);
}

-   (void)connection: (XMPPConnection *)conn
  didReceivePresence: (XMPPPresence *)pres
{
	OFLog(@"Presence: %@", pres);
}

-  (void)connection: (XMPPConnection *)conn
- (void)connection: (XMPPConnection *)conn didThrowException: (id)e
  didThrowException: (id)e
{
	@throw e;
}

- (void)connectionWasClosed: (XMPPConnection *)conn
- (void)connectionWasClosed: (XMPPConnection *)conn error: (OFXMLElement *)error
		      error: (OFXMLElement *)error
{
	OFLog(@"Connection was closed: %@", error);
}
@end