[JDEV] Patch for aim-t to support service discovery
Matthias Wimmer
m at tthias.net
Fri Dec 5 04:37:27 CST 2003
Hi!
I wrote the attached patch to aim-t. It implements service discovery
("disco") for aim-t.
Tot kijk
Matthias
--
Fon: +49-(0)70 0770 07770 http://matthias.wimmer.name/
HAM: DB1MW xmpp:mawis at charente.de
-------------- next part --------------
diff -Naur aim-transport/src/aimtrans.h aim-transport-disco/src/aimtrans.h
--- aim-transport/src/aimtrans.h 2003-01-17 20:51:31.000000000 +0100
+++ aim-transport-disco/src/aimtrans.h 2003-12-05 11:26:06.000000000 +0100
@@ -18,6 +18,8 @@
#define AT_TRANS_VERSION "0.9"
#define AT_NS_AUTH "aimtrans:data"
#define AT_NS_ROSTER "aimtrans:roster"
+#define NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items"
+#define NS_DISCO_INFO "http://jabber.org/protocol/disco#info"
typedef struct
{
@@ -183,6 +185,8 @@
int at_iq_search(ati ti, jpacket jp);
int at_iq_size(ati ti, jpacket jp);
int at_iq_browse(ati ti, jpacket jp);
+int at_iq_disco_items(ati ti, jpacket jp);
+int at_iq_disco_info(ati ti, jpacket jp);
/* messages.c */
int at_parse_incoming_im(aim_session_t *ass,
diff -Naur aim-transport/src/iq.c aim-transport-disco/src/iq.c
--- aim-transport/src/iq.c 2001-11-28 19:05:41.000000000 +0100
+++ aim-transport-disco/src/iq.c 2003-12-05 11:30:34.000000000 +0100
@@ -42,4 +42,6 @@
at_register_iqns(ti, NS_VERSION, &at_iq_version);
at_register_iqns(ti, NS_SEARCH, &at_iq_search);
at_register_iqns(ti, NS_BROWSE, &at_iq_browse);
+ at_register_iqns(ti, NS_DISCO_ITEMS, &at_iq_disco_items);
+ at_register_iqns(ti, NS_DISCO_INFO, &at_iq_disco_info);
}
diff -Naur aim-transport/src/iq_cb.c aim-transport-disco/src/iq_cb.c
--- aim-transport/src/iq_cb.c 2003-01-15 17:51:02.000000000 +0100
+++ aim-transport-disco/src/iq_cb.c 2003-12-05 11:26:06.000000000 +0100
@@ -251,3 +251,90 @@
// WHY! DAMNIT! WHY?
return 1;
}
+
+
+int at_iq_disco_items(ati ti, jpacket jp)
+{
+ xmlnode q;
+
+ if(jpacket_subtype(jp) != JPACKET__GET)
+ {
+ at_bounce(ti, jp, TERROR_BAD);
+ return 1;
+ }
+
+ jutil_iqresult(jp->x);
+ q = xmlnode_insert_tag(jp->x, "query");
+ xmlnode_put_attrib(q, "xmlns", NS_DISCO_ITEMS);
+
+ at_deliver(ti,jp->x);
+
+ return 1;
+
+}
+
+int at_iq_disco_info(ati ti, jpacket jp)
+{
+ xmlnode q, info;
+
+ if(jpacket_subtype(jp) != JPACKET__GET)
+ {
+ at_bounce(ti, jp, TERROR_BAD);
+ return 1;
+ }
+
+ if(jp->to->user != NULL)
+ {
+ q = xmlnode_insert_tag(jutil_iqresult(jp->x),"query");
+ xmlnode_put_attrib(q,"xmlns",NS_DISCO_INFO);
+
+ info = xmlnode_insert_tag(q, "identity");
+ xmlnode_put_attrib(info, "category", "client");
+ xmlnode_put_attrib(info, "type", "pc");
+ xmlnode_put_attrib(info, "name", jp->to->user);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_VCARD);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_LAST);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_TIME);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_VERSION);
+
+ at_deliver(ti,jp->x);
+ return 1;
+ }
+
+ q = xmlnode_insert_tag(jutil_iqresult(jp->x),"query");
+ xmlnode_put_attrib(q,"xmlns",NS_DISCO_INFO);
+
+ info = xmlnode_insert_tag(q, "identity");
+ xmlnode_put_attrib(info, "category", "gateway");
+ xmlnode_put_attrib(info, "type", "aim");
+ xmlnode_put_attrib(info,"name",xmlnode_get_tag_data(ti->vcard,"FN"));
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_VCARD);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_LAST);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_TIME);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_VERSION);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_GATEWAY);
+
+ info = xmlnode_insert_tag(q, "feature");
+ xmlnode_put_attrib(info, "var", NS_REGISTER);
+
+ at_deliver(ti,jp->x);
+ return 1;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://www.jabber.org/jdev/attachments/20031205/dea6e458/attachment-0002.pgp>
More information about the JDev
mailing list