IP Phone: Difference between revisions

From Medien Wiki
No edit summary
 
Line 1: Line 1:
* [http://www.uni-weimar.de/cms/?id=telefonie Anleitung] auf den Seiten des [[SCC-Services|SCC]]
* [https://www.uni-weimar.de/de/universitaet/struktur/zentrale-einrichtungen/scc-rechenzentrum/service/telefonie/ Anleitung] auf den Seiten des [[SCC-Services|SCC]]
* [https://telefon.uni-weimar.de/webdialer/Webdialer Webdialer für Cisco IP Phone]
* [https://telefon.uni-weimar.de/webdialer/Webdialer Webdialer für Cisco IP Phone]
* [https://telefon.uni-weimar.de/ccmuser Einstellungen Cisco IP Phone]
* [https://telefon.uni-weimar.de/ccmuser Einstellungen Cisco IP Phone]

Latest revision as of 20:49, 26 March 2020

Kontextmenü in Mac OS X Kontakte.app (vor OS 10.8: Adressbuch.app)

Um über ein Klick den im OS X Adressbuch geöffneten Kontakt anzuwählen kann folgendes AppleScript verwendet werden, es kann als Call with IP Phone.scpt in ~/Library/Address Book plugins/ gelegt werden. Voraussetzung für das Funktionieren des Scripts ist, dass man schon die Sicherheitszertifikate der Webdialer-URL mit Safari importiert hat und dass man in dort schon eingeloggt ist (Login muss beim SCC beantragt werden). Außerdem muss JavaScript in Safari aktiviert sein[1].

Dial a number with your Cisco IP Phone from within the Mac OS X Contacts.app (formerly known as Address Book.app). Rightclick and use the context menue and select Dial with IP Phone.

-- AppleScript(+JavaScript) to dial phone numbers with a Cisco IP Phone from the Mac OS Contacts.app via the Webdialer URL
-- 2011 Max Neupert, Bauhaus-Universität Weimar with the help of the world wide web and Google

-- some snippets are taken from http://www.mactech.com/articles/mactech/Vol.21/21.10/ScriptingAddressBook/index.html
using terms from application "Contacts"
	on action property
		return "phone"
	end action property
	
	on action title for p with e
		return "mit IP Phone wählen"
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set safariWasRunning to false
		set iTunesWasPlaying to false
		if appIsRunning("Safari") then
			set safariWasRunning to true
		else
			tell application "Safari" to activate
		end if
		tell application "Safari" to open location "https://telefon.uni-weimar.de/webdialer/Webdialer"
		set theNumber to value of e
		set amtsholung to true
		-- to get rid of (0), - and spaces in the number
		set the theNumber to removeChars(theNumber, "(0)")
		set the theNumber to removeChars(theNumber, "-")
		set the theNumber to removeChars(theNumber, " ")
		
		set lengthOfNumber to length of theNumber
		-- the following lines replace the international prefix for germany (+49, or 0049) with 0
		if theNumber begins with "+49" then
			set theNumber to "0" & characters -1 thru -(lengthOfNumber - 3) of theNumber
		else if theNumber begins with "0049" then
			set theNumber to "0" & characters -1 thru -(lengthOfNumber - 4) of theNumber
			
			-- or any other international prefix
		else if theNumber begins with "+" then
			set theNumber to "00" & characters -1 thru -(lengthOfNumber - 1) of theNumber
		end if
		set lengthOfNumber to length of theNumber
		
		ignoring white space, punctuation, diacriticals and case
			-- in case it's a local number ommit the prefix for weimar
			if theNumber begins with "03643" then
				set theNumber to characters -1 thru -(lengthOfNumber - 5) of theNumber as text
			end if
			--in case it's an internal number ommit the prefix
			if theNumber begins with "58" then
				set theNumber to characters 3 thru 6 of theNumber as text
				set amtsholung to false
			end if
		end ignoring
		if amtsholung is true then
			-- the following line adds a 0 to get the outside line = “Amtsholung”
			set theNumber to "0" & theNumber as text
		end if
		
		--the following fades out iTunes if it's playing, inspired by Jeroen van der Waal http://dougscripts.com/itunes/
		if appIsRunning("iTunes") then
			tell application "iTunes" to if player state is playing then set iTunesWasPlaying to true
			if iTunesWasPlaying then
				tell application "iTunes"
					set oldVolume to sound volume
					repeat with i from oldVolume to 0 by -1
						set sound volume to i
						delay 0.01
					end repeat
					pause
					set sound volume to oldVolume
				end tell
			end if
		end if
		
		tell application "Safari"
			-- wait until page is completely loaded
			-- taken from http://www.mactipper.com/2009/10/run-applescript-when-webpage-is-done.html
			repeat until ((do JavaScript "document.readyState" in document 1) is "complete")
				delay 0.5
			end repeat
			delay 1
			do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & theNumber & "'" in document 1
			do JavaScript "document.forms['loginForm'].elements['dial'].click()" in document 1
			if safariWasRunning is false then
				delay 8
				tell application "Safari"
					quit
				end tell
			end if
		end tell
		return true
	end perform action
end using terms from

--from http://codesnippets.joyent.com/posts/show/1124
on appIsRunning(appName)
	tell application "System Events" to (name of processes) contains appName
end appIsRunning

--variation from http://www.macosxautomation.com/applescript/sbrt/sbrt-06.html
on removeChars(theChars, searchString)
	set AppleScript's text item delimiters to the searchString
	set the itemList to every text item of theChars
	set AppleScript's text item delimiters to ""
	set theChars to the itemList as string
	set AppleScript's text item delimiters to ""
	return theChars
end removeChars

Known issues

  1. Scripting doesn't seem to be possible for the Contacts.app Mac OS 10.9 (Mavericks). Also see http://support.apple.com/kb/HT5914
  2. browser window opens and resizes
  3. there are internal numbers which do not start with 58****. They aren't recognized at the moment.
  4. doesn't work with ugly number formats like +49 (0)170 123456789 fixed.
  5. since recently the webdialer stopped working (for me?) hence the whole script has become useless. investigating the issue. that turned out to be a hardware issue of the phone. replaced phone and it works again.
  6. stopped working after internal call fix fixed, works again
  7. University numbers like +49 3643 583872 will be called externally, that means it will cost money! fixed (surprisingly the cisco phone system isn't that smart to correct that internally)
  8. doesn't work with phone number which start like 0049...., (0049), (49) fixed
  9. only works with phone numbers in Germany so far fixed
  10. doesn't work if page loading in browser takes longer than 1 sec. fixed.

Thunderbird Address Book integration

I don't know if there is such a thing. Possible starting points:

Bemerkungen

  1. Schöner als ein Skript für den Browser (in diesem Fall Apple Safari.app) wäre eine Lösung, welche im Hintergrund funktioniert, z.B. mit cURL. Leider gibt es mit cURL unüberwindbare Probleme durch die SSL-Zertifikate und des JavaScrips der Cisco-Seite. Falls eine Telnet-Verbindung zum Telefon aufgebaut werden könnte, dann ließe sich auch diese Methode verwenden