[svn-commits] dvossel: trunk r323212 - in /trunk: ./ channels/ channels/sip/include/ configs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 13 14:44:00 CDT 2011


Author: dvossel
Date: Mon Jun 13 14:43:57 2011
New Revision: 323212

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=323212
Log:
Addition of "outofcall_message_context" sip.conf option.

Review: https://reviewboard.asterisk.org/r/1265/


Modified:
    trunk/CHANGES
    trunk/channels/chan_sip.c
    trunk/channels/sip/include/sip.h
    trunk/configs/sip.conf.sample

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=323212&r1=323211&r2=323212
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Jun 13 14:43:57 2011
@@ -19,8 +19,8 @@
    SIP MESSAGE and XMPP are currently supported.  There are options in
    jabber.conf and sip.conf to allow enabling these features.
      -> jabber.conf: see the "sendtodialplan" and "context" options.
-     -> sip.conf: see the "accept_outofcall_message" and "auth_message_requests"
-        options.
+     -> sip.conf: see the "accept_outofcall_message", "auth_message_requests"
+        and "outofcall_message_context" options.
    The MESSAGE() dialplan function and MessageSend() application have been
    added to go along with this functionality.  More detailed usage information
    can be found on the Asterisk wiki (http://wiki.asterisk.org/).

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=323212&r1=323211&r2=323212
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Jun 13 14:43:57 2011
@@ -15757,8 +15757,12 @@
 				p->callingpres = peer->callingpres;
 		}
 		ast_string_field_set(p, fullcontact, peer->fullcontact);
-		if (!ast_strlen_zero(peer->context))
+		if (!ast_strlen_zero(peer->context)) {
 			ast_string_field_set(p, context, peer->context);
+		}
+		if (!ast_strlen_zero(peer->messagecontext)) {
+			ast_string_field_set(p, messagecontext, peer->messagecontext);
+		}
 		ast_string_field_set(p, peersecret, peer->secret);
 		ast_string_field_set(p, peermd5secret, peer->md5secret);
 		ast_string_field_set(p, language, peer->language);
@@ -16088,6 +16092,9 @@
 			if (ast_strlen_zero(peer->secret) && ast_strlen_zero(peer->md5secret)) {
 				ast_string_field_set(p, context, peer->context);
 			}
+			if (!ast_strlen_zero(peer->messagecontext)) {
+				ast_string_field_set(p, messagecontext, peer->messagecontext);
+			}
 			peer = unref_peer(peer, "from find_peer() in receive_message");
 		}
 	}
@@ -16108,7 +16115,15 @@
 	res = ast_msg_set_to(msg, "%s", to);
 	res |= ast_msg_set_from(msg, "%s", get_in_brackets(from));
 	res |= ast_msg_set_body(msg, "%s", ast_str_buffer(buf));
-	res |= ast_msg_set_context(msg, "%s", p->context);
+
+	if (!ast_strlen_zero(p->messagecontext)) {
+		res |= ast_msg_set_context(msg, "%s", p->messagecontext);
+	} else if (!ast_strlen_zero(sip_cfg.messagecontext)) {
+		res |= ast_msg_set_context(msg, "%s", sip_cfg.messagecontext);
+	} else {
+		res |= ast_msg_set_context(msg, "%s", p->context);
+	}
+
 	res |= ast_msg_set_exten(msg, "%s", p->exten);
 
 	if (res) {
@@ -26679,6 +26694,7 @@
 	ast_copy_flags(&peer->flags[1], &global_flags[1], SIP_PAGE2_FLAGS_TO_COPY);
 	ast_copy_flags(&peer->flags[2], &global_flags[2], SIP_PAGE3_FLAGS_TO_COPY);
 	ast_string_field_set(peer, context, sip_cfg.default_context);
+	ast_string_field_set(peer, messagecontext, sip_cfg.messagecontext);
 	ast_string_field_set(peer, subscribecontext, sip_cfg.default_subscribecontext);
 	ast_string_field_set(peer, language, default_language);
 	ast_string_field_set(peer, mohinterpret, default_mohinterpret);
@@ -26973,6 +26989,8 @@
 			} else if (!strcasecmp(v->name, "context")) {
 				ast_string_field_set(peer, context, v->value);
 				ast_set_flag(&peer->flags[1], SIP_PAGE2_HAVEPEERCONTEXT);
+			} else if (!strcasecmp(v->name, "outofcall_message_context")) {
+				ast_string_field_set(peer, messagecontext, v->value);
 			} else if (!strcasecmp(v->name, "subscribecontext")) {
 				ast_string_field_set(peer, subscribecontext, v->value);
 			} else if (!strcasecmp(v->name, "fromdomain")) {
@@ -27661,6 +27679,7 @@
 	sip_cfg.alwaysauthreject = DEFAULT_ALWAYSAUTHREJECT;
 	sip_cfg.auth_options_requests = DEFAULT_AUTH_OPTIONS;
 	sip_cfg.auth_message_requests = DEFAULT_AUTH_MESSAGE;
+	sip_cfg.messagecontext[0] = '\0';
 	sip_cfg.accept_outofcall_message = DEFAULT_ACCEPT_OUTOFCALL_MESSAGE;
 	sip_cfg.allowsubscribe = FALSE;
 	sip_cfg.disallowed_methods = SIP_UNKNOWN;
@@ -27914,6 +27933,8 @@
 			sip_cfg.auth_message_requests = ast_true(v->value) ? 1 : 0;
 		} else if (!strcasecmp(v->name, "accept_outofcall_message")) {
 			sip_cfg.accept_outofcall_message = ast_true(v->value) ? 1 : 0;
+		} else if (!strcasecmp(v->name, "outofcall_message_context")) {
+			ast_copy_string(sip_cfg.messagecontext, v->value, sizeof(sip_cfg.messagecontext));
 		} else if (!strcasecmp(v->name, "mohinterpret")) {
 			ast_copy_string(default_mohinterpret, v->value, sizeof(default_mohinterpret));
 		} else if (!strcasecmp(v->name, "mohsuggest")) {

Modified: trunk/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/sip.h?view=diff&rev=323212&r1=323211&r2=323212
==============================================================================
--- trunk/channels/sip/include/sip.h (original)
+++ trunk/channels/sip/include/sip.h Mon Jun 13 14:43:57 2011
@@ -691,6 +691,7 @@
 	int legacy_useroption_parsing; /*!< Whether to strip useroptions in URI via semicolons */
 	int matchexternaddrlocally;   /*!< Match externaddr/externhost setting against localnet setting */
 	char regcontext[AST_MAX_CONTEXT];  /*!< Context for auto-extensions */
+	char messagecontext[AST_MAX_CONTEXT];  /*!< Default context for out of dialog msgs. */
 	unsigned int disallowed_methods;   /*!< methods that we should never try to use */
 	int notifyringing;          /*!< Send notifications on ringing */
 	int notifyhold;             /*!< Send notifications on hold */
@@ -939,6 +940,7 @@
 		AST_STRING_FIELD(useragent);    /*!< User agent in SIP request */
 		AST_STRING_FIELD(exten);        /*!< Extension where to start */
 		AST_STRING_FIELD(context);      /*!< Context for this call */
+		AST_STRING_FIELD(messagecontext); /*!< Default context for outofcall messages. */
 		AST_STRING_FIELD(subscribecontext); /*!< Subscribecontext */
 		AST_STRING_FIELD(subscribeuri); /*!< Subscribecontext */
 		AST_STRING_FIELD(fromdomain);   /*!< Domain to show in the from field */
@@ -1172,6 +1174,7 @@
 		AST_STRING_FIELD(description);	/*!< Description of this peer */
 		AST_STRING_FIELD(remotesecret); /*!< Remote secret (trunks, remote devices) */
 		AST_STRING_FIELD(context);      /*!< Default context for incoming calls */
+		AST_STRING_FIELD(messagecontext); /*!< Default context for outofcall messages. */
 		AST_STRING_FIELD(subscribecontext); /*!< Default context for subscriptions */
 		AST_STRING_FIELD(username);     /*!< Temporary username until registration */
 		AST_STRING_FIELD(accountcode);  /*!< Account code */

Modified: trunk/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=323212&r1=323211&r2=323212
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Mon Jun 13 14:43:57 2011
@@ -388,6 +388,11 @@
 ;accept_outofcall_message = no  ; Disable this option to reject all MESSAGE requests outside of a
                                 ; call.  By default, this option is enabled.  When enabled, MESSAGE
                                 ; requests are passed in to the dialplan.
+
+;outofcall_message_context = messages ; Context all out of dialog msgs are sent to. When this
+                                      ; option is not set, the context used during peer matching
+                                      ; is used. This option can be defined at both the peer and
+                                      ; global level.
 
 ;auth_message_requests = yes    ; Enabling this option will authenticate MESSAGE requests.
                                 ; By default this option is enabled.  However, it can be disabled




More information about the svn-commits mailing list