#!/bin/sh
#
# Copyright (C) 2004-2006 Nokia Corporation.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA

CONNECTIVITY_UI_SCRIPT=/usr/bin/osso-connectivity-ui.sh
CONNECTIVITY_UI_SCRIPT2=$AF_INIT_DIR/osso-connectivity-ui.sh
case "$1" in
start)

  source $SESSION_BUS_ADDRESS_FILE
  source $AF_INIT_DIR/maemo-af-desktop.sh start

  # boost desktop startup
  sleep 10

  if [ -x $CONNECTIVITY_UI_SCRIPT ]; then
    source $CONNECTIVITY_UI_SCRIPT start
  fi
  if [ -x $CONNECTIVITY_UI_SCRIPT2 ]; then
    source $CONNECTIVITY_UI_SCRIPT2 start
  fi

  source $AF_INIT_DIR/keyboard.sh start

  if [ -x $AF_INIT_DIR/osso-media-server.sh ]; then
    $AF_INIT_DIR/osso-media-server.sh start &
  fi

  source $AF_INIT_DIR/clipboard.sh start

  ;;
stop)

  source $AF_INIT_DIR/clipboard.sh stop
  source $AF_INIT_DIR/keyboard.sh stop

  if [ -x $CONNECTIVITY_UI_SCRIPT ]; then
    source $CONNECTIVITY_UI_SCRIPT stop
  fi
  if [ -x $CONNECTIVITY_UI_SCRIPT2 ]; then
    source $CONNECTIVITY_UI_SCRIPT2 stop
  fi

  source $AF_INIT_DIR/maemo-af-desktop.sh stop

  ;;
restart)
  echo "$0: not implemented"
  exit 1
  ;;
force-reload)
  echo "$0: not implemented"
  exit 1
  ;;
*)
  echo "Usage: $0 {start|stop}"
  exit 1
  ;;
esac
