sflphone-callto 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. #
  3. # This script can be used as a callto: (or other) protocol handler in
  4. # Mozilla Firefox-based browser.
  5. # In Firefox use Preferences > Applications and set the callto handler
  6. # to this script.
  7. # The sflphone daemon config file
  8. RESFILE=~/.config/sflphone/sflphoned.yml
  9. # Parse sflphonedrc and get default account id string
  10. if [ -f "$RESFILE" ]; then
  11. # Test if a SFLphone client is already open, if not open a new one
  12. # Opening a new client will start sflphoned if not already running
  13. SFLPHONEC=`ps -A | grep ring-client`
  14. if [ "$SFLPHONEC" = "" ]; then
  15. ring-client-gnome&
  16. fi
  17. # FIXME: this doesn't check if account is enabled, and is unreadable/unmaintainable.
  18. # D-Bus API should be fixed so that we can simply dial and let the daemon worry
  19. # about which account (default account? most recently used?) should place the
  20. # call.
  21. #
  22. # Use first ID
  23. ACCOUNTID=`grep order $RESFILE | sed -e 's/order: IP2IP\///' -e 's/\/.*//' | tr -d ' '`
  24. else
  25. echo Fatal: Can't find sflphoned.yml config file.
  26. exit 1
  27. fi
  28. # Check 1st argument (phone number)
  29. if [ -z $1 ]; then
  30. echo "Error: argument 1 (phone number) not provided."
  31. exit 1
  32. fi
  33. # Cleanup destination, keeping numbers only
  34. TO="`echo $1 | sed -e 's/[^0123456789]//g'`"
  35. # Generate call id.
  36. CALLID=${RANDOM}$$
  37. dbus-send \
  38. --type="method_call" \
  39. --dest="org.sflphone.SFLphone" \
  40. "/org/sflphone/SFLphone/CallManager" \
  41. "org.sflphone.SFLphone.CallManager.placeCall" \
  42. string:"$ACCOUNTID" \
  43. string:"$CALLID" \
  44. string:"$TO"
  45. exit 0
  46. # EOF