<!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">                                                          "IP: \t%s\n"
</span><span class="cx">                                                          "Port: \t%s\n"
</span><span class="cx">                                                          "Auth-User: \t%s\n"
</span><del>-                                                         "Auth-Realm: \t%s\n\n",
</del><ins>+                                                         "Auth-Realm: \t%s\n"
+                                                         "MWI-Account:\t%s@%s\n\n",
</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">                                                          " <network-port>%s</network-port>\n"
</span><span class="cx">                                                          " <sip-auth-user>%s</sip-auth-user>\n"
</span><span class="cx">                                                          " <sip-auth-realm>%s</sip-auth-realm>\n"
</span><ins>+                                                         " <mwi-account>%s@%s</mwi-account>\n"
</ins><span class="cx">                                                          " </registration>\n",
</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 && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                         "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                        "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                         " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'",
</span><span class="cx">                                                         profile->name, argv[3]);
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!sql && argv[2] && !strcasecmp(argv[2], "reg") && argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                         "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                        "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                         " from sip_registrations where profile_name='%q' and contact like '%%%q%%'",
</span><span class="cx">                                                         profile->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("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                         "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                        "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                         " from sip_registrations where profile_name='%q' and %s",
</span><span class="cx">                                                         profile->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("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                                                  "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                                                 "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                                                  " from sip_registrations where profile_name='%q'",
</span><span class="cx">                                                                                  profile->name);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2011,7 +2015,7 @@
</span><span class="cx">
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                         "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                        "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                         " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'",
</span><span class="cx">                                                         profile->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("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                         "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                        "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                         " from sip_registrations where profile_name='%q' and contact like '%%%q%%'",
</span><span class="cx">                                                         profile->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("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                         "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                        "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                         " from sip_registrations where profile_name='%q' and %s",
</span><span class="cx">                                                         profile->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("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                                                  "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><del>-                                                                                 "network_ip,network_port,sip_username,sip_realm"
</del><ins>+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</ins><span class="cx">                                                                                  " from sip_registrations where profile_name='%q'",
</span><span class="cx">                                                                                  profile->name);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3108,10 +3112,18 @@
</span><span class="cx">                                                                                  "from sip_registrations where call_id='%q'", ct, es, switch_str_nil(body), call_id
</span><span class="cx">                                                                                  );
</span><span class="cx">                                 } else {
</span><del>-                                        sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
-                                                                                 "from sip_registrations where sip_user='%s' and sip_host='%q'",
-                                                                                 ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
-                                                                                 );
</del><ins>+                                        if (!strcasecmp(es, "message-summary")) {
+                                                sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
+                                                                "from sip_registrations where mwi_user='%s' and mwi_host='%q'",
+                                                                ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
+                                                                );
+                                        } else {
+                                                sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
+                                                                "from sip_registrations where sip_user='%s' and sip_host='%q'",
+                                                                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, "orig-mwi-account"))) {
+                        dup_mwi_account = strdup(mwi_account);
+                        switch_assert(dup_mwi_account != NULL);
+                        sofia_glue_get_user_host(dup_mwi_account, &mwi_user, &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, "Invalid Profile\n");
</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("delete from sip_registrations where call_id='%q'", 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("insert into sip_registrations "
</span><span class="cx">                                                          "(call_id, sip_user, sip_host, presence_hosts, contact, status, rpid, expires,"
</span><del>-                                                         "user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm) "
-                                                         "values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</del><ins>+                                                         "user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm, mwi_user, mwi_host) "
+                                                         "values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</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, &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">                 " network_ip VARCHAR(255),\n"
</span><span class="cx">                 " network_port VARCHAR(6),\n"
</span><span class="cx">                 " sip_username VARCHAR(255),\n"
</span><del>-                " sip_realm VARCHAR(255)\n"
</del><ins>+                " sip_realm VARCHAR(255),\n"
+                " mwi_user VARCHAR(255),\n"
+                " mwi_host VARCHAR(255)\n"
</ins><span class="cx">                 ");\n";
</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("delete from sip_registrations where (contact like '%%TCP%%' "
</span><span class="cx">                                                                  "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
</span><del>-                                                                 "and network_ip!='-1' and network_port!='-1' and sip_username != '-1'",
</del><ins>+                                                                 "and network_ip!='-1' and network_port!='-1' and sip_username != '-1' and mwi_user != '-1' and mwi_host != '-1'",
</ins><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><span class="cx">
</span><span class="cx">                 if (switch_odbc_handle_exec(profile->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("delete from sip_registrations where (contact like '%%TCP%%' "
</span><span class="cx">                                                                  "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
</span><del>-                                                                 "and network_ip!='-1' and network_port!='-1' and sip_username != '-1'",
</del><ins>+                                                                 "and network_ip!='-1' and network_port!='-1' and sip_username != '-1' and mwi_user != '-1' and mwi_host != '-1'",
</ins><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><span class="cx">                 
</span><span class="cx">                 switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", 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 && (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("select sip_user,sip_host,contact,profile_name,network_ip,'%q' "
</span><del>-                                                         "from sip_registrations where sip_user='%q' and sip_host='%q'",
</del><ins>+                                                         "from sip_registrations where mwi_user='%q' and mwi_host='%q'",
</ins><span class="cx">                                                          stream.data, user, host);
</span><span class="cx">         } else if (call_id) {
</span><span class="cx">                 sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q' "
</span><del>-                                                         "from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'",
</del><ins>+                                                         "from sip_registrations where mwi_user='%q' and mwi_host='%q' and call_id='%q'",
</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->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, "mwi-account"))) {
+                dup_mwi_account = strdup(mwi_account);
+                switch_assert(dup_mwi_account != NULL);
+                sofia_glue_get_user_host(dup_mwi_account, &mwi_user, &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->ireg_mutex);
</span><span class="cx">                 sofia_glue_execute_sql(profile, &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("insert into sip_registrations "
</span><span class="cx">                                                          "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,"
</span><del>-                                                         "user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm) "
-                                                         "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q')",
</del><ins>+                                                         "user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host) "
+                                                         "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q')",
</ins><span class="cx">                                                          call_id, to_user, reg_host, profile->presence_hosts ? profile->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->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm);
</del><ins>+                                                         agent, from_user, guess_ip4, profile->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, &sql, SWITCH_TRUE);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-
</del><span class="cx">                 switch_mutex_unlock(profile->ireg_mutex);
</span><span class="cx">
</span><span class="cx">                 if (switch_event_create_subclass(&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(&s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", to_user, reg_host);
</del><ins>+                                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", mwi_user, mwi_host);
</ins><span class="cx">                                         switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name);
</span><span class="cx">                                         switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "VM-Call-ID", 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(&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, "a1-hash")) {
</span><span class="cx">                                 a1_hash = val;
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(var, "mwi-account")) {
+                                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, "a1-hash")) {
</span><span class="cx">                                 a1_hash = val;
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(var, "mwi-account")) {
+                                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, "a1-hash")) {
</span><span class="cx">                                 a1_hash = val;
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(var, "mwi-account")) {
+                                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, "user_name", username);
</span><span class="cx">                         switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, "domain_name", domain_name);
</span><span class="cx">
</span><ins>+                        if (mwi_account) {
+                                switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, "mwi-account", mwi_account);
+                        }
+
</ins><span class="cx">                         if ((uparams = switch_xml_child(user, "params"))) {
</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>