<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][17325] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=17325">17325</a></dd>
<dt>Author</dt> <dd>math.parent</dd>
<dt>Date</dt> <dd>2010-04-16 11:01:19 -0500 (Fri, 16 Apr 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Skinny: VersionMessage per device type</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skinnymod_skinnyc">freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skinnymod_skinnyh">freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skinnyskinny_protocolc">freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skinnyskinny_tablesc">freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skinnyskinny_tablesh">freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skinnytestskinnypl">freeswitch/trunk/src/mod/endpoints/mod_skinny/test-skinny.pl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_skinnymod_skinnyc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c (17324 => 17325)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c        2010-04-16 15:01:00 UTC (rev 17324)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c        2010-04-16 16:01:19 UTC (rev 17325)
</span><span class="lines">@@ -1460,13 +1460,14 @@
</span><span class="cx">         if ((xprofiles = switch_xml_child(xcfg, &quot;profiles&quot;))) {
</span><span class="cx">                 for (xprofile = switch_xml_child(xprofiles, &quot;profile&quot;); xprofile; xprofile = xprofile-&gt;next) {
</span><span class="cx">                         char *profile_name = (char *) switch_xml_attr_soft(xprofile, &quot;name&quot;);
</span><del>-                        switch_xml_t xsettings = switch_xml_child(xprofile, &quot;settings&quot;);
</del><ins>+                        switch_xml_t xsettings;
+                        switch_xml_t xdevice_types;
</ins><span class="cx">                         if (zstr(profile_name)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
</span><span class="cx">                                         &quot;&lt;profile&gt; is missing name attribute\n&quot;);
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-                        if (xsettings) {
</del><ins>+                        if ((xsettings = switch_xml_child(xprofile, &quot;settings&quot;))) {
</ins><span class="cx">                                 switch_memory_pool_t *profile_pool = NULL;
</span><span class="cx">                                 char dbname[256];
</span><span class="cx">                                 switch_core_db_t *db;
</span><span class="lines">@@ -1521,6 +1522,7 @@
</span><span class="cx">                                         profile-&gt;port = 2000;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><ins>+                                /* Database */
</ins><span class="cx">                                 switch_snprintf(dbname, sizeof(dbname), &quot;skinny_%s&quot;, profile-&gt;name);
</span><span class="cx">                                 profile-&gt;dbname = switch_core_strdup(profile-&gt;pool, dbname);
</span><span class="cx"> 
</span><span class="lines">@@ -1558,6 +1560,32 @@
</span><span class="cx">                                 skinny_execute_sql_callback(profile, profile-&gt;sql_mutex, &quot;DELETE FROM skinny_buttons&quot;, NULL, NULL);
</span><span class="cx">                                 skinny_execute_sql_callback(profile, profile-&gt;sql_mutex, &quot;DELETE FROM skinny_active_lines&quot;, NULL, NULL);
</span><span class="cx"> 
</span><ins>+                                /* Device types */
+                                switch_core_hash_init(&amp;profile-&gt;device_type_params_hash, profile-&gt;pool);
+                                if ((xdevice_types = switch_xml_child(xprofile, &quot;device-types&quot;))) {
+                                        switch_xml_t xdevice_type;
+                                        for (xdevice_type = switch_xml_child(xdevice_types, &quot;device-type&quot;); xdevice_type; xdevice_type = xdevice_type-&gt;next) {
+                                                uint32_t id = skinny_str2device_type(switch_xml_attr_soft(xdevice_type, &quot;id&quot;));
+                                                if (id != 0) {
+                                                        char *id_str = switch_mprintf(&quot;%d&quot;, id);
+                                                        skinny_device_type_params_t *params = switch_core_alloc(profile-&gt;pool, sizeof(skinny_device_type_params_t));
+                                                        for (param = switch_xml_child(xdevice_type, &quot;param&quot;); param; param = param-&gt;next) {
+                                                                char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
+                                                                char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
+
+                                                                if (!strcasecmp(var, &quot;firmware-version&quot;)) {
+                                                                    strncpy(params-&gt;firmware_version, val, 16);
+                                                                }
+                                                        } /* param */
+                                                    switch_core_hash_insert(profile-&gt;device_type_params_hash, id_str, params);
+                                                } else {
+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                &quot;Unknow device type %s in profile %s.\n&quot;, switch_xml_attr_soft(xdevice_type, &quot;id&quot;), profile-&gt;name);
+                                                }
+                                        }
+                                }
+
+                                /* Register profile */
</ins><span class="cx">                             switch_mutex_lock(globals.mutex);
</span><span class="cx">                             switch_core_hash_insert(globals.profile_hash, profile-&gt;name, profile);
</span><span class="cx">                             switch_mutex_unlock(globals.mutex);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skinnymod_skinnyh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.h (17324 => 17325)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.h        2010-04-16 15:01:00 UTC (rev 17324)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.h        2010-04-16 16:01:19 UTC (rev 17325)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx">     uint32_t keep_alive;
</span><span class="cx">     char date_format[6];
</span><span class="cx">     int debug;
</span><ins>+    switch_hash_t *device_type_params_hash;
</ins><span class="cx">     /* db */
</span><span class="cx">     char *dbname;
</span><span class="cx">     char *odbc_dsn;
</span><span class="lines">@@ -93,6 +94,10 @@
</span><span class="cx"> };
</span><span class="cx"> typedef struct skinny_profile skinny_profile_t;
</span><span class="cx"> 
</span><ins>+struct skinny_device_type_params {
+        char firmware_version[16];
+};
+typedef struct skinny_device_type_params skinny_device_type_params_t;
</ins><span class="cx"> 
</span><span class="cx"> /*****************************************************************************/
</span><span class="cx"> /* LISTENERS TYPES */
</span><span class="lines">@@ -107,8 +112,9 @@
</span><span class="cx">     skinny_profile_t *profile;
</span><span class="cx">     char device_name[16];
</span><span class="cx">     uint32_t device_instance;
</span><ins>+    uint32_t device_type;
</ins><span class="cx">     
</span><del>-    char firmware_version[16];
</del><ins>+        char firmware_version[16];
</ins><span class="cx"> 
</span><span class="cx">     switch_socket_t *sock;
</span><span class="cx">     switch_memory_pool_t *pool;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skinnyskinny_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c (17324 => 17325)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c        2010-04-16 15:01:00 UTC (rev 17324)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c        2010-04-16 16:01:19 UTC (rev 17325)
</span><span class="lines">@@ -1394,6 +1394,8 @@
</span><span class="cx"> {
</span><span class="cx">         skinny_message_t *message;
</span><span class="cx">         message = switch_core_alloc(listener-&gt;pool, 12+sizeof(message-&gt;data.version));
</span><ins>+        message-&gt;type = VERSION_MESSAGE;
+        message-&gt;length = 4+ sizeof(message-&gt;data.version);
</ins><span class="cx">         strncpy(message-&gt;data.version.version, version, 16);
</span><span class="cx">         return skinny_send_reply(listener, message);
</span><span class="cx"> }
</span><span class="lines">@@ -1655,6 +1657,7 @@
</span><span class="cx"> 
</span><span class="cx">         strncpy(listener-&gt;device_name, request-&gt;data.reg.device_name, 16);
</span><span class="cx">         listener-&gt;device_instance = request-&gt;data.reg.instance;
</span><ins>+        listener-&gt;device_type = request-&gt;data.reg.device_type;
</ins><span class="cx"> 
</span><span class="cx">         xskinny = switch_xml_child(xuser, &quot;skinny&quot;);
</span><span class="cx">         if (xskinny) {
</span><span class="lines">@@ -2126,6 +2129,18 @@
</span><span class="cx"> 
</span><span class="cx"> switch_status_t skinny_handle_version_request(listener_t *listener, skinny_message_t *request)
</span><span class="cx"> {
</span><ins>+        if (zstr(listener-&gt;firmware_version)) {
+                char *id_str;
+                skinny_device_type_params_t *params;
+                id_str = switch_mprintf(&quot;%d&quot;, listener-&gt;device_type);
+                params = (skinny_device_type_params_t *) switch_core_hash_find(listener-&gt;profile-&gt;device_type_params_hash, id_str);
+                if (params) {
+                        if (!zstr(params-&gt;firmware_version)) {
+                                strncpy(listener-&gt;firmware_version, params-&gt;firmware_version, 16);
+                        }
+                }
+        }
+        
</ins><span class="cx">         if (!zstr(listener-&gt;firmware_version)) {
</span><span class="cx">                 return send_version(listener, listener-&gt;firmware_version);
</span><span class="cx">         } else {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skinnyskinny_tablesc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.c (17324 => 17325)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.c        2010-04-16 15:01:00 UTC (rev 17324)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.c        2010-04-16 16:01:19 UTC (rev 17325)
</span><span class="lines">@@ -98,6 +98,24 @@
</span><span class="cx"> SKINNY_DECLARE_ID2STR(skinny_message_type2str, SKINNY_MESSAGE_TYPES, &quot;UnknownMessage&quot;)
</span><span class="cx"> SKINNY_DECLARE_STR2ID(skinny_str2message_type, SKINNY_MESSAGE_TYPES, -1)
</span><span class="cx"> 
</span><ins>+struct skinny_table SKINNY_DEVICE_TYPES[] = {
+    {&quot;Cisco 30 SP+&quot;, 0x0001},
+    {&quot;Cisco 12 SP+&quot;, 0x0002},
+    {&quot;Cisco 12 SP&quot;, 0x0003},
+    {&quot;Cisco 12&quot;, 0x0004},
+    {&quot;Cisco 30 VIP&quot;, 0x0005},
+    {&quot;Cisco IP Phone 7910&quot;, 0x0006},
+    {&quot;Cisco IP Phone 7960&quot;, 0x0007},
+    {&quot;Cisco IP Phone 7940&quot;, 0x0008},
+    {&quot;Cisco IP Phone 7935&quot;, 0x0009},
+    {&quot;Cisco ATA 186&quot;, 0x000c},
+    {&quot;Cisco IP Phone 7961&quot;, 0x4275},
+    {&quot;Cisco IP Phone 7936&quot;, 0x4276},
+    {NULL, 0}
+};
+SKINNY_DECLARE_ID2STR(skinny_device_type2str, SKINNY_DEVICE_TYPES, &quot;UnknownDeviceType&quot;)
+SKINNY_DECLARE_STR2ID(skinny_str2device_type, SKINNY_DEVICE_TYPES, -1)
+
</ins><span class="cx"> struct skinny_table SKINNY_RING_TYPES[] = {
</span><span class="cx">     {&quot;RingOff&quot;, SKINNY_RING_OFF},
</span><span class="cx">     {&quot;RingInside&quot;, SKINNY_RING_INSIDE},
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skinnyskinny_tablesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.h (17324 => 17325)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.h        2010-04-16 15:01:00 UTC (rev 17324)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_tables.h        2010-04-16 16:01:19 UTC (rev 17325)
</span><span class="lines">@@ -89,6 +89,11 @@
</span><span class="cx"> uint32_t skinny_str2message_type(const char *str);
</span><span class="cx"> #define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES)
</span><span class="cx"> 
</span><ins>+struct skinny_table SKINNY_DEVICE_TYPES[13];
+const char *skinny_device_type2str(uint32_t id);
+uint32_t skinny_str2device_type(const char *str);
+#define SKINNY_PUSH_DEVICE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_DEVICE_TYPES)
+
</ins><span class="cx"> enum skinny_tone {
</span><span class="cx">     SKINNY_TONE_SILENCE = 0x00,
</span><span class="cx">     SKINNY_TONE_DIALTONE = 0x21,
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skinnytestskinnypl"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/test-skinny.pl (17324 => 17325)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skinny/test-skinny.pl        2010-04-16 15:01:00 UTC (rev 17324)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/test-skinny.pl        2010-04-16 16:01:19 UTC (rev 17325)
</span><span class="lines">@@ -64,6 +64,11 @@
</span><span class="cx">             )
</span><span class="cx">         );
</span><span class="cx"> 
</span><ins>+if(0) {
+        $socket-&gt;send_message(VERSION_REQ_MESSAGE);
+        $socket-&gt;receive_message(); # VersionMessage
+}
+
</ins><span class="cx"> $socket-&gt;send_message(BUTTON_TEMPLATE_REQ_MESSAGE);
</span><span class="cx"> $socket-&gt;receive_message(); # ButtonTemplateMessage
</span><span class="cx"> 
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>