summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/libiris/jingle_iris.patch
blob: 41acad0e604afaf35e5f760dc4274d7b36224451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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
218
219
220
221
222
223
224
225
226
227
228
229
230
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
diff -ur psi/iris/include/im.h psi-jingle/iris/include/im.h
--- psi/iris/include/im.h	2005-12-27 15:12:42.000000000 +0100
+++ psi-jingle/iris/include/im.h	2005-12-27 11:05:53.000000000 +0100
@@ -22,6 +22,7 @@
 #define XMPP_IM_H
 
 #include<qdatetime.h>
+#include<qvaluelist.h>
 #include"xmpp.h"
 
 namespace XMPP
@@ -153,6 +154,9 @@
 
 		const QString & xsigned() const;
 		const QString & songTitle() const;
+		const QString & capsNode() const;
+		const QString & capsVersion() const;
+		const QString & capsExt() const;
 
 		void setPriority(int);
 		void setShow(const QString &);
@@ -162,6 +166,9 @@
 		void setIsAvailable(bool);
 		void setIsInvisible(bool);
 		void setError(int, const QString &);
+		void setCapsNode(const QString&);
+		void setCapsVersion(const QString&);
+		void setCapsExt(const QString&);
 
 		void setXSigned(const QString &);
 		void setSongTitle(const QString &);
@@ -176,6 +183,7 @@
 		QString v_xsigned;
 		// gabber song extension
 		QString v_songTitle;
+		QString v_capsNode, v_capsVersion, v_capsExt;
 
 		int ecode;
 		QString estr;
@@ -285,6 +293,7 @@
 		bool canRegister() const;
 		bool canSearch() const;
 		bool canGroupchat() const;
+		bool canVoice() const;
 		bool canDisco() const;
 		bool isGateway() const;
 		bool haveVCard() const;
@@ -567,12 +576,25 @@
 		int timeZoneOffset() const;
 		QString clientName() const;
 		QString clientVersion() const;
+		QString capsNode() const;
+		QString capsVersion() const;
+		QString capsExt() const;
 
 		void setOSName(const QString &);
 		void setTimeZone(const QString &, int);
 		void setClientName(const QString &);
 		void setClientVersion(const QString &);
+		void setCapsNode(const QString &);
+		void setCapsVersion(const QString &);
 
+		void setIdentity(DiscoItem::Identity);
+		DiscoItem::Identity identity();
+
+		void addExtension(const QString& ext, const Features& f);
+		void removeExtension(const QString& ext);
+		const Features& extension(const QString& ext) const;
+		QStringList extensions() const;
+		
 		S5BManager *s5bManager() const;
 		IBBManager *ibbManager() const;
 		JidLinkManager *jidLinkManager() const;
diff -ur psi/iris/xmpp-im/client.cpp psi-jingle/iris/xmpp-im/client.cpp
--- psi/iris/xmpp-im/client.cpp	2005-12-27 15:12:44.000000000 +0100
+++ psi-jingle/iris/xmpp-im/client.cpp	2005-12-27 11:05:53.000000000 +0100
@@ -70,6 +70,7 @@
 //!  \endcode
 
 #include<stdarg.h>
+#include<qmap.h>
 #include<qobjectlist.h>
 #include<qtimer.h>
 #include<qguardedptr.h>
@@ -125,7 +126,9 @@
 	int id_seed;
 	Task *root;
 	QString host, user, pass, resource;
-	QString osname, tzname, clientName, clientVersion;
+	QString osname, tzname, clientName, clientVersion, capsNode, capsVersion, capsExt;
+	DiscoItem::Identity identity;
+	QMap<QString,Features> extension_features;
 	int tzoffset;
 	bool active;
 
@@ -149,6 +152,9 @@
 	d->osname = "N/A";
 	d->clientName = "N/A";
 	d->clientVersion = "0.0";
+	d->capsNode = "";
+	d->capsVersion = "";
+	d->capsExt = "";
 
 	d->id_seed = 0xaaaa;
 	d->root = new Task(this, true);
@@ -996,6 +1002,21 @@
 	return d->clientVersion;
 }
 
+QString Client::capsNode() const
+{
+	return d->capsNode;
+}
+
+QString Client::capsVersion() const
+{
+	return d->capsVersion;
+}
+
+QString Client::capsExt() const
+{
+	return d->capsExt;
+}
+
 void Client::setOSName(const QString &name)
 {
 	d->osname = name;
@@ -1017,6 +1038,52 @@
 	d->clientVersion = s;
 }
 
+void Client::setCapsNode(const QString &s)
+{
+	d->capsNode = s;
+}
+
+void Client::setCapsVersion(const QString &s)
+{
+	d->capsVersion = s;
+}
+
+DiscoItem::Identity Client::identity()
+{
+	return d->identity;
+}
+
+void Client::setIdentity(DiscoItem::Identity identity)
+{
+	d->identity = identity;
+}
+
+void Client::addExtension(const QString& ext, const Features& features)
+{
+	if (!ext.isEmpty()) {
+		d->extension_features[ext] = features;
+		d->capsExt = extensions().join(" ");
+	}
+}
+
+void Client::removeExtension(const QString& ext)
+{
+	if (d->extension_features.contains(ext)) {
+		d->extension_features.remove(ext);
+		d->capsExt = extensions().join(" ");
+	}
+}
+
+QStringList Client::extensions() const
+{
+	return d->extension_features.keys();
+}
+
+const Features& Client::extension(const QString& ext) const
+{
+	return d->extension_features[ext];
+}
+
 void Client::s5b_incomingReady()
 {
 	S5BConnection *c = d->s5bman->takeIncoming();
diff -ur psi/iris/xmpp-im/types.cpp psi-jingle/iris/xmpp-im/types.cpp
--- psi/iris/xmpp-im/types.cpp	2005-12-27 15:12:55.000000000 +0100
+++ psi-jingle/iris/xmpp-im/types.cpp	2005-12-27 11:05:53.000000000 +0100
@@ -784,6 +784,21 @@
 	v_songTitle = _songtitle;
 }
 
+void Status::setCapsNode(const QString & _capsNode)
+{
+	v_capsNode = _capsNode;
+}
+
+void Status::setCapsVersion(const QString & _capsVersion)
+{
+	v_capsVersion = _capsVersion;
+}
+
+void Status::setCapsExt(const QString & _capsExt)
+{
+	v_capsExt = _capsExt;
+}
+
 bool Status::isAvailable() const
 {
 	return v_isAvailable;
@@ -836,6 +851,21 @@
 	return v_songTitle;
 }
 
+const QString & Status::capsNode() const
+{
+	return v_capsNode;
+}
+
+const QString & Status::capsVersion() const
+{
+	return v_capsVersion;
+}
+
+const QString & Status::capsExt() const
+{
+	return v_capsExt;
+}
+
 int Status::errorCode() const
 {
 	return ecode;
@@ -1427,6 +1457,15 @@
 	return test(ns);
 }
 
+#define FID_VOICE "http://www.google.com/xmpp/protocol/voice/v1"
+bool Features::canVoice() const
+{
+	QStringList ns;
+	ns << FID_VOICE;
+
+	return test(ns);
+}
+
 #define FID_GATEWAY "jabber:iq:gateway"
 bool Features::isGateway() const
 {
diff -ur psi/iris/xmpp-im/xmpp_tasks.cpp psi-jingle/iris/xmpp-im/xmpp_tasks.cpp
--- psi/iris/xmpp-im/xmpp_tasks.cpp	2005-12-27 15:12:45.000000000 +0100
+++ psi-jingle/iris/xmpp-im/xmpp_tasks.cpp	2005-12-27 11:05:53.000000000 +0100
@@ -516,6 +516,16 @@
 			x.setAttribute("xmlns", "jabber:x:signed");
 			tag.appendChild(x);
 		}
+
+		if(!s.capsNode().isEmpty() && !s.capsVersion().isEmpty()) {
+			QDomElement c = doc()->createElement("c");
+			c.setAttribute("xmlns","http://jabber.org/protocol/caps");
+			c.setAttribute("node",s.capsNode());
+			c.setAttribute("ver",s.capsVersion());
+			if (!s.capsExt().isEmpty()) 
+				c.setAttribute("ext",s.capsExt());
+			tag.appendChild(c);
+		}
 	}
 }
 
@@ -625,6 +635,11 @@
 		else if(i.tagName() == "x" && i.attribute("xmlns") == "http://jabber.org/protocol/e2e") {
 			p.setKeyID(tagContent(i));
 		}
+ 		else if(i.tagName() == "c" && i.attribute("xmlns") == "http://jabber.org/protocol/caps") {
+ 			p.setCapsNode(i.attribute("node"));
+ 			p.setCapsVersion(i.attribute("ver"));
+ 			p.setCapsExt(i.attribute("ext"));
+  		}
 	}
 
 	presence(j, p);
@@ -1265,23 +1280,86 @@
 	//	return TRUE;
 	//}
 	else if(ns == "http://jabber.org/protocol/disco#info") {
+		// Find out the node
+		QString node;
+		bool found;
+		QDomElement q = findSubTag(e, "query", &found);
+		if(found) // NOTE: Should always be true, since a NS was found above
+			node = q.attribute("node");
+		
 		QDomElement iq = createIQ(doc(), "result", e.attribute("from"), e.attribute("id"));
 		QDomElement query = doc()->createElement("query");
 		query.setAttribute("xmlns", "http://jabber.org/protocol/disco#info");
+		if (!node.isEmpty())
+			query.setAttribute("node", node);
 		iq.appendChild(query);
-		QDomElement feature;
 
-		feature = doc()->createElement("feature");
-		feature.setAttribute("var", "http://jabber.org/protocol/bytestreams");
-		query.appendChild(feature);
-
-		feature = doc()->createElement("feature");
-		feature.setAttribute("var", "http://jabber.org/protocol/si");
-		query.appendChild(feature);
-
-		feature = doc()->createElement("feature");
-		feature.setAttribute("var", "http://jabber.org/protocol/si/profile/file-transfer");
-		query.appendChild(feature);
+		// Identity
+		DiscoItem::Identity identity = client()->identity();
+		QDomElement id = doc()->createElement("identity");
+		if (!identity.category.isEmpty() && !identity.type.isEmpty()) {
+			id.setAttribute("category",identity.category);
+			id.setAttribute("type",identity.type);
+			if (!identity.name.isEmpty()) {
+				id.setAttribute("name",identity.name);
+			}
+		}
+		else {
+			// Default values
+			id.setAttribute("category","client");
+			id.setAttribute("type","pc");
+		}
+		query.appendChild(id);
+
+		QDomElement feature;
+		if (node.isEmpty() || node == client()->capsNode() + "#" + client()->capsVersion()) {
+			// Standard features
+			feature = doc()->createElement("feature");
+			feature.setAttribute("var", "http://jabber.org/protocol/bytestreams");
+			query.appendChild(feature);
+
+			feature = doc()->createElement("feature");
+			feature.setAttribute("var", "http://jabber.org/protocol/si");
+			query.appendChild(feature);
+
+			feature = doc()->createElement("feature");
+			feature.setAttribute("var", "http://jabber.org/protocol/si/profile/file-transfer");
+			query.appendChild(feature);
+			
+			feature = doc()->createElement("feature");
+			feature.setAttribute("var", "http://jabber.org/protocol/disco#info");
+			query.appendChild(feature);
+
+			if (node.isEmpty()) {
+				// Extended features
+				QStringList exts = client()->extensions();
+				for (QStringList::ConstIterator i = exts.begin(); i != exts.end(); ++i) {
+					const QStringList& l = client()->extension(*i).list();
+					for ( QStringList::ConstIterator j = l.begin(); j != l.end(); ++j ) {
+						feature = doc()->createElement("feature");
+						feature.setAttribute("var", *j);
+						query.appendChild(feature);
+					}
+				}
+			}
+		}
+		else if (node.startsWith(client()->capsNode() + "#")) {
+			QString ext = node.right(node.length()-client()->capsNode().length()-1);
+			if (client()->extensions().contains(ext)) {
+				const QStringList& l = client()->extension(ext).list();
+				for ( QStringList::ConstIterator it = l.begin(); it != l.end(); ++it ) {
+					feature = doc()->createElement("feature");
+					feature.setAttribute("var", *it);
+					query.appendChild(feature);
+				}
+			}
+			else {
+				// TODO: ERROR
+			}
+		}
+		else {
+			// TODO: ERROR
+		}
 
 		send(iq);
 		return true;
@@ -1599,6 +1677,7 @@
 
 	QDomElement iq;
 	Jid jid;
+	QString node;
 	DiscoItem item;
 };
 
@@ -1626,6 +1705,7 @@
 	d->item = DiscoItem(); // clear item
 
 	d->jid = j;
+	d->node = node;
 	d->iq = createIQ(doc(), "get", d->jid.full(), id());
 	QDomElement query = doc()->createElement("query");
 	query.setAttribute("xmlns", "http://jabber.org/protocol/disco#info");
@@ -1648,6 +1728,29 @@
 	d->iq.appendChild(query);
 }
 
+
+/**
+ * Original requested jid.
+ * Is here because sometimes the responder does not include this information
+ * in the reply.
+ */
+const Jid& JT_DiscoInfo::jid() const
+{
+	return d->jid;
+}
+
+/**
+ * Original requested node.
+ * Is here because sometimes the responder does not include this information
+ * in the reply.
+ */
+const QString& JT_DiscoInfo::node() const
+{
+	return d->node;
+}
+
+
+
 const DiscoItem &JT_DiscoInfo::item() const
 {
 	return d->item;
diff -ur psi/iris/xmpp-im/xmpp_tasks.h psi-jingle/iris/xmpp-im/xmpp_tasks.h
--- psi/iris/xmpp-im/xmpp_tasks.h	2005-12-27 15:12:45.000000000 +0100
+++ psi-jingle/iris/xmpp-im/xmpp_tasks.h	2005-12-27 11:05:53.000000000 +0100
@@ -389,6 +389,8 @@
 		void get(const DiscoItem &);
 	
 		const DiscoItem &item() const;
+		const Jid& jid() const;
+		const QString& node() const;
 	
 		void onGo();
 		bool take(const QDomElement &);