| 2257 | * Handler on incoming SUBSCRIBE |
| 2258 | */ |
| 2259 | static void on_incoming_subscribe(pjsua_acc_id acc_id, |
| 2260 | pjsua_srv_pres *srv_pres, |
| 2261 | pjsua_buddy_id buddy_id, |
| 2262 | const pj_str_t *from, |
| 2263 | pjsip_rx_data *rdata, |
| 2264 | pjsip_status_code *code, |
| 2265 | pj_str_t *reason, |
| 2266 | pjsua_msg_data *msg_data) |
| 2267 | { |
| 2268 | PJ_UNUSED_ARG(acc_id); |
| 2269 | PJ_UNUSED_ARG(srv_pres); |
| 2270 | PJ_UNUSED_ARG(from); |
| 2271 | PJ_UNUSED_ARG(rdata); |
| 2272 | PJ_UNUSED_ARG(reason); |
| 2273 | PJ_UNUSED_ARG(msg_data); |
| 2274 | |
| 2275 | /* Accept immediately if incoming subscription is from friends */ |
| 2276 | if (buddy_id != PJSUA_INVALID_ID) { |
| 2277 | *code = 200; |
| 2278 | return; |
| 2279 | } |
| 2280 | |
| 2281 | PJ_LOG(3,(THIS_FILE, "Incoming subscription request from %.*s", |
| 2282 | (int)from->slen, from->ptr)); |
| 2283 | |
| 2284 | *code = 202; |
| 2285 | |
| 2286 | sub_pending_acc_id = acc_id; |
| 2287 | sub_pending_pres = srv_pres; |
| 2288 | } |
| 2289 | |
| 2290 | /* |
2262 | | PJ_LOG(3,(THIS_FILE, "%.*s status is %.*s", |
2263 | | (int)info.uri.slen, |
2264 | | info.uri.ptr, |
2265 | | (int)info.status_text.slen, |
2266 | | info.status_text.ptr)); |
| 2299 | if (info.sub_state == PJSIP_EVSUB_STATE_TERMINATED) { |
| 2300 | PJ_LOG(3,(THIS_FILE, "%.*s subscription terminated (reason=%.*s)", |
| 2301 | (int)info.uri.slen, |
| 2302 | info.uri.ptr, |
| 2303 | (int)info.sub_term_reason.slen, |
| 2304 | info.sub_term_reason.ptr)); |
| 2305 | |
| 2306 | } else if (info.sub_state != PJSIP_EVSUB_STATE_NULL) { |
| 2307 | PJ_LOG(3,(THIS_FILE, "%.*s status is %.*s", |
| 2308 | (int)info.uri.slen, |
| 2309 | info.uri.ptr, |
| 2310 | (int)info.status_text.slen, |
| 2311 | info.status_text.ptr)); |
| 2312 | } |
| 3817 | if (menuin[1]=='a') { |
| 3818 | pjsua_pres_notify(sub_pending_acc_id, sub_pending_pres, |
| 3819 | PJSIP_EVSUB_STATE_ACTIVE, NULL, NULL, |
| 3820 | PJ_TRUE, NULL); |
| 3821 | } else { |
| 3822 | pj_str_t reason = pj_str("unauthorized"); |
| 3823 | pjsua_pres_notify(sub_pending_acc_id, sub_pending_pres, |
| 3824 | PJSIP_EVSUB_STATE_TERMINATED, NULL, &reason, |
| 3825 | PJ_TRUE, NULL); |
| 3826 | } |
| 3827 | |
| 3828 | sub_pending_pres = NULL; |
| 3829 | sub_pending_acc_id = PJSUA_INVALID_ID; |
| 3830 | break; |
| 3831 | |