diff --git a/tools/mozilla-telify-sflphone/sflphone-handler b/tools/mozilla-telify-sflphone/sflphone-handler index 727ef0f93c26927ed962654154418cd59ca2983a..db1cf92d0abc3536f3eb2e3bce1752b3e12d6cb5 100755 --- a/tools/mozilla-telify-sflphone/sflphone-handler +++ b/tools/mozilla-telify-sflphone/sflphone-handler @@ -5,25 +5,12 @@ # In Firefox use Preferences > Applications and set the callto handler # to this script. -# The sflphone daemon config file -RESFILE=~/.config/sflphone/sflphonedrc -# Parse sflphonedrc and get default account id string -if [ -f "$RESFILE" ]; then - - # Use first ID - ACCOUNTID=`grep Accounts.order $RESFILE | sed -e 's/Accounts.order=//' -e 's/\/.*//'` - - # Accounts.order is not set - if [ -z $ACCOUNTID ]; then - - # Use first account declared in sflphone config - ACCOUNTID="`grep -m 1 Account: $RESFILE | sed -e 's/\[//' -e 's/\]//'`" - fi - -else - echo Fatal: Cant find sflphonedrc config file. - exit 1 +# Test if a SFLphone client is already open, if not open a new one +# Opening a new client will start sflphoned if not already running +SFLPHONEC=`ps -A | grep sflphone-client` +if [ "$SFLPHONEC" = "" ]; then + /usr/bin/sflphone-client-gnome& fi # Check 1st argument (phone number) @@ -38,13 +25,16 @@ TO="`echo $1 | sed -e 's/[^0123456789]//g'`" # Generate call id. CALLID=${RANDOM}$$ -dbus-send \ - --type="method_call" \ - --dest="org.sflphone.SFLphone" \ - "/org/sflphone/SFLphone/CallManager" \ - "org.sflphone.SFLphone.CallManager.placeCall" \ - string:"$ACCOUNTID" \ - string:"$CALLID" \ +# Dbus placeCallFirstAccount method does not reach sflphoned if starting +# Should find another way to do this +sleep 1 + +dbus-send \ + --type="method_call" \ + --dest="org.sflphone.SFLphone" \ + "/org/sflphone/SFLphone/CallManager" \ + "org.sflphone.SFLphone.CallManager.placeCallFirstAccount" \ + string:"$CALLID" \ string:"$TO" exit 0