mirror of https://github.com/sipwise/kamailio.git
Introduce the force_dummy_dialog parameter for presence_dialoginfo modparam("presence_dialoginfo", "force_dummy_dialog", 1) Change-Id: If2981db948c421cc626bfac93d113cd217c839cdchanges/11/1111/2
parent
852eacea8a
commit
4a9f398c41
@ -1,55 +0,0 @@
|
||||
--- a/modules/presence_dialoginfo/notify_body.c
|
||||
+++ b/modules/presence_dialoginfo/notify_body.c
|
||||
@@ -74,8 +74,10 @@
|
||||
LM_DBG("[pres_user]=%.*s [pres_domain]= %.*s, [n]=%d\n",
|
||||
pres_user->len, pres_user->s, pres_domain->len, pres_domain->s, n);
|
||||
|
||||
- if(body_array== NULL)
|
||||
- return NULL;
|
||||
+ if(body_array== NULL) {
|
||||
+ n = 0; /* just to be safe */
|
||||
+ /* return NULL; */
|
||||
+ }
|
||||
|
||||
n_body= agregate_xmls(pres_user, pres_domain, body_array, n);
|
||||
LM_DBG("[n_body]=%p\n", n_body);
|
||||
@@ -126,13 +128,17 @@
|
||||
LM_DBG("[pres_user]=%.*s [pres_domain]= %.*s, [n]=%d\n",
|
||||
pres_user->len, pres_user->s, pres_domain->len, pres_domain->s, n);
|
||||
|
||||
- xml_array = (xmlDocPtr*)pkg_malloc( n*sizeof(xmlDocPtr));
|
||||
- if(xml_array== NULL)
|
||||
+ if (n > 0)
|
||||
{
|
||||
- LM_ERR("while allocating memory");
|
||||
- return NULL;
|
||||
+ xml_array = (xmlDocPtr*)pkg_malloc( n*sizeof(xmlDocPtr));
|
||||
+ if(xml_array== NULL)
|
||||
+ {
|
||||
+ LM_ERR("while allocating memory");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ memset(xml_array, 0, n*sizeof(xmlDocPtr)) ;
|
||||
}
|
||||
- memset(xml_array, 0, n*sizeof(xmlDocPtr)) ;
|
||||
+ else xml_array = NULL;
|
||||
|
||||
/* parse all the XML documents */
|
||||
for(i=0; i<n; i++)
|
||||
@@ -153,14 +159,14 @@
|
||||
j++;
|
||||
|
||||
}
|
||||
-
|
||||
+#if 0
|
||||
if(j== 0) /* no body */
|
||||
{
|
||||
if(xml_array)
|
||||
pkg_free(xml_array);
|
||||
return NULL;
|
||||
}
|
||||
-
|
||||
+#endif
|
||||
/* n: number of bodies in total */
|
||||
/* j: number of useful bodies; created XML structures */
|
||||
/* i: loop counter */
|
@ -0,0 +1,144 @@
|
||||
From 5c9b3afca092dfda33c96dbf5195b8f7bbc2d4cf Mon Sep 17 00:00:00 2001
|
||||
From: lazedo <luis.azedo@factorlusitano.com>
|
||||
Date: Wed, 28 Jan 2015 17:31:06 +0000
|
||||
Subject: [PATCH 1/2] presence_dialoginfo : optionally send dummy dialog
|
||||
|
||||
---
|
||||
.../doc/presence_dialoginfo_admin.xml | 25 ++++++++++++
|
||||
modules/presence_dialoginfo/notify_body.c | 47 +++++++++++++++++++++-
|
||||
modules/presence_dialoginfo/presence_dialoginfo.c | 2 +
|
||||
3 files changed, 73 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/modules/presence_dialoginfo/doc/presence_dialoginfo_admin.xml b/modules/presence_dialoginfo/doc/presence_dialoginfo_admin.xml
|
||||
index b06df96..09901c4 100644
|
||||
--- a/modules/presence_dialoginfo/doc/presence_dialoginfo_admin.xml
|
||||
+++ b/modules/presence_dialoginfo/doc/presence_dialoginfo_admin.xml
|
||||
@@ -223,6 +223,31 @@ modparam("presence_dialoginfo", "force_single_dialog", 1)
|
||||
</example>
|
||||
</section>
|
||||
|
||||
+ <section>
|
||||
+ <title><varname>force_dummy_dialog</varname> (int)</title>
|
||||
+ <para>
|
||||
+ By default the module returns null body
|
||||
+ if there are no bodies to aggregate.
|
||||
+ some sip clients like Bria expect at least one dialog.
|
||||
+ you can activate this parameter to send a dummy dialog.
|
||||
+ </para>
|
||||
+ <para>
|
||||
+ If this parameter is set and there are no dialog bodies to aggregate,
|
||||
+ it will return a dummy dialog.
|
||||
+ </para>
|
||||
+ <para>
|
||||
+ <emphasis>Default value is <quote>0</quote>.</emphasis>
|
||||
+ </para>
|
||||
+ <example>
|
||||
+ <title>Set <varname></varname> parameter</title>
|
||||
+ <programlisting format="linespecific">
|
||||
+...
|
||||
+modparam("presence_dialoginfo", "force_dummy_dialog", 1)
|
||||
+...
|
||||
+</programlisting>
|
||||
+ </example>
|
||||
+ </section>
|
||||
+
|
||||
</section>
|
||||
|
||||
<section>
|
||||
diff --git a/modules/presence_dialoginfo/notify_body.c b/modules/presence_dialoginfo/notify_body.c
|
||||
index 97b9421..bd2097b 100644
|
||||
--- a/modules/presence_dialoginfo/notify_body.c
|
||||
+++ b/modules/presence_dialoginfo/notify_body.c
|
||||
@@ -56,6 +56,7 @@ str* agregate_xmls(str* pres_user, str* pres_domain, str** body_array, int n);
|
||||
int check_relevant_state (xmlChar * dialog_id, xmlDocPtr * xml_array, int total_nodes);
|
||||
|
||||
extern int force_single_dialog;
|
||||
+extern int force_dummy_dialog;
|
||||
|
||||
void free_xml_body(char* body)
|
||||
{
|
||||
@@ -66,6 +67,47 @@ void free_xml_body(char* body)
|
||||
body= NULL;
|
||||
}
|
||||
|
||||
+#define DIALOGINFO_EMPTY_BODY "<dialog-info>\
|
||||
+<dialog direction=\"recipient\">\
|
||||
+<state>terminated</state>\
|
||||
+</dialog>\
|
||||
+</dialog-info>"
|
||||
+
|
||||
+#define DIALOGINFO_EMPTY_BODY_SIZE 512
|
||||
+
|
||||
+str* dlginfo_agg_nbody_empty(str* pres_user, str* pres_domain)
|
||||
+{
|
||||
+ str* n_body= NULL;
|
||||
+
|
||||
+ LM_DBG("creating empty dialog for [pres_user]=%.*s [pres_domain]= %.*s\n",
|
||||
+ pres_user->len, pres_user->s, pres_domain->len, pres_domain->s);
|
||||
+
|
||||
+ str* body_array = (str*)pkg_malloc(sizeof(str));
|
||||
+ char* body = (char*)pkg_malloc(DIALOGINFO_EMPTY_BODY_SIZE);
|
||||
+ sprintf(body, DIALOGINFO_EMPTY_BODY);//, pres_user->len, pres_user->s, pres_domain->len, pres_domain->s);
|
||||
+ body_array->s = body;
|
||||
+ body_array->len = strlen(body);
|
||||
+
|
||||
+
|
||||
+ n_body= agregate_xmls(pres_user, pres_domain, &body_array, 1);
|
||||
+ LM_DBG("[n_body]=%p\n", n_body);
|
||||
+ if(n_body) {
|
||||
+ LM_DBG("[*n_body]=%.*s\n",n_body->len, n_body->s);
|
||||
+ }
|
||||
+ if(n_body== NULL)
|
||||
+ {
|
||||
+ LM_ERR("while aggregating body\n");
|
||||
+ }
|
||||
+
|
||||
+ pkg_free(body);
|
||||
+ pkg_free(body_array);
|
||||
+
|
||||
+
|
||||
+ xmlCleanupParser();
|
||||
+ xmlMemoryDump();
|
||||
+
|
||||
+ return n_body;
|
||||
+}
|
||||
|
||||
str* dlginfo_agg_nbody(str* pres_user, str* pres_domain, str** body_array, int n, int off_index)
|
||||
{
|
||||
@@ -74,9 +116,12 @@ str* dlginfo_agg_nbody(str* pres_user, str* pres_domain, str** body_array, int n
|
||||
LM_DBG("[pres_user]=%.*s [pres_domain]= %.*s, [n]=%d\n",
|
||||
pres_user->len, pres_user->s, pres_domain->len, pres_domain->s, n);
|
||||
|
||||
- if(body_array== NULL)
|
||||
+ if(body_array== NULL && (!force_dummy_dialog))
|
||||
return NULL;
|
||||
|
||||
+ if(body_array== NULL)
|
||||
+ return dlginfo_agg_nbody_empty(pres_user, pres_domain);
|
||||
+
|
||||
n_body= agregate_xmls(pres_user, pres_domain, body_array, n);
|
||||
LM_DBG("[n_body]=%p\n", n_body);
|
||||
if(n_body) {
|
||||
diff --git a/modules/presence_dialoginfo/presence_dialoginfo.c b/modules/presence_dialoginfo/presence_dialoginfo.c
|
||||
index d519dba..7395a78 100644
|
||||
--- a/modules/presence_dialoginfo/presence_dialoginfo.c
|
||||
+++ b/modules/presence_dialoginfo/presence_dialoginfo.c
|
||||
@@ -51,6 +51,7 @@ add_event_t pres_add_event;
|
||||
|
||||
/* module parameters */
|
||||
int force_single_dialog = 0;
|
||||
+int force_dummy_dialog = 0;
|
||||
|
||||
/* module exported commands */
|
||||
static cmd_export_t cmds[] =
|
||||
@@ -61,6 +62,7 @@ static cmd_export_t cmds[] =
|
||||
/* module exported paramaters */
|
||||
static param_export_t params[] = {
|
||||
{ "force_single_dialog", INT_PARAM, &force_single_dialog },
|
||||
+ { "force_dummy_dialog", INT_PARAM, &force_dummy_dialog },
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,27 @@
|
||||
From f12f243e39c840b1306bf376c49ef4dab9e7564f Mon Sep 17 00:00:00 2001
|
||||
From: lazedo <luis.azedo@factorlusitano.com>
|
||||
Date: Tue, 24 Feb 2015 17:19:15 +0000
|
||||
Subject: [PATCH 2/2] presence_dialoginfo: rfc4235 in dummy dialog
|
||||
|
||||
according to rfc4235 the id element is mandatory.
|
||||
granstream phones are affected by this.
|
||||
---
|
||||
modules/presence_dialoginfo/notify_body.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/modules/presence_dialoginfo/notify_body.c b/modules/presence_dialoginfo/notify_body.c
|
||||
index bd2097b..508b9f8 100644
|
||||
--- a/modules/presence_dialoginfo/notify_body.c
|
||||
+++ b/modules/presence_dialoginfo/notify_body.c
|
||||
@@ -68,7 +68,7 @@ void free_xml_body(char* body)
|
||||
}
|
||||
|
||||
#define DIALOGINFO_EMPTY_BODY "<dialog-info>\
|
||||
-<dialog direction=\"recipient\">\
|
||||
+<dialog id=\"615293b33c62dec073e05d9421e9f48b\" direction=\"recipient\">\
|
||||
<state>terminated</state>\
|
||||
</dialog>\
|
||||
</dialog-info>"
|
||||
--
|
||||
2.1.4
|
||||
|
Loading…
Reference in new issue