summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2010-10-12 12:45:15 +0000
committerBenny Prijono <bennylp@teluu.com>2010-10-12 12:45:15 +0000
commitb3c3836ac9841f7ecfa085b0a8de4f68ffd1b8c6 (patch)
tree9728be7b28cb27feccdfbad57187277c4ea25384 /pjsip
parent0ab38c18720fa75094ec8fd98d0bd96d86f373cf (diff)
Closed #1144: New presence callback to report subscription state (thanks Johan Lantz for the suggestion):
- added on_buddy_evsub_state() callback - added sample implementation in pjsua_app.c git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3339 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h15
-rw-r--r--pjsip/src/pjsua-lib/pjsua_pres.c34
2 files changed, 27 insertions, 22 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index d178a863..0661bb2f 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -687,6 +687,21 @@ typedef struct pjsua_callback
*/
void (*on_buddy_state)(pjsua_buddy_id buddy_id);
+
+ /**
+ * Notify application when the state of client subscription session
+ * associated with a buddy has changed. Application may use this
+ * callback to retrieve more detailed information about the state
+ * changed event.
+ *
+ * @param buddy_id The buddy id.
+ * @param sub Event subscription session.
+ * @param event The event which triggers state change event.
+ */
+ void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
+ pjsip_evsub *sub,
+ pjsip_event *event);
+
/**
* Notify application on incoming pager (i.e. MESSAGE request).
* Argument call_id will be -1 if MESSAGE request is not related to an
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index 651dad19..a4909b04 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -1557,7 +1557,11 @@ static void pjsua_evsub_on_state( pjsip_evsub *sub, pjsip_event *event)
buddy->term_reason.slen = 0;
}
- /* Call callback */
+ /* Call callbacks */
+ if (pjsua_var.ua_cfg.cb.on_buddy_evsub_state)
+ (*pjsua_var.ua_cfg.cb.on_buddy_evsub_state)(buddy->index, sub,
+ event);
+
if (pjsua_var.ua_cfg.cb.on_buddy_state)
(*pjsua_var.ua_cfg.cb.on_buddy_state)(buddy->index);
@@ -1656,30 +1660,10 @@ static void pjsua_evsub_on_rx_notify(pjsip_evsub *sub,
}
-/* Event subscription callback. */
-static pjsip_evsub_user pres_callback =
-{
- &pjsua_evsub_on_state,
- &pjsua_evsub_on_tsx_state,
-
- NULL, /* on_rx_refresh: don't care about SUBSCRIBE refresh, unless
- * we want to authenticate
- */
-
- &pjsua_evsub_on_rx_notify,
-
- NULL, /* on_client_refresh: Use default behaviour, which is to
- * refresh client subscription. */
-
- NULL, /* on_server_timeout: Use default behaviour, which is to send
- * NOTIFY to terminate.
- */
-};
-
-
/* It does what it says.. */
static void subscribe_buddy_presence(pjsua_buddy_id buddy_id)
{
+ pjsip_evsub_user pres_callback;
pj_pool_t *tmp_pool = NULL;
pjsua_buddy *buddy;
int acc_id;
@@ -1688,6 +1672,12 @@ static void subscribe_buddy_presence(pjsua_buddy_id buddy_id)
pjsip_tx_data *tdata;
pj_status_t status;
+ /* Event subscription callback. */
+ pj_bzero(&pres_callback, sizeof(pres_callback));
+ pres_callback.on_evsub_state = &pjsua_evsub_on_state;
+ pres_callback.on_tsx_state = &pjsua_evsub_on_tsx_state;
+ pres_callback.on_rx_notify = &pjsua_evsub_on_rx_notify;
+
buddy = &pjsua_var.buddy[buddy_id];
acc_id = pjsua_acc_find_for_outgoing(&buddy->uri);