#!/bin/sh -e
set -e

#DEBHELPER#

ICONPATH="/usr/share/icons/hicolor"

# Get OSSO environment variables (launchers, dbus bus, etc)
if [ -f /etc/osso-af-init/af-defines.sh ]; then
  source /etc/osso-af-init/af-defines.sh
fi

dbus-send --type=method_call --dest=org.freedesktop.Notifications \
    /org/freedesktop/Notifications \
    org.freedesktop.Notifications.SystemNoteInfoprint \
    string:"Updating icons ..."

gtk-update-icon-cache -f ${ICONPATH}

if [ "$1" != "upgrade" ]; then

    dbus-send --type=method_call --dest=org.freedesktop.Notifications \
        /org/freedesktop/Notifications \
        org.freedesktop.Notifications.SystemNoteInfoprint \
        string:"Removing any alarm to restart
Automatic Skype Launcher."

    ALARM_COOKIE=`/usr/bin/gconftool-2 -g /system/skype-autolauncher/alarm_event 2>/dev/null`

    dbus-send --print-reply --dest=com.nokia.alarmd --type=method_call \
        /com/nokia/alarmd com.nokia.alarmd.del_event \
        int32:"$ALARM_COOKIE"

    /usr/bin/gconftool-2 -s /system/skype-autolauncher/alarm_event \
        --type int 0

fi

if [ "$1" = "purge" ]; then

    /usr/bin/gconftool-2 --recursive-unset /system/skype-autolauncher

fi

exit 0
