Jelajahi Sumber

Merge pull request #514 from phil-lavin/feature-trying-master

pua_dialoginfo: support for sending "Trying" state for callee
Daniel-Constantin Mierla 9 tahun lalu
induk
melakukan
b214541fc9

+ 36 - 14
modules/presence/presentity.c

@@ -426,6 +426,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 				goto error;
 			}
 
+			if (pa_dbf.start_transaction)
+			{
+				if (pa_dbf.start_transaction(pa_db, db_table_lock) < 0)
+				{
+					LM_ERR("in start_transaction\n");
+					goto error;
+				}
+			}
+
 			LM_DBG("inserting %d cols into table\n",n_query_cols);
 				
 			if (pa_dbf.insert(pa_db, query_cols, query_vals, n_query_cols) < 0) 
@@ -468,22 +477,8 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 			if (pa_dbf.replace(pa_db, query_cols, query_vals, n_query_cols, 4, 0) < 0) 
 			{
 				LM_ERR("replacing record in database\n");
-				if (pa_dbf.abort_transaction)
-				{
-					if (pa_dbf.abort_transaction(pa_db) < 0)
-						LM_ERR("in abort_transaction\n");
-				}
 				goto error;
 			}
-
-			if (pa_dbf.end_transaction)
-			{
-				if (pa_dbf.end_transaction(pa_db) < 0)
-				{
-					LM_ERR("in end_transaction\n");
-					goto error;
-				}
-			}
 		}
 
 		if( publ_send200ok(msg, presentity->expires, presentity->etag)< 0)
@@ -503,6 +498,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 			goto error;
 		}
 
+		if (pa_dbf.start_transaction)
+		{
+			if (pa_dbf.start_transaction(pa_db, db_table_lock) < 0)
+			{
+				LM_ERR("in start_transaction\n");
+				goto error;
+			}
+		}
+
 		if(EVENT_DIALOG_SLA(presentity->event->evp))
 		{
 
@@ -837,6 +841,15 @@ done:
 	if(pres_uri.s)
 		pkg_free(pres_uri.s);
 
+	if (pa_dbf.end_transaction)
+	{
+		if (pa_dbf.end_transaction(pa_db) < 0)
+		{
+			LM_ERR("in end_transaction\n");
+			goto error;
+		}
+	}
+
 	return 0;
 
 send_412:
@@ -867,6 +880,15 @@ error:
 	if(pres_uri.s)
 		pkg_free(pres_uri.s);
 
+	if (pa_dbf.abort_transaction)
+	{
+		if (pa_dbf.abort_transaction(pa_db) < 0)
+		{
+			LM_ERR("in abort_transaction\n");
+			goto error;
+		}
+	}
+
 	return ret;
 }
 

+ 7 - 0
modules/pua_dialoginfo/doc/pua_dialoginfo.xml

@@ -38,6 +38,13 @@
 		<surname>Darilion</surname>
 		<affiliation><orgname>IPCom</orgname></affiliation>
 	    </editor>
+	    <editor>
+		<firstname>Phil</firstname>
+		<surname>Lavin</surname>
+		<address>
+		    <email>[email protected]</email>
+		</address>
+	    </editor>
 	</authorgroup>
 	<copyright>
 	    <year>2006</year>

+ 18 - 0
modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml

@@ -461,6 +461,24 @@ modparam("pua_dialoginfo", "pubruri_callee_dlg_var", "pubruri_callee")
 		</example>
 		</section>
 
+		<section>
+		<title><varname>callee_trying</varname> (int)</title>
+		<para>
+			If this parameter is set, a "Trying" state will be sent for both the
+			caller and callee, rather than just the caller.
+		</para>
+		<para>
+			<emphasis>Default value is <quote>0</quote>.</emphasis>
+		</para>
+		<example>
+			<title>Set <varname>callee_trying</varname> parameter</title>
+			<programlisting format="linespecific">
+...
+modparam("pua_dialoginfo", "callee_trying", 1)
+...
+</programlisting>
+		</example>
+		</section>
 	</section>
 
 	<section>

+ 11 - 0
modules/pua_dialoginfo/pua_dialoginfo.c

@@ -63,6 +63,7 @@ MODULE_VERSION
 #define DEF_USE_PUBRURI_AVPS 0
 #define DEF_PUBRURI_CALLER_AVP 0
 #define DEF_PUBRURI_CALLEE_AVP 0
+#define DEF_CALLEE_TRYING 0
 
 
 /* define PUA_DIALOGINFO_DEBUG to activate more verbose 
@@ -91,6 +92,7 @@ int caller_confirmed       = DEF_CALLER_ALWAYS_CONFIRMED;
 int include_req_uri        = DEF_INCLUDE_REQ_URI;
 int send_publish_flag      = DEF_SEND_PUBLISH_FLAG;
 int use_pubruri_avps       = DEF_USE_PUBRURI_AVPS;
+int callee_trying          = DEF_CALLEE_TRYING;
 char * pubruri_caller_avp  = DEF_PUBRURI_CALLER_AVP;
 char * pubruri_callee_avp  = DEF_PUBRURI_CALLEE_AVP;
 
@@ -119,6 +121,7 @@ static param_export_t params[]={
 	{"pubruri_callee_avp",  PARAM_STRING, &pubruri_callee_avp },
 	{"pubruri_caller_dlg_var",  PARAM_STR, &caller_dlg_var },
 	{"pubruri_callee_dlg_var",  PARAM_STR, &callee_dlg_var },
+	{"callee_trying",        INT_PARAM, &callee_trying },
 	{0, 0, 0 }
 };
 
@@ -599,6 +602,14 @@ __dialog_created(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)
 			&(dlg->callid), 1, dlginfo->lifetime,
 			0, 0, 0, 0, (send_publish_flag==-1)?1:0);
 
+	if (callee_trying)
+	{
+		dialog_publish_multi("Trying", dlginfo->pubruris_callee,
+				(include_req_uri)?&(dlg->req_uri):&(dlg->to_uri),
+				&(dlg->from_uri),
+				&(dlg->callid), 0, dlginfo->lifetime,
+				0, 0, 0, 0, (send_publish_flag==-1)?1:0);
+	}
 }
 
 	static void