From f598d0eb745e7f200d26f665f295bdc28042037a Mon Sep 17 00:00:00 2001
From: Automerge script <automerge@asterisk.org>
Date: Sat, 1 Dec 2012 01:19:10 +0000
Subject: [PATCH] Merged revisions 376984 via svnmerge from
 file:///srv/subversion/repos/asterisk/trunk

................
  r376984 | file | 2012-11-30 18:47:42 -0600 (Fri, 30 Nov 2012) | 10 lines

  Tweak extension used for incoming calls received on Motif.

  Based on feedback from numerous individuals this patch tweaks incoming calls
  to first look for an extension with the name of the endpoint. If no such extension
  exists the call will silently fall back to the "s" extension as it previously
  did.
  ........

  Merged revisions 376983 from http://svn.asterisk.org/svn/asterisk/branches/11
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376989 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_motif.c     | 6 +++++-
 configs/motif.conf.sample | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/channels/chan_motif.c b/channels/chan_motif.c
index fad388ea28..d567081490 100644
--- a/channels/chan_motif.c
+++ b/channels/chan_motif.c
@@ -686,7 +686,11 @@ static struct ast_channel *jingle_new(struct jingle_endpoint *endpoint, struct j
 	}
 
 	ast_channel_context_set(chan, endpoint->context);
-	ast_channel_exten_set(chan, "s");
+	if (ast_exists_extension(NULL, endpoint->context, endpoint->name, 1, NULL)) {
+		ast_channel_exten_set(chan, endpoint->name);
+	} else {
+		ast_channel_exten_set(chan, "s");
+	}
 	ast_channel_priority_set(chan, 1);
 
 	ao2_unlock(endpoint);
diff --git a/configs/motif.conf.sample b/configs/motif.conf.sample
index c651e69309..ae3ab30d72 100644
--- a/configs/motif.conf.sample
+++ b/configs/motif.conf.sample
@@ -49,6 +49,11 @@
 ;
 ; The only supported method for DTMF is RFC2833. This is always enabled on audio streams and negotiated if possible.
 
+; Incoming Calls
+;
+; Incoming calls will first look for the extension matching the name of the endpoint in the configured context. If
+; no such extension exists the call will automatically fall back to the "s" extension.
+
 ; CallerID
 ;
 ; The incoming caller id number is populated with the username of the caller and the name is populated with the full
-- 
GitLab