Update debian/rules
[browser-switch] / microb
1 #!/bin/sh
2
3 get_name_owner() {
4         output=$(dbus-send --session --type=method_call --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:"$1" 2>/dev/null)
5         RETVAL=$?
6         if [ $RETVAL -ne 0 ]; then
7                 return $RETVAL
8         fi
9         echo "$output" | tail -1
10         return 0
11 }
12
13 case "$1" in
14         --url=* )
15                 url="${1#--url=}"
16                 ;;
17         --url )
18                 url="$2"
19                 ;;
20 esac
21
22 # Check whether Browser Switchboard owns the com.nokia.osso_browser name or not
23 osso_browser_owner=$(get_name_owner com.nokia.osso_browser)
24 if [ $? -ne 0 ]; then
25         # No one owns com.nokia.osso_browser -- let D-Bus start
26         # browser-switchboard to handle this request
27         method=switchboard_launch_microb
28 else
29         # If com.nokia.osso_browser is owned by the owner of
30         # org.maemo.garage.browser-switchboard, then Browser Switchboard must
31         # be the owner
32         browser_switchboard_owner=$(get_name_owner org.maemo.garage.browser-switchboard)
33         if [ "$osso_browser_owner" = "$browser_switchboard_owner" ]; then
34                 # Browser Switchboard owns com.nokia.osso_browser
35                 method=switchboard_launch_microb
36         else
37                 # Assume MicroB owns com.nokia.osso_browser
38                 method=open_new_window
39         fi
40 fi
41
42 dbus-send --session --type=method_call --print-reply --dest="com.nokia.osso_browser" /com/nokia/osso_browser/request com.nokia.osso_browser.$method string:${url:-"new_window"} > /dev/null 2>&1
43 exit 0