Changeset 236 for pjproject/trunk/pjsip/src/pjsua/pjsua_reg.c
- Timestamp:
- Feb 26, 2006 9:23:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua/pjsua_reg.c
r201 r236 35 35 static void regc_cb(struct pjsip_regc_cbparam *param) 36 36 { 37 38 pjsua_acc *acc = param->token; 39 37 40 /* 38 41 * Print registration status. … … 41 44 pjsua_perror(THIS_FILE, "SIP registration error", 42 45 param->status); 43 pjsua.regc = NULL; 46 pjsip_regc_destroy(acc->regc); 47 acc->regc = NULL; 44 48 45 49 } else if (param->code < 0 || param->code >= 300) { … … 47 51 param->code, 48 52 pjsip_get_status_text(param->code)->ptr)); 49 pjsua.regc = NULL; 53 pjsip_regc_destroy(acc->regc); 54 acc->regc = NULL; 50 55 51 56 } else if (PJSIP_IS_STATUS_IN_CLASS(param->code, 200)) { 52 PJ_LOG(3, (THIS_FILE, "SIP registration success, status=%d (%s), " 53 "will re-register in %d seconds", 54 param->code, 55 pjsip_get_status_text(param->code)->ptr, 56 param->expiration)); 57 58 if (param->expiration < 1) { 59 pjsip_regc_destroy(acc->regc); 60 acc->regc = NULL; 61 PJ_LOG(3,(THIS_FILE, "%s: unregistration success", 62 acc->local_uri.ptr)); 63 } else { 64 PJ_LOG(3, (THIS_FILE, 65 "%s: registration success, status=%d (%s), " 66 "will re-register in %d seconds", 67 acc->local_uri.ptr, 68 param->code, 69 pjsip_get_status_text(param->code)->ptr, 70 param->expiration)); 71 } 57 72 58 73 } else { … … 60 75 } 61 76 62 pjsua.regc_last_err = param->status;63 pjsua.regc_last_code = param->code;77 acc->reg_last_err = param->status; 78 acc->reg_last_code = param->code; 64 79 65 pjsua_ui_regc_on_state_changed( pjsua.regc_last_code);80 pjsua_ui_regc_on_state_changed(acc->index); 66 81 } 67 82 … … 70 85 * Update registration. If renew is false, then unregistration will be performed. 71 86 */ 72 void pjsua_regc_update( pj_bool_t renew)87 void pjsua_regc_update(int acc_index, pj_bool_t renew) 73 88 { 74 89 pj_status_t status; … … 76 91 77 92 if (renew) { 78 if (pjsua. regc == NULL) {79 status = pjsua_regc_init( );93 if (pjsua.acc[acc_index].regc == NULL) { 94 status = pjsua_regc_init(acc_index); 80 95 if (status != PJ_SUCCESS) { 81 96 pjsua_perror(THIS_FILE, "Unable to create registration", … … 84 99 } 85 100 } 86 status = pjsip_regc_register(pjsua. regc, 1, &tdata);101 status = pjsip_regc_register(pjsua.acc[acc_index].regc, 1, &tdata); 87 102 } else { 88 if (pjsua. regc == NULL) {103 if (pjsua.acc[acc_index].regc == NULL) { 89 104 PJ_LOG(3,(THIS_FILE, "Currently not registered")); 90 105 return; 91 106 } 92 status = pjsip_regc_unregister(pjsua. regc, &tdata);107 status = pjsip_regc_unregister(pjsua.acc[acc_index].regc, &tdata); 93 108 } 94 109 95 110 if (status == PJ_SUCCESS) 96 status = pjsip_regc_send( pjsua. regc, tdata );111 status = pjsip_regc_send( pjsua.acc[acc_index].regc, tdata ); 97 112 98 113 if (status != PJ_SUCCESS) { … … 108 123 * Initialize client registration. 109 124 */ 110 pj_status_t pjsua_regc_init( void)125 pj_status_t pjsua_regc_init(int acc_index) 111 126 { 112 127 pj_status_t status; 113 128 114 129 /* initialize SIP registration if registrar is configured */ 115 if (pjsua. registrar_uri.slen) {130 if (pjsua.acc[acc_index].reg_uri.slen) { 116 131 117 status = pjsip_regc_create( pjsua.endpt, NULL, ®c_cb, &pjsua.regc); 132 status = pjsip_regc_create( pjsua.endpt, 133 &pjsua.acc[acc_index], 134 ®c_cb, 135 &pjsua.acc[acc_index].regc); 118 136 119 137 if (status != PJ_SUCCESS) { … … 124 142 125 143 126 status = pjsip_regc_init( pjsua.regc, &pjsua.registrar_uri, 127 &pjsua.local_uri, 128 &pjsua.local_uri, 129 1, &pjsua.contact_uri, 130 pjsua.reg_timeout); 144 status = pjsip_regc_init( pjsua.acc[acc_index].regc, 145 &pjsua.acc[acc_index].reg_uri, 146 &pjsua.acc[acc_index].local_uri, 147 &pjsua.acc[acc_index].local_uri, 148 1, &pjsua.acc[acc_index].contact_uri, 149 pjsua.acc[acc_index].reg_timeout); 131 150 if (status != PJ_SUCCESS) { 132 151 pjsua_perror(THIS_FILE, … … 136 155 } 137 156 138 pjsip_regc_set_credentials( pjsua.regc, pjsua.cred_count, 157 pjsip_regc_set_credentials( pjsua.acc[acc_index].regc, 158 pjsua.cred_count, 139 159 pjsua.cred_info ); 140 160 141 pjsip_regc_set_route_set( pjsua.regc, &pjsua.route_set ); 161 pjsip_regc_set_route_set( pjsua.acc[acc_index].regc, 162 &pjsua.acc[acc_index].route_set ); 142 163 } 143 164
Note: See TracChangeset
for help on using the changeset viewer.