Integrating tSIP with web browser

tSIP softphone can be integrated with web browser (or e.g. mail reader like Thunderbird) using Windows' custom protocol mechanism.

To create protocol association run tSIP as administrator and use function located in Settings/Integration.
tSIP browser integration settings
Default protocol name is "tsip" but but it can be changed to e.g. "tel" or "callto" as needed. Also, multiple protocol names can be associated with same application. Association creates few registry entries under HKEY_CLASSES_ROOT:
Windows registry: SIP softphone integration
To remove association manually delete registry entries.
Note: administrator rights are needed only for protocol registration (and may collide with normal operation under Vista and newer Windows version), launch application as usual after this.

There are few additional commands: HANGUP, ANSWER and APP_QUIT. When creating html file these commands are just plain links:
Call *74101
Answer (since 0.1.28)
Quit application (since 0.1.56)

Since version 0.1.76 tSIP accepts also scripts from command line (if enabled in Settings/Integration). Version 0.2.04 added also more practical base64-encoded scripts (as escaping command line turns out to be tricky and error-prone). Example:
ShowMessage("Hello from www!") (href="tsip:SCRIPT_B64=U2hvd01lc3NhZ2UoIkhlbGxvIGZyb20gd3d3ISIp")

Using javascript more fancy user interface can be created, e.g. offering standard telephone keyboard.

If you created association earlier you would probably see some confirmation popup from the browser that can be disabled for subsequent actions:
Opera custom protocol browser popup
Some browsers (Firefox-based in particular) may be not be able to check registry for protocol association or be not flexible enough to pass parameters as required by application.

To mitigate this problem additional batch file can be used (change path according to your exe location):

start "" "D:\_PROJEKTY\libre\tSIP\tSIP\Release_Build\tSIP.exe" /tsip="%1"

How does it work? After clicking the link tSIP.exe is launched with specified parameters. Since typically you wouldn't want to launch new copy of softphone with every new call (and it wouldn't make any sense with HANGUP command) first thing that application is doing is checking if another copy of it is running. If another copy (or more precisely: main window of another copy, though it does not have to be visible, application may sit in tray all the time) if found then new instance passes arguments to it and closes silently. If another copy is not found, then new instance executes command by itself (i.e. user sees softphone launched).

This function is intended for business/CRM-like usage, so softphone filters out from dialed number any digits outside of standard DTMF set. Thus, spaces or () for specifying regional number can be used freely inside of links.

tSIP uses WM_COPYDATA message to pass command between instances. In some cases - when target application runs with elevated privileges - newer version of Windows (Vista and above) block passing this message for security reasons. "Allow WM_COPYDATA to be passed to when elevated" disables this by using ChangeWindowMessageFilter function. Application restart is needed.

Part of mechanism is support for command line control - it can be used from any application:

tSIP.exe /tsip=123456789 (dialing)
tSIP.exe /tsip=HANGUP (disconnecting current call)
tSIP.exe /tsip=ANSWER (answering incoming call)
tSIP.exe /tsip=APP_QUIT (closing running softphone)
tSIP.exe /tsip=SHOWWINDOW (bringing window to the front)
tSIP.exe /tsip=PROGRAMMABLE_BTN_xxx (simulating programmable button being pressed, xxx = button ID, 0...100+)

Note: protocol association in registry uses absolute path to executable - using it makes application less portable, i.e. executable of associated application should stay in same place after association. My implementation does not also handle scenario with multiple tSIP softphone copies running simultaneously - command would be passed to random application copy, although using multiple protocol names for multiple softphone instances might be workaround for this - that way you can decide which softphone copy would receive request. Javascript may be helpful in this scenario allowing to switch link protocol/softphone target on the user side.

Note: try Telify extension for Firefox and Thunderbird!
Telify configuration

See also:

 "Cookie monsters": 7850619    Parse time: 0.001 s