diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-10-31 10:54:53 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-10-31 10:54:53 +0000 |
commit | c25863d18e273d92f61550f7dccf9a54c81dd9b8 (patch) | |
tree | 92acaf2f99184ecf151632902feafc1878969595 /pjsip/src/pjsua-lib/pjsua_pres.c | |
parent | 42ee53bda2fcf662954c7a62803a8c1e1c35e902 (diff) |
Ticket #406: New PJSUA API to update buddy's presence subscription
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1535 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_pres.c')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_pres.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c index 0d750e07..482be7e9 100644 --- a/pjsip/src/pjsua-lib/pjsua_pres.c +++ b/pjsip/src/pjsua-lib/pjsua_pres.c @@ -311,6 +311,42 @@ PJ_DEF(pj_status_t) pjsua_buddy_subscribe_pres( pjsua_buddy_id buddy_id, /* + * Update buddy's presence. + */ +PJ_DEF(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id) +{ + pjsua_buddy *buddy; + + PJ_ASSERT_RETURN(buddy_id>=0 && + buddy_id<(int)PJ_ARRAY_SIZE(pjsua_var.buddy), + PJ_EINVAL); + + PJSUA_LOCK(); + + buddy = &pjsua_var.buddy[buddy_id]; + + /* Return error if buddy's presence monitoring is not enabled */ + if (!buddy->monitor) { + PJSUA_UNLOCK(); + return PJ_EINVALIDOP; + } + + /* Ignore if presence is already active for the buddy */ + if (buddy->sub) { + PJSUA_UNLOCK(); + return PJ_SUCCESS; + } + + /* Initiate presence subscription */ + subscribe_buddy_presence(buddy_id); + + PJSUA_UNLOCK(); + + return PJ_SUCCESS; +} + + +/* * Dump presence subscriptions to log file. */ PJ_DEF(void) pjsua_pres_dump(pj_bool_t verbose) |