summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-06-22 08:00:20 +0000
committerBenny Prijono <bennylp@teluu.com>2011-06-22 08:00:20 +0000
commitce6bdc7415d99992775a3c21126f3a3a7907cdda (patch)
treeb593f826d9a8869247206d28a99bc098e40d801d /pjsip
parent8b7ab1985b045d9002487bd12817cac0ee7b8c2b (diff)
Closed #1313 (Account option to disable registration when account is added) and closed #1314 (New callback to notify application when registration or unregistration has been initiated). Thanks Tony Jago Million for the patch
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3594 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h22
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c11
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c1
3 files changed, 31 insertions, 3 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index b52990eb..fe8ccc08 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -604,6 +604,18 @@ typedef struct pjsua_callback
/**
+ * Notify application when registration or unregistration has been
+ * initiated. Note that this only notifies the initial registration
+ * and unregistration. Once registration session is active, subsequent
+ * refresh will not cause this callback to be called.
+ *
+ * @param acc_id The account ID.
+ * @param renew Non-zero for registration and zero for
+ * unregistration.
+ */
+ void (*on_reg_started)(pjsua_acc_id acc_id, pj_bool_t renew);
+
+ /**
* Notify application when registration status has changed.
* Application may then query the account info to get the
* registration details.
@@ -2552,6 +2564,16 @@ typedef struct pjsua_acc_config
* Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
*/
pjsua_call_hold_type call_hold_type;
+
+
+ /**
+ * Specify whether the account should register as soon as it is
+ * added to the UA. Application can set this to PJ_FALSE and control
+ * the registration manually with pjsua_acc_set_registration().
+ *
+ * Default: PJ_TRUE
+ */
+ pj_bool_t register_on_acc_add;
} pjsua_acc_config;
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index 9cd93254..5398928f 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -452,9 +452,10 @@ PJ_DEF(pj_status_t) pjsua_acc_add( const pjsua_acc_config *cfg,
(int)cfg->id.slen, cfg->id.ptr, id));
/* If accounts has registration enabled, start registration */
- if (pjsua_var.acc[id].cfg.reg_uri.slen)
- pjsua_acc_set_registration(id, PJ_TRUE);
- else {
+ if (pjsua_var.acc[id].cfg.reg_uri.slen) {
+ if (pjsua_var.acc[id].cfg.register_on_acc_add)
+ pjsua_acc_set_registration(id, PJ_TRUE);
+ } else {
/* Otherwise subscribe to MWI, if it's enabled */
if (pjsua_var.acc[id].cfg.mwi_enabled)
pjsua_start_mwi(&pjsua_var.acc[id]);
@@ -2009,6 +2010,10 @@ PJ_DEF(pj_status_t) pjsua_acc_set_registration( pjsua_acc_id acc_id,
pjsip_regc_get_info(pjsua_var.acc[acc_id].regc, &reg_info);
pjsua_var.acc[acc_id].auto_rereg.reg_tp = reg_info.transport;
+
+ if (pjsua_var.ua_cfg.cb.on_reg_started) {
+ (*pjsua_var.ua_cfg.cb.on_reg_started)(acc_id, renew);
+ }
}
if (status != PJ_SUCCESS) {
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 362ed0cd..393d3d1a 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -193,6 +193,7 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
pj_list_init(&cfg->reg_hdr_list);
pj_list_init(&cfg->sub_hdr_list);
cfg->call_hold_type = PJSUA_CALL_HOLD_TYPE_DEFAULT;
+ cfg->register_on_acc_add = PJ_TRUE;
}
PJ_DEF(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg)