#!/bin/sh

# this script is also used as a mcabberevent command

. $HOME/.wmii-3.5/status.d/setup

action=$1
button=$2
script=$3

case "$action" in
    Stop)
    ;;

    Start)
    ;;

    *BarClick)
        case "$button" in
            1) stopBar;;
        esac
    ;;

    MSG)
        #   $events_command MSG IN jabber@id [file] (when receiving a message)
        #   $events_command MSG OUT jabber@id       (when sending a message)
        #   $events_command MSG MUC room_id [file]  (when receiving a MUC message)
        #   $events_command STATUS X jabber@id      (new buddy status is X)
        inout=$2
        buddy=${3%%@*}
        statusbar="${rstatbar}_${buddy}"
        script=`basename $0`
        case "$inout" in
            IN|MUC)
                wmiir ls ${statusbar} \
                    ||  ( startBar ; ln -sf $HOME/.wmii-3.5/status.d/${script} $HOME/.wmii-3.5/status.d/${script}_${buddy})
                imc=`wmiir read ${statusbar} | cut -d ':' -f 2`
                imc=`expr ${imc} + 1 2> /dev/null || echo 1`
                notice "${buddy}:${imc}"
            ;;

            OUT)
                stopBar
            ;;
        esac

    ;;

    STATUS)
    ;;

esac

