The easy Weblog and Wiki Software
[ start | index | login ]
start > jabberPresence

jabberPresence

Created by senikk. Last edited by senikk, 4 years and 343 days ago. Viewed 1,276 times. #1
[edit] [rdf]
labels
attachments

XMPP Online Status

Presence status text and online mode indicator for the XMPP protocol using my SmackBot xmpp bot. I apriciate comments suggestions, corrections etc. You can the XMPP Presence indicator in action at my personal SnipSnap >>http://senikk.com

Example iconset
>>http://psi.affinix.com/files/common/iconsets/psi_dudes/psi_dudes.png

Macros

NameExampleDescription
xmpp-status{xmpp-status:senikk@jabber.org}This was my first test of using my SmackBot with a macro. It returns the Presence status text for the user jabbber id given.
xmpp-indicator{jabber-indicator:senikk@jabber.org}Showing a image presence indicator. Its now working but I need to fix the roster handling.

Todo

  • Make it possible to refer to a snip with a {@jabberID} label instead of jid
  • Add support for {logins} and {list-of-users} macros
  • Add some information in img title attribute like last available, status message etc. I think I have to add a new appendImage() to do this.
  • If not in the bot's roster send a subscription request
  • Add an add to my roster kind of link/image to add a jabber SnipSnap user to your roster, you need to be a logged in user and have a {@jabberID} label. Maybe this should be a part of rendering of the {@jabberID} label
XMPP Status text
package com.brassforum.snipsnap.macro;

import org.radeox.macro.Macro; import org.radeox.macro.parameter.MacroParameter;

import org.snipsnap.notification.xmpp.SmackBot;

import java.io.IOException; import java.io.Writer;

public class XMPPStatusMacro extends Macro { private String[] paramDescription = {"none"};

public String[] getParamDescription() { return paramDescription; }

public String getName() { return "xmpp-status"; }

public String getDescription() { return "XMPP online status"; }

public void execute(Writer writer, MacroParameter params) throws IllegalArgumentException, IOException {

if (params == null || params.getLength() < 1) throw new IllegalArgumentException("Number of arguments does not match");

SmackBot smackbot = SmackBot.getInstance(); writer.write(smackbot.onlineStatus(params.get("0")));

return; } }

XMPP Presence Indicator

package com.brassforum.snipsnap.macro;

import org.radeox.macro.Macro; import org.radeox.macro.parameter.MacroParameter;

import org.snipsnap.notification.xmpp.SmackBot; import org.snipsnap.snip.SnipLink;

import java.io.IOException; import java.io.Writer;

public class XMPPIndicatorMacro extends Macro { private String[] paramDescription = {"none"};

public String[] getParamDescription() { return paramDescription; }

public String getName() { return "xmpp-indicator"; }

public String getDescription() { return "xmpp online indicator"; }

public void execute(Writer writer, MacroParameter params) throws IllegalArgumentException, IOException {

if (params == null || params.getLength() < 1) throw new IllegalArgumentException("Number of arguments does not match");

SmackBot smackbot = SmackBot.getInstance(); String status = smackbot.onlineMode(params.get("0"));

if(status!=null && status.length()>0) SnipLink.appendImage(writer,"xmpp/"+status+".png",status);

return; } }

Icon-Comment senikk, 4 years and 353 days ago. Icon-Permalink

  1. Is there any graphics artists among us SnipSnap users? It would been great with some SnipSnap spesific online mode indicator images.
  2. Do you know of existing indicator images which freely can be used?

Icon-Comment trejkaz, 3 years and 243 days ago. Icon-Permalink

I was thinking of implementing a very similar feature on my upcoming personal website. I've determined the following things to do...

I currently render {jid:trejkaz@jabber.zim.net.au} as a link to xmpp:trejkaz@jabber.zim.net.au. I want to add a status indicator to this.

My JabberIDLabel tag (really just a specialised version of IMLabel, which doesn't store the type at all) will then render using the {jid} macro to achieve a consistent look.

The only funny thing about doing it this way is that I can't link to pages which contain that type of label, since the link would go to the user's Jabber client. But oh well… I'll see how this goes. Maybe the trick will be to show little icons next to the JID which you click on to launch the Jabber client, instead of making the whole string a link.

I'm also using my own bot based on Smack to do this stuff, since I had the bot already and it took only a small modification to make it a singleton. But I bet that anything I ended up doing would port reasonably easily back into SmackBot.

Please login to post a comment.

What is SnipSnap?
SnipSnap is a free and easy to install weblog and wiki tool written in Java.

SnipSnap download
Current version: 1.0b3-uttoxeter
Try our >>Web Start Demo!

Resources

5567 Users and 13713 Snips. Installed 6 years and 41 days ago

Logged in Users: (1)
… and 14 Guests.

snipsnap-changed for older changes.

< August 2008 >
SunMonTueWedThuFriSat
12
3456789
10111213141516
17181920212223
24252627282930
31

snipsnap
Listed on BlogShares
XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

pico-powered

Powered by SnipSnap 1.0b3-uttoxeter
YourKit >>Java Profiler

Fraunhofer FIRST

snipsnap.org | Copyright 2000-2006 Fraunhofer FIRST