Gradient 1.1.0pre@ release - files & notes

This is a pre-release Gradient 1.1, which is a refactored & upgraded version of Gradient 1.0.

The previous version is described, documented, etc. on the old website. A lot of the information on that site is no longer accurate for v1.1, in particular all of the JavaDocs, most of the design notes, and anything that describes document loading is no longer accurate for 1.1.

The 1.1.0 final release will be accompanied by updated documentation.

22 December 2004: Here are some screenshots.

Files

Contents

1. What's the difference between this client and the normal Batik Squiggle SVG viewer?

1.1. XMPP binding

When the document loads, we check for a "link" element in the Gradient namespace. If this element exists and has in a JID attribute a valid Jabber ID (JID) on an XMPP network that we can connect to, then this JID assumed to be the document controller, and is sent a message containing a generated thread ID (which acts as a shared secret between the server and the client) and the URL from which the document was loaded.

1.2. ECMAScript extensions

The ECMAScript DOM scripting environment of the SVG environment has been changed in two ways. Firstly, several XMPP-related events can be caught within the document ECMAscript by declaring functions with certain names. Secondly, several XMPP-related methods have been added that allow scripts to send information over XMPP networks.

1.2.1. XMPP Events

XMPP events are triggered within ECMAScript when XMPP packets (stanzas) arrive via an XMPP network that are routable to this document, i.e. if:

The events can be broken down into to types, controller and everyone else. Controller methods are triggered only by stanzas originating from the controller. The other methods are triggered by anyone else.

1.2.1.1. Generic events

connected(jid)

Fired when the document is connected to the XMPP network. This does not necessarily happen onload, since the user may not be connected at the time, and may choose not to connect to an XMPP network.

1.2.1.2. Controller events

processMessage(elements, type)

processPresence(elements, type)

processIQ(element, type)

Unlike processMessage and processPresence, processIQ is only triggered explicitly if this document is referred to by it's thread ID, i.e. it's impossible for IQ requests to be routable to multiple documents.

This function, if declared, MUST return an element. IQ being the RPC-equivalent of XMPP, the browser needs to know what to send back to the controller. If no element is returned, then any IQ that is targeted a this document will have a 500 error returned.

1.2.1.3. Non-controller events

processUntrustedMessage(from, elements, type)

processUntrustedPresence(from, elements, type)

processUntrustedIQ(from, element, type)

Unlike processUntrustedMessage and processUntrustedPresence, processUntrustedIQ is only triggered explicitly if this document is referred to by it's thread ID, i.e. it's impossible for IQ requests to be routable to multiple documents.

This function, if declared, MUST return an element. IQ being the RPC-equivalent of XMPP, the browser needs to know what to send back to the sender. If no element is returned, then any IQ that is targeted a this document will have a 500 error returned.

1.2.2. XMPP functions

The XMPP functions of the Gradient extension to Squiggle are declared at the same level as alert() and prompt(), i.e. they are not declared or used on a per-document basis, but on a per-environment basis. Why? Allowing one document to send message stanzas as if from another document simply because it has a reference to it (e.g. opener) is a bad idea because it allows impersonation.

1.2.2.1. XMPP environment functions

isConnected()

Returns true if connected to an XMPP server.

getDocJID()

Returns the Jabber ID that this document is using to connect to the XMPP network to which the controller JID is connected.

getDocThread()

Returns the document thread ID.

getControllerJID()

Returns the controller JID of this document.

1.2.2.2. XMPP network functions

sendMessage(elements, [type, [to, [thread]]]);

Sends a message from the document JID.

sendIQ(element, [type, [to, [thread]]]);

2. Known problems

Perfection is the enemy of completion... - Or, "Why this is only a pre-release".

  1. On some J2SDK installs, the client runs as an applet for some reason. This prevents local filesystem access, which puts a crimp in our style and a stacktrace in our console. You can avoid this by commenting out lines 720-723 in org.apache.batik.apps.svgbrowser.Main, but that means you're running web-page scripts with local system access, which is not a good thing, to put it mildly.
  2. There's a memory leak somewhere, 'cos we keep a reference to the canvas, and therefore the scripting environment and the GVT tree, somewhere, after we unload the document. Depending on VM memory settings / hardware leetness / page size/complexity, can crash the app after 10-100 page views. Serious, but allows us to demonstrate the principles behind Gradient.
  3. Server compatibility. Tested with Jabber2d. Jive Messenger 1.1 removes namespace declarations and local namespace prefixes on attributes of IQ children, making it difficult to address IQs to threads. Not tested on Jive Messenger 2, or any other Jabber servers. Demo server is jabber.org (thanks PGM et al), running j2d.
  4. some presence stanzas are processed out of order
  5. the log() function is called from the script security context, and borks the script when attempting to read a file.
  6. alert() and other AWT events triggered on SVGUnload blocks the AWT-Eventqueue and therefore greyscreens the app.

3. To do

  1. Fix memory leak.
  2. Fix log.
  3. Fix problem with running as applet.
  4. add disconnected() event.
  5. The website documentation is all out of date.
  6. So are the JavaDocs
  7. Change examples to use e4x
  8. Create more examples
  9. Remove people when presence unavailable from jid.