#!/bin/sh
#
# Copyright (C) 2012 Canonical, Ltd.
#
# Authors:
#  Bill Filler <bill.filler@canonical.com>
#  Olivier Tilloy <olivier.tilloy@canonical.com>
#
# 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; version 3.
#
# 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, see <http://www.gnu.org/licenses/>.
DBUS_NAME=com.canonical.Android
DBUS_PATH=/com/canonical/android/applications/Applications
DBUS_METHOD=com.canonical.android.applications.Applications.launchApplication

OPTS=`getopt -o f --long "action:,cmp:" -- "$@"`
eval set -- "$OPTS"

while true
do
    case "$1" in
    --action)  
        ACTION="$2"
        shift 2 
    ;;      
    --cmp)  
        CMP="$2"
        shift 2 
    ;;      
    --)     
        shift   
        break   
    ;;      
    esac    
done

dbus-send --type=method_call --session --dest=$DBUS_NAME $DBUS_PATH $DBUS_METHOD string:"$ACTION" string:"$CMP"

exit $?

