[pjsip] Buddy status text

Benny Prijono bennylp at pjsip.org
Mon Sep 10 13:24:42 EDT 2007


Gideon Klompje wrote:
> Hi,
> 
> Please note that I sent this e-mail earlier (2007-09-03 subject: “Buddy 
> status”), but that was while the mailing list was having problems, so 
> I’m not sure it reached the list.  Apologies…

The apology is ours. We apologize for all the mess with the list in 
the past couple of weeks.

> I’ve been playing around with PJSIP for about 2 days now (mainly using 
> py_pjsua), and I have a question about the way buddy status is handled.  
> I’ve noticed that the fields buddy_info.status and 
> buddy_info.status_text only give you one the following (from “enum 
> pjsua_buddy_status { PJSUA_BUDDY_STATUS UNKNOWN, 
> PJSUA_BUDDY_STATUS_ONLINE, PJSUA_BUDDY_STATUS_OFFLINE}”):
> 
> 0 = Unknown
> 1 = Online
> 2 = Offline
> 
> This is neat and all, but I was wondering whether a more detailed status 
> is available.  For example, if I’m monitoring an IP phone connected to 
> an Asterisk PBX, I’d like to know whether the phone (buddy) is “On the 
> phone” (busy) or “Idle” (ready to take a call).  I noticed that the SIP 
> packets contain some XML that contains this information, but the 
> struct/object “buddy_info” does not contain it.

The most recent pjsip in SVN trunk (r1430) contains some support for 
specifying and receiving custom presence status text in the NOTIFY 
and PUBLISH requests. I've just updated the Python module to support 
this feature.

This feature implements subset of RPID XML presence data format. For 
setting custom presence status text, one has to use the new 
pjsua_acc_set_online_status2() instead of the usual 
pjsua_acc_set_online_status().

When pjsip/PJSUA-LIB receives incoming NOTIFY, it will check for 
this custom presence status text, and if it's present it will set 
the pjsua_buddy_info's status_text to this string. If this custom 
status is not present, then status_text will be just "Online" or 
"Offline".

> 
> PS - I spent some time modifying py_pjsua.c to export the field “buf_” 
> (not available in the Python object for some reason) in the hope that it 
> might contain what I’m looking for, but my observations seem to show 
> that it only contains the “contact” string at the time when my 
> on_buddy_state_changed(buddy_id) equivalent is called (either that or my 
> implementation is dodge).  Btw, I’m using v0.5.10.4.  Instead of hacking 
> at the source code all day, I came to my senses and posted this mail.

The buf_ field was really not supposed to be there at all, and it 
has been removed. And sorry for the late reply, I hope by now you've 
had more than enough time to hack pjsip's source code all day. ;)

  -benny










More information about the pjsip mailing list