#!/bin/sh

set -e

# Clean up the feed items published by this application
/usr/bin/aegis-exec -s -u user dbus-send --dest=com.nokia.home.EventFeed --print-reply /eventfeed com.nokia.home.EventFeed.removeItemsBySourceName string:'cutetube'

echo "Removing highlight handlers from defaults.list"
sed -i -e '/x-maemo-highlight\/youtube-video-url=cutetube.desktop\|x-maemo-highlight\/dailymotion-video-url=cutetube.desktop\x-maemo-highlight\/vimeo-video-url=cutetube.desktop/d' /usr/share/applications/defaults.list

case "$1" in
    purge|remove|upgrade)
        initctl stop apps/cutetubed || true
        # Just in case Upstart could not stop the daemon, kill it
        killall cutetubed || true
    ;;

    failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

# Make sure the uninstallation is always considered successful
exit 0
