SipConfigurationAPI

Version 66 (Anonymous, 06/28/2011 04:52 pm)

1 1 Adrian Georgescu
2 66 Adrian Georgescu
h1. Configuration API
3 1 Adrian Georgescu
4 1 Adrian Georgescu
5 66 Adrian Georgescu
6 66 Adrian Georgescu
7 66 Adrian Georgescu
The configuration API is used by the [[SipMiddlewareApi|Middleware API]] to store and read its settings. By managing the settings of the middleware through this configuration API one can create different applications that behave consistently and inherit the same settings. For example a command line client or a GUI program can read and write their settings through this API. In addition, the configuration API offers an extensibility framework, by which applications can add their specific settings which will be managed in the same way as the middleware settings. The settings are loaded and saved from/to persistent storage using a backend; a backend is provided which has a simple text file format.
8 66 Adrian Georgescu
9 1 Adrian Georgescu
The settings can be managed by API calls. The middleware settings have appropriate defaults so that it can function properly with a minimum amount of changes.
10 1 Adrian Georgescu
11 1 Adrian Georgescu
12 66 Adrian Georgescu
h2. Architecture
13 66 Adrian Georgescu
14 66 Adrian Georgescu
15 1 Adrian Georgescu
Configuration API consists of the low-level classes that can be used for storing and retrieving configuration objects. Moreover, it allows the creation of a higher level API for accessing configuration items. The SIP SIMPLE settings are defined using this API, however application-specific settings can also make use of it in order to define a consistent view of all the settings, by either extending the settings objects defined in the middleware or creating new settings objects.
16 1 Adrian Georgescu
17 66 Adrian Georgescu
The module *sipsimple.configuration* contains the main classes of the configuration API. These are:
18 1 Adrian Georgescu
19 66 Adrian Georgescu
* ConfigurationManager
20 66 Adrian Georgescu
* SettingsObject
21 66 Adrian Georgescu
* SettingsGroup
22 66 Adrian Georgescu
* Setting
23 66 Adrian Georgescu
* SettingsObjectExtension
24 1 Adrian Georgescu
25 33 Luci Stanescu
In addition, the exceptions which make up this package are:
26 33 Luci Stanescu
27 66 Adrian Georgescu
* ConfigurationError (base class for all other configuration errors)
28 66 Adrian Georgescu
* ObjectNotFoundError
29 1 Adrian Georgescu
30 66 Adrian Georgescu
The package *sipsimple.configuration.backend* contains the abstract interface for configuration backends, as well as concrete implementations of backends. This package is explained in more detail in [[SipConfigurationAPI#BackendAPI|Configuration Backend API]].
31 1 Adrian Georgescu
32 1 Adrian Georgescu
33 66 Adrian Georgescu
h3. ConfigurationManager
34 1 Adrian Georgescu
35 1 Adrian Georgescu
36 66 Adrian Georgescu
The central entity is the ConfigurationManager, which is used for storing and retrieving settings. Within the ConfigurationManager, settings can be represented in a hierarchical structure, where the root the of tree is the configuration _document_. This structure is represented using a dictionary, defined recursively as:
37 66 Adrian Georgescu
* the keys of the dictionary are unicode objects
38 66 Adrian Georgescu
* the values of the dictionary can be:
39 66 Adrian Georgescu
*** the None object (this represents a default value)
40 66 Adrian Georgescu
*** unicode objects
41 66 Adrian Georgescu
*** lists of unicode objects
42 66 Adrian Georgescu
*** dictionaries using this specification
43 66 Adrian Georgescu
An item in the dictionary with an unicode object or a list as the value is a single setting: the name of the item is the name of the setting. An item with a dictionary as the value is a group of settings: the name of the item is the name of the group. This dictionary representation is stored to a persistent storage and loaded using the configuration backend as explained in [[SipConfigurationAPI#ConfigurationBackendAPI|Configuration Backend API]]. Any backend which is able to store and load such data can be used. A simple [[SipConfigurationAPI#FileBackend|text file backend]] and a [[SipConfigurationAPI#MemoryBackend|volatile memory backend]] are provided. After configuration data is loaded from the backend, it is saved on the ConfigurationManager and can be managed using its methods; in order to save the data using the backend provided, the @save@ method needs to be called; any calls to @update@ or @delete@ will not ask the backend to store the data as well.
44 66 Adrian Georgescu
45 66 Adrian Georgescu
The ConfigurationManager class is a singleton to allow any part of the code to access it without the need to pass references. However, its *start* method needs to be called before it can be used. Once this is done, objects can be added, retrieved or deleted from the underlying storage; if using the [[SipMiddlewareApi#SIPApplication|SIPApplication]] class, its start method takes care of this passing as the backend the one it receives as an argument. The methods of ConfigurationManager are:
46 66 Adrian Georgescu
47 66 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
48 33 Luci Stanescu
 References to the ConfigurationManager instance can be obtained anytime without passing any arguments. However, it needs the manager needs to be started in order to be used, otherwise all methods will raise a RuntimeError.
49 66 Adrian Georgescu
*start*(_self_)
50 66 Adrian Georgescu
 The start method allows the ConfigurationManager instance to use the backend specified in @SIPApplication@ complying to the @Storage API@ for accessing the underlying storage. See [[SipConfigurationAPI#ConfigurationBackendAPI|Configuration Backend API]] for information on what the required interface for the passed object is. Raises a @ConfigurationBackendError@ if the backend cannot load the configuration data from persistent storage.
51 66 Adrian Georgescu
*update*(_self_, *group*, *name*, *data*)
52 66 Adrian Georgescu
 The partial @data@ which must be a dictionary as formerly defined corresponding to an object having the specified name under the specified group. If @group@ is @None@, the object will be saved top-level (its name will the a top-level key in the data dictionary). Note that changes will not be written to the underlying storage until the *save* method is called.
53 66 Adrian Georgescu
*delete*(_self_, *group*, *name*)
54 66 Adrian Georgescu
 If an object stored as @name@ exists in @group@, then it will be deleted. If @group@ is @None@, then the top-level object identified by @name@ will be deleted.
55 66 Adrian Georgescu
*get*(_self_, *group*, *name*)
56 66 Adrian Georgescu
 Retrieves the object stored with @name@ in @group@, if it exists. Otherwise, the method will raise an @ObjectNotFoundError@. If @group@ is @None@, the top-level object identified by @name@ will be retrieved.
57 66 Adrian Georgescu
*get_names*(_self_, *group*)
58 66 Adrian Georgescu
 Returns a list with all the names of the objects in @group@. Returns an empty list if the group does not exist.
59 66 Adrian Georgescu
*save*(_self_)
60 66 Adrian Georgescu
 Flushes the changes made to the configuration to the backend. This method must be called to ensure that all changes have been written to persistent storage. Raises a @ConfigurationBackendError@ if the backend cannot store the data to persistent storage. 
61 1 Adrian Georgescu
62 1 Adrian Georgescu
63 1 Adrian Georgescu
64 66 Adrian Georgescu
h3. SettingsObject
65 66 Adrian Georgescu
66 66 Adrian Georgescu
67 1 Adrian Georgescu
A SettingsObject is used to represent a hierarchy of settings, which are managed via the ConfigurationManager. There are two types of SettingsObject:
68 66 Adrian Georgescu
* SettingsObjects without an ID, i.e. there should be only one instance of this SettingsObject in an application. When a subclass fo SettingsObject lacks a @__id__@ attribute, that is, it doesn't have an ID it is automatically a @Singleton@. This also means that the object cannot be deleted. An example of such a SettingsObject is SIPSimpleSettings. These SettingsObjects are useful to represent global settings.
69 66 Adrian Georgescu
* SettingsObjects with an associated id. The instances are not necessarily persistent. New ones can be created and existing ones can be deleted. An example of such a SettingsObject is the Account. These SettingsObjects are useful to represent settings which apply to entities identifiable by a string id. The ID can be changed, which means these objects cannot be Singletons.
70 1 Adrian Georgescu
71 66 Adrian Georgescu
SettingsObjects can belong to a group, depending on whether the @__group__@ attribute was specified. If it wasn't, the data will be saved top-level using the id of the SettingsObject; otherwise, the data will be saved under the group specified using the id. It is recommended that SettingsObjects with instances per id be saved in a group, although this is not enforced. For example, the Account instances are saved in a group named *Accounts*.
72 1 Adrian Georgescu
73 66 Adrian Georgescu
When a SettingsObject is instantiated its contained settings are loaded from the configuration storage. If it is the first time a SettingsObject is created, the default values for the settings will apply. The SettingsObject will only be copied to storage when its *save* method is called. If a SetttingsObject is deleted (by calling its *delete* method) it can no longer be saved, al subsequent calls to *save* will do nothing.
74 1 Adrian Georgescu
75 1 Adrian Georgescu
76 66 Adrian Georgescu
h4. Defining a global SettingsObject
77 66 Adrian Georgescu
78 66 Adrian Georgescu
79 66 Adrian Georgescu
In order to define a global SettingsObject, the @__id__@ attribute must be defined on the class, while the @__group__@ attribute can be defined. The @__id__@ must not be used in any other SettingsObject which is stored in the same group (or globally if the @__group__@ attribute is missing). An example of defining a global SettingsObject:
80 66 Adrian Georgescu
<pre>
81 1 Adrian Georgescu
from sipsimple.configuration import SettingsObject
82 1 Adrian Georgescu
83 1 Adrian Georgescu
class SIPSimpleSettings(SettingsObject):
84 1 Adrian Georgescu
    __group__ = 'Global'
85 1 Adrian Georgescu
    __id__ = 'SIPSimple'
86 66 Adrian Georgescu
</pre>
87 1 Adrian Georgescu
88 66 Adrian Georgescu
The @__init__@ method must not accept any other argument except _self_. It will be called each time the settings are loaded from the storage, not only the first time the object is created.
89 1 Adrian Georgescu
90 1 Adrian Georgescu
91 33 Luci Stanescu
92 66 Adrian Georgescu
h4. Defining a per-id SettingsObject
93 66 Adrian Georgescu
94 66 Adrian Georgescu
95 66 Adrian Georgescu
In order to define a per-id SettingsObject, the @__group__@ attribute should be defined on the class, while the @__id__@ attribute must be left to None. When instantiating the resulting class, exactly one argument must be given, which represents the string id. Each class defined as a per-id SettingsObject should be allocated a different group from all the other SettingsObjects (including global ones), otherwise the keys under which the SettingsObjects are stored could overlap. An example of defining a per-id SettingsObject:
96 66 Adrian Georgescu
<pre>
97 33 Luci Stanescu
from sipsimple.configuration import SettingsObject
98 33 Luci Stanescu
99 1 Adrian Georgescu
class Account(SettingsObject):
100 33 Luci Stanescu
    __group__ = 'Accounts'
101 44 Adrian Georgescu
    def __init__(self, id):
102 1 Adrian Georgescu
        """Do something each time the Account is loaded"""
103 66 Adrian Georgescu
</pre>
104 65 Adrian Georgescu
105 66 Adrian Georgescu
The @__init__@ method must accept exactly one argument except _self_. It will be called each time the object is loaded from the storage, in addition to the first time the object is created. This allows the SettingsObject to be more than a simple collection of settings.
106 65 Adrian Georgescu
107 1 Adrian Georgescu
108 66 Adrian Georgescu
h4. methods
109 66 Adrian Georgescu
110 66 Adrian Georgescu
111 66 Adrian Georgescu
*save*(_self_)
112 65 Adrian Georgescu
 If the contained Settings of this SettingsObject have changed, the object will be saved to the persistent storage. A CFGSettingsObjectDidChange notification will be issued which contains the modified settings. If the save fails, a CFGManagerSaveFailed notification is issued in addition.
113 66 Adrian Georgescu
*delete*(_self_)
114 1 Adrian Georgescu
 This method can only be called on per-id SettingsObjects. It will delete the object from the persistent storage. All references to this SettingsObject must be removed.
115 1 Adrian Georgescu
116 1 Adrian Georgescu
117 66 Adrian Georgescu
h4. notifications
118 66 Adrian Georgescu
119 66 Adrian Georgescu
120 66 Adrian Georgescu
*CFGManagerSaveFailed*
121 33 Luci Stanescu
 This notification is sent when the save or delete method of a SettingsObject fail to save the data in the configuration manager storage backend. Attributes:
122 66 Adrian Georgescu
 
123 66 Adrian Georgescu
>+_modified_+:
124 66 Adrian Georgescu
125 66 Adrian Georgescu
 A dict instance which maps settings keys in their fully qualified form (attribute names seperated by '.', relative to the SettingsObject) to a ModifiedValue instance; the ModifiedValue instance contains two attributes: _old_ and _new_ which are set to the old and the new Setting's value respectively. If the object was never saved before, it will be None.
126 66 Adrian Georgescu
 
127 66 Adrian Georgescu
>+_exception_+:
128 66 Adrian Georgescu
129 57 Adrian Georgescu
 The exception object that was raised while attempting to save the data in the configuration manager.
130 66 Adrian Georgescu
 
131 66 Adrian Georgescu
>+_operation_+:
132 66 Adrian Georgescu
133 1 Adrian Georgescu
 Attempted opperation, one of 'save' or 'delete'.
134 66 Adrian Georgescu
 
135 66 Adrian Georgescu
>+_timestamp_+:
136 1 Adrian Georgescu
137 66 Adrian Georgescu
 A @datetime.datetime@ object representing the moment the notification was sent.
138 33 Luci Stanescu
139 66 Adrian Georgescu
*CFGSettingsObjectDidChange*
140 66 Adrian Georgescu
 This notification is sent when the save method of a SettingsObject is called and some settings were previously changed. It will not be sent the first time @save@ is called in an object. Attributes:
141 66 Adrian Georgescu
 
142 66 Adrian Georgescu
>+_modified_+:
143 66 Adrian Georgescu
144 66 Adrian Georgescu
 A dict instance which maps settings keys in their fully qualified form (attribute names seperated by '.', relative to the SettingsObject) to a ModifiedValue instance; the ModifiedValue instance contains two attributes: _old_ and _new_ which are set to the old and the new Setting's value respectively.
145 66 Adrian Georgescu
 
146 66 Adrian Georgescu
>+_timestamp_+:
147 66 Adrian Georgescu
148 66 Adrian Georgescu
 A @datetime.datetime@ object representing the moment the notification was sent.
149 66 Adrian Georgescu
150 66 Adrian Georgescu
*CFGSettingsObjectWasCreated*
151 33 Luci Stanescu
 This notification is sent after a SettingsObject representing a configuration entity was saved for the first time. This notification will not be sent for global SettingsObject objects because they are never created, they always exist. Attributes:
152 66 Adrian Georgescu
 
153 66 Adrian Georgescu
>+_timestamp_+:
154 1 Adrian Georgescu
155 66 Adrian Georgescu
 A @datetime.datetime@ object representing the moment the notification was sent.
156 33 Luci Stanescu
157 66 Adrian Georgescu
*CFGSettingsObjectWasActivated*
158 66 Adrian Georgescu
 For global SettingsObject objects this notification is sent after the single object instance is created. For dynamic ID SettingsObject objects, this notification is sent when the object has been loaded from the configuration manager (if the object existed) or the first time @save@ is called on a new object. Attributes:
159 66 Adrian Georgescu
 
160 66 Adrian Georgescu
>+_timestamp_+:
161 66 Adrian Georgescu
162 66 Adrian Georgescu
 A @datetime.datetime@ object representing the moment the notification was sent.
163 66 Adrian Georgescu
164 66 Adrian Georgescu
*CFGSettingsObjectWasDeleted*
165 33 Luci Stanescu
 This notification is sent after a SettingsObject has been deleted. Attributes:
166 66 Adrian Georgescu
 
167 66 Adrian Georgescu
>+_timestamp_+:
168 1 Adrian Georgescu
169 66 Adrian Georgescu
 A @datetime.datetime@ object representing the moment the notification was sent.
170 1 Adrian Georgescu
171 66 Adrian Georgescu
172 66 Adrian Georgescu
h3. Setting
173 66 Adrian Georgescu
174 66 Adrian Georgescu
175 1 Adrian Georgescu
The Setting descriptor is used to describe a setting in SettingsObjects. The following methods are part of the public API of it:
176 66 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *type*, *default*=@None@, *nillable*=@False@)
177 1 Adrian Georgescu
 Create a new Setting descriptor which represents a setting in all instances of a SettingsObject. The default value must be specified if the setting is not nillable. The type will be applied to the values which are set to this descriptor if the value is not already an instance of the type; it is not applied to the default value.
178 1 Adrian Georgescu
179 1 Adrian Georgescu
An example of using a setting:
180 66 Adrian Georgescu
<pre>
181 1 Adrian Georgescu
from sipsimple import __version__
182 1 Adrian Georgescu
from sipsimple.configuration import Setting, SettingsObject
183 1 Adrian Georgescu
184 1 Adrian Georgescu
class SIPSimpleSettings(SettingsObject):
185 33 Luci Stanescu
    __group__ = 'Global'
186 33 Luci Stanescu
    __id__ = 'SIPSimple'
187 1 Adrian Georgescu
188 1 Adrian Georgescu
    user_agent = Setting(type=str, default='sipsimple %s' % __version__)
189 66 Adrian Georgescu
</pre>
190 1 Adrian Georgescu
191 1 Adrian Georgescu
When a setting value is read from the configuration backend, the type is used to reconstruct the value from a unicode object, a list of unicode objects, or a dictionary containing unicode keys and values with any of these three types. Several built-in types are recognised and are handled automatically:
192 66 Adrian Georgescu
* bool: the unicode strings @u'yes'@, @u'true', {{{u'on'@ and @u'1'@ are considered to have the value @True@, while @u'no'@, @u'false'@, @u'off'@ and @u'0'@ are considered to have the value False; the comparison is done case insensitively; all other strings are considered invalid.
193 66 Adrian Georgescu
* int, long and basestring: the type is called using the value as an argument.
194 66 Adrian Georgescu
All other types are instantiated using an un-pickling like mechanism. The @__new__@ method is called without any arguments and @__setstate__@ is called on the object returned by @__new__@ using the value as the sole argument.
195 1 Adrian Georgescu
196 1 Adrian Georgescu
Saving a setting value is done similarly, according to type. The builtin types which are handled are the same:
197 66 Adrian Georgescu
* bool: the unicode objects @u'true'@ and @u'false@ are used depending on the value.
198 66 Adrian Georgescu
* int, long and basestring: @unicode@ is called with the value as the sole argument.
199 66 Adrian Georgescu
For all other types, the @__getstate__@ method is called which should return an appropriate value.
200 1 Adrian Georgescu
201 1 Adrian Georgescu
202 33 Luci Stanescu
203 66 Adrian Georgescu
h3. SettingsGroup
204 66 Adrian Georgescu
205 66 Adrian Georgescu
206 33 Luci Stanescu
A SettingsGroup allows settings to be structured hierarchically. Subclasses of SettingsGroup are containers for Settings and other SettingsGroups just as SettingsObjects are. In addition, the subclasses of SettingsGroup are descriptors and can be used as such to assign a SettingsGroup as a child of another SettingsGroup or a SettingsObject. An example usage containing Setting, SettingsGroup and SettingsObject:
207 66 Adrian Georgescu
<pre>
208 33 Luci Stanescu
from sipsimple import __version__
209 33 Luci Stanescu
from sipsimple.configuration import Setting, SettingsGroup, SettingsObject
210 33 Luci Stanescu
211 33 Luci Stanescu
class TLSSettings(SettingsGroup):
212 33 Luci Stanescu
    verify_server = Setting(type=bool, default=False)
213 33 Luci Stanescu
214 33 Luci Stanescu
class SIPSimpleSettings(SettingsObject):
215 33 Luci Stanescu
    __group__ = 'Global'
216 33 Luci Stanescu
    __id__ = 'SIPSimple'
217 33 Luci Stanescu
218 33 Luci Stanescu
    user_agent = Setting(type=str, default='sipsimple %s' % __version__)
219 33 Luci Stanescu
220 33 Luci Stanescu
    tls = TLSSettings
221 66 Adrian Georgescu
</pre>
222 33 Luci Stanescu
223 33 Luci Stanescu
224 66 Adrian Georgescu
h3. SettingsObjectExtension
225 66 Adrian Georgescu
226 66 Adrian Georgescu
227 33 Luci Stanescu
The SettingsObjectExtension allows an application to add or customize the settings of the middleware according to its needs. In order to add or replace settings/settings groups defined in another SettingsObject, SettingsObjectExtension can be subclassed and the register_extension class method of the original SettingsObject can be called passing the SettingObjectExtension subclass as the sole argument. In order to add/replace settings in a group of settings, the original SettingsGroup can be subclassed. Example:
228 66 Adrian Georgescu
<pre>
229 33 Luci Stanescu
from sipsimple import __version__
230 33 Luci Stanescu
from sipsimple.configuration import Setting, SettingsGroup, SettingsObject, SettingsObjectExtension
231 33 Luci Stanescu
232 33 Luci Stanescu
class TLSSettings(SettingsGroup):
233 33 Luci Stanescu
    verify_server = Setting(type=bool, default=False)
234 33 Luci Stanescu
235 1 Adrian Georgescu
class SIPSimpleSettings(SettingsObject):
236 60 Adrian Georgescu
    __group__ = 'Global'
237 35 Luci Stanescu
    __id__ = 'SIPSimple'
238 1 Adrian Georgescu
239 33 Luci Stanescu
    user_agent = Setting(type=str, default='sipsimple %s' % __version__)
240 22 Adrian Georgescu
241 27 Luci Stanescu
    tls = TLSSettings
242 48 Adrian Georgescu
243 22 Adrian Georgescu
class TLSSettingsExtension(TLSSettings):
244 4 Adrian Georgescu
    verify_client = Setting(type=bool, default=True)
245 22 Adrian Georgescu
246 1 Adrian Georgescu
class SIPSimpleSettingsExtension(SettingsObjectExtension):
247 23 Adrian Georgescu
    default_account = Setting(type=str, default=None, nillable=True)
248 1 Adrian Georgescu
249 17 Adrian Georgescu
    tls = TLSSettingsExtension
250 1 Adrian Georgescu
251 1 Adrian Georgescu
SIPSimpleSettings.register_extension(SIPSimpleSettingsExtension)
252 66 Adrian Georgescu
</pre>
253 1 Adrian Georgescu
254 1 Adrian Georgescu
255 66 Adrian Georgescu
h3. Backend API
256 1 Adrian Georgescu
257 66 Adrian Georgescu
258 66 Adrian Georgescu
The backend API provides a way to use the configuration framework consistently, while using any system for storing the data persistently. The ConfigurationManager makes use of a backend whenever it needs to write/read something to the persistent storage. The backend only needs to know how to handle data in the dictionary format explained in [[SipConfigurationAPI#ConfigurationManager|Configuration Manager]]. In order to use a specific backend, it is given to the ConfigurationManager in its start method.
259 66 Adrian Georgescu
260 66 Adrian Georgescu
The interface *sipsimple.configuration.backend.IBackend* describes the backend:
261 66 Adrian Georgescu
*load*()
262 66 Adrian Georgescu
 Load the configuration data using whatever means employed by the backend implementation and return a dictionary conforming to the definition in [[SipConfigurationAPI#ConfigurationManager|Configuration Manager]].
263 66 Adrian Georgescu
*save*(*data*)
264 1 Adrian Georgescu
 Given a dictionary conforming to the definition in this interface, save the data using whatever means employed by the backend implementation.
265 1 Adrian Georgescu
266 1 Adrian Georgescu
267 1 Adrian Georgescu
268 66 Adrian Georgescu
h4. FileBackend
269 1 Adrian Georgescu
270 66 Adrian Georgescu
271 66 Adrian Georgescu
A concrete implementation of the *IBackend* interface resides in *sipsimple.configuration.backend.file.FileBackend*. The methods different from the ones in *IBackend* are:
272 66 Adrian Georgescu
273 66 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *filename*, *encoding*=@'utf-8'@)
274 48 Adrian Georgescu
 Create a new FileBackend which uses the specified filename for loading and storing the data to; the data is written using the specified encoding, defaulting to UTF-8.
275 17 Adrian Georgescu
276 1 Adrian Georgescu
This object saves the data using a simple text file format with the following syntax:
277 66 Adrian Georgescu
* SettingGroups, SettingsObjects or Groups of SettingsObjects are represented by their name (or id in the case of SettingsObjects) followed by a colon (*:*). These containers can contain other such containers or simple settings. Their children need to be indented more that the container itself. The indentation need not be consistent.
278 66 Adrian Georgescu
 <pre>
279 1 Adrian Georgescu
 Accounts:
280 1 Adrian Georgescu
    user@domain:
281 1 Adrian Georgescu
      display_name = User
282 1 Adrian Georgescu
      tls:
283 1 Adrian Georgescu
        certificate =
284 66 Adrian Georgescu
</pre>
285 66 Adrian Georgescu
* Simple settings are represented by a name followed by an equals sign and the value; whitespace anywhere in between is ignored. The different values are represented in the following way:
286 66 Adrian Georgescu
** None is represented by the absence of a value.
287 66 Adrian Georgescu
  <pre>
288 1 Adrian Georgescu
    setting =
289 66 Adrian Georgescu
</pre>
290 66 Adrian Georgescu
** Unicode objects are represented by a simple string (which can be quoted to include leading and trailing whitespace by either single or double quotes) and can have the following espace sequances: *\' *, *\"*, *\n*, *\r*. The unicode characters are encoded using the encoding specified in the constructor.
291 66 Adrian Georgescu
  <pre>
292 1 Adrian Georgescu
    setting1 = value
293 1 Adrian Georgescu
    setting2 = value with spaces
294 1 Adrian Georgescu
    setting3 = "  value with leading and trailing spaces  "
295 1 Adrian Georgescu
    setting4 = value with a line feed\n
296 66 Adrian Georgescu
</pre>
297 66 Adrian Georgescu
** Lists are represented by unicode strings as described above separated by commas (*,*). Any not-quoted whitespace around the comma is ignored.
298 66 Adrian Georgescu
  <pre>
299 1 Adrian Georgescu
    setting = a, b  , c
300 66 Adrian Georgescu
</pre>
301 66 Adrian Georgescu
** Complex settings can be represented just like a group:
302 66 Adrian Georgescu
  <pre>
303 1 Adrian Georgescu
    complex_setting:
304 1 Adrian Georgescu
      field1 = value
305 1 Adrian Georgescu
      field2 = 123
306 66 Adrian Georgescu
</pre>
307 1 Adrian Georgescu
  
308 1 Adrian Georgescu
309 66 Adrian Georgescu
h4. MemoryBackend
310 22 Adrian Georgescu
311 48 Adrian Georgescu
312 66 Adrian Georgescu
A concrete implementation of the *IBackend* interface resides in *sipsimple.configuration.backend.memory.MemoryBackend*.
313 1 Adrian Georgescu
314 48 Adrian Georgescu
315 1 Adrian Georgescu
316 66 Adrian Georgescu
h2. Middleware Settings
317 48 Adrian Georgescu
318 66 Adrian Georgescu
319 66 Adrian Georgescu
These are the current settings, kept in the modules *sipsimple.configuration.settings* and *sipsimple.account*. The main classes used to access the settings are Account, BonjourAccount and SIPSimpleSettings. All settings can be accessed as simple attributes. The types of attributes is described for each setting below. When setting the value of an attribute, if it's not of the required type, it will be given to the specified type as the only argument. The modified settings are not saved to the persistent storage until the *save* method is called on the main object. Once this is done, a CFGSettingsObjectDidChange notification is sent, the data of which is explained in [[SipConfigurationAPI#SettingsObjectNotifications|SettingsObject Notifications]].
320 66 Adrian Georgescu
321 66 Adrian Georgescu
Only a nillable setting can be assigned the value @None@, even if the type of the setting would otherwise accept @None@ as an argument. The settings as described below are _not_ nillable, unless specified explicitely. To reset the value of a setting, the special object @sipsimple.configuration.DefaultValue@ can be assigned to it. If a default value is not explicitely specified below, it defaults to @None@. Note that a non-nillable setting cannot have the default value of @None@.
322 66 Adrian Georgescu
323 66 Adrian Georgescu
324 66 Adrian Georgescu
h3. General
325 66 Adrian Georgescu
326 66 Adrian Georgescu
327 66 Adrian Georgescu
<pre>
328 1 Adrian Georgescu
SIP SIMPLE settings:
329 1 Adrian Georgescu
             +-- default_account = user@example.com
330 1 Adrian Georgescu
SIP SIMPLE --|-- user_agent = sipsimple 0.16.2
331 1 Adrian Georgescu
             |-- audio
332 23 Adrian Georgescu
             |-- chat
333 1 Adrian Georgescu
             |-- desktop_sharing
334 1 Adrian Georgescu
             |-- file_transfer
335 33 Luci Stanescu
             |-- logs
336 28 Luci Stanescu
             |-- rtp
337 48 Adrian Georgescu
             |-- sip
338 48 Adrian Georgescu
             |-- sounds
339 48 Adrian Georgescu
             +-- tls
340 43 Adrian Georgescu
341 48 Adrian Georgescu
        +-- alert_device = system_default
342 8 Adrian Georgescu
audio --|-- input_device = system_default                   
343 1 Adrian Georgescu
        |-- output_device = system_default
344 28 Luci Stanescu
        |-- sample_rate = 44100
345 1 Adrian Georgescu
        |-- silent = False
346 27 Luci Stanescu
        +-- tail_length = 0
347 33 Luci Stanescu
348 27 Luci Stanescu
       +
349 1 Adrian Georgescu
chat --|
350 27 Luci Stanescu
       +
351 31 Luci Stanescu
352 27 Luci Stanescu
                  +
353 27 Luci Stanescu
desktop_sharing --|
354 53 Adrian Georgescu
                  +
355 27 Luci Stanescu
356 48 Adrian Georgescu
                +
357 27 Luci Stanescu
file_transfer --|
358 1 Adrian Georgescu
                +
359 1 Adrian Georgescu
360 1 Adrian Georgescu
logs --|-- pjsip_level = 5
361 1 Adrian Georgescu
362 27 Luci Stanescu
      +-- audio_codec_list = AudioCodecList(['G722', 'PCMU', 'GSM', 'speex', 'PCMA'])
363 33 Luci Stanescu
rtp --|-- port_range = PortRange(start=50000, end=50500)
364 1 Adrian Georgescu
      +-- timeout = 30
365 1 Adrian Georgescu
366 29 Luci Stanescu
      +-- invite_timeout = 90
367 1 Adrian Georgescu
sip --|-- tcp_port = 0
368 1 Adrian Georgescu
      |-- tls_port = 0
369 29 Luci Stanescu
      |-- transport_list = SIPTransportList(['tls', 'tcp', 'udp'])
370 1 Adrian Georgescu
      +-- udp_port = 0
371 1 Adrian Georgescu
372 1 Adrian Georgescu
      +-- ca_list = None
373 1 Adrian Georgescu
tls --|-- protocol = TLSv1
374 1 Adrian Georgescu
      +-- timeout = 3000
375 1 Adrian Georgescu
376 1 Adrian Georgescu
377 66 Adrian Georgescu
</pre>
378 1 Adrian Georgescu
379 66 Adrian Georgescu
The @sipsimple.configuration.settings.SIPSimpleSettings@ class is a singleton can be instantiated and used anywhere after the [[SipConfigurationAPI#ConfigurationManager|ConfigurationManager]] has been started. 
380 1 Adrian Georgescu
381 1 Adrian Georgescu
The settings are explained below:
382 1 Adrian Georgescu
383 66 Adrian Georgescu
*SIPSimpleSettings.default_account* (type=@str@, default=@'bonjour@local'@, nillable=@True@)
384 66 Adrian Georgescu
>A string, which contains the id of the default Account. This setting is managed by the AccountManager and should not be changed manually. See [[SipMiddlewareApi#AccountManager|AccountManager]] for more information.
385 1 Adrian Georgescu
386 66 Adrian Georgescu
*SIPSimpleSettings.user_agent* (type=@str@, default=@'sipsimple VERSION'@)
387 66 Adrian Georgescu
>This setting will be used to set the value of the User-Agent header in outgoing SIP requests and of the Server header in all SIP responses.
388 1 Adrian Georgescu
389 1 Adrian Georgescu
390 66 Adrian Georgescu
h4. Audio
391 1 Adrian Georgescu
392 1 Adrian Georgescu
393 66 Adrian Georgescu
*SIPSimpleSettings.audio.alert_device* (type=@AudioOutputDevice@, default=@'system_default'@, nillable=@True@)
394 66 Adrian Georgescu
>The name of the alert device, which can be used for alerting the user. If it is set to @'system_default'@, one will be selected automatically by the operating system; if it is set to @None@, a dummy device will be used which will discard any audio data. This device is not used by the middleware but is provided for consistency.
395 1 Adrian Georgescu
396 66 Adrian Georgescu
*SIPSimpleSettings.audio.input_device* (type=@AudioInputDevice@, default=@'system_default'@, nillable=@True@)
397 66 Adrian Georgescu
>The name of the audio device, which will be used for input (recording). If it is set to @'system_default'@, one will be selected automatically by the operating system; if it is set to @None@, a dummy device will be used which doesn't record anything.
398 1 Adrian Georgescu
399 66 Adrian Georgescu
*SIPSimpleSettings.audio.output_device* (type=@AudioOutputDevice@, default=@'system_default'@, nillable=@True@)
400 66 Adrian Georgescu
>The name of the audio device, which will be used for output (playback). If it is set to @'system_default'}}, one will be selected automatically by the operating system; if it is set to {{{None@, a dummy device will be used which will discard any audio data.
401 66 Adrian Georgescu
402 66 Adrian Georgescu
*SIPSimpleSettings.audio.tail_length* (type=@NonNegativeInteger@, default=@200@)
403 66 Adrian Georgescu
>This setting is used as a parameter for the audio echo cancellation algorithm. It's value is a non-negative integer which represents milliseconds. It specifies the length of the echo cancellation filter.
404 66 Adrian Georgescu
405 66 Adrian Georgescu
*SIPSimpleSettings.audio.sample_rate* (type=@SampleRate@, default=@44100@)
406 66 Adrian Georgescu
>This is the sample rate at which the audio system runs, in Hz. All playback and recording will be done at this rate. If an audio codec has a smaller or larger sample rate, it will be resampled to this value (if possible). Example values include 8000, 32000, 44100 etc.
407 1 Adrian Georgescu
 
408 66 Adrian Georgescu
*SIPSimpleSettings.audio.silent* (type=@bool@, default=@False@)
409 66 Adrian Georgescu
>If this setting is set to True, no audio notifications will be played on the alert device (the volume of the alert device will be set to 0).
410 1 Adrian Georgescu
411 1 Adrian Georgescu
412 66 Adrian Georgescu
h4. Chat
413 66 Adrian Georgescu
414 66 Adrian Georgescu
415 1 Adrian Georgescu
Empty section for future use.
416 1 Adrian Georgescu
417 1 Adrian Georgescu
418 66 Adrian Georgescu
h4. Desktop Sharing
419 66 Adrian Georgescu
420 66 Adrian Georgescu
421 1 Adrian Georgescu
Empty section for future use.
422 1 Adrian Georgescu
423 1 Adrian Georgescu
424 66 Adrian Georgescu
h4. File Transfer
425 66 Adrian Georgescu
426 66 Adrian Georgescu
427 1 Adrian Georgescu
Empty section for future use.
428 1 Adrian Georgescu
429 1 Adrian Georgescu
430 66 Adrian Georgescu
h4. Logs
431 1 Adrian Georgescu
432 1 Adrian Georgescu
433 66 Adrian Georgescu
*SIPSimpleSettings.logs.pjsip_level* (type=@NonNegativeInteger@, default=@5@)
434 66 Adrian Georgescu
>This setting controls the amount of log messages generated by the PJSIP core. It must be set to a non-negative integer.
435 1 Adrian Georgescu
436 1 Adrian Georgescu
437 66 Adrian Georgescu
h4. RTP
438 1 Adrian Georgescu
439 1 Adrian Georgescu
440 66 Adrian Georgescu
*SIPSimpleSettings.rtp.port_range* (type=@PortRange@, default=@PortRange(50000, 50500)@)
441 66 Adrian Georgescu
>This setting controls the port range from which ports used by RTP transport will be assigned. The values of the ports need to be in the range 1-65535; the start port must not be larger than the end port.
442 45 Luci Stanescu
443 66 Adrian Georgescu
*SIPSimpleSettings.rtp.audio_codec_list* (type=@AudioCodecLis}t}}, default={{{AudioCodecList(('G722', 'speex', 'PCMU', 'PCMA'))@)
444 66 Adrian Georgescu
>This setting is used to specify the preferred audio codecs, which should be used for audio calls. It must contain only strings, which represent the supported codecs (speex, G722, PCMA, PCMU, iLBC and GSM), in the order in which they are preferred. This setting can be overridden per account.
445 45 Luci Stanescu
446 66 Adrian Georgescu
*SIPSimpleSettings.rtp.timeout* (type=@NonNegativeInteger}t}}, default={{{30))@)
447 66 Adrian Georgescu
>This setting is used to specify the time after which a notification is raised should no RTP be received from the other end. It can be used by an application to decide to terminate the session or print an alert.
448 48 Adrian Georgescu
449 48 Adrian Georgescu
450 66 Adrian Georgescu
h4. SIP
451 48 Adrian Georgescu
452 48 Adrian Georgescu
453 66 Adrian Georgescu
*SIPSimpleSettings.sip.invite_timeout* (type=@NonNegativeInteger@, default=@90@)
454 66 Adrian Georgescu
>This setting is used to terminate an outgoing session request in progress that does not receive a final answer before this internal in seconds is reached.
455 66 Adrian Georgescu
456 66 Adrian Georgescu
*SIPSimpleSettings.sip.udp_port* (type=@Port@, default=@0@)
457 66 Adrian Georgescu
>This is the port on which the Engine will bind and for for sending and receiving UDP packets. It is an integer in the range 0-65535. If it is set to 0, it will be allocated automatically.
458 66 Adrian Georgescu
459 66 Adrian Georgescu
*SIPSimpleSettings.sip.tcp_port* (type=@Port@, default=@0@)
460 66 Adrian Georgescu
>This is the port on which the Engine will listen for TCP connections. It is an integer in the range 0-65535. If it is set to 0, it will be allocated automatically.
461 66 Adrian Georgescu
462 66 Adrian Georgescu
*SIPSimpleSettings.sip.tls_port* (type=@Port@, default=@0@)
463 66 Adrian Georgescu
>This is the port on which the Engine will listen for TLS connections. It is an integer in the range 0-65535. If it is set to 0, it will be allocated automatically. The port must be different than the port used for TCP connections.
464 66 Adrian Georgescu
465 66 Adrian Georgescu
*SIPSimpleSettings.sip.transport_list* (type=@SIPTransportList@, default=@SIPTransportList(('tls', 'tcp', 'udp'))@)
466 66 Adrian Georgescu
>This setting's value is a tuple, which can only contain the strings 'tls', 'tcp' and 'udp'. It has a double purpose:
467 66 Adrian Georgescu
*** Only the transports specified here are used to SIP requests associated with normal accounts.
468 66 Adrian Georgescu
*** The order of the transports specified in this tuple represent the preferred order in which transports should be used. This applies to all SIP requests.
469 66 Adrian Georgescu
470 66 Adrian Georgescu
471 66 Adrian Georgescu
h4. TLS
472 66 Adrian Georgescu
473 66 Adrian Georgescu
474 66 Adrian Georgescu
*SIPSimpleSettings.tls.ca_list* (type=@Path@, default=@None@, nillable=@True@)
475 66 Adrian Georgescu
>The settings points to a file which contains the CA certificates. In can be @None@, in which case no CAs are available. It is interpreted as an absolute path, with a leading _~_ expanded to the home directory of the current user. In order to access the full path to the CA file, the normalized attribute on the setting can be used:
476 66 Adrian Georgescu
  <pre>
477 1 Adrian Georgescu
  SIPSimpleSettings().tls.ca_list.normalized
478 66 Adrian Georgescu
</pre>
479 1 Adrian Georgescu
480 66 Adrian Georgescu
*SIPSimpleSettings.tls.protocol* (type=@TLSProtocol@, default=@'TLSv1'@)
481 66 Adrian Georgescu
>This setting sets the version of the TLS protocol which will be used. It is a string and must be one of @'TLSv1'@.
482 1 Adrian Georgescu
483 66 Adrian Georgescu
*SIPSimpleSettings.tls.timeout* (type=@NonNegativeInteger@, default=@3000@)
484 66 Adrian Georgescu
>This is the timeout for negotiating TLS connections, in milliseconds. It must be an non-negative integer.
485 1 Adrian Georgescu
486 1 Adrian Georgescu
487 66 Adrian Georgescu
h3. Account
488 66 Adrian Georgescu
489 66 Adrian Georgescu
490 66 Adrian Georgescu
<pre>
491 1 Adrian Georgescu
Account user@example.com:
492 1 Adrian Georgescu
          +-- display_name = Example User
493 1 Adrian Georgescu
account --|-- enabled = True
494 1 Adrian Georgescu
          |-- auth
495 1 Adrian Georgescu
          |-- dialog_event
496 1 Adrian Georgescu
          |-- message_summary
497 1 Adrian Georgescu
          |-- msrp
498 1 Adrian Georgescu
          |-- nat_traversal
499 1 Adrian Georgescu
          |-- presence
500 1 Adrian Georgescu
          |-- rtp
501 1 Adrian Georgescu
          |-- sip
502 1 Adrian Georgescu
          |-- tls
503 1 Adrian Georgescu
          +-- xcap
504 1 Adrian Georgescu
505 1 Adrian Georgescu
       +-- password = xyz
506 1 Adrian Georgescu
auth --|-- username = None
507 1 Adrian Georgescu
       +
508 1 Adrian Georgescu
509 1 Adrian Georgescu
               +-- enabled = True
510 1 Adrian Georgescu
dialog_event --|
511 1 Adrian Georgescu
               +
512 1 Adrian Georgescu
513 1 Adrian Georgescu
                  +-- enabled = True
514 1 Adrian Georgescu
message_summary --|-- voicemail_uri = None
515 1 Adrian Georgescu
                  +
516 1 Adrian Georgescu
517 1 Adrian Georgescu
       +-- connection_model = relay
518 1 Adrian Georgescu
msrp --|-- transport = tls
519 1 Adrian Georgescu
       +
520 1 Adrian Georgescu
521 1 Adrian Georgescu
                +-- msrp_relay = None
522 1 Adrian Georgescu
nat_traversal --|-- stun_server_list = None
523 1 Adrian Georgescu
                |-- use_ice = False
524 1 Adrian Georgescu
                |-- use_msrp_relay_for_inbound = True
525 1 Adrian Georgescu
                +-- use_msrp_relay_for_outbound = False
526 1 Adrian Georgescu
527 1 Adrian Georgescu
           +-- enabled = True
528 1 Adrian Georgescu
presence --|-- use_rls = True
529 1 Adrian Georgescu
           +
530 1 Adrian Georgescu
531 1 Adrian Georgescu
      +-- audio_codec_list = None
532 1 Adrian Georgescu
rtp --|-- inband_dtmf = False
533 1 Adrian Georgescu
      |-- srtp_encryption = optional
534 1 Adrian Georgescu
      +-- use_srtp_without_tls = False
535 1 Adrian Georgescu
536 1 Adrian Georgescu
      +-- always_use_my_proxy = False
537 1 Adrian Georgescu
sip --|-- outbound_proxy = SIPProxyAddress('sip.example.com', port=5060, transport='udp')
538 1 Adrian Georgescu
      |-- publish_interval = 3600
539 1 Adrian Georgescu
      |-- register = True
540 1 Adrian Georgescu
      |-- register_interval = 3600
541 1 Adrian Georgescu
      +-- subscribe_interval = 3600
542 1 Adrian Georgescu
543 1 Adrian Georgescu
      +-- certificate = tls/user@example.com.crt
544 1 Adrian Georgescu
tls --|-- verify_server = False
545 1 Adrian Georgescu
      +
546 30 Luci Stanescu
547 1 Adrian Georgescu
       +-- enabled = True
548 1 Adrian Georgescu
xcap --|-- xcap_root = None
549 1 Adrian Georgescu
       +
550 66 Adrian Georgescu
</pre>
551 1 Adrian Georgescu
552 66 Adrian Georgescu
The Account object is used to represent a normal SIP account registered at a SIP provider. It is uniquely identifiable by it's SIP ID, in the form _user@domain_. There is exactly one instance of Account per ID, which means that an Account can be accessed by instantianting it anywhere. However, this is not the recommended way of accessing accounts, since it can lead to creating new accounts. The recommended way is by using the [[SipMiddlewareApi#AccountManager|AccountManager]]. Information about the roles of Account, apart from being a collection of settings, is explained in the [[SipMiddlewareApi#Account|Middleware API]]. 
553 30 Luci Stanescu
554 30 Luci Stanescu
The settings that can be accessed on an Account are described below:
555 33 Luci Stanescu
556 66 Adrian Georgescu
*Account.id* (type=@SIPAddress@)
557 66 Adrian Georgescu
>Its type is a subclass of @str@, so it can be used as a normal string, however it also has two attributes @username@ and @domain@ which point to the specific parts of the SIP address.
558 1 Adrian Georgescu
559 66 Adrian Georgescu
*Account.display_name* (type=@unicode@, default=@None@, nillable=@True@)
560 66 Adrian Georgescu
>The contents of this setting will be sent as part of the _From_ header when sending SIP requests, the _From_ CPIM header and other similar information.
561 30 Luci Stanescu
562 66 Adrian Georgescu
*Account.enabled* (type=@bool@, default=@False@)
563 66 Adrian Georgescu
>If this setting is set to @True@, the Account will automatically activate and can be used in other parts of the middleware. More about this is described in [[SipMiddlewareApi#Account|Account]].
564 30 Luci Stanescu
565 1 Adrian Georgescu
566 66 Adrian Georgescu
h4. Auth
567 1 Adrian Georgescu
568 1 Adrian Georgescu
569 66 Adrian Georgescu
*Account.auth.username* (type=@str@, default=@None@, nillable=@True@)
570 66 Adrian Georgescu
>The username used for authentication if it is different from the one in the SIP ID of the account. If it is @None@ or an empty string, the account SIP ID username will be used instead.
571 1 Adrian Georgescu
572 66 Adrian Georgescu
*Account.auth.password* (type=@str@, default=@''@)
573 66 Adrian Georgescu
>The password, which will be used with this account for authentication.
574 1 Adrian Georgescu
575 51 Adrian Georgescu
576 51 Adrian Georgescu
577 66 Adrian Georgescu
h4. Dialog Event
578 1 Adrian Georgescu
579 30 Luci Stanescu
580 66 Adrian Georgescu
*Account.dialog_event.enabled* (type=@bool@, default=@True@)
581 66 Adrian Georgescu
>If this setting is set to @True@, the Account will subscribe to the _dialog_ event as specified by RFC4235.
582 1 Adrian Georgescu
583 1 Adrian Georgescu
584 66 Adrian Georgescu
h4. MSRP
585 48 Adrian Georgescu
586 31 Luci Stanescu
587 66 Adrian Georgescu
*Account.msrp.transport* (type=@MSRPTransport@, default=@'tls'@)
588 66 Adrian Georgescu
>MSRP can use either TLS or TCP and this setting controls which one should be used for normal accounts.
589 31 Luci Stanescu
590 66 Adrian Georgescu
*Account.msrp.connection_model* (type=@MSRPConnectionModel@, default=@'relay'@)
591 66 Adrian Georgescu
>Whether @relay@ or @acm@ connection models shall be used for NAT traversal purposes.
592 31 Luci Stanescu
593 31 Luci Stanescu
594 33 Luci Stanescu
595 66 Adrian Georgescu
h4. Message Summary
596 1 Adrian Georgescu
597 31 Luci Stanescu
598 66 Adrian Georgescu
*Account.message_summary.enabled* (type=@bool@, default=@True@)
599 66 Adrian Georgescu
>If this setting is set to @True@, the Account will subscribe to the _message-summary_ event, as specified by RFC3842.
600 31 Luci Stanescu
601 66 Adrian Georgescu
*Account.message_summary.voicemail_uri* (type=@str@, default=@None@, nillable=@True@)
602 66 Adrian Georgescu
>This is the SIP URI where the Subscribe is sent and where the user can call to listen to the voicemail messages.
603 31 Luci Stanescu
604 31 Luci Stanescu
605 66 Adrian Georgescu
h4. NAT Traversal
606 31 Luci Stanescu
607 31 Luci Stanescu
608 66 Adrian Georgescu
*Account.nat_traversal.use_ice* (type=@bool@, default=@False@)
609 66 Adrian Georgescu
>If this setting is set to @True@, ICE will be used for finding media candidates for communication over NAT-ed networks.
610 31 Luci Stanescu
611 66 Adrian Georgescu
*Account.nat_traversal.stun_server_list* (type=@StunServerAddressList@, default=@None@, nillable=@True@)
612 66 Adrian Georgescu
>This setting used for NAT traversal can be used to specify the addresses of the STUN servers used for detecting server reflexive candidates in the context of ICE. The value of the setting is a tuple of objects of type @StunServerAddress@. If None, the servers will be looked up in the DNS (SRV record _stun._udp.domain).
613 1 Adrian Georgescu
614 66 Adrian Georgescu
*Account.nat_traversal.msrp_relay* (type=@MSRPRelayAddress@, default=@None@, nillable=@True@)
615 66 Adrian Georgescu
>This setting can be used to specify a MSRP relay for use in MSRP connections. If it is set to @None@. If None, the servers will be looked up in the DNS (SRV record _msrps._tcp.domain).
616 1 Adrian Georgescu
617 66 Adrian Georgescu
*Account.nat_traversal.use_msrp_relay_for_inbound* (type=@bool@, default=@True@)
618 66 Adrian Georgescu
>If this setting is set to @True@, the MSRP relay will be used for all incoming MSRP connections.
619 1 Adrian Georgescu
620 66 Adrian Georgescu
*Account.nat_traversal.use_msrp_relay_for_outbound* (type=@bool@, default=@False@)
621 66 Adrian Georgescu
>If this setting is set to @True@, the MSRP relay will be used for all outgoing MSRP connections.
622 1 Adrian Georgescu
623 34 Luci Stanescu
624 66 Adrian Georgescu
h4. Presence
625 34 Luci Stanescu
626 34 Luci Stanescu
627 66 Adrian Georgescu
*Account.presence.enabled* (type=@bool@, default=@True@)
628 66 Adrian Georgescu
>If this setting is set to @True@, the Account will publish its presence state and subscribe to presence and presence.winfo Event packages.
629 1 Adrian Georgescu
630 66 Adrian Georgescu
*Account.presence.use_rls* (type=@bool@, default=@False@)
631 66 Adrian Georgescu
>If this setting is set to @True@, the Account will store its Buddy Lists in *rls-services* XCAP document  and send a single Subscribe for the _presence_ event to the RLS services address to obtain the presence information for its buddies. If it is set to @False@, it will subscribe to each buddy individually.
632 1 Adrian Georgescu
633 30 Luci Stanescu
634 66 Adrian Georgescu
h4. RTP
635 66 Adrian Georgescu
636 66 Adrian Georgescu
637 66 Adrian Georgescu
*Account.rtp.audio_codecs* (type=@AudioCodecList@, default=@None@, nillable=@True@)
638 66 Adrian Georgescu
>This setting is used to specify the preferred audio codecs, which should be used for audio calls of this account. It must be a tuple containing only strings, which represent the supported codecs (speex, g722, g711, ilbc and gsm), in the order in which they are preferred, or @None@ if the codec_list from the general rtp settings is to be used.
639 66 Adrian Georgescu
640 66 Adrian Georgescu
*Account.audio.srtp_encryption* (type=@SRTPEncryption@, default=@'optional'@)
641 66 Adrian Georgescu
>The value of this setting specifies how the account requires the calls to be encrypted using SRTP. It can be one of the values @'disabled'@, @'optional'@ or @'mandatory'@.
642 66 Adrian Georgescu
643 66 Adrian Georgescu
*Account.audio.use_srtp_without_tls* (type=@bool@, default=@False@)
644 66 Adrian Georgescu
>If this setting is set to @True@, SRTP could be used even if the SIP signaling used to control the call is not over TLS.
645 66 Adrian Georgescu
646 66 Adrian Georgescu
647 66 Adrian Georgescu
648 66 Adrian Georgescu
h4. SIP
649 66 Adrian Georgescu
650 66 Adrian Georgescu
651 66 Adrian Georgescu
*Account.sip.always_use_my_proxy* (type=@bool@, default=@False@)
652 66 Adrian Georgescu
>If this setting is set to @True@ and the outbound proxy is not set, the signalling for outbound requests going to foreign domains will be sent to the account proxy instead of sending it to the foreign proxy.
653 66 Adrian Georgescu
654 66 Adrian Georgescu
*Account.sip.outbound_proxy* (type=@SIPProxyAddress@, default=@None@, nillable=@True@)
655 66 Adrian Georgescu
>This setting specifies whether to send all SIP requests when creating a new SIP dialog to a specific proxy. If this setting is set to @None@, then an RFC3263 lookup will be done based on the domain part of the SIP request URI.
656 66 Adrian Georgescu
657 66 Adrian Georgescu
*Account.sip.register* (type=@bool@, default=@True@)
658 66 Adrian Georgescu
>If this setting is set to @True@, the Account will automatically register when it is active. More about this is described in [[SipMiddlewareApi#Account|Account]].
659 66 Adrian Georgescu
660 66 Adrian Georgescu
*Account.sip.publish_interval* (type=@NonNegativeInteger@, default=@3600@)
661 66 Adrian Georgescu
>This setting controls the number of seconds used for the _Expire_ header when publishing events. It must be a non-negative integer.
662 66 Adrian Georgescu
663 66 Adrian Georgescu
*Account.sip.subscribe_interval* (type=@NonNegativeInteger@, default=@3600@)
664 66 Adrian Georgescu
>This setting controls the number of seconds used for the _Expire_ header when subscribing to events. It must be a non-negative integer.
665 66 Adrian Georgescu
666 66 Adrian Georgescu
*Account.registration.interval* (type=@NonNegativeInteger@, default=@600@)
667 66 Adrian Georgescu
>This setting controls the number of seconds used for the _Expire_ header when registering. It must be a non-negative integer.
668 66 Adrian Georgescu
669 66 Adrian Georgescu
670 66 Adrian Georgescu
h4. TLS
671 66 Adrian Georgescu
672 66 Adrian Georgescu
673 66 Adrian Georgescu
*Account.tls.certificate* (type=@Path@, default=@None@, nillable=@True@)
674 66 Adrian Georgescu
>The path to the file that contains the certificate and its private key used to authenticate on TLS connections. It is interpreted as an absolute path, with a leading _~_ expanded to the home directory of the current user. In order to access the full path to the TLS certificate, the normalized attribute on the setting can be used:
675 66 Adrian Georgescu
  <pre>
676 30 Luci Stanescu
  account.tls.certificate.normalized
677 66 Adrian Georgescu
</pre>
678 30 Luci Stanescu
679 66 Adrian Georgescu
*Account.tls.verify_server* (type=@bool@, default=@False@)
680 66 Adrian Georgescu
>If this setting is set to @True@, the middleware will verify the server's certificate when connecting via TLS.
681 30 Luci Stanescu
682 30 Luci Stanescu
683 66 Adrian Georgescu
h4. XCAP 
684 30 Luci Stanescu
685 30 Luci Stanescu
686 66 Adrian Georgescu
*Account.xcap.enabled* (type=@bool@, default=@True@)
687 66 Adrian Georgescu
>If this setting is set to @True@, The use of XCAP root set below will be activated.
688 35 Luci Stanescu
689 66 Adrian Georgescu
*Account.xcap.xcap_root* (type=@XCAPRoot@, default=@None@, nillable=@True@)
690 66 Adrian Georgescu
>The XCAP root is required for accessing documents via the XCAP protocol. It must be a URL with either the _http_ or _https_ schemes.
691 29 Luci Stanescu
692 48 Adrian Georgescu
693 66 Adrian Georgescu
694 66 Adrian Georgescu
695 66 Adrian Georgescu
h3. BonjourAccount
696 66 Adrian Georgescu
697 66 Adrian Georgescu
698 66 Adrian Georgescu
<pre>
699 29 Luci Stanescu
Account bonjour@local:
700 29 Luci Stanescu
          +-- display_name = Bonjour User
701 29 Luci Stanescu
account --|-- enabled = False
702 29 Luci Stanescu
          |-- msrp
703 29 Luci Stanescu
          |-- rtp
704 29 Luci Stanescu
          |-- sip
705 33 Luci Stanescu
          +-- tls
706 29 Luci Stanescu
707 29 Luci Stanescu
       +-- transport = tcp
708 29 Luci Stanescu
msrp --|
709 29 Luci Stanescu
       +
710 29 Luci Stanescu
711 29 Luci Stanescu
      +-- audio_codec_list = None
712 29 Luci Stanescu
rtp --|-- inband_dtmf = False
713 33 Luci Stanescu
      |-- srtp_encryption = optional
714 29 Luci Stanescu
      +-- use_srtp_without_tls = False
715 29 Luci Stanescu
716 29 Luci Stanescu
      +-- transport_list = SIPTransportList(['udp'])
717 29 Luci Stanescu
sip --|
718 29 Luci Stanescu
      +
719 29 Luci Stanescu
720 29 Luci Stanescu
      +-- certificate = tls/bonjour@local.crt
721 29 Luci Stanescu
tls --|-- verify_server = False
722 29 Luci Stanescu
      +
723 66 Adrian Georgescu
</pre>
724 29 Luci Stanescu
725 29 Luci Stanescu
The BonjourAccount is a singleton object as there can only be one bonjour account on a system. A bonjour account is used in P2P mode and does not interact with any server. Similar to the Account, it is used both as a complex object, which contains the required behavior for bonjour, as well as a container for the settings which apply to it. 
726 29 Luci Stanescu
727 29 Luci Stanescu
The settings of the BonjourAccount are described below:
728 29 Luci Stanescu
 
729 66 Adrian Georgescu
*BonjourAccount.id* (type=@SIPAddress@)
730 66 Adrian Georgescu
>This is not a setting, as it is the static string 'bonjour@local' which represents the id of the BonjourAccount.
731 29 Luci Stanescu
732 66 Adrian Georgescu
*BonjourAccount.enabled* (type=@bool@, default=@True@)
733 66 Adrian Georgescu
>If this setting is set to @True@, the account will be used. More information about this is in [[SipMiddlewareApi#BonjourAccount|BonjourAccount]].
734 29 Luci Stanescu
735 66 Adrian Georgescu
*BonjourAccount.display_name* (type=@unicode@, default=@None@, nillable=@True@)
736 66 Adrian Georgescu
>The contents of this setting will be sent as part of the _From_ header when sending SIP requests.
737 29 Luci Stanescu
738 29 Luci Stanescu
739 66 Adrian Georgescu
h4. MSRP
740 29 Luci Stanescu
741 29 Luci Stanescu
742 66 Adrian Georgescu
*SIPSimpleSettings.msrp.transport* (type=@MSRPTransport@, default=@'tcp'@)
743 66 Adrian Georgescu
>MSRP can use either TLS or TCP and this setting controls which one should be used for the bonjour account.
744 29 Luci Stanescu
745 29 Luci Stanescu
746 66 Adrian Georgescu
h4. RTP
747 29 Luci Stanescu
748 29 Luci Stanescu
749 66 Adrian Georgescu
*BonjourAccount.rtp.audio_codec_list* (type=@AudioCodecList@, default=@('speex', 'g722', 'g711', 'ilbc', 'gsm')@)
750 66 Adrian Georgescu
>This setting is used to specify the preferred audio codecs, which should be used for audio calls of this account. It must be a tuple containing only strings, which represent the supported codecs (speex, g722, g711, ilbc and gsm), in the order in which they are preferred.
751 66 Adrian Georgescu
752 66 Adrian Georgescu
*BonjourAccount.rtp.srtp_encryption* (type=@SRTPEncryption@, default=@'optional'@)
753 66 Adrian Georgescu
>The value of this setting specifies how the account requires the calls to be encrypted using SRTP. It can be one of the values @'disabled'@, @'optional'@ or @'mandatory'@.
754 66 Adrian Georgescu
755 66 Adrian Georgescu
*BonjourAccount.rtp.use_srtp_without_tls* (type=@bool@, default=@False@)
756 66 Adrian Georgescu
>If this setting is set to @True@, SRTP could be used even if the SIP signaling used to control the call is not over TLS.
757 66 Adrian Georgescu
758 66 Adrian Georgescu
759 66 Adrian Georgescu
h4. TLS
760 66 Adrian Georgescu
761 66 Adrian Georgescu
762 66 Adrian Georgescu
*BonjourAccount.tls.certificate* (type=@Path@, default=@None@, nillable=@True@)
763 66 Adrian Georgescu
>The path to the file that contains the certificate and its private key used to authenticate on TLS connections. It is interpreted as an absolute path, with a leading _~_ expanded to the home directory of the current user. In order to access the full path to the certificate file, the normalized attribute on the setting can be used:
764 66 Adrian Georgescu
  <pre>
765 1 Adrian Georgescu
  BonjourAccount().tls.ca_list.normalized
766 66 Adrian Georgescu
</pre>
767 1 Adrian Georgescu
768 66 Adrian Georgescu
*BonjourAccount.tls.verify_server* (type=@bool@, default=@False@)
769 66 Adrian Georgescu
>If this setting is set to @True@, the middleware will verify the server's certificate when connecting via TLS.
770 1 Adrian Georgescu
771 1 Adrian Georgescu
772 66 Adrian Georgescu
h2. SIPClients Settings
773 66 Adrian Georgescu
774 66 Adrian Georgescu
775 1 Adrian Georgescu
The SIPClients scripts use the Configuration API to extend the settings in the middleware with some application-specific settings. The following sections list these additional settings in order to provide an example for the kind of settings which, being application specific, do not find their place in the middleware and should be added by the application.
776 1 Adrian Georgescu
777 1 Adrian Georgescu
778 66 Adrian Georgescu
h3. General
779 1 Adrian Georgescu
780 1 Adrian Georgescu
781 66 Adrian Georgescu
*SIPSimpleSettings.user_data_directory* (type=@AbsolutePath@, default=@'~/.sipclient@)
782 66 Adrian Georgescu
>This is the directory, which will be used by default for storing the SIP SIMPLE data. The relative paths are calculated on runtime based on this setting, which means that if this setting is changed, all relative paths will point inside the new directory. It is a string, which must be an absolute path.
783 1 Adrian Georgescu
784 66 Adrian Georgescu
*SIPSimpleSettings.resources_directory* (type=@AbsolutePath@, default=@None@)
785 66 Adrian Georgescu
>This is the directory, which will be used by default for storing the sound files played for various notifications.
786 1 Adrian Georgescu
787 66 Adrian Georgescu
788 66 Adrian Georgescu
789 66 Adrian Georgescu
h4. Audio
790 66 Adrian Georgescu
791 66 Adrian Georgescu
792 66 Adrian Georgescu
*SIPSimpleSettings.audio.directory* (type=@DataPath@, default=@DataPath('history')@)
793 66 Adrian Georgescu
>This directory will be used to store recorded audio conversations. Under this directory, a subdirectory per account with the id of the account as the name will be created. If it is set to relative path, it is taken relative to @SIPSimpleSettings.user_data_directory@; otherwise it is interpreted as an absolute path. In order to access the full path to the history directory, the value attribute on the setting can be used:
794 66 Adrian Georgescu
  <pre>
795 1 Adrian Georgescu
  SIPSimpleSettings().audio.directory.value
796 66 Adrian Georgescu
</pre>
797 1 Adrian Georgescu
798 1 Adrian Georgescu
799 66 Adrian Georgescu
h4. File Transfer
800 66 Adrian Georgescu
801 66 Adrian Georgescu
802 66 Adrian Georgescu
*SIPSimpleSettings.file_transfer.directory* (type=@DataPath@, default=@DataPath('file_transfers')@)
803 66 Adrian Georgescu
>This directory is used to store the files obtained via MSRP file transfer. If it is set to relative path, it is taken relative to @SIPSimpleSettings.user_data_directory@; otherwise it is interpreted as an absolute path. In order to access the full path to the history directory, the value attribute on the setting can be used:
804 66 Adrian Georgescu
  <pre>
805 1 Adrian Georgescu
  SIPSimpleSettings().file_transfer.directory.value
806 66 Adrian Georgescu
</pre>
807 1 Adrian Georgescu
808 1 Adrian Georgescu
809 66 Adrian Georgescu
h4. Logs
810 66 Adrian Georgescu
811 66 Adrian Georgescu
812 66 Adrian Georgescu
*SIPSimpleSettings.logs.directory* (type=@DataPath@, default=@DataPath('logs')@)
813 66 Adrian Georgescu
>This is the directory where the logs create by the SIP SIMPLE middleware will be stored. If it is set to relative path, it is taken relative to @SIPSimpleSettings.user_data_directory@; otherwise it is interpreted as an absolute path. In order to access the full path to the history directory, the value attribute on the setting can be used:
814 66 Adrian Georgescu
  <pre>
815 1 Adrian Georgescu
  SIPSimpleSettings().logs.directory.value
816 66 Adrian Georgescu
</pre>
817 1 Adrian Georgescu
818 66 Adrian Georgescu
*SIPSimpleSettings.logs.trace_sip* (type=@bool@, default=@False@)
819 66 Adrian Georgescu
>If this setting is set to True, the SIP packets will be written to a log file named 'sip_trace.txt', inside the directory pointed by @SIPSimpleSettings.logging.directory@.
820 1 Adrian Georgescu
821 66 Adrian Georgescu
*SIPSimpleSettings.logs.trace_pjsip* (type=@bool@, default=@False@)
822 66 Adrian Georgescu
>If this setting is set to True, the PJSIP log messages will be written to a log file named 'pjsip_trace.txt', inside the directory pointed by @SIPSimpleSettings.logging.directory@.
823 1 Adrian Georgescu
824 66 Adrian Georgescu
*SIPSimpleSettings.logs.trace_msrp* (type=@bool@, default=@False@)
825 66 Adrian Georgescu
>If this setting is set to True, the MSRP packets will be written to a log file named 'msrp_trace.txt', inside the directory pointed by @SIPSimpleSettings.logging.directory@.
826 1 Adrian Georgescu
827 66 Adrian Georgescu
*SIPSimpleSettings.logs.trace_xcap* (type=@bool@, default=@False@)
828 66 Adrian Georgescu
>If this setting is set to True, the XCAP packets will be written to a log file named 'xcap_trace.txt', inside the directory pointed by @SIPSimpleSettings.logging.directory@.
829 1 Adrian Georgescu
830 1 Adrian Georgescu
831 66 Adrian Georgescu
h4. Sounds
832 1 Adrian Georgescu
833 1 Adrian Georgescu
834 66 Adrian Georgescu
*SIPSimpleSettings.sounds.audio_inbound* (type=@AbsolutePath@, default=@None@, nillable=@True@)
835 66 Adrian Georgescu
>This setting should point to a wav file, which will be played when a SIP session request is received. If it is set to @None@, no sound will be played.
836 1 Adrian Georgescu
837 66 Adrian Georgescu
*SIPSimpleSettings.sounds.audio_outbound* (type=@AbsolutePath@, default=@None@, nillable=@True@)
838 66 Adrian Georgescu
>This setting should point to a wav file, which will be used as ringtone during an outgoing SIP session request as a response to a 180 Ringing. If it is set to @None@, no sound will be played.
839 1 Adrian Georgescu
840 66 Adrian Georgescu
*SIPSimpleSettings.sounds.file_sent* (type=@AbsolutePath@, default=@None@, nillable=@True@)
841 66 Adrian Georgescu
>This setting should point to a wav file, which will be played when an outgoing file transfer is finished. If it is set to @None@, no sound will be played.
842 1 Adrian Georgescu
843 66 Adrian Georgescu
*SIPSimpleSettings.sounds.file_received* (type=@AbsolutePath@, default=@None@, nillable=@True@)
844 66 Adrian Georgescu
>This setting should point to a wav file, which will be played when an incoming file transfer is finished. If it is set to @None@, no sound will be played.
845 1 Adrian Georgescu
846 66 Adrian Georgescu
*SIPSimpleSettings.sounds.message_sent* (type=@AbsolutePath@, default=@None@, nillable=@True@)
847 66 Adrian Georgescu
>This setting is a string representing an absolute path to a wav file, which is played when a message is sent in a chat session. If it is set to @None@, no sound is played.
848 1 Adrian Georgescu
849 66 Adrian Georgescu
*SIPSimpleSettings.sounds.message_received* (type=@AbsolutePath@, default=@None@, nillable=@True@)
850 66 Adrian Georgescu
>This setting is a string representing an absolute path to a wav file, which is played when a message is received in a chat session. If it is set to @None@, no sound is played.
851 1 Adrian Georgescu
852 1 Adrian Georgescu
853 66 Adrian Georgescu
h3. Account
854 1 Adrian Georgescu
855 1 Adrian Georgescu
856 66 Adrian Georgescu
857 66 Adrian Georgescu
h4. Sounds
858 66 Adrian Georgescu
859 66 Adrian Georgescu
860 66 Adrian Georgescu
*Account.sounds.audio_inbound* (type=@AbsolutePath@, default=@None@, nillable=@True@)
861 66 Adrian Georgescu
>This setting should point to a wav file, which will be used to play the incoming ringtone. If it is set to @None@, the wav file set in @SIPSimpleSettings.sounds.audio_inbound@ will be used instead.
862 66 Adrian Georgescu
863 66 Adrian Georgescu
864 66 Adrian Georgescu
h3. BonjourAccount
865 66 Adrian Georgescu
866 66 Adrian Georgescu
867 66 Adrian Georgescu
868 66 Adrian Georgescu
h4. Sounds
869 66 Adrian Georgescu
870 66 Adrian Georgescu
871 66 Adrian Georgescu
*BonjourAccount.sounds.audio_inbound* (type=@AbsolutePath@, default=@None@, nillable=@True@)
872 66 Adrian Georgescu
>This setting should point to a wav file which will be used as the incoming ringtone. If it is set to @None@, the wav file set in @SIPSimpleSettings.sounds.audio_inbound@ will be used instead.