Copyright © 2006 voice-system.ro
hash_size
(int)db_url
(str)db_table
(str)min_expires
(int)default_expires
(int)update_period
(int)bind_pua(pua_api_t* api)
send_publish
send_subscribe
is_dialog
register_puacb
add_event
hash_size
parameterdb_url
parameterdb_table
parametermin_expires
parameterdefault_expires
parameterupdate_period
parameterpua_api
structurepua_is_dialog
usage exampleregister_puacb
usage exampleadd_event
usage exampleThis module offer the functionality of a presence user agent client, sending Subscribe and Publish messages.
Now it can be used with the following modules: pua_mi and pua_usrloc, pua_bla and pua_xmpp. The pua_mi offer the possibility to publish any kind of information or subscribing to a resource through fifo. The pua_usrloc module calls a function exported by pua modules to publish elementary presence information, such as basic status "open" or "closed", for clients that do not implement client-to-server presence. Through pua_bla , BRIDGED LINE APPEARANCE features are added to openser. The pua_xmpp module represents a gateway between SIP and XMPP, so that jabber and SIP clients can exchange presence information.
The module use cache to store presentity list and writes to database on timer to be able to recover upon restart.
The following modules must be loaded before this module:
a database modules.
tm.
The following libraries or applications must be installed before running OpenSER with this module loaded:
libxml.
hash_size
(int)The size of the hash table used for storing Subscribe and Publish information. This parameter will be used as the power of 2 when computing table size.
Default value is "9 (512)".
min_expires
(int)The inferior expires limit for both Publish and Subscribe.
Default value is "0".
default_expires
(int)The default expires value used in case this information is not provisioned.
Default value is "3600".
update_period
(int)The interval at which the information in database and hash table should be updated. In the case of the hash table updating is deleting expired messages.
Default value is "30".
The module requires 1 table in OpenSER database: pua. The SQL syntax to create it can be found in presence_xml-create.sql script in the database directories in the openser/scripts folder. You can also find the complete database documentation on the project webpage, http://www.openser-project.org/docs/db-tables/openser-db-devel.html.
The module provides the following functions that can be used in other OpenSER modules.
bind_pua(pua_api_t* api)
This function binds the pua modules and fills the structure with the two exported function.
send_publish
Field type:
... typedef int (*send_publish_t)(publ_info_t* publ); ...
This function receives as a parameter a structure with Publish required information and sends a Publish message.
The structure received as a parameter:
... typedef struct publ_info str id; /* (optional )a value unique for one combination of pres_uri and flag */ str* pres_uri; /* the presentity uri */ str* body; /* the body of the Publish message; can be NULL in case of an update expires*/ int expires; /* the expires value that will be used in Publish Expires header*/ int flag; /* it can be : INSERT_TYPE or UPDATE_TYPE if missing it will be established according to the result of the search in hash table*/ int source_flag; /* flag identifying the resource ; supported values: UL_PUBLISH, MI_PUBLISH, BLA_PUBLISH, XMPP_PUBLISH*/ int event; /* the event flag; supported values: PRESENCE_EVENT, BLA_EVENT, MWI_EVENT */ str content_type; /* the content_type of the body if present (optional if the same as the default value for that event)*/ str* etag; /* (optional) the value of the etag the request should match */ str* extra_headers /* (optional) extra_headers that should be added to Publish msg*/ publrpl_cb_t* cbrpl;/* callback function to be called when receiving the reply for the sent request */ void* cbparam; /* extra parameter for tha callback function */ }publ_info_t; ...
The callback function type:
... typedef int (publrpl_cb_t)(struct sip_msg* reply, void* extra_param); ...
send_subscribe
Field type:
... typedef int (*send_subscribe_t)(subs_info_t* subs); ...
This function receives as a parameter a structure with Subscribe required information and sends a Subscribe message.
The structure received as a parameter:
... typedef struct subs_info str id; /* an id value unique for one combination of pres_uri and flag */ str* pres_uri; /* the presentity uri */ str* watcher_uri; /* the watcher uri */ str* contact; /* the uri that will be used in Contact header*/ str* remote_target; /* the uri that will be used as R-URI for the Subscribe message(not compulsory; if not set the value of the pres_uri field is used) */ str* outbound_proxy; /* the outbound_proxy to use when sending the Subscribe request*/ int event; /* the event flag; supported value: PRESENCE_EVENT, BLA_EVENT, PWINFO_EVENT*/ int expires; /* the expires value that will be used in Subscribe Expires header */ int flag; /* it can be : INSERT_TYPE or UPDATE_TYPE not compulsory */ int source_flag; /* flag identifying the resource ; supported values: MI_SUBSCRIBE, BLA_SUBSCRIBE, XMPP_SUBSCRIBE, XMPP_INITIAL_SUBS */ }subs_info_t; ...
is_dialog
Field type:
... typedef int (*query_dialog_t)(ua_pres_t* presentity); ...
This function checks is the parameter corresponds to a stored Subscribe initiated dialog.
register_puacb
Field type:
... typedef int (*register_puacb_t)(int types, pua_cb f, void* param ); ...
This function registers a callback to be called on receiving the reply message for a sent Subscribe request. The type parameter should be set the same as the source_flag for that request. The function registered as callback for pua should be of type pua_cb , which is: typedef void (pua_cb)(ua_pres_t* hentity, struct msg_start * fl); The parameters are the dialog structure for that request and the first line of the reply message.
add_event
Field type:
... typedef int (*add_pua_event_t)(int ev_flag, char* name, char* content_type,evs_process_body_t* process_body); - ev_flag : an event flag defined as a macro in pua module - name : the event name to be used in Event request headers - content_type: the default content_type for Publish body for that event (NULL if winfo event) - process_body: function that processes the received body before using it to construct the PUBLISH request (NULL if winfo event) ...
This function allows registering new events to the pua module. Now there are 4 events supported by the pua module: presence, presence;winfo, message-summary, dialog;sla. These events are registered from within the pua module.
Filed type for process_body:
... typedef int (evs_process_body_t)(struct publ_info* publ, str** final_body, int ver, str* tuple); - publ : the structure received as a parameter in send_publish function ( initial body found in publ->body) - final_body: the pointer where the result(final_body) should be stored - ver : a counter for the sent Publish requests (used for winfo events) - tuple : a unique identifier for the resource; if an initial Publish it should be returned as a result and it will be stored for that record, otherwise it will be given as a parameter; ...
Take a look at http://www.openser-project.org/.
First at all check if your question was already answered on one of our mailing lists:
User Mailing List - http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
Developer Mailing List - http://lists.openser-project.org/cgi-bin/mailman/listinfo/devel
E-mails regarding any stable OpenSER release should be sent to
<users@lists.openser-project.org>
and e-mails regarding development versions
should be sent to <devel@lists.openser-project.org>
.
If you want to keep the mail private, send it to
<team@lists.openser-project.org>
.
Please follow the guidelines provided at: http://sourceforge.net/tracker/?group_id=139143.