[asterisk-dev] [Code Review] Enhancements to presence in Asterisk

Mark Michelson reviewboard at asterisk.org
Tue Apr 17 11:24:30 CDT 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1850/
-----------------------------------------------------------

(Updated April 17, 2012, 11:24 a.m.)


Review request for Asterisk Developers.


Changes
-------

A few changes

* Addressed all of Matt's concerns
* Added cleanup of the DB in presence state change unit test
* I realized that a test was not passing because of my change to have ast_presence_state() return an enum instead of an int. Trying to see if the value was less than 0 would never work properly. To fix this, I've added a new enum value AST_PRESENCE_INVALID. It is not possible to set this as a presence. Instead, this is used to indicate that an unknown/invalid presence has been encountered (i.e. something has gone wrong). Previous checks in main/presencestate.c and funcs/func_presencestate.c have been updated to check results against this enum value instead of seeing if a returned value is less than 0.


Summary
-------

This changeset contains revisions to the presence system in Asterisk to make it more palatable for general release in Asterisk 11. While the system as it exists in the 1.8-digiumphones and 10-digiumphones works well, it was missing some functionality and was not implemented in the most optimal way in some cases. Below are a list of the changes made:

* func_presencestate has two CLI commands added. "presencestate list" lists the current states of all CustomPresence entities. "presencestate change" allows for CustomPresence entities' states to be updated. These two commands are modeled after similar ones in func_devstate.
* func_presencestate now populates the event cache on startup to mirror what func_devstate does.
* The functions that change presence state have been updated to behave more like the ast_devstate_changed family of functions. This includes two main changes.
    - There are now two functions to use, either ast_presence_state_changed() or ast_presence_state_changed_literal(). The difference between these is that one takes a printf-style format string and the other takes a literal name.
    - The state change functions now take the state (and subtype and message) as part of the function. This saves the trouble of having to look up the state from the presence state provider on every state change. In the case of CustomPresence, this means far fewer ASTDB reads.
* A new manager action, "PresenceState", has been added. This will return the current presence state, subtype, and message for a given presence provider.


Diffs (updated)
-----

  /team/mmichelson/trunk-digiumphones/funcs/func_presencestate.c 361324 

Diff: https://reviewboard.asterisk.org/r/1850/diff


Testing
-------

I have tested the CLI commands and Manager actions. They exercise the core updates, so I can verify they work as well. I will have an external test written within the coming days and will post it when I have completed it.


Thanks,

Mark

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120417/f11aa7f2/attachment-0001.htm>


More information about the asterisk-dev mailing list