[svn-commits] mmichelson: branch mmichelson/sip_options r394202 - in /team/mmichelson/sip_o...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 12 13:22:46 CDT 2013


Author: mmichelson
Date: Fri Jul 12 13:22:44 2013
New Revision: 394202

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394202
Log:
Add "fromuser" endpoint option.

This also fixes a bug in res_sip_callerid.c where the username
in the from would be blanked if there was no effective connected line
for the outgoing call. We now only try to set the from username in this
module if the connected line number is valid.


Modified:
    team/mmichelson/sip_options/include/asterisk/res_sip.h
    team/mmichelson/sip_options/res/res_sip.c
    team/mmichelson/sip_options/res/res_sip/sip_configuration.c
    team/mmichelson/sip_options/res/res_sip_caller_id.c

Modified: team/mmichelson/sip_options/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/include/asterisk/res_sip.h?view=diff&rev=394202&r1=394201&r2=394202
==============================================================================
--- team/mmichelson/sip_options/include/asterisk/res_sip.h (original)
+++ team/mmichelson/sip_options/include/asterisk/res_sip.h Fri Jul 12 13:22:44 2013
@@ -341,6 +341,8 @@
 		AST_STRING_FIELD(sdpowner);
 		/*! SDP session name */
 		AST_STRING_FIELD(sdpsession);
+		/*! Default username to place in From header */
+		AST_STRING_FIELD(fromuser);
 	);
 	/*! Identification information for this endpoint */
 	struct ast_party_id id;

Modified: team/mmichelson/sip_options/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip.c?view=diff&rev=394202&r1=394201&r2=394202
==============================================================================
--- team/mmichelson/sip_options/res/res_sip.c (original)
+++ team/mmichelson/sip_options/res/res_sip.c Fri Jul 12 13:22:44 2013
@@ -997,7 +997,7 @@
 	int local_port;
 	char uuid_str[AST_UUID_STR_LEN];
 
-	if (!user) {
+	if (ast_strlen_zero(user)) {
 		RAII_VAR(struct ast_uuid *, uuid, ast_uuid_generate(), ast_free_ptr);
 		if (!uuid) {
 			return -1;
@@ -1123,7 +1123,7 @@
 		return NULL;
 	}
 
-	if (sip_dialog_create_from(dlg->pool, &local_uri, NULL, &remote_uri, &selector)) {
+	if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, &remote_uri, &selector)) {
 		pjsip_dlg_terminate(dlg);
 		return NULL;
 	}
@@ -1250,7 +1250,7 @@
 		return -1;
 	}
 
-	if (sip_dialog_create_from(pool, &from, NULL, &remote_uri, &selector)) {
+	if (sip_dialog_create_from(pool, &from, endpoint ? endpoint->fromuser : NULL, &remote_uri, &selector)) {
 		ast_log(LOG_ERROR, "Unable to create From header for %.*s request to endpoint %s\n",
 				(int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
 		pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);

Modified: team/mmichelson/sip_options/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip/sip_configuration.c?view=diff&rev=394202&r1=394201&r2=394202
==============================================================================
--- team/mmichelson/sip_options/res/res_sip/sip_configuration.c (original)
+++ team/mmichelson/sip_options/res/res_sip/sip_configuration.c Fri Jul 12 13:22:44 2013
@@ -673,6 +673,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allowsubscribe", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allowsubscribe));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subminexpiry", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subminexpiry));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subminexpirey", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subminexpiry));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fromuser", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromuser));
 
 	if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {
 		ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");

Modified: team/mmichelson/sip_options/res/res_sip_caller_id.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip_caller_id.c?view=diff&rev=394202&r1=394201&r2=394202
==============================================================================
--- team/mmichelson/sip_options/res/res_sip_caller_id.c (original)
+++ team/mmichelson/sip_options/res/res_sip_caller_id.c Fri Jul 12 13:22:44 2013
@@ -398,7 +398,9 @@
 		pj_strdup2(pool, &id_name_addr->display, id->name.str);
 	}
 
-	pj_strdup2(pool, &id_uri->user, id->number.str);
+	if (id->number.valid) {
+		pj_strdup2(pool, &id_uri->user, id->number.str);
+	}
 }
 
 /*!




More information about the svn-commits mailing list