<!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][14987] </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=14987">14987</a></dd>
<dt>Author</dt> <dd>mochouinard</dd>
<dt>Date</dt> <dd>2009-09-25 15:07:40 -0500 (Fri, 25 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>mod_sofia:  Override the MWI User@Domain used per user/group/domain (<a href="http://jira.freeswitch.org/browse/MODENDP-241">MODENDP-241</a>)
To use this, set a PARAM named MWI-Account with the user@domain you want to monitor the MWI in the user directory.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_regc">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (14986 => 14987)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2009-09-25 19:53:30 UTC (rev 14986)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2009-09-25 20:07:40 UTC (rev 14987)
</span><span class="lines">@@ -1634,10 +1634,12 @@
</span><span class="cx">                                                            &quot;IP:         \t%s\n&quot;
</span><span class="cx">                                                            &quot;Port:       \t%s\n&quot;
</span><span class="cx">                                                            &quot;Auth-User:  \t%s\n&quot;
</span><del>-                                                           &quot;Auth-Realm: \t%s\n\n&quot;,
</del><ins>+                                                           &quot;Auth-Realm: \t%s\n&quot;
+                                                           &quot;MWI-Account:\t%s@%s\n\n&quot;,
</ins><span class="cx">                                                            switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_str_nil(argv[3]),
</span><span class="cx">                                                            switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11]),
</span><del>-                                                           switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15]));
</del><ins>+                                                           switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15]),
+                                                           switch_str_nil(argv[16]), switch_str_nil(argv[17]));
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1669,11 +1671,13 @@
</span><span class="cx">                                                            &quot;        &lt;network-port&gt;%s&lt;/network-port&gt;\n&quot;
</span><span class="cx">                                                            &quot;        &lt;sip-auth-user&gt;%s&lt;/sip-auth-user&gt;\n&quot;
</span><span class="cx">                                                            &quot;        &lt;sip-auth-realm&gt;%s&lt;/sip-auth-realm&gt;\n&quot;
</span><ins>+                                                           &quot;        &lt;mwi-account&gt;%s@%s&lt;/mwi-account&gt;\n&quot;
</ins><span class="cx">                                                            &quot;    &lt;/registration&gt;\n&quot;, 
</span><span class="cx">                                                            switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), 
</span><span class="cx">                                                            switch_amp_encode(switch_str_nil(argv[3]),xmlbuf,buflen),
</span><span class="cx">                                                            switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11]),
</span><del>-                                                           switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15]));
</del><ins>+                                                           switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15]),
+                                                           switch_str_nil(argv[16]), switch_str_nil(argv[17]));
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1791,14 +1795,14 @@
</span><span class="cx">                                 if (!sql &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;pres&quot;) &amp;&amp; argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                         &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                        &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                         &quot; from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'&quot;, 
</span><span class="cx">                                                         profile-&gt;name, argv[3]);
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!sql &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;reg&quot;) &amp;&amp; argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                         &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                        &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                         &quot; from sip_registrations where profile_name='%q' and contact like '%%%q%%'&quot;, 
</span><span class="cx">                                                         profile-&gt;name, argv[3]);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1826,7 +1830,7 @@
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                         &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                        &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                         &quot; from sip_registrations where profile_name='%q' and %s&quot;,
</span><span class="cx">                                                         profile-&gt;name, sqlextra);
</span><span class="cx">                                         switch_safe_free(dup);
</span><span class="lines">@@ -1836,7 +1840,7 @@
</span><span class="cx">                                 if (!sql) {
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                                                  &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                                                 &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                                                  &quot; from sip_registrations where profile_name='%q'&quot;, 
</span><span class="cx">                                                                                  profile-&gt;name);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2011,7 +2015,7 @@
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                         &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                        &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                         &quot; from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'&quot;, 
</span><span class="cx">                                                         profile-&gt;name, argv[3]);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2019,7 +2023,7 @@
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                         &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                        &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                         &quot; from sip_registrations where profile_name='%q' and contact like '%%%q%%'&quot;, 
</span><span class="cx">                                                         profile-&gt;name, argv[3]);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2047,7 +2051,7 @@
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                         &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                        &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                         &quot; from sip_registrations where profile_name='%q' and %s&quot;,
</span><span class="cx">                                                         profile-&gt;name, sqlextra);
</span><span class="cx">                                         switch_safe_free(dup);
</span><span class="lines">@@ -2057,7 +2061,7 @@
</span><span class="cx">                                 if (!sql) {
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                                                  &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><del>-                                                                                 &quot;network_ip,network_port,sip_username,sip_realm&quot;
</del><ins>+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</ins><span class="cx">                                                                                  &quot; from sip_registrations where profile_name='%q'&quot;, 
</span><span class="cx">                                                                                  profile-&gt;name);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3108,10 +3112,18 @@
</span><span class="cx">                                                                                  &quot;from sip_registrations where call_id='%q'&quot;, ct, es, switch_str_nil(body), call_id
</span><span class="cx">                                                                                  );
</span><span class="cx">                                 } else {
</span><del>-                                        sql = switch_mprintf(&quot;select sip_user,sip_host,contact,profile_name,'%q','%q','%q' &quot;
-                                                                                 &quot;from sip_registrations where sip_user='%s' and sip_host='%q'&quot;,
-                                                                                 ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
-                                                                                 );
</del><ins>+                                        if (!strcasecmp(es, &quot;message-summary&quot;)) {
+                                                sql = switch_mprintf(&quot;select sip_user,sip_host,contact,profile_name,'%q','%q','%q' &quot;
+                                                                &quot;from sip_registrations where mwi_user='%s' and mwi_host='%q'&quot;,
+                                                                ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
+                                                                );
+                                        } else {
+                                                sql = switch_mprintf(&quot;select sip_user,sip_host,contact,profile_name,'%q','%q','%q' &quot;
+                                                                &quot;from sip_registrations where sip_user='%s' and sip_host='%q'&quot;,
+                                                                ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
+                                                                );
+
+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                                 
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (14986 => 14987)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-09-25 19:53:30 UTC (rev 14986)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-09-25 20:07:40 UTC (rev 14987)
</span><span class="lines">@@ -651,6 +651,24 @@
</span><span class="cx"> 
</span><span class="cx">                 sofia_profile_t *profile = NULL;
</span><span class="cx"> 
</span><ins>+                char *mwi_account = NULL;
+                char *dup_mwi_account = NULL;
+                char *mwi_user = NULL;
+                char *mwi_host = NULL;
+
+                if ((mwi_account = switch_event_get_header(event, &quot;orig-mwi-account&quot;))) {
+                        dup_mwi_account = strdup(mwi_account);
+                        switch_assert(dup_mwi_account != NULL);
+                        sofia_glue_get_user_host(dup_mwi_account, &amp;mwi_user, &amp;mwi_host);
+                }
+
+                if (!mwi_user) {
+                        mwi_user = (char *) from_user;
+                }
+                if (!mwi_host) {
+                        mwi_host = (char *) from_host;
+                }
+
</ins><span class="cx">                 char guess_ip4[256];
</span><span class="cx"> 
</span><span class="cx">                 if (exp_str) {
</span><span class="lines">@@ -663,7 +681,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if (!profile_name || !(profile = sofia_glue_find_profile(profile_name))) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid Profile\n&quot;);
</span><del>-                        return;
</del><ins>+                        goto end;
</ins><span class="cx">                 }
</span><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
</span><span class="cx">                         sql = switch_mprintf(&quot;delete from sip_registrations where call_id='%q'&quot;, call_id);
</span><span class="lines">@@ -699,10 +717,10 @@
</span><span class="cx">                 switch_find_local_ip(guess_ip4, sizeof(guess_ip4), NULL, AF_INET);
</span><span class="cx">                 sql = switch_mprintf(&quot;insert into sip_registrations &quot;
</span><span class="cx">                                                          &quot;(call_id, sip_user, sip_host, presence_hosts, contact, status, rpid, expires,&quot;
</span><del>-                                                         &quot;user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm) &quot;
-                                                         &quot;values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q')&quot;,
</del><ins>+                                                         &quot;user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm, mwi_user, mwi_host) &quot;
+                                                         &quot;values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')&quot;,
</ins><span class="cx">                                                          call_id, from_user, from_host, presence_hosts, contact_str, rpid, expires, user_agent, to_user, guess_ip4, 
</span><del>-                                                         profile_name, mod_sofia_globals.hostname, network_ip, network_port, username, realm);
</del><ins>+                                                         profile_name, mod_sofia_globals.hostname, network_ip, network_port, username, realm, mwi_user, mwi_host);
</ins><span class="cx"> 
</span><span class="cx">                 if (sql) {
</span><span class="cx">                         sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><span class="lines">@@ -713,8 +731,9 @@
</span><span class="cx">                 if (profile) {
</span><span class="cx">                         sofia_glue_release_profile(profile);
</span><span class="cx">                 }
</span><del>-
</del><ins>+end:
</ins><span class="cx">                 switch_safe_free(fixed_contact_str);
</span><ins>+                switch_safe_free(dup_mwi_account);
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (14986 => 14987)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-09-25 19:53:30 UTC (rev 14986)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-09-25 20:07:40 UTC (rev 14987)
</span><span class="lines">@@ -3597,7 +3597,9 @@
</span><span class="cx">                 &quot;   network_ip      VARCHAR(255),\n&quot; 
</span><span class="cx">                 &quot;   network_port    VARCHAR(6),\n&quot; 
</span><span class="cx">                 &quot;   sip_username    VARCHAR(255),\n&quot; 
</span><del>-                &quot;   sip_realm       VARCHAR(255)\n&quot; 
</del><ins>+                &quot;   sip_realm       VARCHAR(255),\n&quot;
+                &quot;   mwi_user        VARCHAR(255),\n&quot;
+                &quot;   mwi_host        VARCHAR(255)\n&quot;
</ins><span class="cx">                 &quot;);\n&quot;;
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -3740,7 +3742,7 @@
</span><span class="cx">                 
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_registrations where (contact like '%%TCP%%' &quot;
</span><span class="cx">                                                                   &quot;or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' &quot;
</span><del>-                                                                  &quot;and network_ip!='-1' and network_port!='-1' and sip_username != '-1'&quot;, 
</del><ins>+                                                                  &quot;and network_ip!='-1' and network_port!='-1' and sip_username != '-1' and mwi_user != '-1' and mwi_host != '-1'&quot;, 
</ins><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx"> 
</span><span class="cx">                 if (switch_odbc_handle_exec(profile-&gt;master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
</span><span class="lines">@@ -3813,7 +3815,7 @@
</span><span class="cx"> 
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_registrations where (contact like '%%TCP%%' &quot;
</span><span class="cx">                                                                   &quot;or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' &quot;
</span><del>-                                                                  &quot;and network_ip!='-1' and network_port!='-1' and sip_username != '-1'&quot;,
</del><ins>+                                                                  &quot;and network_ip!='-1' and network_port!='-1' and sip_username != '-1' and mwi_user != '-1' and mwi_host != '-1'&quot;,
</ins><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx">                 
</span><span class="cx">                 switch_core_db_test_reactive(profile-&gt;master_db, test_sql, &quot;DROP TABLE sip_registrations&quot;, reg_sql);
</span><span class="lines">@@ -4120,46 +4122,44 @@
</span><span class="cx"> 
</span><span class="cx"> int sofia_glue_get_user_host(char *in, char **user, char **host)
</span><span class="cx"> {
</span><del>-        char *p, *h, *u = in;
</del><ins>+        char *p = NULL, *h = NULL, *u = in;
</ins><span class="cx"> 
</span><del>-        if (user) {
-                *user = NULL;
</del><ins>+        if (!in) {
+                return 0;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        *host = NULL;
-
</del><span class="cx">         /* First isolate the host part from the user part */
</span><span class="cx">         if ((h = strchr(u, '@'))) {
</span><span class="cx">                 *h++ = '\0';
</span><del>-        } else {
-                return 0;
</del><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /* Clean out the user part of its protocol prefix (if any) */
</span><del>-        if (user &amp;&amp; (p = strchr(u, ':'))) {
</del><ins>+        if ((p = strchr(u, ':'))) {
</ins><span class="cx">                 *p++ = '\0';
</span><span class="cx">                 u = p;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /* Clean out the host part of any suffix */
</span><del>-        if ((p = strchr(h, ':'))) {
-                *p = '\0';
</del><ins>+        if (h) {
+                if ((p = strchr(h, ':'))) {
+                        *p = '\0';
+                }
+
+                if ((p = strchr(h, ';'))) {
+                        *p = '\0';
+                }
+
+                if ((p = strchr(h, ' '))) {
+                        *p = '\0';
+                }
</ins><span class="cx">         }
</span><del>-        
-        if ((p = strchr(h, ';'))) {
-                *p = '\0';
</del><ins>+        if (user) {
+                *user = u;
</ins><span class="cx">         }
</span><del>-        
-        if ((p = strchr(h, ' '))) {
-                *p = '\0';
</del><ins>+        if (host) {
+                *host = h;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (user) {
-        *user = u;
-        }
-
-        *host = h;
-
</del><span class="cx">         return 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (14986 => 14987)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-09-25 19:53:30 UTC (rev 14986)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-09-25 20:07:40 UTC (rev 14987)
</span><span class="lines">@@ -345,11 +345,11 @@
</span><span class="cx"> 
</span><span class="cx">         if (for_everyone) {
</span><span class="cx">                 sql = switch_mprintf(&quot;select sip_user,sip_host,contact,profile_name,network_ip,'%q' &quot;
</span><del>-                                                         &quot;from sip_registrations where sip_user='%q' and sip_host='%q'&quot;, 
</del><ins>+                                                         &quot;from sip_registrations where mwi_user='%q' and mwi_host='%q'&quot;, 
</ins><span class="cx">                                                          stream.data, user, host);
</span><span class="cx">         } else if (call_id) {
</span><span class="cx">                 sql = switch_mprintf(&quot;select sip_user,sip_host,contact,profile_name,network_ip,'%q' &quot;
</span><del>-                                                         &quot;from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'&quot;, 
</del><ins>+                                                         &quot;from sip_registrations where mwi_user='%q' and mwi_host='%q' and call_id='%q'&quot;, 
</ins><span class="cx">                                                          stream.data, user, host, call_id);
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_regc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (14986 => 14987)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2009-09-25 19:53:30 UTC (rev 14986)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2009-09-25 20:07:40 UTC (rev 14987)
</span><span class="lines">@@ -710,6 +710,10 @@
</span><span class="cx">         switch_event_t *s_event;
</span><span class="cx">         const char *to_user = NULL;
</span><span class="cx">         const char *to_host = NULL;
</span><ins>+        char *mwi_account = NULL;
+        char *dup_mwi_account = NULL;
+        char *mwi_user = NULL;
+        char *mwi_host = NULL;
</ins><span class="cx">         const char *from_user = NULL;
</span><span class="cx">         const char *from_host = NULL;
</span><span class="cx">         const char *reg_host = profile-&gt;reg_db_domain;
</span><span class="lines">@@ -1004,6 +1008,19 @@
</span><span class="cx">         }
</span><span class="cx">   reg:
</span><span class="cx"> 
</span><ins>+        if ((mwi_account = switch_event_get_header(*v_event, &quot;mwi-account&quot;))) {
+                dup_mwi_account = strdup(mwi_account);
+                switch_assert(dup_mwi_account != NULL);
+                sofia_glue_get_user_host(dup_mwi_account, &amp;mwi_user, &amp;mwi_host);
+        }
+
+        if (!mwi_user) {
+                mwi_user = (char *) to_user;
+        }
+        if (!mwi_host) {
+                mwi_host = (char *) reg_host;
+        }
+
</ins><span class="cx">         if (regtype != REG_REGISTER) {
</span><span class="cx">                 switch_goto_int(r, 0, end);
</span><span class="cx">         }
</span><span class="lines">@@ -1049,21 +1066,20 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_mutex_lock(profile-&gt;ireg_mutex);
</span><span class="cx">                 sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_find_local_ip(guess_ip4, sizeof(guess_ip4), NULL, AF_INET);
</span><span class="cx">                 sql = switch_mprintf(&quot;insert into sip_registrations &quot;
</span><span class="cx">                                                          &quot;(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,&quot;
</span><del>-                                                         &quot;user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm) &quot;
-                                                         &quot;values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q')&quot;, 
</del><ins>+                                                         &quot;user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host) &quot;
+                                                         &quot;values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q')&quot;, 
</ins><span class="cx">                                                          call_id, to_user, reg_host, profile-&gt;presence_hosts ? profile-&gt;presence_hosts : reg_host, 
</span><span class="cx">                                                          contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime * 2, 
</span><del>-                                                         agent, from_user, guess_ip4, profile-&gt;name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm);
</del><ins>+                                                         agent, from_user, guess_ip4, profile-&gt;name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, mwi_user, mwi_host);
</ins><span class="cx">                                                          
</span><span class="cx">                 if (sql) {
</span><span class="cx">                         sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-
</del><span class="cx">                 switch_mutex_unlock(profile-&gt;ireg_mutex);
</span><span class="cx"> 
</span><span class="cx">                 if (switch_event_create_subclass(&amp;s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REGISTER) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1198,7 +1214,7 @@
</span><span class="cx"> 
</span><span class="cx">                         if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER)) {
</span><span class="cx">                                 if (switch_event_create(&amp;s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;Message-Account&quot;, &quot;sip:%s@%s&quot;, to_user, reg_host);
</del><ins>+                                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;Message-Account&quot;, &quot;sip:%s@%s&quot;, mwi_user, mwi_host);
</ins><span class="cx">                                         switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, &quot;VM-Sofia-Profile&quot;, profile-&gt;name);
</span><span class="cx">                                         switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, &quot;VM-Call-ID&quot;, call_id);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1239,6 +1255,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">  end:
</span><ins>+        switch_safe_free(dup_mwi_account);
</ins><span class="cx"> 
</span><span class="cx">         if (auth_params) {
</span><span class="cx">                 switch_event_destroy(&amp;auth_params);
</span><span class="lines">@@ -1568,6 +1585,7 @@
</span><span class="cx">         int first = 0;
</span><span class="cx">         const char *passwd = NULL;
</span><span class="cx">         const char *a1_hash = NULL;
</span><ins>+        const char *mwi_account = NULL;
</ins><span class="cx">         char *sql;
</span><span class="cx">         char *number_alias = NULL;
</span><span class="cx">         switch_xml_t domain, xml = NULL, user, param, uparams, dparams, group = NULL, gparams = NULL;
</span><span class="lines">@@ -1762,6 +1780,9 @@
</span><span class="cx">                         if (!strcasecmp(var, &quot;a1-hash&quot;)) {
</span><span class="cx">                                 a1_hash = val;
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(var, &quot;mwi-account&quot;)) {
+                                mwi_account = val;
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1786,6 +1807,9 @@
</span><span class="cx">                         if (!strcasecmp(var, &quot;a1-hash&quot;)) {
</span><span class="cx">                                 a1_hash = val;
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(var, &quot;mwi-account&quot;)) {
+                                mwi_account = val;
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1810,6 +1834,9 @@
</span><span class="cx">                         if (!strcasecmp(var, &quot;a1-hash&quot;)) {
</span><span class="cx">                                 a1_hash = val;
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(var, &quot;mwi-account&quot;)) {
+                                mwi_account = val;
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1897,6 +1924,10 @@
</span><span class="cx">                         switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, &quot;user_name&quot;, username);
</span><span class="cx">                         switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, &quot;domain_name&quot;, domain_name);
</span><span class="cx"> 
</span><ins>+                        if (mwi_account) {
+                                switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, &quot;mwi-account&quot;, mwi_account);
+                        }
+
</ins><span class="cx">                         if ((uparams = switch_xml_child(user, &quot;params&quot;))) {
</span><span class="cx">                                 xparams_type[i] = 0;
</span><span class="cx">                                 xparams[i++] = uparams;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>