Skip to content

Instantly share code, notes, and snippets.

@RSully
Created April 24, 2013 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RSully/5452522 to your computer and use it in GitHub Desktop.
Save RSully/5452522 to your computer and use it in GitHub Desktop.
This script can be used with something like `xdg` in order to add `sip:` handling to Chrome or Firefox using SFLphone. It takes a single argument, strips it to numerics and triggers a `dbus-send` to SFLphone's method to place a call. It uses the first account, which may or may not be what you want. `xdg-mime default sip-call-handler.desktop x-sc…
#!/usr/bin/php
<?php
// Requirements:
// sudo apt-get install php5-cli php-pear libyaml-dev
// sudo pecl install yaml
$file = $_SERVER['HOME'] . '/.config/sflphone/sflphoned.yml';
$acct_id = get_account_id($file);
$call_to = preg_replace('/[^0-9]/', '', $argv[1]);
// From the SFLPhone git repo (tools/sflphone-callto)
$res = `dbus-send --type="method_call" --dest="org.sflphone.SFLphone" "/org/sflphone/SFLphone/CallManager" "org.sflphone.SFLphone.CallManager.placeCall" string:"$acct_id" string:"\${RANDOM}\$\$" string:"$call_to"`;
function get_account_id($file) {
$arr = yaml_parse(file_get_contents($file));
return $arr['accounts'][0]['id'];
}
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=/home/test/Desktop/call.php "%U"
Name=SIP Call Handler
Comment=Trigger SFL phone
MimeType=x-scheme-handler/sip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment