<h1>Project "FreeSWITCH user-contributed scripts, etc" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: 510a78e4ab5f20a15f09a69e39d4417da7a1dcf3 (commit)
      from: 164b017dbbd88db3f85dbfb3a21e320b8c54e46a (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Mitch Capper
comments: 
Do not put empty params in the xml config unless we specifically want them as they can break things in freeswitch.  Also cleaned up the config gen a bit

<span style="color: #000080; font-weight: bold">diff --git a/mitchcapper/FSClient/Account.cs b/mitchcapper/FSClient/Account.cs</span>
<span style="color: #000080; font-weight: bold">index 5d86035..3ed6dc9 100644</span>
<span style="color: #A00000">--- a/mitchcapper/FSClient/Account.cs</span>
<span style="color: #00A000">+++ b/mitchcapper/FSClient/Account.cs</span>
<span style="color: #800080; font-weight: bold">@@ -63,7 +63,7 @@ namespace FSClient {</span>
 
                                                                   };
                 #region Static Methods
<span style="color: #A00000">-</span>
<span style="color: #00A000">+                private static string[] AllowedEmptyFields = new string[] { };</span>
                 private static void callback(object state) {
                         Broker.get_instance().reload_sofia(Sofia.RELOAD_CONFIG_MODE.SOFT);
                 }
<span style="color: #800080; font-weight: bold">@@ -128,7 +128,7 @@ namespace FSClient {</span>
                         account.guid = &quot;&quot;;
                         account.guid = old_guid;
                 }
<span style="color: #A00000">-                public static void RemoveAccount(Account account){</span>
<span style="color: #00A000">+                public static void RemoveAccount(Account account) {</span>
                         account.KillGateway();
                         accounts.Remove(account);
                         ReloadSofia();
<span style="color: #800080; font-weight: bold">@@ -137,7 +137,7 @@ namespace FSClient {</span>
                 public static void create_gateway_nodes(XmlNode gateways_node, bool tls_enabled) {
                         foreach (Account account in accounts) {
                                 if (account.enabled)
<span style="color: #A00000">-                                        account.create_gateway_node(gateways_node,tls_enabled);</span>
<span style="color: #00A000">+                                        account.create_gateway_node(gateways_node, tls_enabled);</span>
                         }
                 }
                 public static void HandleGatewayEvent(FSEvent evt) {
<span style="color: #800080; font-weight: bold">@@ -177,7 +177,7 @@ namespace FSClient {</span>
                         _guid.PropertyChanged += (s, e) =&gt; {
 
                                 if (!guid_ok(this, _guid.value) || String.IsNullOrEmpty(_guid.value)) {
<span style="color: #A00000">-                                        for (int i = 1; i &lt;= 10; i++){</span>
<span style="color: #00A000">+                                        for (int i = 1; i &lt;= 10; i++) {</span>
                                                 int val = i == 10 ? 0 : i; // want 0 checked last.
                                                 if (guid_ok(this, val.ToString())) {
                                                         _guid.value = val.ToString();
<span style="color: #800080; font-weight: bold">@@ -267,7 +267,7 @@ namespace FSClient {</span>
                                         is_default_account = false;
                                 else
                                         ensure_default_account();
<span style="color: #A00000">-                                </span>
<span style="color: #00A000">+</span>
                                 RaisePropertyChanged(&quot;enabled&quot;);
                         }
                 }
<span style="color: #800080; font-weight: bold">@@ -326,7 +326,7 @@ namespace FSClient {</span>
 
                 #endregion
                 private string old_gateway_id;
<span style="color: #A00000">-                private void acct_status_check(){</span>
<span style="color: #00A000">+                private void acct_status_check() {</span>
                         if (enabled &amp;&amp; state == &quot;NOREG&quot;)
                                 Broker.get_instance().reload_sofia(Sofia.RELOAD_CONFIG_MODE.SOFT);
 
<span style="color: #800080; font-weight: bold">@@ -336,23 +336,24 @@ namespace FSClient {</span>
                         XmlUtils.AddNodeAttrib(node, &quot;name&quot;, gateway_id);
                         old_gateway_id = gateway_id;
                         foreach (FieldValue value in values) {
<span style="color: #A00000">-                                if (!String.IsNullOrEmpty(value.field.xml_name)){</span>
<span style="color: #A00000">-                                        if (value.field.name == &quot;register-transport&quot; &amp;&amp; value.value == &quot;tls&quot; &amp;&amp; ! tls_enabled){</span>
<span style="color: #A00000">-                                                MessageBox.Show(&quot;Warning the register-transport for account: &quot; + name + &quot; is set to tls, however you have tls disabled in your sofia settings this account will be disabled for now&quot;);</span>
<span style="color: #A00000">-                                                gateways_node.RemoveChild(node);</span>
<span style="color: #A00000">-                                                enabled = false;</span>
<span style="color: #A00000">-                                                return;</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                        if (value.field.name == &quot;sip_secure_media&quot;)</span>
<span style="color: #A00000">-                                                secure_media = value.value == &quot;true&quot;;</span>
<span style="color: #A00000">-                                        Utils.add_xml_param(node, value.field.xml_name, value.value);</span>
<span style="color: #00A000">+                                if (String.IsNullOrEmpty(value.field.xml_name))</span>
<span style="color: #00A000">+                                        continue;</span>
<span style="color: #00A000">+                                if (String.IsNullOrWhiteSpace(value.value) &amp;&amp; !AllowedEmptyFields.Contains(value.field.name))</span>
<span style="color: #00A000">+                                        continue;</span>
<span style="color: #00A000">+                                if (value.field.name == &quot;register-transport&quot; &amp;&amp; value.value == &quot;tls&quot; &amp;&amp; !tls_enabled) {</span>
<span style="color: #00A000">+                                        MessageBox.Show(&quot;Warning the register-transport for account: &quot; + name + &quot; is set to tls, however you have tls disabled in your sofia settings this account will be disabled for now&quot;);</span>
<span style="color: #00A000">+                                        gateways_node.RemoveChild(node);</span>
<span style="color: #00A000">+                                        enabled = false;</span>
<span style="color: #00A000">+                                        return;</span>
                                 }
<span style="color: #00A000">+                                if (value.field.name == &quot;sip_secure_media&quot;)</span>
<span style="color: #00A000">+                                        secure_media = value.value == &quot;true&quot;;</span>
<span style="color: #00A000">+                                Utils.add_xml_param(node, value.field.xml_name, value.value);</span>
                         }
                         //Was preventing gateway ID from being passed to create_channel so removed (needed for incoming calls)
                         //FieldValue user = FieldValue.GetByName(values, &quot;username&quot;);
                         //Utils.add_xml_param(node, &quot;extension-in-contact&quot;, user.value);
                 }
<span style="color: #A00000">-</span>
                 public void ReloadAccount() {
                         KillGateway();
                         ReloadSofia();
<span style="color: #000080; font-weight: bold">diff --git a/mitchcapper/FSClient/Sofia.cs b/mitchcapper/FSClient/Sofia.cs</span>
<span style="color: #000080; font-weight: bold">index 4051172..83dbbb5 100644</span>
<span style="color: #A00000">--- a/mitchcapper/FSClient/Sofia.cs</span>
<span style="color: #00A000">+++ b/mitchcapper/FSClient/Sofia.cs</span>
<span style="color: #800080; font-weight: bold">@@ -68,10 +68,9 @@ namespace FSClient {</span>
                                                                                         new Field(Field.FIELD_TYPE.Int,&quot;RTP Hold Timeout Seconds&quot;,&quot;rtp-hold-timeout-sec&quot;,&quot;rtp-hold-timeout-sec&quot;,&quot;1800&quot;,&quot;Advanced&quot;),
                                                                                         new Field(Field.FIELD_TYPE.Int,&quot;RTP Tiemout Seconds&quot;,&quot;rtp-timeout-sec&quot;,&quot;rtp-timeout-sec&quot;,&quot;300&quot;,&quot;Advanced&quot;),
                                                                                         new Field(Field.FIELD_TYPE.String,&quot;RTP Timer Name&quot;,&quot;rtp-timer-name&quot;,&quot;rtp-timer-name&quot;,&quot;soft&quot;,&quot;Advanced&quot;),
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
                                                                            };
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                private static string[] AllowedEmptyFields = new string[] { };</span>
                 public FieldValue[] values = FieldValue.FieldValues(fields);
                 public void gen_config(XmlNode config_node) {
 
<span style="color: #800080; font-weight: bold">@@ -82,37 +81,40 @@ namespace FSClient {</span>
                         XmlNode profile = XmlUtils.AddNodeNode(profiles, &quot;profile&quot;);
                         XmlUtils.AddNodeAttrib(profile, &quot;name&quot;, &quot;softphone&quot;);
                         XmlNode gateways = XmlUtils.AddNodeNode(profile, &quot;gateways&quot;);
<span style="color: #A00000">-                        Account.create_gateway_nodes(gateways,FieldValue.GetByName(values, &quot;tls&quot;).value == &quot;true&quot;);</span>
<span style="color: #00A000">+                        Account.create_gateway_nodes(gateways, FieldValue.GetByName(values, &quot;tls&quot;).value == &quot;true&quot;);</span>
                         XmlNode settings = XmlUtils.AddNodeNode(profile, &quot;settings&quot;);
 
                         Utils.add_xml_param(settings, &quot;context&quot;, &quot;public&quot;);
                         Utils.add_xml_param(settings, &quot;dialplan&quot;, &quot;xml&quot;);
                         Utils.add_xml_param(settings, &quot;disable-register&quot;, &quot;true&quot;);
                         foreach (FieldValue value in values) {
<span style="color: #A00000">-                                if (!String.IsNullOrEmpty(value.field.xml_name)){</span>
<span style="color: #A00000">-                                        String param_value = value.value;</span>
<span style="color: #A00000">-                                        if (value.field.name == &quot;tls&quot; &amp;&amp; value.value == &quot;true&quot;) {//lets make sure that we have a cafile.pem</span>
<span style="color: #A00000">-                                                </span>
<span style="color: #A00000">-                                                String base_dir = FieldValue.GetByName(values, &quot;tls-cert-dir&quot;).value;</span>
<span style="color: #A00000">-                                                if (String.IsNullOrWhiteSpace(base_dir))</span>
<span style="color: #A00000">-                                                        base_dir = &quot;conf/ssl&quot;;</span>
<span style="color: #A00000">-                                                                //this is what freeswitch uses by default if its empty, if this changes this code needs to be updated</span>
<span style="color: #A00000">-                                                base_dir = base_dir.Replace(&#39;/&#39;, &#39;\\&#39;); //windows file path</span>
<span style="color: #A00000">-                                                if (base_dir[base_dir.Length - 1] != &#39;\\&#39;)</span>
<span style="color: #A00000">-                                                        base_dir += &#39;\\&#39;;</span>
<span style="color: #A00000">-                                                if (!System.IO.File.Exists(base_dir + &quot;cafile.pem&quot;)){</span>
<span style="color: #A00000">-                                                        MessageBox.Show(&quot;Your sofia settings have TLS enabled however you do not have a cafile.pem in your cert folder, this will most likely cause the entire softphone profile not to load so I am disabling TLS in the profile for now&quot;);</span>
<span style="color: #A00000">-                                                        param_value = &quot;false&quot;;</span>
<span style="color: #A00000">-                                                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                        Utils.add_xml_param(settings, value.field.xml_name, param_value);</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #00A000">+                                if (String.IsNullOrEmpty(value.field.xml_name))</span>
<span style="color: #00A000">+                                        continue;</span>
<span style="color: #00A000">+                                if (String.IsNullOrWhiteSpace(value.value) &amp;&amp; !AllowedEmptyFields.Contains(value.field.name))</span>
<span style="color: #00A000">+                                        continue;</span>
<span style="color: #00A000">+                                String param_value = value.value;</span>
<span style="color: #00A000">+                                if (value.field.name == &quot;tls&quot; &amp;&amp; value.value == &quot;true&quot; &amp;&amp; ! tls_cert_exist_check())</span>
<span style="color: #00A000">+                                        param_value = &quot;false&quot;;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                Utils.add_xml_param(settings, value.field.xml_name, param_value);</span>
                         }
 
                         DelayedFunction.DelayedCall(&quot;SofiaProfileCheck&quot;, sofia_profile_check, 1200);
                 }
<span style="color: #A00000">-</span>
<span style="color: #00A000">+                private bool tls_cert_exist_check(){</span>
<span style="color: #00A000">+                        String base_dir = FieldValue.GetByName(values, &quot;tls-cert-dir&quot;).value;</span>
<span style="color: #00A000">+                        if (String.IsNullOrWhiteSpace(base_dir))</span>
<span style="color: #00A000">+                                base_dir = &quot;conf/ssl&quot;;</span>
<span style="color: #00A000">+                        //this is what freeswitch uses by default if its empty, if this changes this code needs to be updated</span>
<span style="color: #00A000">+                        base_dir = base_dir.Replace(&#39;/&#39;, &#39;\\&#39;); //windows file path</span>
<span style="color: #00A000">+                        if (base_dir[base_dir.Length - 1] != &#39;\\&#39;)</span>
<span style="color: #00A000">+                                base_dir += &#39;\\&#39;;</span>
<span style="color: #00A000">+                        if (!System.IO.File.Exists(base_dir + &quot;cafile.pem&quot;)) {</span>
<span style="color: #00A000">+                                MessageBox.Show(&quot;Your sofia settings have TLS enabled however you do not have a cafile.pem in your cert folder, this will most likely cause the entire softphone profile not to load so I am disabling TLS in the profile for now&quot;);</span>
<span style="color: #00A000">+                                return false;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        return true;</span>
<span style="color: #00A000">+                }</span>
                 public enum RELOAD_CONFIG_MODE {
                         SOFT,
                         HARD,
</pre></div>
========================================================================<pre>

Summary of changes:
 mitchcapper/FSClient/Account.cs |   35 ++++++++++++++-------------
 mitchcapper/FSClient/Sofia.cs   |   48 ++++++++++++++++++++------------------
 2 files changed, 43 insertions(+), 40 deletions(-)
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH user-contributed scripts, etc</p>