Debian Codegraph @

Xpjproject/pjsip/src/pjsip-simple/dlg_event.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2024 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2013 Maxim Kondratenko <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include <pjsip-simple/dlg_event.h>
20 #include <pjsip-simple/errno.h>
21 #include <pjsip-simple/evsub_msg.h>
22 #include <pjsip/sip_module.h>
23 #include <pjsip/sip_multipart.h>
24 #include <pjsip/sip_endpoint.h>
25 #include <pjsip/sip_dialog.h>
26 #include <pj/assert.h>
27 #include <pj/guid.h>
28 #include <pj/log.h>
29 #include <pj/os.h>
30 #include <pj/pool.h>
31 #include <pj/string.h>
32
33
34 #define THIS_FILE "dlg_event.c"
35 #define DLG_EVENT_DEFAULT_EXPIRES PJSIP_DLG_EVENT_DEFAULT_EXPIRES
36
37 #if PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE < 200 || \
38 PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE > 699 || \
39 PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE/100 == 3
40 # error Invalid PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE value
41 #endif
42
43 /*
44 * Dialog event module (mod-dlg_event)
45 */
46 static struct pjsip_module mod_dlg_event =
47 {
48 NULL, NULL, /* prev, next. */
49 { "mod-dlg_event", 12 }, /* Name. */
50 -1, /* Id */
51 PJSIP_MOD_PRIORITY_DIALOG_USAGE,/* Priority */
52 NULL, /* load() */
53 NULL, /* start() */
54 NULL, /* stop() */
55 NULL, /* unload() */
56 NULL, /* on_rx_request() */
57 NULL, /* on_rx_response() */
58 NULL, /* on_tx_request. */
59 NULL, /* on_tx_response() */
60 NULL, /* on_tsx_state() */
61 };
62
63
64 /*
65 * Dialog event message body type.
66 */
67 typedef enum content_type_e
68 {
69 CONTENT_TYPE_NONE,
70 CONTENT_TYPE_DIALOG_INFO,
71 } content_type_e;
72
73 /*
74 * This structure describe an entity, for both subscriber and notifier.
75 */
76 struct pjsip_dlg_event
77 {
78 pjsip_evsub *sub; /**< Event subscription record. */
79 pjsip_dialog *dlg; /**< The dialog. */
80 content_type_e content_type; /**< Content-Type. */
81 pj_pool_t *status_pool; /**< Pool for dlgev_status */
82 pjsip_dlg_event_status status; /**< Dialog event status. */
83 pj_pool_t *tmp_pool; /**< Pool for tmp_status */
84 pjsip_dlg_event_status tmp_status; /**< Temp, before NOTIFY is answered */
85 pj_bool_t is_ts_valid; /**< Is tmp_status valid? */
86 pjsip_evsub_user user_cb; /**< The user callback. */
87 pj_mutex_t *mutex; /**< Mutex */
88 };
89
90 typedef struct pjsip_dlg_event pjsip_dlg_event;
91
92 /*
93 * Forward decl for evsub callback.
94 */
95 static void dlg_event_on_evsub_state(pjsip_evsub *sub, pjsip_event *event);
96 static void dlg_event_on_evsub_tsx_state(pjsip_evsub *sub, pjsip_transaction *tsx,
97 pjsip_event *event);
98 static void dlg_event_on_evsub_rx_notify(pjsip_evsub *sub,
99 pjsip_rx_data *rdata,
100 int *p_st_code,
101 pj_str_t **p_st_text,
102 pjsip_hdr *res_hdr,
103 pjsip_msg_body **p_body);
104 static void dlg_event_on_evsub_client_refresh(pjsip_evsub *sub);
105
106
107 /*
108 * Event subscription callback for dialog event.
109 */
110 static pjsip_evsub_user dlg_event_user =
111 {
112 &dlg_event_on_evsub_state,
113 &dlg_event_on_evsub_tsx_state,
114 NULL,
115 &dlg_event_on_evsub_rx_notify,
116 &dlg_event_on_evsub_client_refresh,
117 NULL,
118 };
119
120
121 /*
122 * Some static constants.
123 */
124 const pj_str_t STR_DIALOG_EVENT = { "Event", 5 };
125 const pj_str_t STR_DIALOG = { "dialog", 6 };
126 const pj_str_t STR_DIALOG_APPLICATION = { "application", 11 };
127 const pj_str_t STR_DIALOG_INFO_XML = { "dialog-info+xml", 15 };
128 const pj_str_t STR_APP_DIALOG_INFO_XML = { "application/dialog-info+xml", 27 };
129
130
131 /*
132 * Init dialog event module.
133 */
134 PJ_DEF(pj_status_t) pjsip_dlg_event_init_module(pjsip_endpoint *endpt,
135 pjsip_module *mod_evsub)
136 {
137 pj_status_t status;
138 pj_str_t accept[1];
139
140 /* Check arguments. */
141 PJ_ASSERT_RETURN(endpt && mod_evsub, PJ_EINVAL);
142
143 /* Must have not been registered */
144 PJ_ASSERT_RETURN(mod_dlg_event.id == -1, PJ_EINVALIDOP);
145
146 /* Register to endpoint */
147 status = pjsip_endpt_register_module(endpt, &mod_dlg_event);
148 if (status != PJ_SUCCESS)
149 return status;
150
151 accept[0] = STR_APP_DIALOG_INFO_XML;
152
153 /* Register event package to event module. */
154 status = pjsip_evsub_register_pkg(&mod_dlg_event, &STR_DIALOG,
155 DLG_EVENT_DEFAULT_EXPIRES,
156 PJ_ARRAY_SIZE(accept), accept);
157 if (status != PJ_SUCCESS) {
158 pjsip_endpt_unregister_module(endpt, &mod_dlg_event);
159 return status;
160 }
161
162 return PJ_SUCCESS;
163 }
164
165
166 /*
167 * Get dialog event module instance.
168 */
169 PJ_DEF(pjsip_module*) pjsip_dlg_event_instance(void)
170 {
171 return &mod_dlg_event;
172 }
173
174
175 /*
176 * Create client subscription.
177 */
178 PJ_DEF(pj_status_t)
179 pjsip_dlg_event_create_uac(pjsip_dialog *dlg,
180 const pjsip_evsub_user *user_cb,
181 unsigned options,
182 pjsip_evsub **p_evsub)
183 {
184 pj_status_t status;
185 pjsip_dlg_event *dlgev;
186 char obj_name[PJ_MAX_OBJ_NAME];
187 pjsip_evsub *sub;
188
189 PJ_ASSERT_RETURN(dlg && p_evsub, PJ_EINVAL);
190
191 pjsip_dlg_inc_lock(dlg);
192
193 /* Create event subscription */
194 status = pjsip_evsub_create_uac(dlg, &dlg_event_user, &STR_DIALOG,
195 options, &sub);
196 if (status != PJ_SUCCESS)
197 goto on_return;
198
199 /* Create dialog event */
200 dlgev = PJ_POOL_ZALLOC_T(dlg->pool, pjsip_dlg_event);
201 dlgev->dlg = dlg;
202 dlgev->sub = sub;
203 if (user_cb)
204 pj_memcpy(&dlgev->user_cb, user_cb, sizeof(pjsip_evsub_user));
205
206 status = pj_mutex_create_recursive(dlg->pool, "dlgev_mutex",
207 &dlgev->mutex);
208 if (status != PJ_SUCCESS)
209 goto on_return;
210
211 pj_ansi_snprintf(obj_name, PJ_MAX_OBJ_NAME, "dlgev%p", dlg->pool);
212 dlgev->status_pool = pj_pool_create(dlg->pool->factory, obj_name,
213 512, 512, NULL);
214 pj_ansi_snprintf(obj_name, PJ_MAX_OBJ_NAME, "tmdlgev%p", dlg->pool);
215 dlgev->tmp_pool = pj_pool_create(dlg->pool->factory, obj_name,
216 512, 512, NULL);
217
218 /* Attach to evsub */
219 pjsip_evsub_set_mod_data(sub, mod_dlg_event.id, dlgev);
220
221 *p_evsub = sub;
222
223 on_return:
224 pjsip_dlg_dec_lock(dlg);
225 return status;
226 }
227
228
229 /*
230 * Forcefully terminate dialog event.
231 */
232 PJ_DEF(pj_status_t) pjsip_dlg_event_terminate(pjsip_evsub *sub,
233 pj_bool_t notify)
234 {
235 return pjsip_evsub_terminate(sub, notify);
236 }
237
238 /*
239 * Create SUBSCRIBE
240 */
241 PJ_DEF(pj_status_t) pjsip_dlg_event_initiate(pjsip_evsub *sub,
242 pj_int32_t expires,
243 pjsip_tx_data **p_tdata)
244 {
245 return pjsip_evsub_initiate(sub, &pjsip_subscribe_method, expires,
246 p_tdata);
247 }
248
249
250 /*
251 * Add custom headers.
252 */
253 PJ_DEF(pj_status_t) pjsip_dlg_event_add_header(pjsip_evsub *sub,
254 const pjsip_hdr *hdr_list )
255 {
256 return pjsip_evsub_add_header( sub, hdr_list );
257 }
258
259
260 /*
261 * Accept incoming subscription.
262 */
263 PJ_DEF(pj_status_t) pjsip_dlg_event_accept(pjsip_evsub *sub,
264 pjsip_rx_data *rdata,
265 int st_code,
266 const pjsip_hdr *hdr_list)
267 {
268 return pjsip_evsub_accept( sub, rdata, st_code, hdr_list );
269 }
270
271
272 /*
273 * Get dialog event status.
274 */
275 PJ_DEF(pj_status_t) pjsip_dlg_event_get_status(pjsip_evsub *sub,
276 pjsip_dlg_event_status *status)
277 {
278 pjsip_dlg_event *dlgev;
279
280 PJ_ASSERT_RETURN(sub && status, PJ_EINVAL);
281
282 dlgev = (pjsip_dlg_event*) pjsip_evsub_get_mod_data(sub, mod_dlg_event.id);
283 PJ_ASSERT_RETURN(dlgev!=NULL, PJSIP_SIMPLE_ENOPRESENCE);
284
285 pj_mutex_lock(dlgev->mutex);
286
287 if (dlgev->is_ts_valid) {
288 PJ_ASSERT_ON_FAIL(dlgev->tmp_pool!=NULL,
289 {pj_mutex_unlock(dlgev->mutex);
290 return PJSIP_SIMPLE_ENOPRESENCE;});
291 pj_memcpy(status, &dlgev->tmp_status, sizeof(pjsip_dlg_event_status));
292 } else {
293 PJ_ASSERT_ON_FAIL(dlgev->status_pool!=NULL,
294 {pj_mutex_unlock(dlgev->mutex);
295 return PJSIP_SIMPLE_ENOPRESENCE;});
296 pj_memcpy(status, &dlgev->status, sizeof(pjsip_dlg_event_status));
297 }
298
299 pj_mutex_unlock(dlgev->mutex);
300
301 return PJ_SUCCESS;
302 }
303
304
305 /*
306 * Send request.
307 */
308 PJ_DEF(pj_status_t) pjsip_dlg_event_send_request(pjsip_evsub *sub,
309 pjsip_tx_data *tdata )
310 {
311 return pjsip_evsub_send_request(sub, tdata);
312 }
313
314
315
316 PJ_DEF(pj_status_t)
317 pjsip_dlg_event_parse_dialog_info(pjsip_rx_data *rdata,
318 pj_pool_t *pool,
319 pjsip_dlg_event_status *dlgev_st)
320 {
321 return pjsip_dlg_event_parse_dialog_info2(
322 (char*)rdata->msg_info.msg->body->data,
323 rdata->msg_info.msg->body->len,
324 pool, dlgev_st);
325 }
326
327 PJ_DEF(pj_status_t)
328 pjsip_dlg_event_parse_dialog_info2(char *body, unsigned body_len,
329 pj_pool_t *pool,
330 pjsip_dlg_event_status *dlgev_st)
331 {
332 pjsip_dlg_info_dialog_info *dialog_info;
333 pjsip_dlg_info_dialog *dialog;
334
335 dlgev_st->info_cnt = 0;
336 dialog_info = pjsip_dlg_info_parse(pool, body, body_len);
337 if (dialog_info == NULL)
338 return PJSIP_SIMPLE_EBADPIDF;
339
340 dialog = pjsip_dlg_info_dialog_info_get_dialog(dialog_info);
341 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_info_entity,
342 pjsip_dlg_info_dialog_info_get_entity(dialog_info));
343 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_info_state,
344 pjsip_dlg_info_dialog_info_get_state(dialog_info));
345
346 if (dialog) {
347 pjsip_dlg_info_local * local;
348 pjsip_dlg_info_remote * remote;
349
350 dlgev_st->info[dlgev_st->info_cnt].dialog_node =
351 pj_xml_clone(pool, dialog);
352
353 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_id,
354 pjsip_dlg_info_dialog_get_id(dialog));
355 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_call_id,
356 pjsip_dlg_info_dialog_get_call_id(dialog));
357 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_remote_tag,
358 pjsip_dlg_info_dialog_get_remote_tag(dialog));
359 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_local_tag,
360 pjsip_dlg_info_dialog_get_local_tag(dialog));
361 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_direction,
362 pjsip_dlg_info_dialog_get_direction(dialog));
363 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_state,
364 pjsip_dlg_info_dialog_get_state(dialog));
365 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].dialog_duration,
366 pjsip_dlg_info_dialog_get_duration(dialog));
367
368 local =pjsip_dlg_info_dialog_get_local(dialog);
369 if (local) {
370 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].local_identity,
371 pjsip_dlg_info_local_get_identity(local));
372 pj_strdup(pool,
373 &dlgev_st->info[dlgev_st->info_cnt].local_identity_display,
374 pjsip_dlg_info_local_get_identity_display(local));
375 pj_strdup(pool,
376 &dlgev_st->info[dlgev_st->info_cnt].local_target_uri,
377 pjsip_dlg_info_local_get_target_uri(local));
378 } else {
379 dlgev_st->info[dlgev_st->info_cnt].local_identity.ptr = NULL;
380 dlgev_st->info[dlgev_st->info_cnt].local_identity_display.ptr =
381 NULL;
382 dlgev_st->info[dlgev_st->info_cnt].local_target_uri.ptr = NULL;
383 }
384
385 remote = pjsip_dlg_info_dialog_get_remote(dialog);
386 if (remote) {
387 pj_strdup(pool, &dlgev_st->info[dlgev_st->info_cnt].remote_identity,
388 pjsip_dlg_info_remote_get_identity(remote));
389 pj_strdup(pool,
390 &dlgev_st->info[dlgev_st->info_cnt].remote_identity_display,
391 pjsip_dlg_info_remote_get_identity_display(remote));
392 pj_strdup(pool,
393 &dlgev_st->info[dlgev_st->info_cnt].remote_target_uri,
394 pjsip_dlg_info_remote_get_target_uri(remote));
395 } else {
396 dlgev_st->info[dlgev_st->info_cnt].remote_identity.ptr = NULL;
397 dlgev_st->info[dlgev_st->info_cnt].remote_identity_display.ptr =
398 NULL;
399 dlgev_st->info[dlgev_st->info_cnt].remote_target_uri.ptr = NULL;
400 }
401 } else {
402 dlgev_st->info[dlgev_st->info_cnt].dialog_node = NULL;
403 }
404 dlgev_st->info_cnt++;
405
406 return PJ_SUCCESS;
407 }
408
409
410 /*
411 * This callback is called by event subscription when subscription
412 * state has changed.
413 */
414 static void dlg_event_on_evsub_state( pjsip_evsub *sub, pjsip_event *event)
415 {
416 pjsip_dlg_event *dlgev;
417
418 dlgev = (pjsip_dlg_event*) pjsip_evsub_get_mod_data(sub, mod_dlg_event.id);
419 PJ_ASSERT_ON_FAIL(dlgev!=NULL, {return;});
420
421 if (dlgev->user_cb.on_evsub_state)
422 (*dlgev->user_cb.on_evsub_state)(sub, event);
423
424 if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) {
425 if (dlgev->status_pool) {
426 pj_pool_release(dlgev->status_pool);
427 dlgev->status_pool = NULL;
428 }
429 if (dlgev->tmp_pool) {
430 pj_pool_release(dlgev->tmp_pool);
431 dlgev->tmp_pool = NULL;
432 }
433 if (dlgev->mutex) {
434 pj_mutex_destroy(dlgev->mutex);
435 dlgev->mutex = NULL;
436 }
437 }
438 }
439
440 /*
441 * Called when transaction state has changed.
442 */
443 static void dlg_event_on_evsub_tsx_state(pjsip_evsub *sub,
444 pjsip_transaction *tsx,
445 pjsip_event *event)
446 {
447 pjsip_dlg_event *dlgev;
448
449 dlgev = (pjsip_dlg_event*) pjsip_evsub_get_mod_data(sub, mod_dlg_event.id);
450 PJ_ASSERT_ON_FAIL(dlgev!=NULL, {return;});
451
452 if (dlgev->user_cb.on_tsx_state)
453 (*dlgev->user_cb.on_tsx_state)(sub, tsx, event);
454 }
455
456
457 /*
458 * Process the content of incoming NOTIFY request and update temporary
459 * status.
460 *
461 * return PJ_SUCCESS if incoming request is acceptable. If return value
462 * is not PJ_SUCCESS, res_hdr may be added with Warning header.
463 */
464 static pj_status_t
465 dlg_event_process_rx_notify(pjsip_dlg_event *dlgev,
466 pjsip_rx_data *rdata,
467 int *p_st_code,
468 pj_str_t **p_st_text,
469 pjsip_hdr *res_hdr)
470 {
471 pjsip_ctype_hdr *ctype_hdr;
472 pj_status_t status = PJ_SUCCESS;
473
474 *p_st_text = NULL;
475
476 /* Check Content-Type and msg body are dlgevent. */
477 ctype_hdr = rdata->msg_info.ctype;
478
479 if (ctype_hdr==NULL || rdata->msg_info.msg->body==NULL)
480 {
481 pjsip_warning_hdr *warn_hdr;
482 pj_str_t warn_text;
483
484 *p_st_code = PJSIP_SC_BAD_REQUEST;
485
486 warn_text = pj_str("Message body is not dlgevent");
487 warn_hdr = pjsip_warning_hdr_create(rdata->tp_info.pool, 399,
488 pjsip_endpt_name(dlgev->dlg->endpt),
489 &warn_text);
490 pj_list_push_back(res_hdr, warn_hdr);
491
492 return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_BAD_REQUEST);
493 }
494
495 /* Parse content. */
496 if (pj_stricmp(&ctype_hdr->media.type, &STR_DIALOG_APPLICATION)==0 &&
497 pj_stricmp(&ctype_hdr->media.subtype, &STR_DIALOG_INFO_XML)==0)
498 {
499 status = pjsip_dlg_event_parse_dialog_info(rdata, dlgev->tmp_pool,
500 &dlgev->tmp_status);
501 }
502 else {
503 status = PJSIP_SIMPLE_EBADCONTENT;
504 }
505
506 /* If application calls dlgev_get_status(), redirect the call to
507 * retrieve the temporary status.
508 */
509 dlgev->is_ts_valid = (status == PJ_SUCCESS? PJ_TRUE: PJ_FALSE);
510
511 if (status != PJ_SUCCESS) {
512 /* Unsupported or bad Content-Type */
513 if (PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE >= 300) {
514 pjsip_accept_hdr *accept_hdr;
515 pjsip_warning_hdr *warn_hdr;
516
517 *p_st_code = PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE;
518
519 /* Add Accept header */
520 accept_hdr = pjsip_accept_hdr_create(rdata->tp_info.pool);
521 accept_hdr->values[accept_hdr->count++] = STR_APP_DIALOG_INFO_XML;
522 pj_list_push_back(res_hdr, accept_hdr);
523
524 /* Add Warning header */
525 warn_hdr = pjsip_warning_hdr_create_from_status(
526 rdata->tp_info.pool,
527 pjsip_endpt_name(dlgev->dlg->endpt),
528 status);
529 pj_list_push_back(res_hdr, warn_hdr);
530
531 return status;
532 } else {
533 pj_assert(PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE/100 == 2);
534 PJ_PERROR(4,(THIS_FILE, status,
535 "Ignoring dlgev error due to "
536 "PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE setting [%d]",
537 PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE));
538 *p_st_code = PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE;
539 status = PJ_SUCCESS;
540 }
541 }
542
543 return PJ_SUCCESS;
544 }
545
546
547 /*
548 * Called when NOTIFY is received.
549 */
550 static void dlg_event_on_evsub_rx_notify(pjsip_evsub *sub,
551 pjsip_rx_data *rdata,
552 int *p_st_code,
553 pj_str_t **p_st_text,
554 pjsip_hdr *res_hdr,
555 pjsip_msg_body **p_body)
556 {
557 pjsip_dlg_event *dlgev;
558 pj_status_t status;
559
560 dlgev = (pjsip_dlg_event*) pjsip_evsub_get_mod_data(sub, mod_dlg_event.id);
561 PJ_ASSERT_ON_FAIL(dlgev!=NULL, {return;});
562
563 if (rdata->msg_info.msg->body) {
564 status = dlg_event_process_rx_notify( dlgev, rdata, p_st_code, p_st_text,
565 res_hdr );
566 if (status != PJ_SUCCESS)
567 return;
568
569 } else {
570 unsigned i;
571 pj_mutex_lock(dlgev->mutex);
572 for (i=0; i<dlgev->status.info_cnt; ++i) {
573 dlgev->status.info[i].dialog_node = NULL;
574 }
575 pj_mutex_unlock(dlgev->mutex);
576 }
577
578 /* Notify application. */
579 if (dlgev->user_cb.on_rx_notify) {
580 (*dlgev->user_cb.on_rx_notify)(sub, rdata, p_st_code, p_st_text,
581 res_hdr, p_body);
582 }
583
584
585 /* If application responded NOTIFY with 2xx, copy temporary status
586 * to main status, and mark the temporary status as invalid.
587 */
588 pj_mutex_lock(dlgev->mutex);
589
590 if ((*p_st_code)/100 == 2) {
591 pj_pool_t *tmp;
592
593 pj_memcpy(&dlgev->status, &dlgev->tmp_status,
594 sizeof(pjsip_dlg_event_status));
595
596 /* Swap the pool */
597 tmp = dlgev->tmp_pool;
598 dlgev->tmp_pool = dlgev->status_pool;
599 dlgev->status_pool = tmp;
600 }
601
602 dlgev->is_ts_valid = PJ_FALSE;
603 pj_pool_reset(dlgev->tmp_pool);
604
605 pj_mutex_unlock(dlgev->mutex);
606
607 /* Done */
608 }
609
610 /*
611 * Called when it's time to send SUBSCRIBE.
612 */
613 static void dlg_event_on_evsub_client_refresh(pjsip_evsub *sub)
614 {
615 pjsip_dlg_event *dlgev;
616
617 dlgev = (pjsip_dlg_event*) pjsip_evsub_get_mod_data(sub, mod_dlg_event.id);
618 PJ_ASSERT_ON_FAIL(dlgev!=NULL, {return;});
619
620 if (dlgev->user_cb.on_client_refresh) {
621 (*dlgev->user_cb.on_client_refresh)(sub);
622 } else {
623 pj_status_t status;
624 pjsip_tx_data *tdata;
625
626 status = pjsip_dlg_event_initiate(sub, -1, &tdata);
627 if (status == PJ_SUCCESS)
628 pjsip_dlg_event_send_request(sub, tdata);
629 }
630 }