Hello all,

I'm trying to implement rfc4235 support in OpenSER. After teaching OpenSER 
about the dialog event [patch 1], it should have been able to handle PUBLISH 
and SUBSCRIBE with event: dialog.

But it didn't.

After a debugging session it was concluded that _only_ for dialog events, 
OpenSER does not take the RURI as presentity URI, but the From: header. My 
question is why is there a special case for the dialog event in the _general_ 
presence module? Especially since it breaks dialog events.

My guess is that it is to support dialog;bla, but the current implementation 
(hack?) breaks regular dialog support.

The second patch extends the current special case to require the event: dialog 
header to have a parameter, but in my opinion it would be cleaner if there 
aren't any event specific hacks in the general presence module. Unfortunately 
I have no clue how bla works, so no usefull input from me.

Patches are against 1.3+svn

Feedback is welcomed.
-- 
Greetings,

Alex Hermann
Index: openser-1.3/modules/presence_xml/add_events.c
===================================================================
--- openser-1.3.orig/modules/presence_xml/add_events.c	2008-07-21 17:14:32.000000000 +0200
+++ openser-1.3/modules/presence_xml/add_events.c	2008-07-21 17:35:40.000000000 +0200
@@ -106,6 +106,23 @@
 		return -1;
 	}
 	
+	/* constructing dialog event */
+	memset(&event, 0, sizeof(pres_ev_t));
+	event.name.s= "dialog";
+	event.name.len= 6;
+
+	event.etag_not_new= 1;
+	event.evs_publ_handl= xml_publ_handl;
+	event.content_type.s= "application/dialog-info+xml";
+	event.content_type.len= 27;
+	event.type= PUBL_TYPE;
+	event.free_body= free_xml_body;
+	event.default_expires= 3600;
+	if(pres_add_event(&event)< 0)
+	{
+		LM_ERR("while adding event dialog\n");
+		return -1;
+	}
 	return 0;
 }
 /*
Index: openser-1.3/modules/pua/add_events.c
===================================================================
--- openser-1.3.orig/modules/pua/add_events.c	2008-07-21 17:15:06.000000000 +0200
+++ openser-1.3/modules/pua/add_events.c	2008-07-22 13:49:05.000000000 +0200
@@ -43,6 +43,14 @@
 		return -1;
 	}
 
+	/* add dialog */
+	if(add_pua_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml",
+				bla_process_body)< 0)
+	{
+		LM_ERR("while adding event presence\n");
+		return -1;
+	}
+	
 	/* add dialog;sla */
 	if(add_pua_event(BLA_EVENT, "dialog;sla", "application/dialog-info+xml",
 				bla_process_body)< 0)
@@ -295,3 +303,8 @@
 	return 0;
 }
 
+int dialog_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
+{
+	*fin_body= publ->body;
+	return 0;
+}
Index: openser-1.3/modules/pua/add_events.h
===================================================================
--- openser-1.3.orig/modules/pua/add_events.h	2008-07-21 17:15:06.000000000 +0200
+++ openser-1.3/modules/pua/add_events.h	2008-07-21 17:35:40.000000000 +0200
@@ -38,5 +38,6 @@
 int pres_process_body(struct publ_info* publ, str** fin_body, int ver, str** tuple);
 int bla_process_body (struct publ_info* publ, str** fin_body, int ver, str** tuple);
 int mwi_process_body (struct publ_info* publ, str** fin_body, int ver, str** tuple);
+int dialog_process_body (struct publ_info* publ, str** fin_body, int ver, str** tuple);
 
 #endif
Index: openser-1.3/modules/pua/hash.h
===================================================================
--- openser-1.3.orig/modules/pua/hash.h	2008-07-21 17:15:06.000000000 +0200
+++ openser-1.3/modules/pua/hash.h	2008-07-21 17:35:40.000000000 +0200
@@ -38,6 +38,7 @@
 #define PWINFO_EVENT        1<<1
 #define BLA_EVENT           1<<2
 #define MSGSUM_EVENT        1<<3
+#define DIALOG_EVENT        1<<5
 
 #define UL_PUBLISH          1<<0
 #define BLA_PUBLISH         1<<1
@@ -129,6 +130,10 @@
 static inline int get_event_flag(str* event)
 {
     switch (event->len) {
+    case 6:
+	if (strncmp(event->s, "dialog", 6) == 0)
+	    return DIALOG_EVENT;
+	break;
     case 8:
 	if (strncmp(event->s, "presence", 8) == 0)
 	    return PRESENCE_EVENT;
Index: openser-1.3/modules/presence/subscribe.c
===================================================================
--- openser-1.3.orig/modules/presence/subscribe.c	(revision 4490)
+++ openser-1.3/modules/presence/subscribe.c	(working copy)
@@ -539,7 +539,7 @@
 	/* getting presentity uri from Request-URI if initial subscribe - or else from database*/
 	if(to_tag_gen)
 	{	
-		if(parsed_event->parsed!= EVENT_DIALOG)
+		if(parsed_event->parsed!= EVENT_DIALOG || parsed_event->params==NULL)
 		{
 			if( parse_sip_msg_uri(msg)< 0)
 			{
@@ -652,7 +652,7 @@
 	if(reason.s)
 		pkg_free(reason.s);
 	
-	if(parsed_event->parsed!= EVENT_DIALOG && subs.pres_uri.s)
+	if((parsed_event->parsed!= EVENT_DIALOG || parsed_event->params==NULL) && subs.pres_uri.s)
 		pkg_free(subs.pres_uri.s);
 	
 	if((!server_address.s) || (server_address.len== 0))
@@ -684,7 +684,7 @@
 		}
 	}
 
-	if(parsed_event->parsed!= EVENT_DIALOG &&subs.pres_uri.s)
+	if((parsed_event->parsed!= EVENT_DIALOG || parsed_event->params==NULL) &&subs.pres_uri.s)
 		pkg_free(subs.pres_uri.s);
 	
 	if(subs.auth_rules_doc)
@@ -816,7 +816,7 @@
 		subs->from_domain = uri.host;
 	}
 
-	if(subs->event->evp->parsed== EVENT_DIALOG)
+	if(subs->event->evp->parsed== EVENT_DIALOG && subs->event->evp->params!=NULL)
 	{
 		subs->pres_uri= pfrom->uri;
 	}
@@ -965,7 +965,7 @@
 	{
 		lock_get(&subs_htable[i].lock);
 		s= search_shtable(subs_htable, subs->callid,subs->to_tag,subs->from_tag, i);
-		if(s && s->event->evp->parsed!= EVENT_DIALOG)
+		if(s && (s->event->evp->parsed!= EVENT_DIALOG || s->event->evp->params== NULL))
 		{
 			pres_uri.s= (char*)pkg_malloc(s->pres_uri.len* sizeof(char));
 			if(pres_uri.s== NULL)
@@ -995,7 +995,7 @@
 	
 	LM_DBG("Record found in hash_table\n");
 	
-	if(s->event->evp->parsed!= EVENT_DIALOG)
+	if(s->event->evp->parsed!= EVENT_DIALOG || s->event->evp->params== NULL)
 		subs->pres_uri= pres_uri;
 	
 	subs->status= s->status;
@@ -1195,7 +1195,7 @@
 
 	subs->local_cseq= row_vals[local_cseq_col].val.int_val;
 	
-	if(subs->event->evp->parsed!= EVENT_DIALOG)
+	if(subs->event->evp->parsed!= EVENT_DIALOG || subs->event->evp->params==NULL)
 	{
 		pres_uri.s= (char*)row_vals[pres_uri_col].val.string_val;
 		pres_uri.len= strlen(pres_uri.s);
_______________________________________________
Devel mailing list
Devel@lists.openser.org
http://lists.openser.org/cgi-bin/mailman/listinfo/devel

Reply via email to