Browse code

modules_k/*: moved k modules in directory modules/

Daniel-Constantin Mierla authored on 20/01/2013 11:57:52
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,394 +0,0 @@
1
-/*
2
- * $Id: add_events.c  2007-05-03 15:05:20Z anca_vamanu $
3
- *
4
- * pua module - presence user agent module
5
- *
6
- * Copyright (C) 2007 Voice Sistem S.R.L.
7
- *
8
- * This file is part of Kamailio, a free SIP server.
9
- *
10
- * Kamailio is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * Kamailio is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
- *
24
- *	initial version 2007-05-03 (anca)
25
- */
26
-#include <stdio.h>
27
-#include <stdlib.h>
28
-#include <string.h>
29
-#include <libxml/parser.h>
30
-
31
-#include "event_list.h"
32
-#include "add_events.h"
33
-#include "pua.h"
34
-#include "pidf.h"
35
-
36
-extern int dlginfo_increase_version;
37
-
38
-int pua_add_events(void)
39
-{
40
-	/* add presence */
41
-	if(add_pua_event(PRESENCE_EVENT, "presence", "application/pidf+xml", 
42
-				pres_process_body)< 0)
43
-	{
44
-		LM_ERR("while adding event presence\n");
45
-		return -1;
46
-	}
47
-
48
-	/* add dialog */
49
-	if (dlginfo_increase_version) {
50
-		if(add_pua_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml",
51
-					bla_process_body)< 0)
52
-		{
53
-			LM_ERR("while adding event dialog w/ dlginfo_increase_version\n");
54
-			return -1;
55
-		}
56
-	} else {
57
-		if(add_pua_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml",
58
-					dlg_process_body)< 0)
59
-		{
60
-			LM_ERR("while adding event dialog w/o dlginfo_increase_version\n");
61
-			return -1;
62
-		}
63
-	}
64
-
65
-	/* add dialog;sla */
66
-	if(add_pua_event(BLA_EVENT, "dialog;sla", "application/dialog-info+xml",
67
-				bla_process_body)< 0)
68
-	{
69
-		LM_ERR("while adding event dialog;sla\n");
70
-		return -1;
71
-	}
72
-
73
-	/* add message-summary*/
74
-	if(add_pua_event(MSGSUM_EVENT, "message-summary", 
75
-				"application/simple-message-summary", mwi_process_body)< 0)
76
-	{
77
-		LM_ERR("while adding event message-summary\n");
78
-		return -1;
79
-	}
80
-	
81
-	/* add presence;winfo */
82
-	if(add_pua_event(PWINFO_EVENT, "presence.winfo", NULL, NULL)< 0)
83
-	{
84
-		LM_ERR("while adding event presence.winfo\n");
85
-		return -1;
86
-	}
87
-	
88
-	/* add application/reginfo+xml */
89
-	if (dlginfo_increase_version) {
90
-		if(add_pua_event(REGINFO_EVENT, "reg", "application/reginfo+xml", reginfo_process_body)< 0) {
91
-			LM_ERR("while adding event application/reginfo+xml with version increase\n");
92
-			return -1;
93
-		}
94
-	} else {
95
-		if(add_pua_event(REGINFO_EVENT, "reg", "application/reginfo+xml", dlg_process_body)< 0) {
96
-			LM_ERR("while adding event application/reginfo+xml\n");
97
-			return -1;
98
-		}
99
-	}
100
-	
101
-	return 0;
102
-
103
-}	
104
-
105
-int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_param)
106
-{
107
-
108
-	xmlDocPtr doc= NULL;
109
-	xmlNodePtr node= NULL;
110
-	char* tuple_id= NULL, *person_id= NULL;
111
-	int tuple_id_len= 0;
112
-	char buf[50];
113
-	str* body= NULL;
114
-	int alloc_tuple= 0;
115
-	str* tuple= NULL;
116
-
117
-	doc= xmlParseMemory(publ->body->s, publ->body->len );
118
-	if(doc== NULL)
119
-	{
120
-		LM_ERR("while parsing xml memory\n");
121
-		goto error;
122
-	}
123
-
124
-	node= xmlDocGetNodeByName(doc, "tuple", NULL);
125
-	if(node == NULL)
126
-	{
127
-		LM_ERR("while extracting tuple node\n");
128
-		goto error;
129
-	}
130
-	tuple= *(tuple_param);
131
-
132
-	tuple_id= xmlNodeGetAttrContentByName(node, "id");
133
-	if(tuple_id== NULL)
134
-	{
135
-
136
-		if(tuple== NULL)	// generate a tuple_id
137
-		{
138
-			tuple_id= buf;
139
-			tuple_id_len= sprintf(tuple_id, "%p", publ);
140
-			tuple_id[tuple_id_len]= '\0'; 
141
-
142
-			tuple=(str*)pkg_malloc(sizeof(str));
143
-			if(tuple== NULL)
144
-			{
145
-				LM_ERR("No more memory\n");
146
-				goto error;
147
-			}
148
-			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
149
-			if(tuple->s== NULL)
150
-			{
151
-				LM_ERR("NO more memory\n");
152
-				goto error;
153
-			}
154
-			memcpy(tuple->s, tuple_id, tuple_id_len);
155
-			tuple->len= tuple_id_len;
156
-
157
-			*tuple_param= tuple;
158
-			alloc_tuple= 1;
159
-
160
-			LM_DBG("allocated tuple_id\n\n");
161
-		}
162
-		else
163
-		{
164
-			tuple_id= buf;
165
-			tuple_id_len= tuple->len;
166
-			memcpy(tuple_id, tuple->s, tuple_id_len);
167
-			tuple_id[tuple_id_len]= '\0';
168
-		}
169
-		/* add tuple id */
170
-		if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
171
-		{
172
-			LM_ERR("while extracting xml"
173
-						" node\n");
174
-			goto error;
175
-		}
176
-	}
177
-	else
178
-	{
179
-		if(tuple== NULL)
180
-		{
181
-			strcpy(buf, tuple_id);
182
-			xmlFree(tuple_id);
183
-			tuple_id= buf;
184
-			tuple_id_len= strlen(tuple_id);
185
-		
186
-			tuple=(str*)pkg_malloc(sizeof(str));
187
-			if(tuple== NULL)
188
-			{
189
-				LM_ERR("No more memory\n");
190
-				goto error;
191
-			}
192
-			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
193
-			if(tuple->s== NULL)
194
-			{
195
-				LM_ERR("NO more memory\n");
196
-				goto error;
197
-			}
198
-			memcpy(tuple->s, tuple_id, tuple_id_len);
199
-			tuple->len= tuple_id_len;
200
-			*tuple_param= tuple;
201
-			alloc_tuple= 1;
202
-		}
203
-	}
204
-
205
-	node= xmlDocGetNodeByName(doc, "person", NULL);
206
-	if(node)
207
-	{
208
-		LM_DBG("found person node\n");
209
-		person_id= xmlNodeGetAttrContentByName(node, "id");
210
-		if(person_id== NULL)
211
-		{	
212
-			if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
213
-			{
214
-				LM_ERR("while extracting xml"
215
-						" node\n");
216
-				goto error;
217
-			}
218
-		}
219
-		else
220
-		{
221
-			xmlFree(person_id);
222
-		}
223
-	}	
224
-	body= (str*)pkg_malloc(sizeof(str));
225
-	if(body== NULL)
226
-	{
227
-		LM_ERR("NO more memory left\n");
228
-		goto error;
229
-	}
230
-	memset(body, 0, sizeof(str));
231
-	xmlDocDumpFormatMemory(doc,(xmlChar**)(void*)&body->s, &body->len, 1);	
232
-	if(body->s== NULL || body->len== 0)
233
-	{
234
-		LM_ERR("while dumping xml format\n");
235
-		goto error;
236
-	}	
237
-	xmlFreeDoc(doc);
238
-	doc= NULL;
239
-	
240
-	*fin_body= body;
241
-	xmlMemoryDump();
242
-	xmlCleanupParser();
243
-	return 1;
244
-
245
-error:
246
-	if(doc)
247
-		xmlFreeDoc(doc);
248
-	if(body)
249
-		pkg_free(body);
250
-	if(tuple && alloc_tuple)
251
-	{
252
-		if(tuple->s)
253
-			pkg_free(tuple->s);
254
-		pkg_free(tuple);
255
-		tuple= NULL;
256
-	}
257
-	return -1;
258
-
259
-}	
260
-
261
-int bla_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
262
-{
263
-	xmlNodePtr node= NULL;
264
-	xmlDocPtr doc= NULL;
265
-	char* version;
266
-	str* body= NULL;
267
-	int len;
268
-	str* init_body;
269
-
270
-	init_body= publ->body;
271
-
272
-	doc= xmlParseMemory(init_body->s, init_body->len );
273
-	if(doc== NULL)
274
-	{
275
-		LM_ERR("while parsing xml memory\n");
276
-		goto error;
277
-	}
278
-	/* change version and state*/
279
-	node= xmlDocGetNodeByName(doc, "dialog-info", NULL);
280
-	if(node == NULL)
281
-	{
282
-		LM_ERR("while extracting dialog-info node\n");
283
-		goto error;
284
-	}
285
-	version= int2str(ver,&len);
286
-	version[len]= '\0';
287
-
288
-	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL)
289
-	{
290
-		LM_ERR("while setting version attribute\n");
291
-		goto error;	
292
-	}
293
-	body= (str*)pkg_malloc(sizeof(str));
294
-	if(body== NULL)
295
-	{
296
-		LM_ERR("NO more memory left\n");
297
-		goto error;
298
-	}
299
-	memset(body, 0, sizeof(str));
300
-	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);	
301
-
302
-	xmlFreeDoc(doc);
303
-	doc= NULL;
304
-	*fin_body= body;	
305
-	if(*fin_body== NULL)
306
-		LM_DBG("NULL fin_body\n");
307
-
308
-	xmlMemoryDump();
309
-	xmlCleanupParser();
310
-	LM_DBG("successful\n");
311
-	return 1;
312
-
313
-error:
314
-	if(doc)
315
-		xmlFreeDoc(doc);
316
-	if(body)
317
-		pkg_free(body);
318
-	
319
-	xmlMemoryDump();
320
-	xmlCleanupParser();
321
-	return -1;
322
-}
323
-
324
-int reginfo_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
325
-{
326
-	xmlNodePtr node= NULL;
327
-	xmlDocPtr doc= NULL;
328
-	char* version;
329
-	str* body= NULL;
330
-	int len;
331
-	str* init_body;
332
-
333
-	init_body= publ->body;
334
-
335
-	doc= xmlParseMemory(init_body->s, init_body->len );
336
-	if(doc== NULL) {
337
-		LM_ERR("while parsing xml memory\n");
338
-		goto error;
339
-	}
340
-	/* change version and state*/
341
-	node= xmlDocGetNodeByName(doc, "reginfo", NULL);
342
-	if(node == NULL) {
343
-		LM_ERR("while extracting dialog-info node\n");
344
-		goto error;
345
-	}
346
-	version= int2str(ver,&len);
347
-	version[len]= '\0';
348
-
349
-	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL) {
350
-		LM_ERR("while setting version attribute\n");
351
-		goto error;	
352
-	}
353
-	body= (str*)pkg_malloc(sizeof(str));
354
-	if(body== NULL) {
355
-		LM_ERR("NO more memory left\n");
356
-		goto error;
357
-	}
358
-	memset(body, 0, sizeof(str));
359
-	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);	
360
-
361
-	xmlFreeDoc(doc);
362
-	doc= NULL;
363
-	*fin_body= body;	
364
-	if(*fin_body== NULL)
365
-		LM_DBG("NULL fin_body\n");
366
-
367
-	xmlMemoryDump();
368
-	xmlCleanupParser();
369
-	LM_DBG("successful\n");
370
-	return 1;
371
-
372
-error:
373
-	if(doc)
374
-		xmlFreeDoc(doc);
375
-	if(body)
376
-		pkg_free(body);
377
-	
378
-	xmlMemoryDump();
379
-	xmlCleanupParser();
380
-	return -1;
381
-}
382
-
383
-int mwi_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
384
-{
385
-	*fin_body= publ->body;
386
-	return 0;
387
-}
388
-
389
-int dlg_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
390
-{
391
-	*fin_body= publ->body;
392
-	return 0;
393
-}
394
-
Browse code

- Merge of the implementation of the RFC3680 (reginfo-package) into master

Carsten Bock authored on 13/06/2011 13:04:27
Showing 1 changed files
... ...
@@ -85,6 +85,19 @@ int pua_add_events(void)
85 85
 		return -1;
86 86
 	}
87 87
 	
88
+	/* add application/reginfo+xml */
89
+	if (dlginfo_increase_version) {
90
+		if(add_pua_event(REGINFO_EVENT, "reg", "application/reginfo+xml", reginfo_process_body)< 0) {
91
+			LM_ERR("while adding event application/reginfo+xml with version increase\n");
92
+			return -1;
93
+		}
94
+	} else {
95
+		if(add_pua_event(REGINFO_EVENT, "reg", "application/reginfo+xml", dlg_process_body)< 0) {
96
+			LM_ERR("while adding event application/reginfo+xml\n");
97
+			return -1;
98
+		}
99
+	}
100
+	
88 101
 	return 0;
89 102
 
90 103
 }	
... ...
@@ -308,6 +321,65 @@ error:
308 321
 	return -1;
309 322
 }
310 323
 
324
+int reginfo_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
325
+{
326
+	xmlNodePtr node= NULL;
327
+	xmlDocPtr doc= NULL;
328
+	char* version;
329
+	str* body= NULL;
330
+	int len;
331
+	str* init_body;
332
+
333
+	init_body= publ->body;
334
+
335
+	doc= xmlParseMemory(init_body->s, init_body->len );
336
+	if(doc== NULL) {
337
+		LM_ERR("while parsing xml memory\n");
338
+		goto error;
339
+	}
340
+	/* change version and state*/
341
+	node= xmlDocGetNodeByName(doc, "reginfo", NULL);
342
+	if(node == NULL) {
343
+		LM_ERR("while extracting dialog-info node\n");
344
+		goto error;
345
+	}
346
+	version= int2str(ver,&len);
347
+	version[len]= '\0';
348
+
349
+	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL) {
350
+		LM_ERR("while setting version attribute\n");
351
+		goto error;	
352
+	}
353
+	body= (str*)pkg_malloc(sizeof(str));
354
+	if(body== NULL) {
355
+		LM_ERR("NO more memory left\n");
356
+		goto error;
357
+	}
358
+	memset(body, 0, sizeof(str));
359
+	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);	
360
+
361
+	xmlFreeDoc(doc);
362
+	doc= NULL;
363
+	*fin_body= body;	
364
+	if(*fin_body== NULL)
365
+		LM_DBG("NULL fin_body\n");
366
+
367
+	xmlMemoryDump();
368
+	xmlCleanupParser();
369
+	LM_DBG("successful\n");
370
+	return 1;
371
+
372
+error:
373
+	if(doc)
374
+		xmlFreeDoc(doc);
375
+	if(body)
376
+		pkg_free(body);
377
+	
378
+	xmlMemoryDump();
379
+	xmlCleanupParser();
380
+	return -1;
381
+}
382
+
311 383
 int mwi_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
312 384
 {
313 385
 	*fin_body= publ->body;
Browse code

* Fixed pua module memory leak. Credits to Anca Vamanu.

Juha Heinanen authored on 13/05/2009 12:39:09
Showing 1 changed files
... ...
@@ -114,10 +114,11 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
114 114
 		LM_ERR("while extracting tuple node\n");
115 115
 		goto error;
116 116
 	}
117
+	tuple= *(tuple_param);
118
+
117 119
 	tuple_id= xmlNodeGetAttrContentByName(node, "id");
118 120
 	if(tuple_id== NULL)
119 121
 	{
120
-		tuple= *(tuple_param);
121 122
 
122 123
 		if(tuple== NULL)	// generate a tuple_id
123 124
 		{
... ...
@@ -144,7 +145,6 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
144 145
 			alloc_tuple= 1;
145 146
 
146 147
 			LM_DBG("allocated tuple_id\n\n");
147
-
148 148
 		}
149 149
 		else
150 150
 		{
... ...
@@ -152,7 +152,7 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
152 152
 			tuple_id_len= tuple->len;
153 153
 			memcpy(tuple_id, tuple->s, tuple_id_len);
154 154
 			tuple_id[tuple_id_len]= '\0';
155
-		}	
155
+		}
156 156
 		/* add tuple id */
157 157
 		if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
158 158
 		{
... ...
@@ -184,10 +184,10 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
184 184
 			}
185 185
 			memcpy(tuple->s, tuple_id, tuple_id_len);
186 186
 			tuple->len= tuple_id_len;
187
+			*tuple_param= tuple;
187 188
 			alloc_tuple= 1;
188
-
189
-		}	
190
-	}	
189
+		}
190
+	}
191 191
 
192 192
 	node= xmlDocGetNodeByName(doc, "person", NULL);
193 193
 	if(node)
Browse code

* modules: presence_mwi, presence_xml, pua, pua_mi

Moved back to modules_k presence related modules, because they include
stuff from sl module that does not exist in modules yet.

Juha Heinanen authored on 18/04/2009 12:53:54
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,322 @@
1
+/*
2
+ * $Id: add_events.c  2007-05-03 15:05:20Z anca_vamanu $
3
+ *
4
+ * pua module - presence user agent module
5
+ *
6
+ * Copyright (C) 2007 Voice Sistem S.R.L.
7
+ *
8
+ * This file is part of Kamailio, a free SIP server.
9
+ *
10
+ * Kamailio is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version
14
+ *
15
+ * Kamailio is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License 
21
+ * along with this program; if not, write to the Free Software 
22
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
+ *
24
+ *	initial version 2007-05-03 (anca)
25
+ */
26
+#include <stdio.h>
27
+#include <stdlib.h>
28
+#include <string.h>
29
+#include <libxml/parser.h>
30
+
31
+#include "event_list.h"
32
+#include "add_events.h"
33
+#include "pua.h"
34
+#include "pidf.h"
35
+
36
+extern int dlginfo_increase_version;
37
+
38
+int pua_add_events(void)
39
+{
40
+	/* add presence */
41
+	if(add_pua_event(PRESENCE_EVENT, "presence", "application/pidf+xml", 
42
+				pres_process_body)< 0)
43
+	{
44
+		LM_ERR("while adding event presence\n");
45
+		return -1;
46
+	}
47
+
48
+	/* add dialog */
49
+	if (dlginfo_increase_version) {
50
+		if(add_pua_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml",
51
+					bla_process_body)< 0)
52
+		{
53
+			LM_ERR("while adding event dialog w/ dlginfo_increase_version\n");
54
+			return -1;
55
+		}
56
+	} else {
57
+		if(add_pua_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml",
58
+					dlg_process_body)< 0)
59
+		{
60
+			LM_ERR("while adding event dialog w/o dlginfo_increase_version\n");
61
+			return -1;
62
+		}
63
+	}
64
+
65
+	/* add dialog;sla */
66
+	if(add_pua_event(BLA_EVENT, "dialog;sla", "application/dialog-info+xml",
67
+				bla_process_body)< 0)
68
+	{
69
+		LM_ERR("while adding event dialog;sla\n");
70
+		return -1;
71
+	}
72
+
73
+	/* add message-summary*/
74
+	if(add_pua_event(MSGSUM_EVENT, "message-summary", 
75
+				"application/simple-message-summary", mwi_process_body)< 0)
76
+	{
77
+		LM_ERR("while adding event message-summary\n");
78
+		return -1;
79
+	}
80
+	
81
+	/* add presence;winfo */
82
+	if(add_pua_event(PWINFO_EVENT, "presence.winfo", NULL, NULL)< 0)
83
+	{
84
+		LM_ERR("while adding event presence.winfo\n");
85
+		return -1;
86
+	}
87
+	
88
+	return 0;
89
+
90
+}	
91
+
92
+int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_param)
93
+{
94
+
95
+	xmlDocPtr doc= NULL;
96
+	xmlNodePtr node= NULL;
97
+	char* tuple_id= NULL, *person_id= NULL;
98
+	int tuple_id_len= 0;
99
+	char buf[50];
100
+	str* body= NULL;
101
+	int alloc_tuple= 0;
102
+	str* tuple= NULL;
103
+
104
+	doc= xmlParseMemory(publ->body->s, publ->body->len );
105
+	if(doc== NULL)
106
+	{
107
+		LM_ERR("while parsing xml memory\n");
108
+		goto error;
109
+	}
110
+
111
+	node= xmlDocGetNodeByName(doc, "tuple", NULL);
112
+	if(node == NULL)
113
+	{
114
+		LM_ERR("while extracting tuple node\n");
115
+		goto error;
116
+	}
117
+	tuple_id= xmlNodeGetAttrContentByName(node, "id");
118
+	if(tuple_id== NULL)
119
+	{
120
+		tuple= *(tuple_param);
121
+
122
+		if(tuple== NULL)	// generate a tuple_id
123
+		{
124
+			tuple_id= buf;
125
+			tuple_id_len= sprintf(tuple_id, "%p", publ);
126
+			tuple_id[tuple_id_len]= '\0'; 
127
+
128
+			tuple=(str*)pkg_malloc(sizeof(str));
129
+			if(tuple== NULL)
130
+			{
131
+				LM_ERR("No more memory\n");
132
+				goto error;
133
+			}
134
+			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
135
+			if(tuple->s== NULL)
136
+			{
137
+				LM_ERR("NO more memory\n");
138
+				goto error;
139
+			}
140
+			memcpy(tuple->s, tuple_id, tuple_id_len);
141
+			tuple->len= tuple_id_len;
142
+
143
+			*tuple_param= tuple;
144
+			alloc_tuple= 1;
145
+
146
+			LM_DBG("allocated tuple_id\n\n");
147
+
148
+		}
149
+		else
150
+		{
151
+			tuple_id= buf;
152
+			tuple_id_len= tuple->len;
153
+			memcpy(tuple_id, tuple->s, tuple_id_len);
154
+			tuple_id[tuple_id_len]= '\0';
155
+		}	
156
+		/* add tuple id */
157
+		if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
158
+		{
159
+			LM_ERR("while extracting xml"
160
+						" node\n");
161
+			goto error;
162
+		}
163
+	}
164
+	else
165
+	{
166
+		if(tuple== NULL)
167
+		{
168
+			strcpy(buf, tuple_id);
169
+			xmlFree(tuple_id);
170
+			tuple_id= buf;
171
+			tuple_id_len= strlen(tuple_id);
172
+		
173
+			tuple=(str*)pkg_malloc(sizeof(str));
174
+			if(tuple== NULL)
175
+			{
176
+				LM_ERR("No more memory\n");
177
+				goto error;
178
+			}
179
+			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
180
+			if(tuple->s== NULL)
181
+			{
182
+				LM_ERR("NO more memory\n");
183
+				goto error;
184
+			}
185
+			memcpy(tuple->s, tuple_id, tuple_id_len);
186
+			tuple->len= tuple_id_len;
187
+			alloc_tuple= 1;
188
+
189
+		}	
190
+	}	
191
+
192
+	node= xmlDocGetNodeByName(doc, "person", NULL);
193
+	if(node)
194
+	{
195
+		LM_DBG("found person node\n");
196
+		person_id= xmlNodeGetAttrContentByName(node, "id");
197
+		if(person_id== NULL)
198
+		{	
199
+			if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
200
+			{
201
+				LM_ERR("while extracting xml"
202
+						" node\n");
203
+				goto error;
204
+			}
205
+		}
206
+		else
207
+		{
208
+			xmlFree(person_id);
209
+		}
210
+	}	
211
+	body= (str*)pkg_malloc(sizeof(str));
212
+	if(body== NULL)
213
+	{
214
+		LM_ERR("NO more memory left\n");
215
+		goto error;
216
+	}
217
+	memset(body, 0, sizeof(str));
218
+	xmlDocDumpFormatMemory(doc,(xmlChar**)(void*)&body->s, &body->len, 1);	
219
+	if(body->s== NULL || body->len== 0)
220
+	{
221
+		LM_ERR("while dumping xml format\n");
222
+		goto error;
223
+	}	
224
+	xmlFreeDoc(doc);
225
+	doc= NULL;
226
+	
227
+	*fin_body= body;
228
+	xmlMemoryDump();
229
+	xmlCleanupParser();
230
+	return 1;
231
+
232
+error:
233
+	if(doc)
234
+		xmlFreeDoc(doc);
235
+	if(body)
236
+		pkg_free(body);
237
+	if(tuple && alloc_tuple)
238
+	{
239
+		if(tuple->s)
240
+			pkg_free(tuple->s);
241
+		pkg_free(tuple);
242
+		tuple= NULL;
243
+	}
244
+	return -1;
245
+
246
+}	
247
+
248
+int bla_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
249
+{
250
+	xmlNodePtr node= NULL;
251
+	xmlDocPtr doc= NULL;
252
+	char* version;
253
+	str* body= NULL;
254
+	int len;
255
+	str* init_body;
256
+
257
+	init_body= publ->body;
258
+
259
+	doc= xmlParseMemory(init_body->s, init_body->len );
260
+	if(doc== NULL)
261
+	{
262
+		LM_ERR("while parsing xml memory\n");
263
+		goto error;
264
+	}
265
+	/* change version and state*/
266
+	node= xmlDocGetNodeByName(doc, "dialog-info", NULL);
267
+	if(node == NULL)
268
+	{
269
+		LM_ERR("while extracting dialog-info node\n");
270
+		goto error;
271
+	}
272
+	version= int2str(ver,&len);
273
+	version[len]= '\0';
274
+
275
+	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL)
276
+	{
277
+		LM_ERR("while setting version attribute\n");
278
+		goto error;	
279
+	}
280
+	body= (str*)pkg_malloc(sizeof(str));
281
+	if(body== NULL)
282
+	{
283
+		LM_ERR("NO more memory left\n");
284
+		goto error;
285
+	}
286
+	memset(body, 0, sizeof(str));
287
+	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);	
288
+
289
+	xmlFreeDoc(doc);
290
+	doc= NULL;
291
+	*fin_body= body;	
292
+	if(*fin_body== NULL)
293
+		LM_DBG("NULL fin_body\n");
294
+
295
+	xmlMemoryDump();
296
+	xmlCleanupParser();
297
+	LM_DBG("successful\n");
298
+	return 1;
299
+
300
+error:
301
+	if(doc)
302
+		xmlFreeDoc(doc);
303
+	if(body)
304
+		pkg_free(body);
305
+	
306
+	xmlMemoryDump();
307
+	xmlCleanupParser();
308
+	return -1;
309
+}
310
+
311
+int mwi_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
312
+{
313
+	*fin_body= publ->body;
314
+	return 0;
315
+}
316
+
317
+int dlg_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
318
+{
319
+	*fin_body= publ->body;
320
+	return 0;
321
+}
322
+
Browse code

* modules: peering, pua, pua_mi, presence, presence_xml, presence_mwi

Moved some k modules that don't exist in s from modules_k to modules.

Juha Heinanen authored on 18/04/2009 12:29:07
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,322 +0,0 @@
1
-/*
2
- * $Id: add_events.c  2007-05-03 15:05:20Z anca_vamanu $
3
- *
4
- * pua module - presence user agent module
5
- *
6
- * Copyright (C) 2007 Voice Sistem S.R.L.
7
- *
8
- * This file is part of Kamailio, a free SIP server.
9
- *
10
- * Kamailio is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * Kamailio is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
- *
24
- *	initial version 2007-05-03 (anca)
25
- */
26
-#include <stdio.h>
27
-#include <stdlib.h>
28
-#include <string.h>
29
-#include <libxml/parser.h>
30
-
31
-#include "event_list.h"
32
-#include "add_events.h"
33
-#include "pua.h"
34
-#include "pidf.h"
35
-
36
-extern int dlginfo_increase_version;
37
-
38
-int pua_add_events(void)
39
-{
40
-	/* add presence */
41
-	if(add_pua_event(PRESENCE_EVENT, "presence", "application/pidf+xml", 
42
-				pres_process_body)< 0)
43
-	{
44
-		LM_ERR("while adding event presence\n");
45
-		return -1;
46
-	}
47
-
48
-	/* add dialog */
49
-	if (dlginfo_increase_version) {
50
-		if(add_pua_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml",
51
-					bla_process_body)< 0)
52
-		{
53
-			LM_ERR("while adding event dialog w/ dlginfo_increase_version\n");
54
-			return -1;
55
-		}
56