24U Phone Companion 2.0 Syntax

Complete syntax and functionality of the plug-in functions

Phone_Version ( { versionFormat } )

Returns version string of the active 24U Phone Companion, formatted as requested by the parameter.

Parameters

versionFormatDefines the format of the returned version.

Parameter values for versionFormat

"short" To get just the version number. Default value.
"long" To get the plug-in name followed by its version number.
"platform" To get the platform of the code currently running.
"autoupdate" To get autoupdate compatible (comparable) version number.

Description

This function is very important and it has the same output format in all 24U Plug-Ins. You should call this function every time you need to check if the plug-in is properly installed to the FileMaker. Even if the plug-in is not registered (or badly registered) this function should work. Calling this function in the startup script of your solution is recommended.

Result

Returns requested version format or platform. If this function returns "?" than the plug-in is not properly installed or FileMaker cannot load and activate it for some reason.

Examples

Phone_Version( "long" )
This will return the plug-in name and its version. In this case it is 24U Phone Companion 2.0

Phone_Version( "platform" )
Returns "Mac OS X" or "Windows" depending on the platform the plug-in is currently running.

Phone_Version( "autoupdate" )
Returns 04020600 for version 4.2.6 of the plug-in.

Phone_Register ( serialNumber )

Attempts to unlock (register) your copy of 24U Phone Companion with the specified code.

Parameters

serialNumberThe code to unlock the plug-in.

Description

If the code(s) is valid, 24U Phone Companion gets unlocked and stays in this state until you quit the FileMaker Pro application, deactivate the plug-in, or the registration code expires. While unlocked, 24U Phone Companion is fully functional and does not bother the user with a shareware reminder.

Result

Returns a non-zero error code when the serial numbers are wrong if the numbers cannot be used. Returns 0 if the plug-in was successfully registered.

Examples

Phone_Register( "PHC10J-CM244H-U4UGBN" )
This function will register the plug-in with serial number PHC10J-CM244H-U4UGBN. This method is useful when you register the plug-in with developer license but it can be used for end-user licenses as well.

Note: All serial numbers here are only for demonstration purposes. They will not work in real plug-in.

Phone_Connect ( serverIP ; serverPort { ; timeout } )

Connect to STLI server.

Parameters

serverIPThe IP address of the server.
serverPortThe port of the server.
timeoutThe timeout for connection. Use float number in seconds. The default value is 3s.

Description

Call this function establish TCP connection to STLI server. This server is needed to control the line. All phone functions will work only if the plug-in is properly connected.

Result

Function returns 0 id connection was successfully established. Otherwise it returns negative error code.

Examples

Phone_Connect( "10.0.0.2" ; 26535 )
The plug-in will attempt to connect to server with IP 10.0.0.2 on port 26535.

Phone_Connect( "132.65.28.17" ; 25001 ; 9.5 )
The plug-in will attempt to connect to server with IP 132.65.28.17 on port 25001 with 9.5 seconds timeout.

Phone_Disconnect

Disconnect from STLI server.

Description

This function will cause that TCP connection to STLI server will be terminated. Use this function when you no longer need phone services.

Result

Function returns 0 if the connection was terminated. It returns 0 even if there was no previous connection. Error code is returned when the connection was not terminated in the standard way (abnormal termination).

Examples

Phone_Disconnect
Function has no parameters. This will allways terminate the connection and return status code.

Phone_Dial ( localDevice ; calledDirectoryNumber )

Dials a specified telephone number on the specified calling device.

Parameters

localDeviceThe phone number of device from which the call originates. The device must be local.
calledDirectoryNumberIndicates the device to which the call should be directed. The number should direct to local or extranl device.

Description

This function will dial the number on the local phone. The format should be FileMaker text. It can contain all numbers, "*", "#" and "+".

Result

Function returns 0 if the number was successfully dialed. It doesn't matter if the other side accepted the call or not. If some error occured (line is not ready, server is not ready, line was forcefully disconnected or similar) the status number is returned.

Examples

Phone_Dial( "11" ; "17" )
This will dial the number 17 on the device with number 11.

Phone_Dial( "103" ; "05555925" )
You can use any number for outside calls. This will dial 05555925 number on the device with local number 103.

Phone_Answer ( localDevice )

Answers (off-hook) an incoming call.

Parameters

localDeviceThe local device which should answer the call.

Description

The called local device shoud be able to accept incoming call. It should be either speakerphone or headset equipped phone. The local device should be monitored for incoming calls. Use Phone_SetScriptEvent function to monitor incoming calls.

Result

Function returns 0 if the call was successfully accepted. It the device cannot accept call or another problem occured than the status code is returned.

Examples

Phone_Answer( "19" )
This will accept the call on the local device with number 19.

Phone_HangUp ( localDevice )

Hang up a call.

Parameters

localDeviceThe phone number of the local device which should hang up.

Description

This function will hang up a call on the local phone. The call should be properly established and local device should be monitored with some event. Use Phone_SetScriptEvent to start monitoring events.

Result

Function returns 0 if the phone was properly hanged up. In case of error the function returns negative error code.

Examples

Phone_HangUp( "19" )
This will hang up a call on the phone with number 19.

Phone_RawCommand ( commandString )

Sends the unmodified command to the server.

Parameters

commandStringThe command string. The string will be encoded using UTF-8 encoding and sent to the server without waiting for answer.

Description

This function can be used to send low level commands directly to the server. This is useful for communication with non-standard server or to send commands which plug-in does not implement yet.

Result

Function returns 0 if the command was successfully sent. It doesn't matter if the other side accepted the command.

Note

This function does not wait for response. Use Phone_SetScriptRawEvent in cojunction with raw commands to catch server responses

Examples

Phone_RawCommand( "HoldCall 199348" )
Send command "HoldCall" with number 199348 to the server. Do not wait for reply. What the server will do is undefined.

Phone_SetScriptEvent ( localDevice ; event ; scriptName )

Tell the plug-in to launch the script when specified event is triggered from outside.

Parameters

localDeviceThe phone number of the device for which the event will be triggered.
eventThe type of the event which should be installed. See table below for possible types.
scriptNameThe name of the script which should be triggered.

Parameter values for event

"onIncomingCall" Run the script on incoming call from outside.
"onAnswerCall" Run the script when incoming call is answered.
"onHangUp" Run the script on hang up.
"onCalling" Run the script when when the call is made from the phone.

Description

The function will call the specified script when the event of the specified type occurs. The script will receive a parameter which contains the number of controlled phone on the first line and the phone number of the second side on the second line.

To remove event for some number call Phone_SetScriptEvent( localDevice ; event ; "" ).
To remove all events for some number call Phone_SetScriptEvent( localDevice ; "" ; "" ).
To remove all events for all numbers call Phone_SetScriptEvent( "" ; "" ; "" ).

Result

Function returns 0 if event is sucessfully installed or uninstalled. In case of error the function returns negative error code.

Notes

Each triggered script from plug-in receives script parameter which can be read by Get( ScriptParameter ) script step. The parameter consists of several lines of text. See the notes below to learn what each line of script parameter means (parameters are sorted from the first line) :

Parameters passed to the "onIncomingCall" handler"

localDevice The local device which registered incoming call.
callerID The number of the caller.
calledID The number of line which received the call. This parameter is optional. It is filled only on PBXs where it is supported

Parameters passed to the "onAnswerCall" handler

localDevice The local device which just answered call.
callerID The number of the caller.
calledID The number of line which received the call. This parameter is optional. It is filled only on PBXs where it is supported

Parameters passed to the "onHangUp" handler

localDevice The local device which where the event happened.

Parameters passed to the "onCalling" handler

localDevice The local device which is used right now for outgoing call.
calledID The number where the call directs.

Examples

Phone_SetScriptEvent( "19" ; "onAnswerCall" ; "Save answered call" )
This will install the script named "Save answered call" for the local device with number 19

Phone_SetScriptEvent( "105" ; "onCalling" ; "Show announcment" )
The script "Show announcment" will be called every time the user makes a call from the phone with number 105.

Phone_SetScriptRawEvent ( pattern ; scriptName )

Tell the plug-in to launch the script when it receives a message from monitored device which corrsponds to regular expression.

Parameters

patternRegular expression pattern. If incoming message matches this pattern, the script is triggered. To disable the filter set this parameter to "".
scriptNameThe name of the script which should be triggered.

Description

This function is similar to Phone_SetScriptEvent. It does not recognize the meaning of events. It just filters them using regular expressions and triggers the script on match.
It is recommended to always use some kind of filter. Using this function without filter can slowdown FileMaker application.

To remove triggers for some pattern Phone_SetScriptRawEvent( pattern ; "" ).
To remove triggers with some script name call Phone_SetScriptRawEvent( "" ; scriptName ).
To remove all triggers use Phone_SetScriptRawEvent( "" ; "" ).

Function returns 0 if script trigger is sucessfully installed or uninstalled. In case of error the function returns negative error code.

Result

Function returns 0 if script trigger is sucessfully installed or uninstalled. In case of error the function returns negative error code.

Note

Each triggered script from plug-in receives script parameter which can be read by Get( ScriptParameter ) script step. The parameter contains the message which triggered the script. The message is read into the FileMaker using UTF-8 encoding.

Examples

Phone_SetScriptRawEvent( "^[Ff]ailed .*" ; "Handle Failed Call" )
Call the script "Handle Failed Call" when incoming message contains word Failed or failed on the start.

Phone_SetScriptRawEvent( "^[Dd]evice[Ii]nformation 34 .*" ; "Read Phone Information" )
The script "Read Phone Information" will be called every time something happens on phone with number 34.

Phone_SetScriptRawEvent( "" ; "Read Phone Information" )
The script "Read Phone Information" will not be triggered in the future. It will be removed from all pattern queues.

Phone_SetScriptRawEvent( "^[Ff]ailed .*" ; "" )
All scripts triggered by "^[Ff]ailed .*" regular expression will be removed from the queue. No such script will be called in the future.

Phone_Get ( what )

Function to get plug-in or phone server settings and other useful data.

Parameters

whatWhich data shoud be get.

Parameter values for what

"lastError" Returns the error code of the last error. If no error occured 0 is returned.
"lastErrorMessage" Returns the error message string of the last error. If no error occured "" is returned.
"serverStatus" Returs eiter "connected" or "disconnected".
"monitoredDevices" Returns a value list of the devices which are currently monitored for events. See functions Phone_SetScriptEvent and Phone_SetScriptRawEvent to see how to install the event handler script. The value list is delimited by line break.
"serverResponseTimeout" Default 3 s. How long Phone Companion waits for reply from the middleware.
"serverCommunicationDelay" If Phone Companion sends more than one message it waits very short time between each message. Use this parameter to obtain this value in seconds.

Description

Use this function to get important parameters.

Result

Function returns data if everything is OK. In case of error the function returns "?". You can use Phone_Get("lastError") for more detailed error description.

Examples

Phone_Get( "lastError" )
Returns the error code of the last command. For example -50.

Phone_Set ( what ; newValue )

Set plug-in or phone server settings and other useful parameters.

Parameters

whatWhich data shoud be get.
newValueThe new value for data.

Parameter values for what

"serverResponseTimeout" Sets how long Phone Companion waits for reply from TeamCall Server or Express. The time is in seconds and the default value is 3 s.
"serverCommunicationDelay" If Phone Companion sends more than one message it waits very short time between each message. The default value is 0.1 s. Use longer delays if the middleware is not able to react to fast communication.

Description

Use this function to set important parameters. Default communication delays and timeouts are set to work on local area networs. You can set longer values on slower networks (slow wireless networks) but the plug-in reactions will be also slower. Try to keep serverCommunicationDelay parameter as low as possible. Setting it too high (>1s) will essentially delay plug-in responses and probably will not help on broken link.

Result

Function returns the real value of parameter if everything is OK. In case of error the function returns "?". You can use Phone_Get("lastError") for more detailed error description.

Examples

Phone_Set( "serverResponseTimeout" ; 4.5 )
The plug-in will wait for each answer from TeamCall up to 4.5 seconds. This also means that FileMaker will frozen for 4.5 seconds if TeamCall does not respond - do not set it too high.

5. Error Codes Table

Here is the list of all error codes which can be returned from the plug-in. The error codes are derived from MacErrors.h header file from Mac OS. Plug-In's custom error codes are positive numbers in range between 2400 and 9999. If function fails it either returns "?" signaling error or it directly returns the error code. If it returns "?" you can use Phone_Get("lastError") to obtain the code.

CodeDescription
-4 Not implemented If you see this error please report the error and steps to reproduce it to 24U Support. This error should never be invoked in the release version of the plug-in.
2400 Unknown error An unknown error occurred. If you see this error please report the error and steps to reproduce it to 24U Support. We will try to identify error conditions and add the new error code to this list.
2450 Middleware Error Error on middleware communication occured. Read "lastErrorMessage" to get exact error string.