--> http://www.macosxhints.com/article.php? ... 0145110629
--> http://www.macosxhints.com/article.php? ... 7010729892
tags: call dial action phone vonage number
// THIS ONE IS VERY SIMPLE AND YOUR PASSWORD IS NOT STORED IN THE KEYCHAIN BUT IT IS MUCH FASTER TO EXECUTE
- Code: Select all
(*
Launchbar Vonage Dialer v0.1
Edward Anastas - http://www.wishcentral.com
February 2, 2007
Modified from...
--> http://www.macosxhints.com/article.php?story=20040317010729892
Automatic Vonage Dialer v0.2 (AddressBook Plug-In)
Aaron Freimark, abf@mac.com
March 16, 2004
and...
--> http://www.macosxhints.com/article.php?story=20050810145110629
1. - Save this script anywhere on your hardrive (ex. ~/Library/Scripts/Vonage-Launchbar-Dialer.scpt)
2. - Go to your Launchbar preferences and select "Launching" tab
3. - Under "Open phone numbers:" select the script
*)
property myVonageLogin : "YourUsername"
property myVonagePassword : "YourPassword"
property myVonageNumber : "13105551212"
property lb_prefix : "tel:"
on handle_string(numFromLaunchbar)
-- Format the number to dial
if numFromLaunchbar starts with lb_prefix then set numToDial to ¬
(text ((count lb_prefix) + 1) thru -1 of numFromLaunchbar)
-- Display "calling... <number>" in LargeType
open location "x-launchbar:large-type?title=Calling...&string=" & numToDial
set theURL to "https://secure.click2callu.com/tpcc/makecall"
set theData to " -d username=" & myVonageLogin
set theData to theData & " -d password=" & myVonagePassword
set theData to theData & " -d fromnumber=" & myVonageNumber
set theData to theData & " -d tonumber=" & numToDial
-- Use curl to hit the URL and dial the number
set errorCode to do shell script "curl \"" & theURL & "\"" & theData
--If there was an error, return a message.
if (characters 1 thru 3 of errorCode) as string ? "000" then
display dialog "Error: " & errorCode buttons {"OK"}
end if
end handle_string
// THIS ONE IS MORE SECURE BECAUSE IT STORES YOUR PASSWORD IN KEYCHAIN BUT IT CAN TAKE A LITTLE LONGER TO EXECUTE
- Code: Select all
(*
Launchbar Vonage Dialer v0.1
Edward Anastas - http://www.wishcentral.com
February 2, 2007
Modified from...
--> http://www.macosxhints.com/article.php?story=20040317010729892
Automatic Vonage Dialer v0.2 (AddressBook Plug-In)
Aaron Freimark, abf@mac.com
March 16, 2004
and...
--> http://www.macosxhints.com/article.php?story=20050810145110629
1. - Save this script anywhere on your hardrive (ex. ~/Library/Scripts/Vonage-Launchbar-Dialer.scpt)
2. - Go to your Launchbar preferences and select "Launching" tab
3. - Under "Open phone numbers:" select the script
*)
property myVonageLogin : "YourUsername"
property myVonageNumber : "13105551212"
-- The lines below are correct for the U.S. dialing
-- YOU MUST MODIFY THESE LINES WITH YOUR INFO ***
property myCountryCode : "1"
property myLongDistanceCode : "1"
property myIntlAccessCode : "011"
property keyName : "Vonage"
on handle_string(numFromLaunchbar)
-- FORMAT PHONE NUMBER
set numToDial to CleanTheNumber(numFromLaunchbar)
set errorCode to open location "x-launchbar:large-type?title=Calling...&string=" & numToDial
set numToDial to InsertLDCodes(numToDial)
-- GET THE PASSWORD AND VONAGE ACCOUNT INFORMATION
set theKey to GetKeyNamed(keyName)
-- set theKey to myVonageKey
if theKey is null then
set theKey to CreateKey(keyName)
end if
tell application "Keychain Scripting"
set myVonageLogin to account of theKey
set myVonagePassword to password of theKey
end tell
set NumberList to GetNumbers(myVonageLogin, myVonagePassword)
if (count of NumberList) is greater than 1 then
set myVonageNumber to GetDefaultNumber(comment of theKey, NumberList)
if myVonageNumber is null then
set myVonageNumber to SelectNumber(NumberList)
end if
else
set myVonageNumber to item 1 of NumberList
end if
set theURL to "https://secure.click2callu.com/tpcc/makecall"
set theData to " -d username=" & myVonageLogin
set theData to theData & " -d password=" & myVonagePassword
set theData to theData & " -d fromnumber=" & myVonageNumber
set theData to theData & " -d tonumber=" & numToDial
-- Use curl to hit the URL and dial the number
set errorCode to do shell script "curl \"" & theURL & "\"" & theData
--If there was an error, return a message.
if (characters 1 thru 3 of errorCode) as string ? "000" then
display dialog "Error: " & errorCode buttons {"OK"}
end if
end handle_string
-- Add the long distance or international access code if it's not already there.
on InsertLDCodes(theNumber)
if (characters 1 thru 2 of theNumber) as string = "+" & myCountryCode then
-- The number was formatted correctly.
return theNumber
end if
if character 1 of theNumber = myLongDistanceCode then
-- Domestic long distance with LD access code
return theNumber
end if
if character 1 of theNumber = "+" then
-- international number, add prefix
return myIntlAccessCode & " " & theNumber
end if
-- local number, must add the LD code for Vonage
-- return myLongDistanceCode & " " & theNumber
return myLongDistanceCode & theNumber
end InsertLDCodes
-- Remove non-numerical digits from the phone number
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 is in theDigits then set cleanedNumber to cleanedNumber & j
end repeat
return cleanedNumber
end CleanTheNumber
-- KEYCHAIN SCRIPTS FROM
on GetKeyNamed(keyName)
tell application "Keychain Scripting"
try
tell current keychain
get some generic key whose name is keyName
return result
end tell
on error
return null
end try
end tell
end GetKeyNamed
on CreateKey(keyName)
tell application "Address Book"
display dialog "Enter Username" default answer myVonageLogin buttons {"OK"} default button "OK"
set myVonageLogin to text returned of the result
display dialog "Enter Password" default answer "password" buttons {"OK"} default button "OK"
set myVonagePassword to text returned of the result
display dialog "Enter Vonage Number" default answer myVonageNumber buttons {"OK"} default button "OK"
set myVonageNumber to text returned of the result
(* set VonageNumbers to GetNumbers(myVonageLogin, myVonagePassword)
if (count of VonageNumbers) is 1 then
set myVonageNumber to item 1 of VonageNumbers
else
set myVonageNumber to null
end if *)
end tell
tell application "Keychain Scripting"
tell current keychain
make new generic key with properties ¬
{name:keyName, account:myVonageLogin, password:myVonagePassword, comment:"Default Number: " & myVonageNumber}
return result
end tell
end tell
end CreateKey
on GetDefaultNumber(comments, VonageNumbers)
set theNumber to null
repeat with currentWord in VonageNumbers
if currentWord is in comments then
set theNumber to currentWord
end if
end repeat
return theNumber
end GetDefaultNumber
on GetNumbers(login, pass)
set theURL to "https://secure.click2callu.com/tpcc/getnumbers?"
set theURL to theURL & "username=" & login
set theURL to theURL & "&password=" & pass
set errorCode to do shell script "curl \"" & theURL & "\""
return words in errorCode
end GetNumbers
on SelectNumber(NumberList)
tell application "Address Book"
display dialog "Choose a number" buttons NumberList
return button returned of result
end tell
end SelectNumber
