#!/bin/sh
set -e

YOUTUBE_HIGHLIGHT="x-maemo-highlight/youtube-video-url=cutetube.desktop"
DAILYMOTION_HIGHLIGHT="x-maemo-highlight/dailymotion-video-url=cutetube.desktop"
VIMEO_HIGHLIGHT="x-maemo-highlight/vimeo-video-url=cutetube.desktop"
DEFAULTS="/usr/share/applications/defaults.list"

echo "Adding highlight handlers to defaults.list"

if ! grep $YOUTUBE_HIGHLIGHT $DEFAULTS; then echo $YOUTUBE_HIGHLIGHT >> $DEFAULTS; fi

if ! grep $DAILYMOTION_HIGHLIGHT $DEFAULTS; then echo $DAILYMOTION_HIGHLIGHT >> $DEFAULTS; fi

if ! grep $VIMEO_HIGHLIGHT $DEFAULTS; then echo $VIMEO_HIGHLIGHT >> $DEFAULTS; fi

case "$1" in
    configure)

    echo "Starting cutetubed ..."
    [[ -e /etc/init/apps/cutetubed.conf ]] && initctl start apps/cutetubed
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
