Configure Firefox to handle callto links in Ubuntu/Debian

Hi all ūüôā

in this post I will show you how to configure Mozilla Firefox to handle callto links. By default if you click on callto link in Firefox shows the following error:

The address wasn't understood

Firefox doesn't know how to open this address, because the protocol (callto) isn't associated with any program.

You might need to install other software to open this address.

These steps are tested on Ubuntu 12.04 LTS i386, Ubuntu 13.10 i386 and Debian Wheezy amd64.

1. Install SFLPhone Software for VOIP calls

apt-get install sflphone-gnome

2.¬†Start the app. First time you will see this screen. Just click ‚ÄúContinue‚ÄĚ:

SFLPhone

¬†We need to choose ‚ÄúRegister an existing SIP account‚ÄĚ on the next screen and click ‚ÄúContinue‚ÄĚ:

SFLPhone

¬†On the next screen we choose ‚ÄúSIP‚ÄĚ and click ‚ÄúContinue‚ÄĚ:

Here we need to fill our data:

Alias: Our name
Host name: Our SIP Server IP
User name: Your user or ID
Password: Your password

¬†After filling the required data, click ‚ÄúContinue‚ÄĚ:

¬†On the next screen just click ‚ÄúApply‚ÄĚ. We don’t need to setup anything here:

 Next you will see summary for your account.

 4. Save this script to /usr/bin/sflphone-handler

#!/bin/sh
#
# This script can be used as a callto: (or other) protocol handler in
# Mozilla Firefox-based browser.
# In Firefox use Preferences > Applications and set the callto handler
# to this script.

# 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)
if [ -z $1 ]; then
echo "Error: argument 1 (phone number) not provided."
    exit 1
fi

# Cleanup destination, keeping numbers only
TO="`echo $1 | sed -e 's/[^0123456789]//g'`"

# Generate call id.
CALLID=${RANDOM}$$

# 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

# EOF

 Or you can download it from:

https://github.com/LukeCarrier/sflphone/blob/master/tools/mozilla-telify-sflphone/sflphone-handler

5. Make this script executable:

chown root:root /usr/bin/sflphone-handler
chmod 755 /usr/bin/sflphone-handler

6. Add callto handler

sudo echo "x-scheme-handler/callto=sflphone.desktop" >> /usr/share/applications/defaults.list

7. Configure SFLPhone to accept parameters

nano /usr/share/applications/sflphone.desktop

and change

Exec=sflphone-client-gnome

to

Exec=sflphone-client-gnome %u

8. Configure Firefox

Open Firefox and click on callto link. First time you will see this screen:

¬†We need to click ‚ÄúChoose‚ÄĚ and navigate to /usr/bin/sflphone-handler.

Then check ‚ÄúRemember my choice for callto links‚ÄĚ and click ‚ÄúOK‚ÄĚ.

After a while SFLPhone application should start and automatically call the number from the link.