Updated the progress on this, removed the nonsensical <callerMatch> element (so <callerPattern> goes straight into <userMatch>) and added the SipXconfig side to the whole thing so custom caller ID based rules can be defined through the GUI.


Am 07.07.2011 13:46, schrieb David Becker:
The attached patch extends the mappingrules.xml with an optional <callerMatch><callerPattern /></callerMatch> tag set (child of userMatch), this takes a reg ex like the userPattern but is applied to the from address instead of the to address. The intended purpose is to allow a single number to resolve into different extensions depending on who is calling it, e.g. in the case of regional offices with one central contact number that gets routed to different call centers depending on the caller's area code.

It's a work-in-progress, I'm looking for feedback on what I have so far.



_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev/


--
-------------------------------------------------------------------
David Becker

IANT- APPLIED NGN-TECHNOLOGIES

Schlüsselfertige VoIP-Lösungen und mehr...

IANT GmbH
Salzdahlumer Straße 46/48
D-38302 Wolfenbüttel
Fon: +49/(0)5331/ 900989-450
Fax: +49/(0)5331/ 900989-499
Internet: www.iant.de

Ust.-IdNr: DE264352710
HRB 201710, Amtsgericht Braunschweig
Geschäftsführer: Prof. Dr.-Ing. Diederich Wermser, Dipl.-Ing. Jan Schumacher

IANT is Member of GROUPLINK
www.grouplink.de

>From b37ae06f0967079db85c6e7611d44524cbd418a0 Mon Sep 17 00:00:00 2001
From: David Becker <[email protected]>
Date: Fri, 5 Aug 2011 10:58:21 +0200
Subject: [PATCH] Added caller-ID based dialplan rules.

---
 .../include/digitmaps/MappingRulesUrlMapping.h     |    1 +
 sipXcommserverLib/include/digitmaps/UrlMapping.h   |   12 +++-
 sipXcommserverLib/meta/urlmap.xsd                  |   10 +++
 .../src/digitmaps/MappingRulesUrlMapping.cpp       |   11 ++-
 sipXcommserverLib/src/digitmaps/UrlMapping.cpp     |   69 ++++++++++++++++++-
 .../etc/database/add-custom-incoming-dial-rule.sql |   12 ++++
 sipXconfig/neoconf/etc/database/database.xml       |    6 ++-
 .../admin/dialplan/CustomIncomingDialingRule.java  |   41 ++++++++++++
 .../sipxconfig/admin/dialplan/DialingRule.java     |    4 +
 .../sipxconfig/admin/dialplan/DialingRuleType.java |    1 +
 .../sipxconfig/admin/dialplan/IDialingRule.java    |    4 +-
 .../admin/dialplan/config/MappingRules.java        |    6 ++
 .../sipxconfig/admin/dialplan/dialingRule.hbm.xml  |   14 ++++
 .../sipxconfig/admin/dialplan/dialplan.beans.xml   |    5 ++
 .../WEB-INF/dialplan/DialRulesPanel.properties     |    1 +
 .../dialplan/EditCustomIncomingDialRule.html       |   36 ++++++++++
 .../dialplan/EditCustomIncomingDialRule.page       |   22 ++++++
 .../dialplan/EditCustomIncomingDialRule.properties |    7 ++
 .../dialplan/EditFlexibleDialPlan.properties       |    1 +
 .../dialplan/EditFlexibleDialPlan_de.properties    |    3 +-
 .../WEB-INF/dialplan/SelectRuleType.properties     |    1 +
 .../WEB-INF/dialplan/SelectRuleType_de.properties  |    3 +-
 .../sipxconfig/site/dialplan/EditDialRule.java     |    1 +
 .../sipxconfig/site/dialplan/SelectRuleType.java   |    1 +
 .../lib/redirect_plugins/SipRedirectorMapping.cpp  |    3 +
 25 files changed, 261 insertions(+), 14 deletions(-)
 create mode 100644 
sipXconfig/neoconf/etc/database/add-custom-incoming-dial-rule.sql
 create mode 100644 
sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/CustomIncomingDialingRule.java
 create mode 100644 
sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.html
 create mode 100644 
sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.page
 create mode 100644 
sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.properties

diff --git a/sipXcommserverLib/include/digitmaps/MappingRulesUrlMapping.h 
b/sipXcommserverLib/include/digitmaps/MappingRulesUrlMapping.h
index 256ac7b..1e7c443 100644
--- a/sipXcommserverLib/include/digitmaps/MappingRulesUrlMapping.h
+++ b/sipXcommserverLib/include/digitmaps/MappingRulesUrlMapping.h
@@ -72,6 +72,7 @@ public:
 
    /// Evaluate a request URI using mapping rules semantics, return contacts 
and permissions.
    OsStatus getContactList(const Url& requestUri,   ///< target to check
+                           UtlString& sourceUri,    ///< source of this request
                            ResultSet& rContacts,    ///< contacts generated 
from first match
                            ResultSet& rPermissions, ///< permissions that 
target must have
                            UtlString& callTag       ///< call tag for contacts.
diff --git a/sipXcommserverLib/include/digitmaps/UrlMapping.h 
b/sipXcommserverLib/include/digitmaps/UrlMapping.h
index c8354a9..d3e87c6 100644
--- a/sipXcommserverLib/include/digitmaps/UrlMapping.h
+++ b/sipXcommserverLib/include/digitmaps/UrlMapping.h
@@ -35,6 +35,8 @@
 #define XML_TAG_PERMISSION           ("permission")
 #define XML_ATT_AUTHTYPE             ("authType")
 
+#define XML_TAG_CALLERMATCH          ("callerMatch")
+#define XML_TAG_CALLERPATTERN        ("callerPattern")
 #define XML_TAG_CALLERLOCATIONMATCH  ("callerLocationMatch")
 #define XML_TAG_CALLERLOCATION       ("callerLocation")
 
@@ -121,7 +123,8 @@ protected:
                                                      UtlString& variableDigits,
                                                      const TiXmlNode*& 
prMatchingUserMatchContainerNode,
                                                      const TiXmlNode*& 
prMatchingHostMatchContainerNode,
-                                                     const char* ruleType = 
NULL  ///< e.g. Emergency to match only emerg rules
+                                                     const char* ruleType = 
NULL,  ///< e.g. Emergency to match only emerg rules
+                                                     const Url* sourceUri = 
NULL
                                                      ) const;
 
     OsStatus doTransform(const Url& requestUri,
@@ -142,9 +145,14 @@ private:
    OsStatus getUserMatchContainer(const Url&              requestUri,
                                   const TiXmlNode* const  pHostMatchNode,
                                   UtlString&              variableDigits,
-                                  const TiXmlNode*&       
prMatchingUserMatchContainerNode
+                                  const TiXmlNode*&       
prMatchingUserMatchContainerNode,
+                                  const Url*              sourceUri = NULL
                                   ) const;
 
+   OsStatus isCallerCovered(const Url*              sourceUri,
+                            const TiXmlNode* const  pUserMatchNode
+                            ) const;
+
    /// Get the name/value pair from an element; supports two syntaxes.
    bool getNamedAttribute(const TiXmlElement* component, ///< the xml element 
to interpret
                           UtlString&    name,            ///< the content name
diff --git a/sipXcommserverLib/meta/urlmap.xsd 
b/sipXcommserverLib/meta/urlmap.xsd
index 97f862a..98e9dd3 100644
--- a/sipXcommserverLib/meta/urlmap.xsd
+++ b/sipXcommserverLib/meta/urlmap.xsd
@@ -117,6 +117,7 @@
         <element ref='dmp:description' minOccurs='0' />
         <element ref='dmp:callTag' minOccurs='0' />
         <element ref='dmp:userPattern' minOccurs='0' maxOccurs='unbounded'/>
+        <element ref='dmp:callerPattern'   minOccurs='0' 
maxOccurs='unbounded'/>
         <element ref='dmp:permissionMatch'   minOccurs='0' 
maxOccurs='unbounded'/>
       </sequence>
     </complexType>
@@ -131,6 +132,15 @@
     </annotation>
   </element>
 
+  <element name='callerPattern' type='normalizedString'>
+    <annotation>
+      <documentation>
+        A pattern expression used to match the user part of a SIP URL.
+        The pattern is implicitly anchored at both ends.
+      </documentation>
+    </annotation>
+  </element>
+
   <element name='permissionMatch'>
     <annotation>
       <documentation>
diff --git a/sipXcommserverLib/src/digitmaps/MappingRulesUrlMapping.cpp 
b/sipXcommserverLib/src/digitmaps/MappingRulesUrlMapping.cpp
index d444fb3..99116d6 100644
--- a/sipXcommserverLib/src/digitmaps/MappingRulesUrlMapping.cpp
+++ b/sipXcommserverLib/src/digitmaps/MappingRulesUrlMapping.cpp
@@ -58,7 +58,8 @@ MappingRulesUrlMapping::loadMappings(const UtlString& 
configFileName,
 /* ============================ ACCESSORS ================================= */
 
 OsStatus
-MappingRulesUrlMapping::getContactList(const Url& requestUri,   
+MappingRulesUrlMapping::getContactList(const Url& requestUri,
+                                       UtlString& sourceUri,
                                        ResultSet& rContacts,    
                                        ResultSet& rPermissions,
                                        UtlString& callTag
@@ -66,13 +67,16 @@ MappingRulesUrlMapping::getContactList(const Url& 
requestUri,
 {
    OsStatus contactsSet = OS_FAILED; 
    UtlString variableDigits;
+   Url source(sourceUri);
    const TiXmlNode* pMatchingUserMatchContainerNode = 0;
    const TiXmlNode* pMatchingHostMatchContainerNode = 0;
    
    if( getUserMatchContainerMatchingRequestURI(requestUri,
                                                variableDigits,                 
                                    
                                                pMatchingUserMatchContainerNode,
-                                               pMatchingHostMatchContainerNode 
) == OS_SUCCESS )
+                                               pMatchingHostMatchContainerNode,
+                                               NULL,
+                                               &source ) == OS_SUCCESS )
    {
       contactsSet = parsePermMatchContainer( requestUri, 
                                              variableDigits, 
@@ -150,7 +154,7 @@ MappingRulesUrlMapping::parsePermMatchContainer(const Url& 
requestUri,
              }
 
              //if no permission node - then it means no permission required - 
allow all
-             if((!bPermNodePresent || bPermissionFound ) )
+             if((!bPermNodePresent || bPermissionFound ))
              {
                 //if the premission matches in the permissions database
                 //go ahead and get the transform tag
@@ -164,4 +168,3 @@ MappingRulesUrlMapping::parsePermMatchContainer(const Url& 
requestUri,
     }
     return doTransformStatus;
 }
-
diff --git a/sipXcommserverLib/src/digitmaps/UrlMapping.cpp 
b/sipXcommserverLib/src/digitmaps/UrlMapping.cpp
index 14daf0d..ff3f934 100644
--- a/sipXcommserverLib/src/digitmaps/UrlMapping.cpp
+++ b/sipXcommserverLib/src/digitmaps/UrlMapping.cpp
@@ -370,7 +370,8 @@ UrlMapping::getUserMatchContainerMatchingRequestURI(const 
Url&  requestUri,
                                                     UtlString&  variableDigits,
                                                     const TiXmlNode*& 
prMatchingUserMatchContainerNode,
                                                     const TiXmlNode*& 
prMatchingHostMatchContainerNode,
-                                                    const char* ruleType
+                                                    const char* ruleType,
+                                                    const Url* sourceUri
                                                     ) const
 {
     prMatchingUserMatchContainerNode = 0;
@@ -512,7 +513,8 @@ UrlMapping::getUserMatchContainerMatchingRequestURI(const 
Url&  requestUri,
                             userMatchFound = getUserMatchContainer(requestUri,
                                                                    
pHostMatchNode,
                                                                    
variableDigits,
-                                                                   
prMatchingUserMatchContainerNode);
+                                                                   
prMatchingUserMatchContainerNode,
+                                                                   sourceUri);
                          }
                       }
                    }
@@ -528,7 +530,8 @@ OsStatus
 UrlMapping::getUserMatchContainer(const Url&             requestUri,
                                   const TiXmlNode* const pHostMatchNode,
                                   UtlString&             variableDigits,
-                                  const TiXmlNode*&      
prMatchingUserMatchContainerNode ) const
+                                  const TiXmlNode*&      
prMatchingUserMatchContainerNode,
+                                  const Url*             sourceUri) const
 {
     UtlString testUser;
     requestUri.getUserId(testUser);
@@ -568,7 +571,8 @@ UrlMapping::getUserMatchContainer(const Url&             
requestUri,
                          UtlString regStr;
                          convertRegularExpression(userRE, regStr);
                          RegEx userExpression(regStr.data());
-                         if (userExpression.Search(testUser.data(), 
testUser.length()))
+                         if (userExpression.Search(testUser.data(), 
testUser.length())
+                             && isCallerCovered(sourceUri, pUserMatchNode) == 
OS_SUCCESS)
                          {
                             getVDigits(userExpression, variableDigits);
                             prMatchingUserMatchContainerNode = pUserMatchNode;
@@ -1069,3 +1073,60 @@ bool UrlMapping::getNamedAttribute(const TiXmlElement* 
component,
 
    return foundNameValue;
 }
+
+
+OsStatus
+UrlMapping::isCallerCovered(const Url*             sourceUri,
+                            const TiXmlNode* const pUserMatchNode) const
+{
+    OsStatus isCovered = OS_FAILED;
+    bool usesCallerMapping = false;
+
+    UtlString callerName;
+    if (sourceUri != NULL) {
+        sourceUri->getUserId(callerName);
+    }
+    else {
+        return OS_SUCCESS;
+    }
+    const TiXmlElement* const pUserMatchElement = pUserMatchNode->ToElement();
+
+    const TiXmlNode* pCallerPatternNode = NULL;
+    //get the caller text value from it
+    for( pCallerPatternNode = pUserMatchElement->FirstChild( 
XML_TAG_CALLERPATTERN );
+        pCallerPatternNode && (isCovered != OS_SUCCESS);
+        pCallerPatternNode = pCallerPatternNode->NextSibling( 
XML_TAG_CALLERPATTERN ) )
+    {
+        if(pCallerPatternNode && pCallerPatternNode->Type() == 
TiXmlNode::ELEMENT)
+        {
+            //found callerPattern tag
+            usesCallerMapping = true;
+            const TiXmlElement* pCallerPatternElement = 
pCallerPatternNode->ToElement();
+
+            const TiXmlNode* pCallerPatternText = 
pCallerPatternElement->FirstChild();
+            if(pCallerPatternText && pCallerPatternText->Type() == 
TiXmlNode::TEXT)
+            {
+                const TiXmlText* pXmlCaller = pCallerPatternText->ToText();
+                if (pXmlCaller)
+                {
+                    UtlString callerRE = pXmlCaller->Value();
+                    UtlString regStr;
+                    convertRegularExpression(callerRE, regStr);
+                    RegEx callerExpression(regStr.data());
+                    if (callerExpression.Search(callerName.data(), 
callerName.length()))
+                    {
+                        //getVDigits(userExpression, variableDigits);
+                        //prMatchingUserMatchContainerNode = pUserMatchNode;
+                        isCovered = OS_SUCCESS;
+                    }
+                }
+            }
+        }
+    }
+    if (usesCallerMapping) {
+        return isCovered;
+    }
+    else {
+        return OS_SUCCESS;
+    }
+}
diff --git a/sipXconfig/neoconf/etc/database/add-custom-incoming-dial-rule.sql 
b/sipXconfig/neoconf/etc/database/add-custom-incoming-dial-rule.sql
new file mode 100644
index 0000000..28f89bd
--- /dev/null
+++ b/sipXconfig/neoconf/etc/database/add-custom-incoming-dial-rule.sql
@@ -0,0 +1,12 @@
+create table incoming_caller_pattern (
+   custom_incoming_dialing_rule_id int4 not null,
+   element_prefix varchar(255),
+   element_digits int4,
+   index int4 not null,
+   primary key (custom_incoming_dialing_rule_id, index)
+);
+
+create table custom_incoming_dialing_rule (
+   custom_incoming_dialing_rule_id int4 not null,
+   primary key (custom_incoming_dialing_rule_id)
+);
diff --git a/sipXconfig/neoconf/etc/database/database.xml 
b/sipXconfig/neoconf/etc/database/database.xml
index 1599366..d70e578 100644
--- a/sipXconfig/neoconf/etc/database/database.xml
+++ b/sipXconfig/neoconf/etc/database/database.xml
@@ -73,7 +73,7 @@
 -->
 <project name="database" basedir=".">
   <property name="sipxconfig.db.name" value="SIPXCONFIG" />
-  <property name="sipxconfig.db.user" value="@sipxconfig.db.user@" />
+  <property name="sipxconfig.db.user" value="postgres" />
   <property name="sipxconfig.db.password" value="" />
   <property name="sql.dir" location="${basedir}" />
   <property name="sipxpbx.conf.dir" location="${basedir}/.." />
@@ -376,6 +376,7 @@
   </target>
 
   <target name="version12" description="upgrade from version 11" 
unless="version13">
+       <antcall target="add-custom-incoming-dial-rule" />
     <!-- When freezing schema uncomment this line -->
     <!-- sipx-version version="13" -->
   </target>
@@ -1182,6 +1183,9 @@
   <target name="openacd-skills" unless="openacd-skills">
     <db-patch patch="openacd-skills"/>
   </target>
+  <target name="add-custom-incoming-dial-rule" 
unless="add-custom-incoming-dial-rule">
+    <db-patch patch="add-custom-incoming-dial-rule"/>
+  </target>
 
   <!--
     - SUPPORT UTILITIES
diff --git 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/CustomIncomingDialingRule.java
 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/CustomIncomingDialingRule.java
new file mode 100644
index 0000000..9e59654
--- /dev/null
+++ 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/CustomIncomingDialingRule.java
@@ -0,0 +1,41 @@
+package org.sipfoundry.sipxconfig.admin.dialplan;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CustomIncomingDialingRule extends CustomDialingRule {
+    private List<DialPattern> m_callerPatterns = new ArrayList<DialPattern>();
+
+    public CustomIncomingDialingRule() {
+        m_callerPatterns.add(new DialPattern());
+    }
+
+    public List<DialPattern> getCallerPatterns() {
+               return m_callerPatterns;
+       }
+
+       public void setCallerPatterns(List<DialPattern> patterns) {
+               m_callerPatterns = patterns;
+       }
+
+    @Override
+    protected Object clone() throws CloneNotSupportedException {
+        CustomIncomingDialingRule clone = (CustomIncomingDialingRule) 
super.clone();
+        clone.m_callerPatterns = new ArrayList(m_callerPatterns);
+        return clone;
+    }
+    @Override
+    public DialingRuleType getType() {
+        return DialingRuleType.CUSTOM_INCOMING;
+    }
+
+       @Override
+    public String[] getIncomingPatterns() {
+        String[] patterns = new String[m_callerPatterns.size()];
+        for (int i = 0; i < patterns.length; i++) {
+            DialPattern p = m_callerPatterns.get(i);
+            patterns[i] = p.calculatePattern();
+        }
+        return patterns;
+    }
+}
diff --git 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRule.java
 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRule.java
index 737aa6a..5949b21 100644
--- 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRule.java
+++ 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRule.java
@@ -55,6 +55,10 @@ public abstract class DialingRule extends BeanWithId 
implements NamedObject, IDi
 
     public abstract DialingRuleType getType();
 
+    public String[] getIncomingPatterns() {
+       return new String[0];
+    }
+
     @Override
     protected Object clone() throws CloneNotSupportedException {
         DialingRule clone = (DialingRule) super.clone();
diff --git 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRuleType.java
 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRuleType.java
index c59e8c7..a276856 100644
--- 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRuleType.java
+++ 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/DialingRuleType.java
@@ -18,6 +18,7 @@ public final class DialingRuleType extends Enum {
             CallTag.EMERG);
     public static final DialingRuleType MAPPING_RULE = new 
DialingRuleType("Mapping Rule", MappingRule.class);
     public static final DialingRuleType CUSTOM = new DialingRuleType("Custom", 
CustomDialingRule.class);
+    public static final DialingRuleType CUSTOM_INCOMING = new 
DialingRuleType("CustomIncoming", CustomIncomingDialingRule.class);
     public static final DialingRuleType LOCAL = new DialingRuleType("Local", 
LocalRule.class, CallTag.LOCL);
     public static final DialingRuleType INTERNAL = new 
DialingRuleType("Internal", InternalRule.class);
     public static final DialingRuleType LONG_DISTANCE = new 
DialingRuleType("Long Distance", LongDistanceRule.class);
diff --git 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/IDialingRule.java
 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/IDialingRule.java
index 600d10e..725377e 100644
--- 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/IDialingRule.java
+++ 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/IDialingRule.java
@@ -32,7 +32,9 @@ public interface IDialingRule {
     public abstract List<Gateway> getEnabledGateways();
 
     public abstract String[] getPatterns();
-
+    
+    public abstract String[] getIncomingPatterns();
+    
     public abstract Transform[] getTransforms();
 
     public Map<String, List<Transform>> getSiteTransforms();
diff --git 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/config/MappingRules.java
 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/config/MappingRules.java
index 14455ed..60fb7e6 100644
--- 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/config/MappingRules.java
+++ 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/config/MappingRules.java
@@ -109,6 +109,12 @@ public class MappingRules extends RulesXmlFile {
             Element userPattern = userMatch.addElement("userPattern");
             userPattern.setText(pattern);
         }
+        patterns = rule.getIncomingPatterns();
+        for (int i = 0; i < patterns.length; i++) {
+            String pattern = patterns[i];
+            Element userPattern = userMatch.addElement("callerPattern");
+            userPattern.setText(pattern);
+        }
         addTransforms(rule, userMatch);
     }
 
diff --git 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialingRule.hbm.xml
 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialingRule.hbm.xml
index 6bdf0b2..cdb6e58 100644
--- 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialingRule.hbm.xml
+++ 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialingRule.hbm.xml
@@ -51,8 +51,22 @@
         <key column="custom_dialing_rule_id" />
         <element type="string" column="permission" />
       </bag>
+
+           <joined-subclass name="CustomIncomingDialingRule" 
table="custom_incoming_dialing_rule">
+             <key column="custom_incoming_dialing_rule_id" />
+             <list name="callerPatterns" table="incoming_caller_pattern">
+               <key column="custom_incoming_dialing_rule_id" />
+               <index column="index" />
+               <composite-element class="DialPattern">
+                 <property name="prefix" column="element_prefix" />
+                 <property name="digits" column="element_digits" />
+               </composite-element>
+             </list>
+           </joined-subclass>
+
     </joined-subclass>
 
+
     <joined-subclass name="EmergencyRule" table="emergency_dialing_rule">
       <key column="emergency_dialing_rule_id" />
       <property name="optionalPrefix" />
diff --git 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialplan.beans.xml
 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialplan.beans.xml
index 82ae375..a555786 100644
--- 
a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialplan.beans.xml
+++ 
b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/admin/dialplan/dialplan.beans.xml
@@ -92,6 +92,10 @@
     <property name="permissionManager" ref="permissionManager" />
   </bean>
 
+  <bean id="defaultCustomIncomingRule" 
class="org.sipfoundry.sipxconfig.admin.dialplan.CustomIncomingDialingRule" 
scope="prototype">
+    <property name="permissionManager" ref="permissionManager" />
+  </bean>
+
   <bean id="siteToSiteRule" 
class="org.sipfoundry.sipxconfig.admin.dialplan.SiteToSiteDialingRule" 
scope="prototype">
     <property name="permissionManager" ref="permissionManager" />
   </bean>
@@ -112,6 +116,7 @@
       <list>
         <value>internalRule</value>
         <value>defaultCustomRule</value>
+        <value>defaultCustomIncomingRule</value>
         <value>longDistanceRule</value>
         <value>localRule</value>
         <value>emergencyRule</value>
diff --git a/sipXconfig/web/context/WEB-INF/dialplan/DialRulesPanel.properties 
b/sipXconfig/web/context/WEB-INF/dialplan/DialRulesPanel.properties
index 5b939db..1aa2619 100644
--- a/sipXconfig/web/context/WEB-INF/dialplan/DialRulesPanel.properties
+++ b/sipXconfig/web/context/WEB-INF/dialplan/DialRulesPanel.properties
@@ -3,6 +3,7 @@ label.addDialingRule=Add Dialing Rule...
 label.createDialingRule=Create New Dialing Rule...
 rule.attendantRule=Attendant
 rule.defaultCustomRule=Custom
+rule.defaultCustomIncomingRule=Custom by caller ID
 rule.emergencyRule=Emergency
 rule.internalRule=Voicemail
 rule.internationalRule=International
diff --git 
a/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.html 
b/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.html
new file mode 100644
index 0000000..442bdcb
--- /dev/null
+++ b/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.html
@@ -0,0 +1,36 @@
+<div jwcid="@dialplan/DialRuleCommon" 
availableSchedules="ognl:availableSchedules"
+  ruleId="ognl:ruleId" rule="ognl:rule" callback="ognl:callback" 
dialRuleHelp="message:quick.help">
+  <fieldset>
+    <legend><span key="label.dialedNumber"/></legend>
+    <table>
+      <tbody>
+        <span jwcid="@dialplan/PatternsEditor"
+          patterns="ognl:rule.dialPatterns"/>
+      </tbody>
+    </table>
+  </fieldset>
+  <fieldset>
+    <legend><span key="label.callerNumber"/></legend>
+    <table>
+      <tbody>
+        <span jwcid="@dialplan/PatternsEditor"
+          patterns="ognl:rule.callerPatterns"/>
+      </tbody>
+    </table>
+  </fieldset>
+  <fieldset>
+    <legend><span key="label.requiredPermissions"/></legend>
+    <span jwcid="@contrib:MultiplePropertySelection"
+      selectedList="ognl:rule.permissions"
+      model="bean:permissionTypeModel"/>
+  </fieldset>
+  <fieldset>
+    <legend><span key="label.resultingCall"/></legend>
+    <table>
+      <tbody>
+        <span jwcid="@dialplan/CallPatternEditor"
+          pattern="ognl:rule.callPattern"/>
+      </tbody>
+    </table>
+  </fieldset>
+</div>
diff --git 
a/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.page 
b/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.page
new file mode 100644
index 0000000..3b4c908
--- /dev/null
+++ b/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.page
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry 
Specification 4.0//EN" 
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
+<page-specification 
class="org.sipfoundry.sipxconfig.site.dialplan.EditDialRule">
+  <!--
+    - B E A N S
+  -->
+  <bean name="permissionAdapter" 
class="org.sipfoundry.sipxconfig.site.permission.PermissionOptionAdapter"
+    lifecycle="request">
+    <set name="locale" value="locale" />
+  </bean>
+  <bean name="permissionTypeModel"
+    
class="org.sipfoundry.sipxconfig.components.selection.AdaptedSelectionModel" 
lifecycle="request">
+    <set name="collection" value="permissionManager.callPermissions" />
+    <set name="adapter" value="bean:permissionAdapter" />
+  </bean>
+
+  <!--
+    - C O M P O N E N T S
+  -->
+
+</page-specification>
+
diff --git 
a/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.properties 
b/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.properties
new file mode 100644
index 0000000..b062ee1
--- /dev/null
+++ 
b/sipXconfig/web/context/WEB-INF/dialplan/EditCustomIncomingDialRule.properties
@@ -0,0 +1,7 @@
+quick.help=<b>Prefixes</b><br/>Prefixes can be integers (e.g. 2), ranges (e.g. 
1-5),\
+or lists (e.g. 2,3,4)
+title=Edit Custom Rule
+label.dialedNumber=Dialed Number
+label.callerNumber=Caller ID of the incoming call
+label.resultingCall=Resulting Call
+label.requiredPermissions=Required Permissions
diff --git 
a/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan.properties 
b/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan.properties
index a42f50e..2a75845 100644
--- a/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan.properties
+++ b/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan.properties
@@ -26,6 +26,7 @@ schedule.always=Always
 type.International=International
 type.Emergency=Emergency
 type.Custom=Custom
+type.CustomIncoming=Caller ID based
 type.Local=Local
 type.Internal=Voicemail
 type.Long_Distance=Long Distance
diff --git 
a/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan_de.properties 
b/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan_de.properties
index fdefd7e..1158fb4 100644
--- a/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan_de.properties
+++ b/sipXconfig/web/context/WEB-INF/dialplan/EditFlexibleDialPlan_de.properties
@@ -29,7 +29,8 @@ schedule.always=Immer
 
 type.International=International
 type.Emergency=Notruf
-type.Custom=Kundenspezifisch
+type.Custom=Benutzerdefiniert
+type.CustomIncoming=A-Nummern-basiert
 type.Local=Lokal
 type.Internal=Anrufbeantworter
 type.Long_Distance=Ferngespr\u00E4ch
diff --git a/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType.properties 
b/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType.properties
index aa455b5..07df9e9 100644
--- a/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType.properties
+++ b/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType.properties
@@ -3,6 +3,7 @@
 label.addNewRule=Add New Rule...
 rule.attendantRule=Attendant
 rule.defaultCustomRule=Custom
+rule.customIncomingRule=Caller ID based
 rule.emergencyRule=Emergency
 rule.internalRule=Voicemail
 rule.internationalRule=International
diff --git 
a/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType_de.properties 
b/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType_de.properties
index d48e915..24fd4ba 100644
--- a/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType_de.properties
+++ b/sipXconfig/web/context/WEB-INF/dialplan/SelectRuleType_de.properties
@@ -3,7 +3,8 @@
 #Fri Oct 06 16:02:21 CEST 2006
 label.addNewRule=F\u00FCge neue Regel hinzu
 rule.attendantRule=Antwortsystem
-rule.defaultCustomRule=Kundenspezifisch
+rule.defaultCustomRule=Benutzerdefiniert
+rule.defaultCustomIncomingRule=A-Nummern-basiert
 rule.emergencyRule=Notfall
 rule.internalRule=Anrufbeantworter
 rule.internationalRule=International
diff --git 
a/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/EditDialRule.java 
b/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/EditDialRule.java
index 8084a10..279f762 100644
--- 
a/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/EditDialRule.java
+++ 
b/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/EditDialRule.java
@@ -37,6 +37,7 @@ import org.sipfoundry.sipxconfig.phone.PhoneModel;
 public abstract class EditDialRule extends SipxBasePage implements 
PageBeginRenderListener {
 
     public static final String CUSTOM = "dialplan/EditCustomDialRule";
+    public static final String CUSTOM_INCOMING = 
"dialplan/EditCustomIncomingDialRule";
     public static final String INTERNAL = "dialplan/EditInternalDialRule";
     public static final String ATTENDANT = "dialplan/EditAttendantDialRule";
     public static final String LOCAL = "dialplan/EditLocalDialRule";
diff --git 
a/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/SelectRuleType.java
 
b/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/SelectRuleType.java
index b7fef26..9e86cf7 100644
--- 
a/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/SelectRuleType.java
+++ 
b/sipXconfig/web/src/org/sipfoundry/sipxconfig/site/dialplan/SelectRuleType.java
@@ -32,6 +32,7 @@ public abstract class SelectRuleType extends BaseComponent {
 
     static {
         TYPE_2_PAGE.put(DialingRuleType.CUSTOM, EditDialRule.CUSTOM);
+        TYPE_2_PAGE.put(DialingRuleType.CUSTOM_INCOMING, 
EditDialRule.CUSTOM_INCOMING);
         TYPE_2_PAGE.put(DialingRuleType.INTERNAL, EditDialRule.INTERNAL);
         TYPE_2_PAGE.put(DialingRuleType.ATTENDANT, EditDialRule.ATTENDANT);
         TYPE_2_PAGE.put(DialingRuleType.LOCAL, EditDialRule.LOCAL);
diff --git a/sipXregistry/lib/redirect_plugins/SipRedirectorMapping.cpp 
b/sipXregistry/lib/redirect_plugins/SipRedirectorMapping.cpp
index b4941eb..fee3911 100644
--- a/sipXregistry/lib/redirect_plugins/SipRedirectorMapping.cpp
+++ b/sipXregistry/lib/redirect_plugins/SipRedirectorMapping.cpp
@@ -94,6 +94,8 @@ SipRedirectorMapping::lookUp(
 {
    UtlString callTag = "UNK";
    UtlString permissionName;
+   UtlString sourceUri;
+   message.getFromUri(&sourceUri);
    ResultSet urlMappingRegistrations;
    ResultSet urlMappingPermissions;
 
@@ -107,6 +109,7 @@ SipRedirectorMapping::lookUp(
    {
       mMap.getContactList(
          requestUri,
+         sourceUri,
          urlMappingRegistrations,
          urlMappingPermissions,
          callTag);
-- 
1.5.5.6

_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev/

Reply via email to