Skip to content

Commit e6956ce

Browse files
committed
dialog: add active_only parameter to load_dialog_ctx
The new parameter makes the function to return only active dialogs - dialogs that are in state <= 4
1 parent 62b1c0d commit e6956ce

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

modules/dialog/dialog.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int w_get_dlg_vals(struct sip_msg *msg, pv_spec_t *v_name,
149149
pv_spec_t *v_val, str *callid);
150150
static int w_tsl_dlg_flag(struct sip_msg *msg, void *_idx, int *_val);
151151
static int w_set_dlg_shtag(struct sip_msg *msg, str *shtag);
152-
static int load_dlg_ctx(struct sip_msg *msg, str *callid, void* lmode);
152+
static int load_dlg_ctx(struct sip_msg *msg, str *callid, void* lmode, int *active);
153153
static int unload_dlg_ctx(struct sip_msg *msg);
154154

155155
static int fixup_route(void** param);
@@ -263,7 +263,8 @@ static const cmd_export_t cmds[]={
263263
REQUEST_ROUTE},
264264
{"load_dialog_ctx",(cmd_function)load_dlg_ctx, {
265265
{CMD_PARAM_STR,0,0},
266-
{CMD_PARAM_STR|CMD_PARAM_OPT,fixup_lmode,0}, {0,0,0}},
266+
{CMD_PARAM_STR|CMD_PARAM_OPT,fixup_lmode,0},
267+
{CMD_PARAM_INT|CMD_PARAM_OPT,0,0}, {0,0,0}},
267268
ALL_ROUTES},
268269
{"unload_dialog_ctx",(cmd_function)unload_dlg_ctx,
269270
{{0,0,0}}, ALL_ROUTES},
@@ -2409,10 +2410,11 @@ static int fixup_leg(void **param)
24092410
}
24102411

24112412

2412-
static int load_dlg_ctx(struct sip_msg *msg, str *callid, void *lmode)
2413+
static int load_dlg_ctx(struct sip_msg *msg, str *callid, void *lmode, int *active)
24132414
{
24142415
struct dlg_cell *dlg = NULL;
24152416
int mode;
2417+
int active_only = (active?*active:0);
24162418

24172419
if (lmode)
24182420
mode = (int)(long)lmode;
@@ -2427,12 +2429,12 @@ static int load_dlg_ctx(struct sip_msg *msg, str *callid, void *lmode)
24272429
switch (mode) {
24282430
case DLG_CTX_LOAD_BY_CALLID:
24292431
/* callid */
2430-
dlg = get_dlg_by_callid( callid, 0 );
2432+
dlg = get_dlg_by_callid( callid, active_only );
24312433
break;
24322434

24332435
case DLG_CTX_LOAD_BY_DID:
24342436
/* did */
2435-
dlg = get_dlg_by_did( callid, 0);
2437+
dlg = get_dlg_by_did( callid, active_only );
24362438
break;
24372439
}
24382440

modules/dialog/doc/dialog_admin.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ if ( get_dialogs_by_profile("caller",$fU,$avp(dlg_jsons),$avp(dlg_no)) ) {
18821882

18831883
<section id="func_load_dialog_ctx" xreflabel="load_dialog_ctx()">
18841884
<title>
1885-
<function moreinfo="none">load_dialog_ctx( dialog [, id_type])</function>
1885+
<function moreinfo="none">load_dialog_ctx( dialog [, id_type] [, active_only])</function>
18861886
</title>
18871887
<para>
18881888
The function loads and switches to the context of the given dialog.
@@ -1910,6 +1910,13 @@ if ( get_dialogs_by_profile("caller",$fU,$avp(dlg_jsons),$avp(dlg_no)) ) {
19101910
will be assumed.
19111911
</para>
19121912
</listitem>
1913+
<listitem>
1914+
<para><emphasis>id_type (integer,optional)</emphasis> - if
1915+
set to something different than <emphasis>0</emphasis>,
1916+
it only considers active dialogs - dialogs that are not
1917+
deleted.
1918+
</para>
1919+
</listitem>
19131920
</itemizedlist>
19141921
<para>
19151922
This function can be used from any type of route.

0 commit comments

Comments
 (0)