blob: e4614d754e0c463d68d213dbde005bdefa307027 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/bin/sh
SKYPE="skype"
DBUS_SEND="dbus-send"
BUS="--system"
SKYPE_BUS=""
ID=`id -u`
print_help()
{
cat << EOF
Skype "callto://" handler
Usage: skype-callto-handler [BUS] callto://user
Where BUS can be either "--system" (default) or "--session"
EOF
}
if [ -z "$1" -o "$1" = "--help" ]; then
print_help
exit 1
fi
if [ "--system" = "$1" -o "--session" = "$1" ];then
BUS="$1"
shift 1
fi
if [ "--session" = "$BUS" ]; then
SKYPE_BUS="--use-session-dbus"
fi
if [ -z "$1" ];then
print_help
exit 1
fi
CALLTO=`echo $1 | sed 's/callto:\/\///'`
PING=`$DBUS_SEND $BUS --type=method_call --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ServiceExists string:com.Skype.API 2> /dev/null`; RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "ERROR: Failed to connect to DBUS daemon!"
exit 1
fi
echo "$PING" | grep -q "boolean:true"; RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Running Skype instance not found, launching"
$SKYPE $SKYPE_BUS --callto "$CALLTO" &
exit 0
fi
SKYPE_ID=`$DBUS_SEND $BUS --type=method_call --print-reply --dest=com.Skype.API /com/Skype com.Skype.API.Ping 2> /dev/null`;RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "ERROR: Skype is running on specified bus, but is misbehaving!"
exit 1
fi
TEMP=`echo "$SKYPE_ID" | grep -o "int32:[0-9]*"`
SKYPE_ID=`echo "$TEMP" | cut -f2 -d':'`
if [ $ID -ne $SKYPE_ID ]; then
echo "ERROR: Skype is running on specified bus, but for different UNIX user!"
exit 1
fi
REPLY=`$DBUS_SEND $BUS --type=method_call --print-reply --dest=com.Skype.API /com/Skype com.Skype.API.Invoke string:CALL\ $CALLTO 2> /dev/null`;RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "ERROR: Error when communicating with Skype!"
exit 1
fi
TEMP=`echo "$REPLY" | grep -o "string:.*"`
REPLY=`echo "$TEMP" | cut -f2 -d':'`
echo $REPLY
exit 0
|