STS Asterisk Interface Library for Cocoa
A Cocoa Interface to the Asterisk Telephony Server
Licensing
The STS Asterisk Interface Library is licensed under the GNU General Public License (GPL) Version 2. For projects and software products for which the terms of the GPL license are not suitable, alternative licensing is available from Sunrise Telephone Systems Ltd. upon request.
Prerequisites
The STS Asterisk Interface Library will work with MacOS X version 10.3.x "Panther" and MacOS X version 10.4.x "Tiger". It uses Apple's Cocoa and Security Services frameworks and is best used in combination with the STS Template Engine but does not require any other frameworks or libraries. With a bit of effort it could be adapted to work with earlier versions of MacOS X or with GNUstep.
Release
The STS Asterisk Interface Library will be made available as Objective-C source code for download on this page once the development work has been completed. Until then parts of the library are available as a preview.
Preview
The STS Asterisk Interface Library is being developed by Sunrise Telephone Systems Ltd. in order to facilitate the development of Cocoa based configuration and management tools for the open source telephony server Asterisk using MacOS X's Aqua GUI natively. However, the interfaces have been designed so that the library can easily be adapted to GNUstep and thereby allow the development of Asterisk configuration and management tools on other operating systems, such as BSD, Linux, Solaris and Windows.
The library consists of five classes: AstPaths to read the default locations from Asterisk's master configuration file, AstAuth to obtain authorization for privileged operations required to control and configure Asterisk, AstControl to start, stop, reload and observe Asterisk, AstConfig to read and modify Asterisk's configuration files and AstDB to read and modify Asterisk's internal database. The classes are described in more detail further below.
Overview of Provided Classes
Class AstPaths
Provides an interface to read the Asterisk master configuration file at /etc/asterisk/asterisk.conf
which contains paths used by Asterisk.
- requires: Cocoa
- inherits from: NSObject
- defined in: AstPaths.h
Methods
+sharedAstPaths -astExecutable -astConfigDirectory -astModulesDirectory -astLibraryDirectory -astAGIscriptDirectory -astSpoolDirectory -astRunDirectory -astLogDirectory
Class AstAuth
Provides an interface to the security server to authorize privileged operations as required by classes AstControl, AstConfig and AstDB.
- requires: Cocoa, Security Services and AstPaths
- inherits from: NSObject
- defined in: AstAuth.h
Methods
+defaultAstAuth -authRef -authRights -lastStatus -isAuthorized -authorize -authorizeWithTimeout: -deauthorize
Class AstControl
Provides a Cocoa interface to obtain status information about and start, stop and reload Asterisk.
- requires: Cocoa, AstPaths and AstAuth
- inherits from: NSObject
- defined in: AstControl.h
Methods
+defaultAstControl -astExecutablePath -astPIDFilePath -authRef -setAuthRef: -versionString -isInstalled -isRunning -start -stop -reload -kill
Class AstConfig
Provides a Cocoa interface to read and modify configuration files of Asterisk.
- requires: Cocoa, AstPaths and AstAuth
- inherits from: NSObject
- defined in: AstConfig.h
Methods
+defaultAstConfig -astConfigPath -authRef -setAuthRef: -hasConfigurationFile: -arrayWithConfigurationFileNames -arrayWithIncludeReferencesInFile: -addFileWithContentsOfConfiglet:insertingIncludeReferenceIn: -appendConfiglet:toConfigurationFile: -removeConfigurationFile: -hasGlobalDeclaration: -addGlobalDeclaration: -removeGlobalDeclaration: -hasContextDeclared: -hasContextIncluded:inContextDeclaration: -addContextInclusion:inContextDeclaration: -removeContextInclusion:fromContextDeclaration: -hasExtensionDeclared:inFile: -arrayWithExtensionsInFile: -removeExtensionDeclaration:fromFile: -hasRegistrationOfUser:andHost:forProtocol: -addRegistration:forProtocol: -removeRegistrationOfUser:andHost:forProtocol:
Class AstDB
Provides a Cocoa interface to read and modify Asterisk's internal database.
Methods
+defaultAstDB -authRef -setAuthRef: -containsDictionary: -arrayWithNamesOfDictionaries -dictionaryWithEntriesInDictionary: -addEntriesFromDictionary:toDictionary: -keyExists:inDictionary: -arrayWithNamesOfKeysInDictionary: -valueForKey:inDictionary: -addKey:withValue:toDictionary: -removeKey:fromDictionary:
Detailed Descriptions
Please refer to the header files by clicking on their respective links.
Preview Downloads
Implementations of the following classes are available for download as a preview ...
Sample Code
// create and initialise an AstAuth object AstAuth *astAuth = [AstAuth defaultAstAuth]; // create and initialise an AstControl object AstControl *astControl = [AstControl defaultAstControl]; // create and initialise an AstConfig object AstConfig *astConfig = [AstConfig defaultAstConfig]; // pre-authorize for asterisk privileged operations [astAuth authorize]; // assign the authorization to the control object [astControl setAuthRef:[astAuth authRef]]; // start Asterisk [astControl start]; // write a configlet to the configuration directory [astConfig addFileWithContentsOfConfiglet:configString insertingIncludeReferenceIn:@"extensions.conf"]; // reload Asterisk [astControl reload];
Methodology
All software developed at Sunrise Telephone Systems Ltd is developed using VDM methodology informally. That is to say all software components are defined in terms of pre-conditions, post-conditions and error-conditions before the code is being finalised. Whilst we do not use VDM-SL to define formal semantics, we follow VDM principles and define semantics in plain English instead. Throughout the coding process, all code is verified against pre-, post-, error-conditions and the associated semantics on an ongoing basis.
About Sunrise
Please visit www.sunrisetel.net for more information.