From 8164345756b1a246760db876b399e6ca246e6dde Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)>
Date: Wed, 10 Feb 2010 16:53:02 -0500
Subject: [PATCH] [#2445] Update sflphone-handler in order to use
 placeCallFirstAccount method

---
 .../mozilla-telify-sflphone/sflphone-handler  | 40 +++++++------------
 1 file changed, 15 insertions(+), 25 deletions(-)

diff --git a/tools/mozilla-telify-sflphone/sflphone-handler b/tools/mozilla-telify-sflphone/sflphone-handler
index 727ef0f93c..db1cf92d0a 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
-- 
GitLab