I Have attached the script. In the meantime I cannot see osascript sandbox erros in the log anymore. Maybe there was a different cause of this. But the problem with Contacs remains: the context menu entry is not showing up when clicking on a phone numer. I've found a similar request here:
http://macscripter.net/viewtopic.php?id=42032
It seems to be a Mavericks 10.9.2 issue.
(*
Automatic SNOM Dialer v0.3
based on Torsten Uhlmann, tuhlmann@agynamix.de
based on Automatic Vonage Dialer by Aaron Freimark, abf@mac.com, March 16, 2004
Bernd Wild, bwild@intarsys.de
Put this script into your "Address Book Plugins" folder in your ~/Library folder.
*)
property mySnomLogin : ""
property mySnomPassword : "<mypassword>"
property mySnomPhoneAddress : "<mysnomURL>"
using terms from application "Contacts"
on action property
return "phone"
end action property
on action titleforperswithfone
return "Wählen mit SNOM"
end action title
on should enable actionforperswithfone
if label of fone contains "fax" then return false
return true
end should enable action
on perform actionforperswithfone
set numToDial to (value of fone) as string
--Erase everything that's not a digit from the phone number
set numToDial to CleanTheNumber(numToDial)
display dialog "Ich wähle dann folgende Nummer:" default answer numToDial buttons {"OK", "Abbrechen"} default button 1
if button returned of result = "OK" then
set numToDial to text returned of the result
set theURL to "https://" & mySnomLogin & ":" & mySnomPassword & "@"
set theURL to theURL & mySnomPhoneAddress & "/command.htm?number=" & numToDial
-- Use curl to hit the URL and dial the number
set errorCode to do shell script "curl -k \"" & theURL & "\""
beep
-- display dialog "Info: Wählen der Nummer " & numToDial buttons {"OK"}
--If there was an error, return a message.
if (characters 1 thru 3 of errorCode) as string is not equal to "000" then
display dialog "Fehler: " & errorCode buttons {"OK"}
end if
end if
end perform action
end using terms from
on CleanTheNumber(numToDial) -- remove punctuation from a string, leaving just the number
set theDigits to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
set cleanedNumber to ""
repeat with i from 1 to length of numToDial
set j to (character i of numToDial)
if j = "+" then set cleanedNumber to cleanedNumber & "00"
if j is in theDigits then set cleanedNumber to cleanedNumber & j
end repeat
set precode to (text 1 thru 4 of cleanedNumber)
if precode = "0049" then set cleanedNumber to "0" & (text 5 thru -1 of cleanedNumber)
return cleanedNumber
end CleanTheNumber