diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-02-19 15:37:19 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-02-19 15:37:19 +0000 |
commit | 51f0bc5a46378786d98caf84df2cf31bb169e45b (patch) | |
tree | e17a65e4ebdf98d4f46857f51d26afe7f1fb2aa7 /pjsip/src/pjsua/pjsua_reg.c | |
parent | c1fa8a21eda0357a8c25a63b634615f6785e4d48 (diff) |
SIMPLE test with FWD, and added more info in UI
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@201 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua/pjsua_reg.c')
-rw-r--r-- | pjsip/src/pjsua/pjsua_reg.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/pjsip/src/pjsua/pjsua_reg.c b/pjsip/src/pjsua/pjsua_reg.c index 972791b1..f11ff3fd 100644 --- a/pjsip/src/pjsua/pjsua_reg.c +++ b/pjsip/src/pjsua/pjsua_reg.c @@ -37,9 +37,15 @@ static void regc_cb(struct pjsip_regc_cbparam *param) /* * Print registration status. */ - if (param->code < 0 || param->code >= 300) { + if (param->status!=PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "SIP registration error", + param->status); + pjsua.regc = NULL; + + } else if (param->code < 0 || param->code >= 300) { PJ_LOG(2, (THIS_FILE, "SIP registration failed, status=%d (%s)", - param->code, pjsip_get_status_text(param->code)->ptr)); + param->code, + pjsip_get_status_text(param->code)->ptr)); pjsua.regc = NULL; } else if (PJSIP_IS_STATUS_IN_CLASS(param->code, 200)) { @@ -53,6 +59,7 @@ static void regc_cb(struct pjsip_regc_cbparam *param) PJ_LOG(4, (THIS_FILE, "SIP registration updated status=%d", param->code)); } + pjsua.regc_last_err = param->status; pjsua.regc_last_code = param->code; pjsua_ui_regc_on_state_changed(pjsua.regc_last_code); @@ -68,19 +75,33 @@ void pjsua_regc_update(pj_bool_t renew) pjsip_tx_data *tdata; if (renew) { - PJ_LOG(3,(THIS_FILE, "Performing SIP registration...")); + if (pjsua.regc == NULL) { + status = pjsua_regc_init(); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to create registration", + status); + return; + } + } status = pjsip_regc_register(pjsua.regc, 1, &tdata); } else { - PJ_LOG(3,(THIS_FILE, "Performing SIP unregistration...")); + if (pjsua.regc == NULL) { + PJ_LOG(3,(THIS_FILE, "Currently not registered")); + return; + } status = pjsip_regc_unregister(pjsua.regc, &tdata); } + if (status == PJ_SUCCESS) + status = pjsip_regc_send( pjsua.regc, tdata ); + if (status != PJ_SUCCESS) { - pjsua_perror("Unable to create REGISTER request", status); - return; + pjsua_perror(THIS_FILE, "Unable to create/send REGISTER", + status); + } else { + PJ_LOG(3,(THIS_FILE, "%s sent", + (renew? "Registration" : "Unregistration"))); } - - pjsip_regc_send( pjsua.regc, tdata ); } /* @@ -96,7 +117,8 @@ pj_status_t pjsua_regc_init(void) status = pjsip_regc_create( pjsua.endpt, NULL, ®c_cb, &pjsua.regc); if (status != PJ_SUCCESS) { - pjsua_perror("Unable to create client registration", status); + pjsua_perror(THIS_FILE, "Unable to create client registration", + status); return status; } @@ -107,7 +129,9 @@ pj_status_t pjsua_regc_init(void) 1, &pjsua.contact_uri, pjsua.reg_timeout); if (status != PJ_SUCCESS) { - pjsua_perror("Client registration initialization error", status); + pjsua_perror(THIS_FILE, + "Client registration initialization error", + status); return status; } |