Browse code

pua_mi: id parameter introduced in mi pua_publish

- the parameter is before etag
- required to refer to same call for dialog-info
- patch by Alex Hermann (SF#2826542)

Daniel-Constantin Mierla authored on 17/03/2010 19:32:40
Showing 3 changed files
... ...
@@ -14,27 +14,26 @@ Juha Heinanen
14 14
 
15 15
    Copyright � 2006 voice-system.ro
16 16
    Revision History
17
-   Revision $Revision$ $Date: 2008-08-06 12:08:33 +0200
18
-                              (Mi, 06 Aug 2008) $
19
-     __________________________________________________________
17
+   Revision $Revision$ $Date$
18
+     __________________________________________________________________
20 19
 
21 20
    Table of Contents
22 21
 
23 22
    1. Admin Guide
24 23
 
25
-        1.1. Overview
26
-        1.2. Dependencies
24
+        1. Overview
25
+        2. Dependencies
27 26
 
28
-              1.2.1. Kamailio Modules
29
-              1.2.2. External Libraries or Applications
27
+              2.1. Kamailio Modules
28
+              2.2. External Libraries or Applications
30 29
 
31
-        1.3. Exported Parameters
32
-        1.4. Exported Functions
33
-        1.5. Exported MI functions
30
+        3. Exported Parameters
31
+        4. Exported Functions
32
+        5. Exported MI functions
34 33
 
35
-              1.5.1. pua_publish
34
+              5.1. pua_publish
36 35
 
37
-        1.6. pua_subscribe
36
+        6. pua_subscribe
38 37
 
39 38
    List of Examples
40 39
 
... ...
@@ -42,44 +41,63 @@ Juha Heinanen
42 41
 
43 42
 Chapter 1. Admin Guide
44 43
 
45
-1.1. Overview
44
+   Table of Contents
45
+
46
+   1. Overview
47
+   2. Dependencies
48
+
49
+        2.1. Kamailio Modules
50
+        2.2. External Libraries or Applications
51
+
52
+   3. Exported Parameters
53
+   4. Exported Functions
54
+   5. Exported MI functions
55
+
56
+        5.1. pua_publish
57
+
58
+   6. pua_subscribe
46 59
 
47
-   The pua_mi offers the possibility to publish presence
48
-   information and subscribe to presence information via MI
49
-   transports.
60
+1. Overview
50 61
 
51
-   Using this module you can create independent
52
-   applications/scripts to publish not sip-related information
53
-   (e.g., system resources like CPU-usage, memory, number of
54
-   active subscribers ...). Also, this module allows non-SIP
55
-   speaking applications to subscribe presence information kept in
56
-   a SIP presence server.
62
+   The pua_mi offers the possibility to publish presence information and
63
+   subscribe to presence information via MI transports.
57 64
 
58
-1.2. Dependencies
65
+   Using this module you can create independent applications/scripts to
66
+   publish not sip-related information (e.g., system resources like
67
+   CPU-usage, memory, number of active subscribers ...). Also, this module
68
+   allows non-SIP speaking applications to subscribe presence information
69
+   kept in a SIP presence server.
59 70
 
60
-1.2.1. Kamailio Modules
71
+2. Dependencies
72
+
73
+   2.1. Kamailio Modules
74
+   2.2. External Libraries or Applications
75
+
76
+2.1. Kamailio Modules
61 77
 
62 78
    The following modules must be loaded before this module:
63 79
      * pua
64 80
 
65
-1.2.2. External Libraries or Applications
81
+2.2. External Libraries or Applications
66 82
 
67
-   The following libraries or applications must be installed
68
-   before running Kamailio with this module loaded:
83
+   The following libraries or applications must be installed before
84
+   running Kamailio with this module loaded:
69 85
      * none
70 86
 
71
-1.3. Exported Parameters
87
+3. Exported Parameters
72 88
 
73 89
      * none
74 90
 
75
-1.4. Exported Functions
91
+4. Exported Functions
92
+
93
+   The module does not export functions to be used in configuration
94
+   script.
76 95
 
77
-   The module does not export functions to be used in
78
-   configuration script.
96
+5. Exported MI functions
79 97
 
80
-1.5. Exported MI functions
98
+   5.1. pua_publish
81 99
 
82
-1.5.1.  pua_publish
100
+5.1.  pua_publish
83 101
 
84 102
    Command parameters:
85 103
      * presentity_uri - e.g. sip:system@kamailio.org
... ...
@@ -88,13 +106,18 @@ Chapter 1. Admin Guide
88 106
        information (e.g. presence).
89 107
      * content type - Content type of published information (e.g.
90 108
        application/pidf+xml) or . if no information is enclosed.
91
-     * ETag - ETag that publish should match or . if no ETag is
92
-       given.
93
-     * extra_headers - Extra headers added to PUBLISH request or .
94
-       if no extra headers.
109
+     * id - id for a series of related PUBLISHes to the same
110
+       presentity-uri or . to always use the same series. For example
111
+       dialog-info must reuse the same id for the same call otherwise
112
+       status will be lost when multiple parallel calls to/from the same
113
+       user take place. The dialog-id from the dialog-info body qualifies
114
+       as a suitable id here.
115
+     * ETag - ETag that publish should match or . if no ETag is given.
116
+     * extra_headers - Extra headers added to PUBLISH request or . if no
117
+       extra headers.
95 118
      * body - The body of the publish request containing published
96
-       information or missing if no published information. It has
97
-       to be a single line for FIFO transport.
119
+       information or missing if no published information. It has to be a
120
+       single line for FIFO transport.
98 121
 
99 122
    Example 1.1. pua_publish FIFO example
100 123
 ...
... ...
@@ -106,20 +129,19 @@ presence
106 129
 application/pidf+xml
107 130
 .
108 131
 .
109
-<?xml version='1.0'?><presence xmlns='urn:ietf:params:xml:ns:pidf' xmlns
110
-:dm='urn:ietf:params:xml:ns:pidf:data-model' xmlns:rpid='urn:ietf:params
111
-:xml:ns:pidf:rpid' xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='s
112
-ystem@kamailio.org'><tuple id='0x81475a0'><status><basic>open</basic></s
113
-tatus></tuple><dm:person id='pdd748945'><rpid:activities><rpid:away/>awa
114
-y</rpid:activities><dm:note>CPU:16 MEM:476</dm:note></dm:person></presen
115
-ce>
116
-
132
+.
133
+<?xml version='1.0'?><presence xmlns='urn:ietf:params:xml:ns:pidf' xmlns:dm='urn
134
+:ietf:params:xml:ns:pidf:data-model' xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpi
135
+d' xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='system@kamailio.org'><tup
136
+le id='0x81475a0'><status><basic>open</basic></status></tuple><dm:person id='pdd
137
+748945'><rpid:activities><rpid:away/>away</rpid:activities><dm:note>CPU:16 MEM:4
138
+76</dm:note></dm:person></presence>
117 139
 
118
-1.6.  pua_subscribe
140
+6.  pua_subscribe
119 141
 
120 142
    Command parameters:
121 143
      * presentity_uri - e.g. sip:presentity@kamailio.org
122 144
      * watcher_uri - e.g. sip:watcher@kamailio.org
123 145
      * event package
124
-     * expires - Relative time in seconds for the desired validity
125
-       of the subscription.
146
+     * expires - Relative time in seconds for the desired validity of the
147
+       subscription.
... ...
@@ -118,6 +118,18 @@
118 118
 		information is enclosed.
119 119
 			       </para> 
120 120
 			</listitem>
121
+			<listitem>
122
+				<para>
123
+					<emphasis>id</emphasis>
124
+					- id for a series of related PUBLISHes to the same 
125
+		presentity-uri or . to always use the same series.
126
+		For example dialog-info must reuse the same id for the
127
+		same call otherwise status will be lost when multiple
128
+		parallel calls to/from the same user take place. The
129
+		dialog-id from the dialog-info body qualifies as a suitable
130
+		id here.
131
+		                </para> 
132
+			</listitem>
121 133
 			<listitem>
122 134
 				<para>
123 135
 					<emphasis>ETag</emphasis>
... ...
@@ -154,6 +166,7 @@ presence
154 166
 application/pidf+xml
155 167
 .
156 168
 .
169
+.
157 170
 <?xml version='1.0'?><presence xmlns='urn:ietf:params:xml:ns:pidf' xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='system@kamailio.org'><tuple id='0x81475a0'><status><basic>open</basic></status></tuple><dm:person id='pdd748945'><rpid:activities><rpid:away/>away</rpid:activities><dm:note>CPU:16 MEM:476</dm:note></dm:person></presence>
158 171
 ]]>
159 172
 </programlisting>
... ...
@@ -58,6 +58,7 @@ struct mi_root* mi_pua_publish(struct mi_root* cmd, void* param)
58 58
 	publ_info_t publ;
59 59
 	str event;
60 60
 	str content_type;
61
+	str id;
61 62
 	str etag;
62 63
 	str extra_headers;
63 64
 	int result;
... ...
@@ -138,6 +139,19 @@ struct mi_root* mi_pua_publish(struct mi_root* cmd, void* param)
138 139
 	LM_DBG("content type '%.*s'\n",
139 140
 	    content_type.len, content_type.s);
140 141
 
142
+	node = node->next;
143
+	if(node == NULL)
144
+		return 0;
145
+
146
+	/* Get id */
147
+	id= node->value;
148
+	if(id.s== NULL || id.len== 0)
149
+	{
150
+		LM_ERR("empty id parameter\n");
151
+		return init_mi_tree(400, "Empty id parameter", 20);
152
+	}
153
+	LM_DBG("id '%.*s'\n", id.len, id.s);
154
+
141 155
 	node = node->next;
142 156
 	if(node == NULL)
143 157
 		return 0;
... ...
@@ -213,7 +227,12 @@ struct mi_root* mi_pua_publish(struct mi_root* cmd, void* param)
213 227
 	{
214 228
 		publ.content_type= content_type;
215 229
 	}	
216
-	
230
+
231
+	if(! (id.len== 1 && id.s[0]== '.'))
232
+	{
233
+		publ.id= id;
234
+	}
235
+
217 236
 	if(! (etag.len== 1 && etag.s[0]== '.'))
218 237
 	{
219 238
 		publ.etag= &etag;