Browse code

presence_xml: use parameter default_expires instead of 3600 constant

- GH #2996

Adrian Tabacioiu authored on 14/01/2022 13:33:34 • Daniel-Constantin Mierla committed on 18/01/2022 19:19:16
Showing 4 changed files
... ...
@@ -33,6 +33,7 @@
33 33
 #include "../../core/parser/parse_content.h"
34 34
 #include "../../core/data_lump_rpl.h"
35 35
 #include "../../core/ut.h"
36
+#include "../presence/presence.h"
36 37
 #include "xcap_auth.h"
37 38
 #include "notify_body.h"
38 39
 #include "add_events.h"
... ...
@@ -65,7 +66,7 @@ int xml_add_events(void)
65 66
 		event.agg_nbody = pres_agg_nbody;
66 67
 		event.evs_publ_handl = xml_publ_handl;
67 68
 		event.free_body = free_xml_body;
68
-		event.default_expires = 3600;
69
+		event.default_expires = pxml_default_expires;
69 70
 		event.get_rules_doc = pres_get_rules_doc;
70 71
 		event.get_pidf_doc = pres_get_pidf_doc;
71 72
 		if(psapi.add_event(&event) < 0) {
... ...
@@ -85,7 +86,7 @@ int xml_add_events(void)
85 86
 		event.content_type.len = 27;
86 87
 		event.type = WINFO_TYPE;
87 88
 		event.free_body = free_xml_body;
88
-		event.default_expires = 3600;
89
+		event.default_expires = pxml_default_expires;
89 90
 
90 91
 		if(psapi.add_event(&event) < 0) {
91 92
 			LM_ERR("while adding event presence.winfo\n");
... ...
@@ -106,7 +107,7 @@ int xml_add_events(void)
106 107
 		event.content_type.len = 27;
107 108
 		event.type = PUBL_TYPE;
108 109
 		event.free_body = free_xml_body;
109
-		event.default_expires = 3600;
110
+		event.default_expires = pxml_default_expires;
110 111
 		if(psapi.add_event(&event) < 0) {
111 112
 			LM_ERR("while adding event dialog;sla\n");
112 113
 			return -1;
... ...
@@ -124,7 +125,7 @@ int xml_add_events(void)
124 125
 		event.content_type.len = 25;
125 126
 
126 127
 		event.type = PUBL_TYPE;
127
-		event.default_expires = 3600;
128
+		event.default_expires = pxml_default_expires;
128 129
 		if(psapi.add_event(&event) < 0) {
129 130
 			LM_ERR("while adding event xcap-diff\n");
130 131
 			return -1;
... ...
@@ -413,6 +413,27 @@ modparam("presence_xml", "presence_single_body_lookup_element", "status")
413 413
 </programlisting>
414 414
         </example>
415 415
     </section>
416
+
417
+<section id="presence_xml.p.default_expires">
418
+        <title><varname>default_expires</varname> (int)</title>
419
+        <para>
420
+        The default expires value used when missing from SUBSCRIBE
421
+        message (in seconds).
422
+        </para>
423
+        <para>
424
+        <emphasis>Default value is <quote>3600</quote>.
425
+        </emphasis>
426
+        </para>
427
+        <example>
428
+        <title>Set <varname>default_expires</varname> parameter</title>
429
+        <programlisting format="linespecific">
430
+...
431
+modparam("presence_xml", "default_expires", 3600)
432
+...
433
+</programlisting>
434
+    </example>
435
+</section>
436
+
416 437
 	</section>
417 438
 
418 439
 
... ...
@@ -98,6 +98,8 @@ int pxml_force_single_body = 0;
98 98
 str pxml_single_body_priorities = str_init("Available|Ringing|On the Phone");
99 99
 str pxml_single_body_lookup_element = str_init("note");
100 100
 
101
+unsigned int pxml_default_expires = 3600;
102
+
101 103
 /** SL API structure */
102 104
 sl_api_t slb;
103 105
 
... ...
@@ -138,6 +140,7 @@ static param_export_t params[]={
138 140
 	{ "force_presence_single_body", INT_PARAM, &pxml_force_single_body },
139 141
 	{ "presence_single_body_priorities",  PARAM_STR, &pxml_single_body_priorities },
140 142
 	{ "presence_single_body_lookup_element", PARAM_STR, &pxml_single_body_lookup_element },
143
+	{ "default_expires", INT_PARAM, &pxml_default_expires },
141 144
 	{ 0, 0, 0}
142 145
 };
143 146
 /* clang-format on */
... ...
@@ -53,4 +53,6 @@ extern int pxml_integrated_xcap_server;
53 53
 extern xcap_serv_t *xs_list;
54 54
 extern xcapGetNewDoc_t xcap_GetNewDoc;
55 55
 
56
+extern unsigned int pxml_default_expires;
57
+
56 58
 #endif