Monday, November 08, 2010 at 12:06 AM.

system.verbs.builtins.tcp.im.builtinDrivers.jabber.code.handlers.iqVersion

on iqVersion ( connection, mesAdr, iq, query ) {
	<<Changes
		<<5/14/02; 1:51:34 PM by JB
			<<Changelog created.
	<<iqVersion will respond to a version information request from anybody, or handle
	on addAtt ( XMLadr, name, value ) {
		if not defined ( XMLadr^.["/atts"] ) {
			new ( tableType, @XMLadr^.["/atts"] )};
		XMLadr^.["/atts"].[name] = value};
	
	local ( type = xml.getAttributeValue ( iq, "type" ), reply );
	
	if type == "error" { // don't know how this could fail, but do nothing
		return};
	
	if type == "get" { // somebody is asking for our version info
		new ( tableType, @reply );
		local ( id = "", from = xml.getAttributeValue(iq, "from") );
		try { id = xml.getAttributeValue(iq, "id") }; // this should be sent, but we'll still return something if not
		bundle { // <iq id="id" type="result" to="from">
			iq = xml.addTable ( @reply, "iq" );
			if id != "" { addAtt(iq, "id", id) };
			addAtt(iq, "type", "result");
			addAtt(iq, "to", from )};
		
		bundle { // query tag
			q = xml.addTable ( iq, "query");
			addAtt ( q, "xmlns", "jabber:iq:version" )};
		
		bundle { // send the version information
			xml.addValue(q, "name", "Frontier/Radio Userland");
			xml.addValue(q, "os", environment.osFlavor );
			xml.addValue(q, "version", "1.0")};
		
		tcp.im.builtinDrivers.jabber.code.writeXML (iq, connection: connection );
		return};
	
	if type == "result" { // we are getting somebody's data back
		local ( id = xml.getAttributeValue ( iq, "id" ), from = xml.getAttributeValue ( iq, "from" ), idTbl );
		idTbl = tcp.im.builtinDrivers.jabber.code.idTables.getAdr(id);
		if not defined(idTbl^) {
			return};
		new ( tableType, @idTbl^.versionResults );
		for item in query {
			if typeOf(item^) == stringType {
				local ( name = xml.convertToDisplayName( nameOf( item^ ) ), value = item^ );
				idTbl^.versionResults[name] = value}};
		// special case handling for the server; record server version info in the connection table
		if string.lower(from) == string.lower(connection^.host) {
			table.assign(@connection^.serverVersion, idTbl^.versionResults)};
		return}};
iqRegister(@system.temp.jabber.references[1], nil, nil, nil, "temp" )



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.