<!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][14581] </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=14581">14581</a></dd>
<dt>Author</dt> <dd>mrene</dd>
<dt>Date</dt> <dd>2009-08-20 19:59:09 -0500 (Thu, 20 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/MODENDP-242">MODENDP-242</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h</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_sofiah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (14580 => 14581)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2009-08-20 18:52:48 UTC (rev 14580)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2009-08-21 00:59:09 UTC (rev 14581)
</span><span class="lines">@@ -902,5 +902,6 @@
</span><span class="cx"> void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port);
</span><span class="cx"> sofia_destination_t* sofia_glue_get_destination(char *data);
</span><span class="cx"> void sofia_glue_free_destination(sofia_destination_t *dst);
</span><ins>+switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, const char *body, const char *o_contact, const char *network_ip);
</ins><span class="cx"> char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix);
</span><span class="cx"> void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, const char *prefix);
</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 (14580 => 14581)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-08-20 18:52:48 UTC (rev 14580)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-08-21 00:59:09 UTC (rev 14581)
</span><span class="lines">@@ -4275,6 +4275,71 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, const char *body, const char *o_contact, const char *network_ip)
+{
+        char *id = NULL;
+        nua_handle_t *nh;
+        sofia_destination_t *dst = NULL;
+        char *contact_str, *contact, *user_via = NULL;
+
+        contact = sofia_glue_get_url_from_contact((char*) o_contact, 1);
+        if (sofia_glue_check_nat(profile, network_ip)) {
+                char *ptr = NULL;
+                const char *transport_str = NULL;
+
+
+                id = switch_mprintf(&quot;sip:%s@%s&quot;, user, profile-&gt;extsipip);
+                switch_assert(id);
+
+                if ((ptr = sofia_glue_find_parameter(o_contact, &quot;transport=&quot;))) {
+                        sofia_transport_t transport = sofia_glue_str2transport(ptr);
+                        transport_str = sofia_glue_transport2str(transport);
+                        switch (transport) {
+                                case SOFIA_TRANSPORT_TCP:
+                                        contact_str = profile-&gt;tcp_public_contact;
+                                        break;
+                                case SOFIA_TRANSPORT_TCP_TLS:
+                                        contact_str = profile-&gt;tls_public_contact;
+                                        break;
+                                default:
+                                        contact_str = profile-&gt;public_url;
+                                        break;
+                        }
+                        user_via = sofia_glue_create_external_via(NULL, profile, transport);
+                } else {
+                        user_via = sofia_glue_create_external_via(NULL, profile, SOFIA_TRANSPORT_UDP);
+                        contact_str = profile-&gt;public_url;
+                }
+
+        } else {
+                contact_str = profile-&gt;url;
+                id = switch_mprintf(&quot;sip:%s@%s&quot;, user, host);
+        }
+
+        dst = sofia_glue_get_destination((char*) o_contact);
+        switch_assert(dst);
+
+        nh = nua_handle(profile-&gt;nua, NULL, NUTAG_URL(contact),
+                        SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id),
+                        SIPTAG_CONTACT_STR(contact_str), TAG_END());
+        nua_handle_bind(nh, &amp;mod_sofia_globals.destroy_private);
+
+        nua_notify(nh,
+                        NUTAG_NEWSUB(1),
+                        TAG_IF(dst-&gt;route_uri, NUTAG_PROXY(dst-&gt;route_uri)), TAG_IF(dst-&gt;route, SIPTAG_ROUTE_STR(dst-&gt;route)),
+                        TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
+                        SIPTAG_EVENT_STR(event),
+                        SIPTAG_CONTENT_TYPE_STR(contenttype),
+                        SIPTAG_PAYLOAD_STR(body), TAG_END());
+
+        switch_safe_free(contact);
+        switch_safe_free(id);
+        sofia_glue_free_destination(dst);
+        switch_safe_free(user_via);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
</ins><span class="cx"> /* For Emacs:
</span><span class="cx">  * Local Variables:
</span><span class="cx">  * mode:c
</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 (14580 => 14581)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-08-20 18:52:48 UTC (rev 14580)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-08-21 00:59:09 UTC (rev 14581)
</span><span class="lines">@@ -1365,19 +1365,17 @@
</span><span class="cx"> 
</span><span class="cx"> static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char **columnNames)
</span><span class="cx"> {
</span><del>-        char *sub_to_user = argv[0];
-        char *sub_to_host = argv[1];
-        char *event = &quot;message-summary&quot;;
-        char *o_contact = argv[2];
</del><ins>+        const char *user = argv[0];
+        const char *host = argv[1];
+        const char *event = &quot;message-summary&quot;;
+        const char *contenttype = &quot;application/simple-message-summary&quot;;
+        const char *body = argv[5];
+        const char *o_contact = argv[2];
+        const char *network_ip = argv[4];
+
</ins><span class="cx">         char *profile_name = argv[3];
</span><del>-        char *network_ip = argv[4];
-        char *body = argv[5];
-        char *id = NULL;
-        nua_handle_t *nh;
</del><span class="cx">         struct mwi_helper *h = (struct mwi_helper *) pArg;
</span><span class="cx">         sofia_profile_t *ext_profile = NULL, *profile = h-&gt;profile;
</span><del>-        sofia_destination_t *dst = NULL;
-        char *contact_str, *contact, *user_via = NULL;
</del><span class="cx"> 
</span><span class="cx">         if (profile_name &amp;&amp; strcasecmp(profile_name, h-&gt;profile-&gt;name)) {
</span><span class="cx">                 if ((ext_profile = sofia_glue_find_profile(profile_name))) {
</span><span class="lines">@@ -1385,62 +1383,8 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        contact = sofia_glue_get_url_from_contact(o_contact, 1);
-        if (sofia_glue_check_nat(profile, network_ip)) {
-                char *ptr = NULL;
-                const char *transport_str = NULL;
</del><ins>+        sofia_glue_send_notify(profile, user, host, event, contenttype, body, o_contact, network_ip);
</ins><span class="cx"> 
</span><del>-
-                id = switch_mprintf(&quot;sip:%s@%s&quot;, sub_to_user, profile-&gt;extsipip);
-                switch_assert(id);
-
-                if ((ptr = sofia_glue_find_parameter(o_contact, &quot;transport=&quot;))) {
-                        sofia_transport_t transport = sofia_glue_str2transport(ptr);
-                        transport_str = sofia_glue_transport2str(transport);
-
-                        switch (transport) {
-                        case SOFIA_TRANSPORT_TCP:
-                                contact_str = profile-&gt;tcp_public_contact;
-                                break;
-                        case SOFIA_TRANSPORT_TCP_TLS:
-                                contact_str = profile-&gt;tls_public_contact;
-                                break;
-                        default:
-                                contact_str = profile-&gt;public_url;
-                                break;
-                        }
-                        user_via = sofia_glue_create_external_via(NULL, profile, transport);
-                } else {
-                        user_via = sofia_glue_create_external_via(NULL, profile, SOFIA_TRANSPORT_UDP);
-                        contact_str = profile-&gt;public_url;
-                }
-                
-        } else {
-                contact_str = profile-&gt;url;
-                id = switch_mprintf(&quot;sip:%s@%s&quot;, sub_to_user, sub_to_host);
-        }
-
-        dst = sofia_glue_get_destination(o_contact);
-        switch_assert(dst);
-
-        nh = nua_handle(profile-&gt;nua, NULL, NUTAG_URL(contact),
-                                        SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id),
-                                        SIPTAG_CONTACT_STR(contact_str), TAG_END());
-        nua_handle_bind(nh, &amp;mod_sofia_globals.destroy_private);
-
-        nua_notify(nh,
-                           NUTAG_NEWSUB(1),
-                           TAG_IF(dst-&gt;route_uri, NUTAG_PROXY(dst-&gt;route_uri)), TAG_IF(dst-&gt;route, SIPTAG_ROUTE_STR(dst-&gt;route)),
-                           TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
-                           SIPTAG_EVENT_STR(event),
-                           SIPTAG_CONTENT_TYPE_STR(&quot;application/simple-message-summary&quot;),
-                           SIPTAG_PAYLOAD_STR(body), TAG_END());
-        
-        switch_safe_free(contact);
-        switch_safe_free(id);
-        sofia_glue_free_destination(dst);
-        switch_safe_free(user_via);
-
</del><span class="cx">         if (ext_profile) {
</span><span class="cx">                 sofia_glue_release_profile(ext_profile);
</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 (14580 => 14581)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2009-08-20 18:52:48 UTC (rev 14580)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2009-08-21 00:59:09 UTC (rev 14581)
</span><span class="lines">@@ -439,11 +439,8 @@
</span><span class="cx"> void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip)
</span><span class="cx"> {
</span><span class="cx">         const char *event = &quot;check-sync&quot;;
</span><del>-        nua_handle_t *nh;
-        char *contact_url = NULL;
-        char *contact_str = NULL;
-        char *user_via = NULL;
-        char *id = NULL;
</del><ins>+        const char *contenttype = &quot;application/simple-message-summary&quot;;
+        const char *body = &quot;&quot;;
</ins><span class="cx"> 
</span><span class="cx">         if (switch_stristr(&quot;snom&quot;, user_agent)) {
</span><span class="cx">                 event = &quot;check-sync;reboot=true&quot;;
</span><span class="lines">@@ -451,65 +448,8 @@
</span><span class="cx">                 event = &quot;reboot_now&quot;;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((contact_url = sofia_glue_get_url_from_contact((char *)contact, 1))) {
-                char *p;
-                id = switch_mprintf(&quot;sip:%s@%s&quot;, user, network_ip);
</del><ins>+        sofia_glue_send_notify(profile, user, host, event, contenttype, body, contact, network_ip);
</ins><span class="cx"> 
</span><del>-                if ((p = strstr(contact_url, &quot;;fs_&quot;))) {
-                        *p = '\0';
-                }
-                if (sofia_glue_check_nat(profile, network_ip)) {
-                        char *ptr = NULL;
-                        const char *transport_str = NULL;
-                        
-                        if ((ptr = sofia_glue_find_parameter(contact_url, &quot;transport=&quot;))) {
-                                sofia_transport_t transport = sofia_glue_str2transport(ptr);
-                                transport_str = sofia_glue_transport2str(transport);
-                                
-                                switch (transport) {
-                                case SOFIA_TRANSPORT_TCP:
-                                        contact_str = profile-&gt;tcp_public_contact;
-                                        break;
-                                case SOFIA_TRANSPORT_TCP_TLS:
-                                        contact_str = profile-&gt;tls_public_contact;
-                                        break;
-                                default:
-                                        contact_str = profile-&gt;public_url;
-                                        break;
-                                }
-                                
-                                user_via = sofia_glue_create_external_via(NULL, profile, transport);
-                        } else {
-                                user_via = sofia_glue_create_external_via(NULL, profile, SOFIA_TRANSPORT_UDP);
-                                contact_str = profile-&gt;public_url;
-                        }
-                
-                } else {
-                        contact_str = profile-&gt;url;
-                }
-
-                nh = nua_handle(profile-&gt;nua, NULL, 
-                                                NUTAG_URL(contact_url), 
-                                                SIPTAG_FROM_STR(id), 
-                                                SIPTAG_TO_STR(id), 
-                                                SIPTAG_CONTACT_STR(contact_str), 
-                                                TAG_END());
-
-                nua_handle_bind(nh, &amp;mod_sofia_globals.destroy_private);
-                nua_notify(nh,
-                                   NUTAG_NEWSUB(1),
-                                   TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
-                                   SIPTAG_EVENT_STR(event), 
-                                   SIPTAG_CONTENT_TYPE_STR(&quot;application/simple-message-summary&quot;),
-                                   SIPTAG_PAYLOAD_STR(&quot;&quot;),
-                                   TAG_END());
-
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Sending reboot command to %s\n&quot;, contact_url);
-                free(contact_url);
-        }
-
-        switch_safe_free(user_via);
-        switch_safe_free(id);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int sofia_sla_dialog_del_callback(void *pArg, int argc, char **argv, char **columnNames)
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>