summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
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);