<!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][16053] </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=16053">16053</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-12-23 23:44:23 -0600 (Wed, 23 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>xmas presence 2009</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibsspandspINSTALL">freeswitch/trunk/libs/spandsp/INSTALL</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h</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="#freeswitchtrunksrcswitch_channelc">freeswitch/trunk/src/switch_channel.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunklibsspandspINSTALL"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/INSTALL (16052 => 16053)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/INSTALL        2009-12-24 04:35:17 UTC (rev 16052)
+++ freeswitch/trunk/libs/spandsp/INSTALL        2009-12-24 05:44:23 UTC (rev 16053)
</span><span class="lines">@@ -1,100 +1,43 @@
</span><del>-Building and installing spandsp
-===============================
</del><ins>+Installation Instructions
+*************************
</ins><span class="cx">
</span><del>-A number of distributions include spandsp, but they usually use older versions
-of the library, which lack a lot of the features of the current version. Before
-installing spandsp, make sure there are no older versions already on your
-machine. Make sure libtiff is installed on your machine. Versions 3.5.7,
-3.6.0, 3.7.1 and 3.8.2 seem to work OK. There have been several bugs related
-to FAX document handling in some versions of libtiff. Also, some people have
-had trouble using spandsp because they had more than one version of libtiff
-on their machine. Take care with this. If you are using an RPM based system,
-such as RedHat or Fedora, you will need the libtiff and libtiff-devel RPMs
-installed to be able to build spandsp.
</del><ins>+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
+Software Foundation, Inc.
</ins><span class="cx">
</span><del>-You can use the usual:
</del><ins>+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
</ins><span class="cx">
</span><del>- ./configure
- make
- make install
-
-process to build the spandsp library. Note that if you use configure in this
-way, the software will be installed in /usr/local. In this case make sure your
-/etc/ld.so.conf file has an entry for /usr/local/lib. If you wish the software
-to be installed in /usr, you should build it with the commands.
-
- ./configure --prefix=/usr
- make
- make install
-
-
-Building the programming documentation
-======================================
-
-If you wish to build the programming documentation for spandsp, configure
-spandsp with:
-
- ./configure --enable-doc
-
-You need doxygen installed on your machine.
-
-
-Building the test suite
-=======================
-
-Most sections of the spandsp library have an accompanying test program in the
-test directory. If you wish to build these test programs, configure spandsp
-with:
-
- ./configure --enable-tests
-
-To build these tests you will need libaudiofile installed on your machine. To
-build the modem tests, with the GUI monitoring feature you will need Fltk 1.1.4
-or later, an audio meter module and a cartesian plotting module. Fltk may be
-obtained from http://www.fltk.org. The audio meter module may be obtained from
-http://www.soft-switch.org/downloads/Fl_Audio_Meter.tgz . The cartesian plotting
-module may be obtained from http://134.226.68.29/fltk. However, there is no
-suitable makefile supplied with that. You can find a version at
-http://www.soft-switch.org/downloads/Fl_Cartesian.tgz which will build as a
-Linux library. The actual code in both these versions is identical.
-You need to have Fltk 1.1.4 or later installed before building the plotting
-library.
-
-
-Applications
-============
-
-Applications support for spandsp is built into packages such as Callweaver,
-FreeSwitch and iaxmodem. Code to add spandsp based FAX support to Asterisk may
-be found at http://sourceforge.net/projects/agx-ast-addons.
-
-
-
-
</del><span class="cx"> Basic Installation
</span><span class="cx"> ==================
</span><span class="cx">
</span><del>- These are generic installation instructions.
</del><ins>+These are generic installation instructions.
</ins><span class="cx">
</span><span class="cx"> The `configure' shell script attempts to guess correct values for
</span><span class="cx"> various system-dependent variables used during compilation. It uses
</span><span class="cx"> those values to create a `Makefile' in each directory of the package.
</span><span class="cx"> It may also create one or more `.h' files containing system-dependent
</span><span class="cx"> definitions. Finally, it creates a shell script `config.status' that
</span><del>-you can run in the future to recreate the current configuration, a file
-`config.cache' that saves the results of its tests to speed up
-reconfiguring, and a file `config.log' containing compiler output
-(useful mainly for debugging `configure').
</del><ins>+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
</ins><span class="cx">
</span><ins>+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
</ins><span class="cx"> If you need to do unusual things to compile the package, please try
</span><span class="cx"> to figure out how `configure' could check whether to do them, and mail
</span><span class="cx"> diffs or instructions to the address given in the `README' so they can
</span><del>-be considered for the next release. If at some point `config.cache'
-contains results you don't want to keep, you may remove or edit it.
</del><ins>+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
</ins><span class="cx">
</span><del>- The file `configure.ac' is used to create `configure' by a program
-called `autoconf'. You only need `configure.ac' if you want to change
-it or regenerate `configure' using a newer version of `autoconf'.
</del><ins>+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
</ins><span class="cx">
</span><span class="cx"> The simplest way to compile this package is:
</span><span class="cx">
</span><span class="lines">@@ -127,20 +70,22 @@
</span><span class="cx"> Compilers and Options
</span><span class="cx"> =====================
</span><span class="cx">
</span><del>- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. You can give `configure'
-initial values for variables by setting them in the environment. Using
-a Bourne-compatible shell, you can do that on the command line like
-this:
- CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
</del><ins>+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about. Run `./configure --help' for
+details on some of the pertinent environment variables.
</ins><span class="cx">
</span><del>-Or on systems that have the `env' program, you can do it like this:
- env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
</del><ins>+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
</ins><span class="cx">
</span><ins>+ ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
</ins><span class="cx"> Compiling For Multiple Architectures
</span><span class="cx"> ====================================
</span><span class="cx">
</span><del>- You can compile the package for more than one kind of computer at the
</del><ins>+You can compile the package for more than one kind of computer at the
</ins><span class="cx"> same time, by placing the object files for each architecture in their
</span><span class="cx"> own directory. To do this, you must use a version of `make' that
</span><span class="cx"> supports the `VPATH' variable, such as GNU `make'. `cd' to the
</span><span class="lines">@@ -148,28 +93,28 @@
</span><span class="cx"> the `configure' script. `configure' automatically checks for the
</span><span class="cx"> source code in the directory that `configure' is in and in `..'.
</span><span class="cx">
</span><del>- If you have to use a `make' that does not supports the `VPATH'
-variable, you have to compile the package for one architecture at a time
-in the source code directory. After you have installed the package for
-one architecture, use `make distclean' before reconfiguring for another
-architecture.
</del><ins>+ If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory. After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
</ins><span class="cx">
</span><span class="cx"> Installation Names
</span><span class="cx"> ==================
</span><span class="cx">
</span><del>- By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
</del><ins>+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
</ins><span class="cx">
</span><span class="cx"> You can specify separate installation prefixes for
</span><span class="cx"> architecture-specific files and architecture-independent files. If you
</span><del>-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
</del><ins>+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
</ins><span class="cx">
</span><span class="cx"> In addition, if you use an unusual directory layout you can give
</span><del>-options like `--bindir=PATH' to specify different values for particular
</del><ins>+options like `--bindir=DIR' to specify different values for particular
</ins><span class="cx"> kinds of files. Run `configure --help' for a list of the directories
</span><span class="cx"> you can set and what kinds of files go in them.
</span><span class="cx">
</span><span class="lines">@@ -180,7 +125,7 @@
</span><span class="cx"> Optional Features
</span><span class="cx"> =================
</span><span class="cx">
</span><del>- Some packages pay attention to `--enable-FEATURE' options to
</del><ins>+Some packages pay attention to `--enable-FEATURE' options to
</ins><span class="cx"> `configure', where FEATURE indicates an optional part of the package.
</span><span class="cx"> They may also pay attention to `--with-PACKAGE' options, where PACKAGE
</span><span class="cx"> is something like `gnu-as' or `x' (for the X Window System). The
</span><span class="lines">@@ -195,48 +140,86 @@
</span><span class="cx"> Specifying the System Type
</span><span class="cx"> ==========================
</span><span class="cx">
</span><del>- There may be some features `configure' can not figure out
-automatically, but needs to determine by the type of host the package
-will run on. Usually `configure' can figure that out, but if it prints
-a message saying it can not guess the host type, give it the
-`--host=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name with three fields:
</del><ins>+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
</ins><span class="cx"> CPU-COMPANY-SYSTEM
</span><span class="cx">
</span><del>-See the file `config.sub' for the possible values of each field. If
</del><ins>+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
</ins><span class="cx"> `config.sub' isn't included in this package, then this package doesn't
</span><del>-need to know the host type.
</del><ins>+need to know the machine type.
</ins><span class="cx">
</span><del>- If you are building compiler tools for cross-compiling, you can also
-use the `--target=TYPE' option to select the type of system they will
-produce code for and the `--build=TYPE' option to select the type of
-system on which you are compiling the package.
</del><ins>+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
</ins><span class="cx">
</span><ins>+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
</ins><span class="cx"> Sharing Defaults
</span><span class="cx"> ================
</span><span class="cx">
</span><del>- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
</del><ins>+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
</ins><span class="cx"> `configure' looks for `PREFIX/share/config.site' if it exists, then
</span><span class="cx"> `PREFIX/etc/config.site' if it exists. Or, you can set the
</span><span class="cx"> `CONFIG_SITE' environment variable to the location of the site script.
</span><span class="cx"> A warning: not all `configure' scripts look for a site script.
</span><span class="cx">
</span><del>-Operation Controls
</del><ins>+Defining Variables
</ins><span class="cx"> ==================
</span><span class="cx">
</span><del>- `configure' recognizes the following options to control how it
-operates.
</del><ins>+Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
</ins><span class="cx">
</span><del>-`--cache-file=FILE'
- Use and save the results of the tests in FILE instead of
- `./config.cache'. Set FILE to `/dev/null' to disable caching, for
- debugging `configure'.
</del><ins>+ ./configure CC=/usr/local2/bin/gcc
</ins><span class="cx">
</span><ins>+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script). Here is a another example:
+
+ /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
+configuration-related scripts to be executed by `/bin/bash'.
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
</ins><span class="cx"> `--help'
</span><ins>+`-h'
</ins><span class="cx"> Print a summary of the options to `configure', and exit.
</span><span class="cx">
</span><ins>+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
</ins><span class="cx"> `--quiet'
</span><span class="cx"> `--silent'
</span><span class="cx"> `-q'
</span><span class="lines">@@ -248,8 +231,6 @@
</span><span class="cx"> Look for the package's source code in directory DIR. Usually
</span><span class="cx"> `configure' can determine that directory automatically.
</span><span class="cx">
</span><del>-`--version'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
</del><ins>+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
</ins><span class="cx">
</span><del>-`configure' also accepts some other, not widely useful, options.
</del></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (16052 => 16053)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2009-12-24 04:35:17 UTC (rev 16052)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2009-12-24 05:44:23 UTC (rev 16053)
</span><span class="lines">@@ -211,7 +211,7 @@
</span><span class="cx">                 callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, tech_pvt->profile->sipip);
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        header = (tech_pvt->cid_type == CID_TYPE_RPID) ? "Remote-Party-ID" : "P-Asserted-Identity";
</del><ins>+        header = (tech_pvt->cid_type == CID_TYPE_RPID && !switch_stristr("aastra", ua)) ? "Remote-Party-ID" : "P-Asserted-Identity";
</ins><span class="cx">
</span><span class="cx">         if (!zstr(callee_name) && !zstr(callee_number)) {
</span><span class="cx">                 if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) {
</span><span class="lines">@@ -394,6 +394,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (switch_channel_test_flag(channel, CF_ANSWERED) || sofia_test_flag(tech_pvt, TFLAG_ANS)) {
</span><ins>+                        const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
</ins><span class="cx">                         if (!tech_pvt->got_bye) {
</span><span class="cx">                                 switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye");
</span><span class="cx">                         }
</span><span class="lines">@@ -401,6 +402,7 @@
</span><span class="cx">                         if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><span class="cx">                                 nua_bye(tech_pvt->nh,
</span><span class="cx">                                                 TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)),
</span><ins>+                                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</ins><span class="cx">                                                 TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
</span><span class="cx">                                                 TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
</span><span class="cx">                                                 TAG_END());
</span><span class="lines">@@ -472,6 +474,7 @@
</span><span class="cx">         const char *b_sdp = NULL;
</span><span class="cx">         int is_proxy = 0;
</span><span class="cx">         char *sticky = NULL;
</span><ins>+        const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
</ins><span class="cx">
</span><span class="cx">         if (sofia_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -508,6 +511,7 @@
</span><span class="cx">                                         nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                 SIPTAG_CONTACT_STR(tech_pvt->profile->url),
</span><span class="cx">                                                                 SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><ins>+                                                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</ins><span class="cx">                                                                 SOATAG_REUSE_REJECTED(1),
</span><span class="cx">                                                                 SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
</span><span class="cx">                                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><span class="lines">@@ -519,6 +523,7 @@
</span><span class="cx">                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                 SIPTAG_CONTACT_STR(tech_pvt->profile->url),
</span><span class="cx">                                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><ins>+                                                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</ins><span class="cx">                                                                 SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><span class="cx">                                                                 SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),                                                                
</span><span class="cx">                                                                 TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
</span><span class="lines">@@ -1448,6 +1453,14 @@
</span><span class="cx">                                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><span class="cx">                                                                          TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
</span><span class="cx">                                                                          TAG_END());
</span><ins>+                                                } else if ((ua && (switch_stristr("aastra", ua)))) {
+                                                        snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <sip:%s@%s>", name, number, tech_pvt->profile->sipip);
+                                                        
+                                                        sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
+                                                        nua_update(tech_pvt->nh,
+                                                                         TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
+                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
+                                                                         TAG_END());
</ins><span class="cx">                                                 }
</span><span class="cx">
</span><span class="cx">                                                 tech_pvt->last_sent_callee_id_name = switch_core_session_strdup(tech_pvt->session, name);
</span><span class="lines">@@ -1683,9 +1696,12 @@
</span><span class="cx">                 if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
</span><span class="cx">                         !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
</span><span class="cx">                         char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
</span><ins>+                        const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
+
</ins><span class="cx">                         nua_respond(tech_pvt->nh, SIP_180_RINGING,
</span><span class="cx">                                                 SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                 SIPTAG_HEADER_STR(generate_pai_str(session)),
</span><ins>+                                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</ins><span class="cx">                                                 TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
</span><span class="cx">                                                 TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
</span><span class="cx">                                                          SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
</span><span class="lines">@@ -1701,6 +1717,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         char *sticky = NULL;
</span><span class="cx">                         const char *val = NULL;
</span><ins>+                        const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
</ins><span class="cx">
</span><span class="cx">                         if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
</span><span class="cx">                                 sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
</span><span class="lines">@@ -1774,6 +1791,7 @@
</span><span class="cx">
</span><span class="cx">                                 if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><span class="cx">                                         char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
</span><ins>+                                        
</ins><span class="cx">                                         if (sofia_use_soa(tech_pvt)) {
</span><span class="cx">                                                 nua_respond(tech_pvt->nh,
</span><span class="cx">                                                                         SIP_183_SESSION_PROGRESS,
</span><span class="lines">@@ -1785,6 +1803,7 @@
</span><span class="cx">                                                                         SOATAG_ORDERED_USER(1),
</span><span class="cx">                                                                         SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
</span><span class="cx">                                                                         SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"),
</span><ins>+                                                                        TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</ins><span class="cx">                                                                         TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
</span><span class="cx">                                                                         TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
</span><span class="cx">                                                                                  SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
</span><span class="lines">@@ -1799,6 +1818,7 @@
</span><span class="cx">                                                                         SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                                         SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><span class="cx">                                                                         SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),                                                                        
</span><ins>+                                                                        TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</ins><span class="cx">                                                                         TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
</span><span class="cx">                                                                         TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
</span><span class="cx">                                                                                  SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (16052 => 16053)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2009-12-24 04:35:17 UTC (rev 16052)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2009-12-24 05:44:23 UTC (rev 16053)
</span><span class="lines">@@ -522,6 +522,7 @@
</span><span class="cx">         uint32_t timer_t4;
</span><span class="cx">         char *contact_user;
</span><span class="cx">         char *local_network;
</span><ins>+        uint32_t trans_timeout;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct private_object {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (16052 => 16053)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-12-24 04:35:17 UTC (rev 16052)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-12-24 05:44:23 UTC (rev 16053)
</span><span class="lines">@@ -284,6 +284,7 @@
</span><span class="cx">         switch_channel_t *channel;
</span><span class="cx">         private_object_t *tech_pvt;
</span><span class="cx">         char *extra_headers;
</span><ins>+        const char *call_info = NULL;
</ins><span class="cx"> #ifdef MANUAL_BYE
</span><span class="cx">         int cause;
</span><span class="cx">         char st[80] = "";
</span><span class="lines">@@ -295,12 +296,12 @@
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">
</span><del>-
</del><span class="cx"> #ifdef MANUAL_BYE
</span><span class="cx">         status = 200;
</span><span class="cx">         phrase = "OK";
</span><span class="cx">         
</span><span class="cx">         sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
</span><ins>+        call_info = switch_channel_get_variable(channel, "presence_call_info");
</ins><span class="cx">
</span><span class="cx">         if (sip->sip_reason && sip->sip_reason->re_protocol &&
</span><span class="cx">                 (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
</span><span class="lines">@@ -328,7 +329,8 @@
</span><span class="cx">         
</span><span class="cx">         switch_channel_hangup(channel, cause);
</span><span class="cx">         nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua),
</span><del>-                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
</del><ins>+                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
+                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
</ins><span class="cx">                 
</span><span class="cx">         switch_safe_free(extra_headers);
</span><span class="cx">
</span><span class="lines">@@ -948,7 +950,7 @@
</span><span class="cx">
</span><span class="cx">         while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) {
</span><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
</span><del>-                        if (qsize > 0 && (qsize >= 500 || ++loop_count >= 500)) {
</del><ins>+                        if (qsize > 0 && (qsize >= 1024 || ++loop_count >= profile->trans_timeout)) {
</ins><span class="cx">                                 switch_size_t newlen;
</span><span class="cx">                                 uint32_t itterations = 0;
</span><span class="cx">                                 switch_size_t len = 0;
</span><span class="lines">@@ -2449,6 +2451,8 @@
</span><span class="cx">                                         goto done;
</span><span class="cx">                                 }
</span><span class="cx">
</span><ins>+                                profile->trans_timeout = 500;
+
</ins><span class="cx">                                 profile->auto_rtp_bugs = RTP_BUG_CISCO_SKIP_MARK_BIT_2833 | RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
</span><span class="cx">
</span><span class="cx">                                 profile->pool = pool;
</span><span class="lines">@@ -2910,7 +2914,14 @@
</span><span class="cx">                                                         sofia_clear_pflag(profile, PFLAG_PASS_CALLEE_ID);
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "sql-in-transactions")) {
</span><ins>+                                                int tmp = atoi(val);
+
</ins><span class="cx">                                                 if (switch_true(val)) {
</span><ins>+                                                        tmp = 500;
+                                                }
+
+                                                if (tmp > 0) {
+                                                        profile->trans_timeout = tmp;
</ins><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
</span><span class="lines">@@ -3376,7 +3387,9 @@
</span><span class="cx">                 char network_ip[80];
</span><span class="cx">                 int network_port = 0;
</span><span class="cx">                 switch_caller_profile_t *caller_profile = NULL;
</span><ins>+                char *call_info = NULL;
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">                 sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</span><span class="cx">
</span><span class="cx">                 switch_channel_set_variable(channel, "sip_reply_host", network_ip);
</span><span class="lines">@@ -3402,7 +3415,7 @@
</span><span class="cx">                         } else if (sip->sip_server && sip->sip_server->g_string) {
</span><span class="cx">                                 switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string);
</span><span class="cx">                         }
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
</span><span class="cx">
</span><span class="cx">                         sofia_update_callee_id(session, profile, sip, SWITCH_FALSE);
</span><span class="lines">@@ -3428,6 +3441,11 @@
</span><span class="cx">                                 return;
</span><span class="cx">                         }
</span><span class="cx">
</span><ins>+                        if (sip->sip_call_info) {
+                                call_info = sip_header_as_string(profile->home, (void *) sip->sip_call_info);
+                                switch_channel_set_variable(channel, "presence_call_info", call_info);
+                        }
+
</ins><span class="cx">                         if ((br = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                                 switch_xml_t root = NULL, domain = NULL;
</span><span class="cx">                                 switch_core_session_t *a_session;
</span><span class="lines">@@ -3648,20 +3666,25 @@
</span><span class="cx">                                         
</span><span class="cx">                                         sql = switch_mprintf("insert into sip_dialogs "
</span><span class="cx">                                                                                  "(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user,"
</span><del>-                                                                                 "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id, presence_data) "
-                                                                                 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</del><ins>+                                                                                 "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data,call_info) "
+                                                                                 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</ins><span class="cx">                                                                                  call_id,
</span><span class="cx">                                                                                  switch_core_session_get_uuid(session),
</span><span class="cx">                                                                                  to_user, to_host, from_user, from_host, contact_user,
</span><span class="cx">                                                                                  contact_host, astate, "outbound", user_agent,
</span><span class="cx">                                                                                  profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
</span><del>-                                                                                 switch_str_nil(presence_id), switch_str_nil(presence_data));
</del><ins>+                                                                                 switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(call_info));
</ins><span class="cx">                                         
</span><span class="cx">                                         switch_assert(sql);
</span><span class="cx">
</span><span class="cx">                                         sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><span class="cx">
</span><span class="cx">                                 }
</span><ins>+                                
+                                if (call_info) {
+                                        su_free(profile->home, call_info);
+                                }
+
</ins><span class="cx">                         } else if (status == 200 && (profile->pres_type)) {
</span><span class="cx">                                 char *sql = NULL;
</span><span class="cx">                                 const char *presence_data = switch_channel_get_variable(channel, "presence_data");
</span><span class="lines">@@ -5240,6 +5263,8 @@
</span><span class="cx">         char acl_token[512] = "";
</span><span class="cx">         sofia_transport_t transport;
</span><span class="cx">         const char *gw_name = NULL;
</span><ins>+        char *call_info_str = NULL;
+        nua_handle_t *bnh = NULL;
</ins><span class="cx">
</span><span class="cx">         profile->ib_calls++;
</span><span class="cx">
</span><span class="lines">@@ -5799,12 +5824,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((call_info = sip_call_info(sip))) {
</span><del>-                char *tmp = sip_header_as_string(profile->home, (void *) call_info);
</del><ins>+                call_info_str = sip_header_as_string(nh->nh_home, (void *) call_info);
</ins><span class="cx">                 if (call_info->ci_params && (msg_params_find(call_info->ci_params , "answer-after=0"))) {
</span><span class="cx">                         switch_channel_set_variable(channel, "sip_auto_answer_detected", "true");
</span><span class="cx">                 }
</span><del>-                switch_channel_set_variable(channel, "sip_call_info", tmp);
-                su_free(profile->home, tmp);
</del><ins>+                switch_channel_set_variable(channel, "sip_call_info", call_info_str);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (profile->pres_type) {
</span><span class="lines">@@ -5857,77 +5881,95 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (call_info_str) {
+                char *sql;
+                char cid[512] = "";
+                char *str;
+
+                if (sip->sip_to && sip->sip_to->a_url) {
+                        sql = switch_mprintf("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q'",
+                                                                 call_info_str, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
+                        
+                        if ((str = sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, cid, sizeof(cid)))) {
+                                bnh = nua_handle_by_call_id(nua, str);
+                        }
+
+                        free(sql);
+                }
+        }
+
</ins><span class="cx">         if (sip->sip_replaces) {
</span><del>-                nua_handle_t *bnh;
-                if ((bnh = nua_handle_by_replaces(nua, sip->sip_replaces))) {
-                        sofia_private_t *b_private = NULL;
-                        if ((b_private = nua_handle_magic(bnh))) {
-                                switch_core_session_t *b_session = NULL;
-                                if ((b_session = switch_core_session_locate(b_private->uuid))) {
-                                        switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
-                                        const char *uuid;
-                                        int one_leg = 1;
-                                        private_object_t *b_tech_pvt = NULL;
-                                        const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
-                                        const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
-                                        
-                                        if (app && data && !strcasecmp(app, "conference")) {
-                                                destination_number = switch_core_session_sprintf(b_session, "answer,conference:%s", data);
-                                                dialplan = "inline";
</del><ins>+                bnh = nua_handle_by_replaces(nua, sip->sip_replaces);
+        }
+
+        if (bnh) {
+                sofia_private_t *b_private = NULL;
+                if ((b_private = nua_handle_magic(bnh))) {
+                        switch_core_session_t *b_session = NULL;
+
+                        if ((b_session = switch_core_session_locate(b_private->uuid))) {
+                                switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
+                                const char *uuid;
+                                int one_leg = 1;
+                                private_object_t *b_tech_pvt = NULL;
+                                const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
+                                const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
+                        
+                                if (app && data && !strcasecmp(app, "conference")) {
+                                        destination_number = switch_core_session_sprintf(b_session, "answer,conference:%s", data);
+                                        dialplan = "inline";
+                                } else {
+                                        if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) {
+                                                b_tech_pvt = switch_core_session_get_private(b_session);
+                                        }
+
+                                        if ((uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
+                                                one_leg = 0;
</ins><span class="cx">                                         } else {
</span><del>-                                                if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) {
-                                                        b_tech_pvt = switch_core_session_get_private(b_session);
-                                                }
-
-                                                if ((uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
-                                                        one_leg = 0;
-                                                } else {
-                                                        uuid = switch_core_session_get_uuid(b_session);
-                                                }
</del><ins>+                                                uuid = switch_core_session_get_uuid(b_session);
+                                        }
</ins><span class="cx">                                         
</span><del>-                                                if (uuid) {
-                                                        switch_core_session_t *c_session = NULL;
-                                                        int do_conf = 0;                                        
-                                                
-                                                        uuid = switch_core_session_strdup(b_session, uuid);
</del><ins>+                                        if (uuid) {
+                                                switch_core_session_t *c_session = NULL;
+                                                int do_conf = 0;                                        
+                                                uuid = switch_core_session_strdup(b_session, uuid);
</ins><span class="cx">
</span><del>-                                                        if ((c_session = switch_core_session_locate(uuid))) {
-                                                                switch_channel_t *c_channel = switch_core_session_get_channel(c_session);
-                                                                private_object_t *c_tech_pvt = NULL;
-                                        
-                                                                if (switch_core_session_check_interface(c_session, sofia_endpoint_interface)) {
-                                                                        c_tech_pvt = switch_core_session_get_private(c_session);
-                                                                }
</del><ins>+                                                if ((c_session = switch_core_session_locate(uuid))) {
+                                                        switch_channel_t *c_channel = switch_core_session_get_channel(c_session);
+                                                        private_object_t *c_tech_pvt = NULL;
+
+                                                        if (switch_core_session_check_interface(c_session, sofia_endpoint_interface)) {
+                                                                c_tech_pvt = switch_core_session_get_private(c_session);
+                                                        }
</ins><span class="cx">                                                                 
</span><span class="cx">
</span><del>-                                                                if (!one_leg &&
-                                                                        (!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) &&
-                                                                        (!c_tech_pvt || !sofia_test_flag(c_tech_pvt, TFLAG_SIP_HOLD))) {
-                                                                        char *ext = switch_core_session_sprintf(b_session, "conference:%s@sla+flags{mintwo}", uuid);
</del><ins>+                                                        if (!one_leg &&
+                                                                (!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) &&
+                                                                (!c_tech_pvt || !sofia_test_flag(c_tech_pvt, TFLAG_SIP_HOLD))) {
+                                                                char *ext = switch_core_session_sprintf(b_session, "conference:%s@sla+flags{mintwo}", uuid);
</ins><span class="cx">                                                                 
</span><del>-                                                                        switch_channel_set_flag(c_channel, CF_REDIRECT);
-                                                                        switch_ivr_session_transfer(b_session, ext, "inline", NULL);
-                                                                        switch_ivr_session_transfer(c_session, ext, "inline", NULL);
-                                                                        switch_channel_clear_flag(c_channel, CF_REDIRECT);
-                                                                        do_conf = 1;
-                                                                }
-                                                                switch_core_session_rwunlock(c_session);
</del><ins>+                                                                switch_channel_set_flag(c_channel, CF_REDIRECT);
+                                                                switch_ivr_session_transfer(b_session, ext, "inline", NULL);
+                                                                switch_ivr_session_transfer(c_session, ext, "inline", NULL);
+                                                                switch_channel_clear_flag(c_channel, CF_REDIRECT);
+                                                                do_conf = 1;
</ins><span class="cx">                                                         }
</span><ins>+                                                        switch_core_session_rwunlock(c_session);
+                                                }
</ins><span class="cx">                                                 
</span><del>-                                                        if (do_conf) {
-                                                                destination_number = switch_core_session_sprintf(b_session, "answer,conference:%s@sla+flags{mintwo}", uuid);
-                                                        } else {
-                                                                destination_number = switch_core_session_sprintf(b_session, "answer,intercept:%s", uuid);
-                                                        }
</del><ins>+                                                if (do_conf) {
+                                                        destination_number = switch_core_session_sprintf(b_session, "answer,conference:%s@sla+flags{mintwo}", uuid);
+                                                } else {
+                                                        destination_number = switch_core_session_sprintf(b_session, "answer,intercept:%s", uuid);
+                                                }
</ins><span class="cx">
</span><del>-                                                        dialplan = "inline";
-                                                }
</del><ins>+                                                dialplan = "inline";
</ins><span class="cx">                                         }
</span><del>-                                        switch_core_session_rwunlock(b_session);
</del><span class="cx">                                 }
</span><ins>+                                switch_core_session_rwunlock(b_session);
</ins><span class="cx">                         }
</span><del>-                        nua_handle_unref(bnh);
</del><span class="cx">                 }
</span><ins>+                nua_handle_unref(bnh);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         check_decode(displayname, session);
</span><span class="lines">@@ -6074,20 +6116,26 @@
</span><span class="cx">                                 full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
</span><span class="cx">                         }
</span><span class="cx">                         
</span><ins>+                        if (call_info_str) {
+                                switch_channel_set_variable(channel, "presence_call_info", call_info_str);
+                        }
+
+
</ins><span class="cx">                         sql = switch_mprintf("insert into sip_dialogs "
</span><span class="cx">                                                                  "(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user,"
</span><del>-                                                                 "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data) "
-                                                                 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</del><ins>+                                                                 "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data,call_info) "
+                                                                 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</ins><span class="cx">                                                                  call_id,
</span><span class="cx">                                                                  tech_pvt->sofia_private->uuid,
</span><span class="cx">                                                                  to_user, to_host, dialog_from_user, dialog_from_host,
</span><span class="cx">                                                                  contact_user, contact_host, "confirmed", "inbound", user_agent,
</span><span class="cx">                                                                  profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
</span><del>-                                                                 switch_str_nil(presence_id), switch_str_nil(presence_data));
</del><ins>+                                                                 switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(call_info_str));
</ins><span class="cx">
</span><span class="cx">                         switch_assert(sql);
</span><span class="cx">                         
</span><span class="cx">                         sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><ins>+
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (is_nat) {
</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 (16052 => 16053)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-12-24 04:35:17 UTC (rev 16052)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-12-24 05:44:23 UTC (rev 16053)
</span><span class="lines">@@ -3806,7 +3806,8 @@
</span><span class="cx"> " hostname VARCHAR(255),\n"
</span><span class="cx"> " contact VARCHAR(255),\n"
</span><span class="cx"> " presence_id VARCHAR(255),\n"
</span><del>- " presence_data VARCHAR(255)\n"
</del><ins>+ " presence_data VARCHAR(255),\n"
+ " call_info VARCHAR(255)\n"
</ins><span class="cx">                 ");\n";
</span><span class="cx">
</span><span class="cx">         char sub_sql[] =
</span><span class="lines">@@ -3880,7 +3881,7 @@
</span><span class="cx">                         "create index sr_sip_realm on sip_registrations (sip_realm)",
</span><span class="cx">                         "create index ss_call_id on sip_subscriptions (call_id)",
</span><span class="cx">                         "create index ss_hostname on sip_subscriptions (hostname)",
</span><del>-                        "create index ss_hostname on sip_subscriptions (network_ip)",
</del><ins>+                        "create index ss_network_ip on sip_subscriptions (network_ip)",
</ins><span class="cx">                         "create index ss_sip_user on sip_subscriptions (sip_user)",
</span><span class="cx">                         "create index ss_sip_host on sip_subscriptions (sip_host)",
</span><span class="cx">                         "create index ss_presence_hosts on sip_subscriptions (presence_hosts)",
</span><span class="lines">@@ -3890,11 +3891,13 @@
</span><span class="cx">                         "create index ss_sub_to_host on sip_subscriptions (sub_to_host)",
</span><span class="cx">                         "create index sd_uuid on sip_dialogs (uuid)",
</span><span class="cx">                         "create index sd_hostname on sip_dialogs (hostname)",
</span><ins>+                        "create index sd_presence_data on sip_dialogs (presence_data)",
+                        "create index sd_call_info on sip_dialogs (call_info)",
</ins><span class="cx">                         "create index sp_hostname on sip_presence (hostname)",
</span><span class="cx">                         "create index sa_nonce on sip_authentication (nonce)",
</span><span class="cx">                         "create index sa_hostname on sip_authentication (hostname)",
</span><span class="cx">                         "create index ssa_hostname on sip_shared_appearance_subscriptions (hostname)",
</span><del>-                        "create index ssa_hostname on sip_shared_appearance_subscriptions (network_ip)",
</del><ins>+                        "create index ssa_network_ip on sip_shared_appearance_subscriptions (network_ip)",
</ins><span class="cx">                         "create index ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)",
</span><span class="cx">                         "create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
</span><span class="cx">                         "create index ssa_aor on sip_shared_appearance_subscriptions (aor)",
</span><span class="lines">@@ -3959,14 +3962,14 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 free(test_sql);
</span><del>-                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and contact like '%%'", mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and call_info like '%%'", mod_sofia_globals.hostname);
</ins><span class="cx">
</span><span class="cx">                 if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
</span><span class="cx">                         switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL);
</span><span class="cx">                         switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                test_sql = switch_mprintf("delete from sip_presence where hostname='%q'", mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname);
</ins><span class="cx">
</span><span class="cx">                 if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
</span><span class="cx">                         switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL);
</span><span class="lines">@@ -4026,11 +4029,11 @@
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><del>-                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and contact like '%%'", mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and call_info like '%%'", mod_sofia_globals.hostname);
</ins><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_dialogs", dialog_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><del>-                test_sql = switch_mprintf("delete from sip_presence where hostname='%q'", mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname);
</ins><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_presence", pres_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><span class="lines">@@ -4061,7 +4064,7 @@
</span><span class="cx">                                                         NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)",
</span><span class="cx">                                                         NULL, NULL, NULL);
</span><del>-                switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (network_ip)",
</del><ins>+                switch_core_db_exec(db, "create index if not exists ssd_network_ip on sip_shared_appearance_dialogs (network_ip)",
</ins><span class="cx">                                                         NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
</span><span class="cx">                                                         NULL, NULL, NULL);
</span><span class="lines">@@ -4089,7 +4092,7 @@
</span><span class="cx">
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists ss_call_id on sip_subscriptions (call_id)", NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists ss_hostname on sip_subscriptions (hostname)", NULL, NULL, NULL);
</span><del>-                switch_core_db_exec(db, "create index if not exists ss_hostname on sip_subscriptions (network_ip)", NULL, NULL, NULL);
</del><ins>+                switch_core_db_exec(db, "create index if not exists ss_network_ip on sip_subscriptions (network_ip)", NULL, NULL, NULL);
</ins><span class="cx">                 switch_core_db_exec(db, "create index if not exists ss_sip_user on sip_subscriptions (sip_user)", NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists ss_sip_host on sip_subscriptions (sip_host)", NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists ss_presence_hosts on sip_subscriptions (presence_hosts)", NULL, NULL, NULL);
</span><span class="lines">@@ -4100,9 +4103,10 @@
</span><span class="cx">
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists sd_uuid on sip_dialogs (uuid)", NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists sd_hostname on sip_dialogs (hostname)", NULL, NULL, NULL);
</span><del>-                switch_core_db_exec(db, "create index if not exists sd_hostname on sip_dialogs (contact)", NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists sd_hostname on sip_dialogs (presence_id)", NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists sd_hostname on sip_dialogs (presence_data)", NULL, NULL, NULL);
</del><ins>+                switch_core_db_exec(db, "create index if not exists sd_contact on sip_dialogs (contact)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists sd_presence_id on sip_dialogs (presence_id)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists sd_presence_data on sip_dialogs (presence_data)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists sd_call_info on sip_dialogs (call_info)", NULL, NULL, NULL);
</ins><span class="cx">
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists sp_hostname on sip_presence (hostname)", NULL, NULL, NULL);
</span><span class="cx">
</span><span class="lines">@@ -4500,12 +4504,13 @@
</span><span class="cx">         nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
</span><span class="cx">
</span><span class="cx">         nua_notify(nh,
</span><del>-                        NUTAG_NEWSUB(1),
-                        TAG_IF(dst->route_uri, NUTAG_PROXY(route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->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());
</del><ins>+                         NUTAG_NEWSUB(1),
+                         TAG_IF(dst->route_uri, NUTAG_PROXY(route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
+                         TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
+                         TAG_IF(event, SIPTAG_EVENT_STR(event)),
+                         TAG_IF(contenttype, SIPTAG_CONTENT_TYPE_STR(contenttype)),
+                         TAG_IF(body, SIPTAG_PAYLOAD_STR(body)),
+                         TAG_END());
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(contact);
</span><span class="cx">         switch_safe_free(route_uri);
</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 (16052 => 16053)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-12-24 04:35:17 UTC (rev 16052)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-12-24 05:44:23 UTC (rev 16053)
</span><span class="lines">@@ -41,7 +41,13 @@
</span><span class="cx"> static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, char **columnNames);
</span><span class="cx"> static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames);
</span><span class="cx"> static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames);
</span><ins>+static int broadsoft_sla_callback(void *pArg, int argc, char **argv, char **columnNames);
</ins><span class="cx">
</span><ins>+struct resub_helper {
+        sofia_profile_t *profile;
+        switch_event_t *event;
+};
+
</ins><span class="cx"> struct presence_helper {
</span><span class="cx">         sofia_profile_t *profile;
</span><span class="cx">         switch_event_t *event;
</span><span class="lines">@@ -201,16 +207,18 @@
</span><span class="cx">
</span><span class="cx"> void sofia_presence_establish_presence(sofia_profile_t *profile)
</span><span class="cx"> {
</span><del>-
</del><ins>+        struct resub_helper h = { 0 };
+        h.profile = profile;
+        
</ins><span class="cx">         if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex,
</span><span class="cx">                                                                                 "select sip_user,sip_host,'Registered','unknown','' from sip_registrations",
</span><del>-                                                                                sofia_presence_resub_callback, profile) != SWITCH_TRUE) {
</del><ins>+                                                                                sofia_presence_resub_callback, &h) != SWITCH_TRUE) {
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex,
</span><span class="cx">                                                                                 "select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions "
</span><del>-                                                                                "where proto='ext' or proto='user' or proto='conf'", sofia_presence_resub_callback, profile) != SWITCH_TRUE) {
</del><ins>+                                                                                "where proto='ext' or proto='user' or proto='conf'", sofia_presence_resub_callback, &h) != SWITCH_TRUE) {
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -380,9 +388,14 @@
</span><span class="cx">         char *status = switch_event_get_header(event, "status");
</span><span class="cx">         char *event_type = switch_event_get_header(event, "event_type");
</span><span class="cx">         char *alt_event_type = switch_event_get_header(event, "alt_event_type");
</span><ins>+        //char *event_subtype = switch_event_get_header(event, "event_subtype");
</ins><span class="cx">         char *sql = NULL;
</span><span class="cx">         char *euser = NULL, *user = NULL, *host = NULL;
</span><ins>+        char *call_info = switch_event_get_header(event, "presence-call-info");
+        char *call_info_state = switch_event_get_header(event, "presence-call-info-state");
+        struct resub_helper h = { 0 };
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">         if (!mod_sofia_globals.running) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -534,7 +547,8 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s DUMP PRESENCE_PROBE_SQL:\n%s\n", profile->name, sql);
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_resub_callback, profile);
</del><ins>+                                h.profile = profile;
+                                sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_resub_callback, &h);
</ins><span class="cx">                                 if (mod_sofia_globals.debug_presence > 0) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s END_PRESENCE_PROBE_SQL\n\n", profile->name);
</span><span class="cx">                                 }
</span><span class="lines">@@ -574,6 +588,53 @@
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                if (call_info) {
+                        sql = switch_mprintf("select sip_subscriptions.call_id,sip_subscriptions.expires,'%q',3, sip_dialogs.state,sip_dialogs.call_info, "
+                                                                 "sip_subscriptions.sub_to_host,'%q',event "
+                                                                 "from sip_subscriptions left join sip_dialogs on sip_subscriptions.sub_to_user=sip_dialogs.sip_from_user "
+                                                                 "and sip_subscriptions.sub_to_host=sip_dialogs.sip_from_host "
+                                                                 "where sip_subscriptions.hostname='%q' "
+                                                                 "and sub_to_user='%q' and sub_to_host='%q' "
+                                                                 "and (event='call-info' or event='line-seize') and sip_dialogs.call_info='%q'",
+                                                                 call_info,
+                                                                 call_info_state,
+                                                                 mod_sofia_globals.hostname,
+                                                                 euser,
+                                                                 host,
+                                                                 call_info
+                                                                 );
+                        
+                        if (mod_sofia_globals.debug_presence > 1) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PRES SQL %s\n", sql);
+                        }
+                        sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, broadsoft_sla_callback, profile);
+                        switch_safe_free(sql);
+
+
+
+                        sql = switch_mprintf("select sip_subscriptions.call_id,sip_subscriptions.expires,'',3, sip_dialogs.state,sip_dialogs.call_info, "
+                                                                 "sip_subscriptions.sub_to_host,'',event "
+                                                                 "from sip_subscriptions inner join sip_dialogs on sip_subscriptions.sub_to_user=sip_dialogs.sip_from_user "
+                                                                 "and sip_subscriptions.sub_to_host=sip_dialogs.sip_from_host "
+                                                                 "where sip_subscriptions.hostname='%q' "
+                                                                 "and sub_to_user='%q' and sub_to_host='%q' "
+                                                                 "and event='call-info' and sip_dialogs.call_info!='%q'",
+                                                                 mod_sofia_globals.hostname,
+                                                                 euser,
+                                                                 host,
+                                                                 call_info
+                                                                 );
+                        
+                        if (mod_sofia_globals.debug_presence > 1) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"PRES SQL %s\n", sql);
+                        }
+
+                        sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, broadsoft_sla_callback, profile);
+                        switch_safe_free(sql);
+
+                }
+
+
</ins><span class="cx">                 if ((sql = switch_mprintf(
</span><span class="cx">                                                         
</span><span class="cx">                                                          "select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
</span><span class="lines">@@ -815,7 +876,8 @@
</span><span class="cx">
</span><span class="cx"> static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames)
</span><span class="cx"> {
</span><del>-        sofia_profile_t *profile = (sofia_profile_t *) pArg;
</del><ins>+        struct resub_helper *h = (struct resub_helper *) pArg;
+        sofia_profile_t *profile = h->profile;
</ins><span class="cx">         char *user = argv[0];
</span><span class="cx">         char *host = argv[1];
</span><span class="cx">         char *status = argv[2];
</span><span class="lines">@@ -828,6 +890,7 @@
</span><span class="cx">         char *direction = NULL;
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">         char to_buf[128] = "";
</span><ins>+        switch_event_header_t *hp;
</ins><span class="cx">
</span><span class="cx">         if (argc > 5) {
</span><span class="cx">                 uuid = switch_str_nil(argv[5]);
</span><span class="lines">@@ -878,6 +941,15 @@
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", direction);
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                if (h->event) {
+                        for (hp = h->event->headers; hp; hp = hp->next) {
+                                if (!strncasecmp(hp->name, "fwd-", 4)) {
+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, hp->name + 4, hp->value);
+                                }
+                        }
+                }
+
+
</ins><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1391,6 +1463,114 @@
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static int broadsoft_sla_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+        char *call_id = argv[0];
+        char *expires = argv[1];
+        char *header = argv[2];
+        char *onoff = argv[3];
+        char *state = NULL;
+        char *call_info = NULL;
+        char *call_info_state = NULL;
+        char *event = NULL;
+        char *host = NULL;
+        sofia_profile_t *profile = (sofia_profile_t *) pArg;
+        nua_handle_t *nh;
+        char sstr[128] = "", expires_str[128] = "";        
+        time_t exptime = 3600;
+        int on = atoi(onoff);
+        char buf[512] = "";
+        const char *r_state = "idle";
+        int i;
+
+        if (mod_sofia_globals.debug_presence > 1) {
+                for(i = 0; i < argc; i++) {
+                        printf("COL [%s]=[%s]\n", columnNames[i], argv[i]);
+                }
+                printf("\non=%d\n\n", on);
+        }
+
+        if (on >= 2 && argc >= 7) {
+                state = argv[4];
+                call_info = argv[5];
+                host = argv[6];
+                call_info_state = argv[7];
+                if (argc > 8) event = argv[8];
+        } else {
+                call_info = header;
+        }
+        
+        if (zstr(event)) {
+                event = "call-info";
+        }
+
+        if (expires) {
+                long tmp = atol(expires);
+                exptime = tmp - switch_epoch_time_now(NULL);
+        }
+
+        if (exptime > 0) {
+                switch_snprintf(sstr, sizeof(sstr), "active;expires=%u", (unsigned)exptime);
+        } else {
+                switch_snprintf(sstr, sizeof(sstr), "terminated;reason=noresource");
+        }
+
+        switch_snprintf(expires_str, sizeof(expires_str), "%u", (unsigned)exptime);
+
+        if (zstr(call_info)) {
+                call_info = header;
+        }
+
+        if (on == 3) {
+                if (!zstr(call_info_state)) {
+                        r_state = call_info_state;
+                } else if (!zstr(argv[4])) {
+                        r_state = "active";
+                } else {
+                        r_state = "idle";
+                }
+        } else if (on) {
+                r_state = "seized";
+        }
+        
+
+        if (zstr(call_info)) {
+                switch_snprintf(buf, sizeof(buf), "<sip:%s>;apperance-index=*", host);
+                call_info = buf;
+        }
+        
+        if (mod_sofia_globals.debug_presence > 1) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[%s][%s][%s][%s]\n", event, call_info, call_id, r_state);
+        }
+
+        if (!strcasecmp(event, "line-seize") && (nh = nua_handle_by_call_id(profile->nua, call_id))) {
+                if (strcasecmp(r_state, "seized")) {
+                        char *new_header = switch_mprintf("%s;appearance-state=%s", call_info, r_state);
+                        nua_notify(nh,
+                                         SIPTAG_EXPIRES_STR("0"),
+                                         SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
+                                         SIPTAG_EVENT_STR("line-seize"), SIPTAG_CALL_INFO_STR(new_header), TAG_END());
+                        switch_safe_free(new_header);
+
+                }
+                        return 0;
+        }
+
+        if (profile && call_id && call_info && (nh = nua_handle_by_call_id(profile->nua, call_id))) {
+                char *new_header = switch_mprintf("%s;appearance-state=%s", call_info, r_state);
+                
+                nua_notify(nh,
+                                 TAG_IF(*expires_str, SIPTAG_EXPIRES_STR(expires_str)),
+                                 SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
+                                 SIPTAG_EVENT_STR("call-info"), SIPTAG_CALL_INFO_STR(new_header), TAG_END());
+
+                switch_safe_free(new_header);
+        }
+        
+
+        return 0;
+}
+
</ins><span class="cx"> void sofia_presence_handle_sip_i_subscribe(int status,
</span><span class="cx">                                                                                  char const *phrase,
</span><span class="cx">                                                                                  nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
</span><span class="lines">@@ -1456,7 +1636,7 @@
</span><span class="cx">                                         display = "\"user\"";
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                } else {
</del><ins>+                } else {
</ins><span class="cx">                         display = "\"user\"";
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -1494,6 +1674,13 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                if (is_nat && profile->local_network && switch_check_network_list_ip(network_ip, profile->local_network)) {
+                        if (profile->debug) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP %s is on local network, not seting NAT mode.\n", network_ip);
+                        }
+                        is_nat = NULL;
+                }
+
</ins><span class="cx">                 if (is_nat) {
</span><span class="cx">                         contact_host = network_ip;
</span><span class="cx">                         switch_snprintf(new_port, sizeof(new_port), ":%d", network_port);
</span><span class="lines">@@ -1514,7 +1701,7 @@
</span><span class="cx">                                                                                 ipv6 ? "]" : "",
</span><span class="cx">                                                                                 new_port,
</span><span class="cx">                                                                                 contact->m_url->url_params,
</span><del>-                                                                                is_nat ? ";fs_nat" : "");
</del><ins>+                                                                                is_nat ? ";fs_nat=yes" : "");
</ins><span class="cx">                 } else {
</span><span class="cx">                         contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s>%s",
</span><span class="cx">                                                                                 display,
</span><span class="lines">@@ -1523,7 +1710,7 @@
</span><span class="cx">                                                                                 contact_host,
</span><span class="cx">                                                                                 ipv6 ? "]" : "",
</span><span class="cx">                                                                                 new_port,
</span><del>-                                                                                is_nat ? ";fs_nat" : "");
</del><ins>+                                                                                is_nat ? ";fs_nat=yes" : "");
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1743,8 +1930,134 @@
</span><span class="cx">                                                 TAG_IF(sticky, NUTAG_PROXY(sticky)), TAG_END());
</span><span class="cx">
</span><span class="cx">                         switch_safe_free(sticky);
</span><ins>+                        
+                }
</ins><span class="cx">
</span><ins>+
+
+
+                
+                if (sub_state == nua_substate_terminated) {
+                        char *full_call_info = NULL;
+
+                        if (sip->sip_call_info) {
+                                full_call_info = sip_header_as_string(profile->home, (void *) sip->sip_call_info);
+                        }
+
+                        nua_notify(nh,
+                                         SIPTAG_EXPIRES_STR("0"),
+                                         SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
+                                         TAG_IF(full_call_info, SIPTAG_CALL_INFO_STR(full_call_info)),
+                                         TAG_END());
+
+                        
+                        if (!strcasecmp(event, "line-seize")) {
+                                if (full_call_info) {
+                                        sql = switch_mprintf("select call_id,expires,'%q',0 from sip_subscriptions where hostname='%q' "
+                                                                                 "and sub_to_user='%q' and sub_to_host='%q' "
+                                                                                 "and event='call-info' and contact != '%q'",
+                                                                                 full_call_info,
+                                                                                 mod_sofia_globals.hostname,
+                                                                                 to_user,
+                                                                                 to_host,
+                                                                                 contact_str
+                                                                                 );
+                                        if (mod_sofia_globals.debug_presence > 1) {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "UNSEIZE SQL %s\n", sql);
+                                        }
+
+                                        sofia_glue_execute_sql_callback(profile, NULL, sql, broadsoft_sla_callback, profile);
+                                        switch_safe_free(sql);
+                                }
+                        }
+                                
+                        if (full_call_info) {
+                                su_free(profile->home, full_call_info);
+                        }
+                                
+
+
+                } else {
+                        if (!strcasecmp(event, "line-seize")) {
+                                char *full_call_info = NULL;
+
+                                if (sip->sip_call_info) {
+                                        full_call_info = sip_header_as_string(profile->home, (void *) sip->sip_call_info);
+                                }
+                                
+
+                                nua_notify(nh,
+                                                 SIPTAG_EXPIRES_STR(exp_delta_str),
+                                                 SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
+                                                 SIPTAG_EVENT_STR("line-seize"), SIPTAG_CALL_INFO_STR(full_call_info), TAG_END());
+
+                                if (full_call_info) {
+                                        sql = switch_mprintf("select sip_subscriptions.call_id,sip_subscriptions.expires,'%q',4, sip_dialogs.state,sip_dialogs.call_info, "
+                                                                                 "sip_subscriptions.sub_to_host,'','call-info' "
+                                                                                 "from sip_subscriptions left join sip_dialogs on sip_subscriptions.sub_to_user=sip_dialogs.sip_from_user "
+                                                                                 "and sip_subscriptions.sub_to_host=sip_dialogs.sip_from_host "
+                                                                                 "where sip_subscriptions.hostname='%q' "
+                                                                                 "and sub_to_user='%q' and sub_to_host='%q' "
+                                                                                 "and event='call-info'and sip_subscriptions.contact != '%q'",
+                                                                                 full_call_info,
+                                                                                 mod_sofia_globals.hostname,
+                                                                                 to_user,
+                                                                                 to_host,
+                                                                                 contact_str
+                                                                                 );
+                        
+                                        if (mod_sofia_globals.debug_presence > 1) {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SEIZE SQL %s\n", sql);
+                                        }
+
+                                        sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, broadsoft_sla_callback, profile);
+                                        switch_safe_free(sql);
+                                        su_free(profile->home, full_call_info);
+                                }
+                        }
+
+                                
+
+                        if (!strcasecmp(event, "call-info")) {
+
+#if 0
+                                int x = 0;
+                                for (x = 1; x < 5; x++) {
+                                        char tmp[128] = "";
+                                        
+                                        switch_snprintf(tmp, sizeof(tmp), "<sip:%s>;apperance-index=%d;appearance-state=idle", to_host, x);
+                                        nua_notify(nh,
+                                                         SIPTAG_EXPIRES_STR(exp_delta_str),
+                                                         SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
+                                                         SIPTAG_EVENT_STR("call-info"), SIPTAG_CALL_INFO_STR(tmp), TAG_END());
+                                }
+#endif
+
+                                        
+
+                                sql = switch_mprintf("select sip_subscriptions.call_id,sip_subscriptions.expires,'',2, sip_dialogs.state,sip_dialogs.call_info, "
+                                                                         "sip_subscriptions.sub_to_host "
+                                                                         "from sip_subscriptions inner join sip_dialogs on sip_subscriptions.sub_to_user=sip_dialogs.sip_from_user "
+                                                                         "and sip_subscriptions.sub_to_host=sip_dialogs.sip_from_host "
+                                                                         "where sip_subscriptions.hostname='%q' "
+                                                                         "and sub_to_user='%q' and sub_to_host='%q' "
+                                                                         "and event='call-info' and sip_subscriptions.contact != '%q'",
+                                                                         mod_sofia_globals.hostname,
+                                                                         to_user,
+                                                                         to_host,
+                                                                         contact_str
+                                                                         );
+
+                                if (mod_sofia_globals.debug_presence > 1) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CALL-INFO SQL %s\n", sql);
+                                }
+                                sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, broadsoft_sla_callback, profile);
+                                switch_safe_free(sql);
+                        }
+
</ins><span class="cx">                 }
</span><ins>+                
+                
</ins><span class="cx">
</span><span class="cx">                 sent_reply++;
</span><span class="cx">
</span><span class="lines">@@ -1758,14 +2071,16 @@
</span><span class="cx">
</span><span class="cx">                 switch_safe_free(sstr);
</span><span class="cx">
</span><del>-                if ((sql = switch_mprintf(
-                                                                 "select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
-                                                                 "full_via,expires,user_agent,accept,profile_name,network_ip"
-                                                                 " from sip_subscriptions where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
-                                                                 to_host, to_user, to_host, to_host))) {
-                        sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_reg_callback, profile);
-                        
-                        switch_safe_free(sql);
</del><ins>+                if (!strcasecmp(event, "message-summary")) {                
+                        if ((sql = switch_mprintf(
+                                                                         "select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
+                                                                         "full_via,expires,user_agent,accept,profile_name,network_ip"
+                                                                         " from sip_subscriptions where event='message-summary' and sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
+                                                                         to_host, to_user, to_host, to_host))) {
+                                sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_reg_callback, profile);
+                                
+                                switch_safe_free(sql);
+                        }
</ins><span class="cx">                 }
</span><span class="cx">          end:
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_channelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_channel.c (16052 => 16053)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_channel.c        2009-12-24 04:35:17 UTC (rev 16052)
+++ freeswitch/trunk/src/switch_channel.c        2009-12-24 05:44:23 UTC (rev 16053)
</span><span class="lines">@@ -467,6 +467,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">         switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
</span><ins>+        const char *call_info = NULL;
</ins><span class="cx">
</span><span class="cx">         if (!status) {
</span><span class="cx">                 type = SWITCH_EVENT_PRESENCE_OUT;
</span><span class="lines">@@ -480,6 +481,8 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        call_info = switch_channel_get_variable(channel, "presence_call_info");
+
</ins><span class="cx">         if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_channel_event_set_data(channel, event);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", __FILE__);
</span><span class="lines">@@ -494,6 +497,29 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
</span><ins>+                
+                if (call_info) {
+                        char *call_info_state = "active";
+
+                        if (!switch_channel_up(channel)) {
+                                call_info_state = "idle";
+                        } else if (!strcasecmp(status, "hold")) {
+                                call_info_state = "held";
+                        } else if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
+                                if (channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
+                                        call_info_state = "progressing";
+                                } else {
+                                        call_info_state = "alerting";
+                                }
+                        }
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info-state", call_info_state);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info", call_info);
+                }
+
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction",
+                                                                         channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
+
+
</ins><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", channel->event_count++);
</span><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><span class="lines">@@ -2191,6 +2217,8 @@
</span><span class="cx">                 free(stream.data);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        switch_channel_presence(channel, "unknown", "answered", NULL);
+
</ins><span class="cx">         switch_channel_audio_sync(channel);
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>