xmas presence 2009

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16053 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-12-24 05:44:23 +00:00
parent f2b9cbf23e
commit 88a21f40f2
7 changed files with 644 additions and 246 deletions

View File

@ -1,100 +1,43 @@
Building and installing spandsp Installation Instructions
=============================== *************************
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.
You can use the usual:
./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.
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation Basic Installation
================== ==================
These are generic installation instructions. These are generic installation instructions.
The `configure' shell script attempts to guess correct values for The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package. those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file you can run in the future to recreate the current configuration, and a
`config.cache' that saves the results of its tests to speed up file `config.log' containing compiler output (useful mainly for
reconfiguring, and a file `config.log' containing compiler output debugging `configure').
(useful mainly for debugging `configure').
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.)
If you need to do unusual things to compile the package, please try If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache' be considered for the next release. If you are using the cache, and at
contains results you don't want to keep, you may remove or edit it. some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' is used to create `configure' by a program The file `configure.ac' (or `configure.in') is used to create
called `autoconf'. You only need `configure.ac' if you want to change `configure' by a program called `autoconf'. You only need
it or regenerate `configure' using a newer version of `autoconf'. `configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is: The simplest way to compile this package is:
@ -127,20 +70,22 @@ The simplest way to compile this package is:
Compilers and Options Compilers and Options
===================== =====================
Some systems require unusual options for compilation or linking that Some systems require unusual options for compilation or linking that the
the `configure' script does not know about. You can give `configure' `configure' script does not know about. Run `./configure --help' for
initial values for variables by setting them in the environment. Using details on some of the pertinent environment variables.
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this: You can give `configure' initial values for configuration parameters
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures Compiling For Multiple Architectures
==================================== ====================================
You can compile the package for more than one kind of computer at the You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the supports the `VPATH' variable, such as GNU `make'. `cd' to the
@ -148,28 +93,28 @@ directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH' 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 variable, you have to compile the package for one architecture at a
in the source code directory. After you have installed the package for time in the source code directory. After you have installed the
one architecture, use `make distclean' before reconfiguring for another package for one architecture, use `make distclean' before reconfiguring
architecture. for another architecture.
Installation Names Installation Names
================== ==================
By default, `make install' will install the package's files in By default, `make install' installs the package's commands under
`/usr/local/bin', `/usr/local/man', etc. You can specify an `/usr/local/bin', include files under `/usr/local/include', etc. You
installation prefix other than `/usr/local' by giving `configure' the can specify an installation prefix other than `/usr/local' by giving
option `--prefix=PATH'. `configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PATH as the prefix for installing programs and libraries. PREFIX as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix. Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. you can set and what kinds of files go in them.
@ -180,7 +125,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features Optional Features
================= =================
Some packages pay attention to `--enable-FEATURE' options to Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package. `configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The is something like `gnu-as' or `x' (for the X Window System). The
@ -195,48 +140,86 @@ you can use the `configure' options `--x-includes=DIR' and
Specifying the System Type Specifying the System Type
========================== ==========================
There may be some features `configure' can not figure out There may be some features `configure' cannot figure out automatically,
automatically, but needs to determine by the type of host the package but needs to determine by the type of machine the package will run on.
will run on. Usually `configure' can figure that out, but if it prints Usually, assuming the package is built to be run on the _same_
a message saying it can not guess the host type, give it the architectures, `configure' can figure that out, but if it prints a
`--host=TYPE' option. TYPE can either be a short name for the system message saying it cannot guess the machine type, give it the
type, such as `sun4', or a canonical name with three fields: `--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:
CPU-COMPANY-SYSTEM CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If where SYSTEM can have one of these forms:
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also OS KERNEL-OS
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 See the file `config.sub' for the possible values of each field. If
system on which you are compiling the package. `config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
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.
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'.
Sharing Defaults Sharing Defaults
================ ================
If you want to set default values for `configure' scripts to share, If you want to set default values for `configure' scripts to share, you
you can create a site shell script called `config.site' that gives can create a site shell script called `config.site' that gives default
default values for variables like `CC', `cache_file', and `prefix'. values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then `configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the `PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script. `CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script. A warning: not all `configure' scripts look for a site script.
Operation Controls Defining Variables
================== ==================
`configure' recognizes the following options to control how it Variables not defined in a site shell script can be set in the
operates. 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:
`--cache-file=FILE' ./configure CC=/usr/local2/bin/gcc
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for causes the specified `gcc' to be used as the C compiler (unless it is
debugging `configure'. 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.
`--help' `--help'
`-h'
Print a summary of the options to `configure', and exit. Print a summary of the options to `configure', and exit.
`--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'.
`--quiet' `--quiet'
`--silent' `--silent'
`-q' `-q'
@ -248,8 +231,6 @@ operates.
Look for the package's source code in directory DIR. Usually Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically. `configure' can determine that directory automatically.
`--version' `configure' also accepts some other, not widely useful, options. Run
Print the version of Autoconf used to generate the `configure' `configure --help' for more details.
script, and exit.
`configure' also accepts some other, not widely useful, options.

View File

@ -211,7 +211,7 @@ char *generate_pai_str(switch_core_session_t *session)
callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, tech_pvt->profile->sipip); callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, tech_pvt->profile->sipip);
} }
header = (tech_pvt->cid_type == CID_TYPE_RPID) ? "Remote-Party-ID" : "P-Asserted-Identity"; header = (tech_pvt->cid_type == CID_TYPE_RPID && !switch_stristr("aastra", ua)) ? "Remote-Party-ID" : "P-Asserted-Identity";
if (!zstr(callee_name) && !zstr(callee_number)) { if (!zstr(callee_name) && !zstr(callee_number)) {
if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) { if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) {
@ -394,6 +394,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
} }
if (switch_channel_test_flag(channel, CF_ANSWERED) || sofia_test_flag(tech_pvt, TFLAG_ANS)) { if (switch_channel_test_flag(channel, CF_ANSWERED) || sofia_test_flag(tech_pvt, TFLAG_ANS)) {
const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
if (!tech_pvt->got_bye) { if (!tech_pvt->got_bye) {
switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye"); switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye");
} }
@ -401,6 +402,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
nua_bye(tech_pvt->nh, nua_bye(tech_pvt->nh,
TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)), TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
TAG_END()); TAG_END());
@ -472,6 +474,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
const char *b_sdp = NULL; const char *b_sdp = NULL;
int is_proxy = 0; int is_proxy = 0;
char *sticky = NULL; char *sticky = NULL;
const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
if (sofia_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) { if (sofia_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) {
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -508,6 +511,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
nua_respond(tech_pvt->nh, SIP_200_OK, nua_respond(tech_pvt->nh, SIP_200_OK,
SIPTAG_CONTACT_STR(tech_pvt->profile->url), SIPTAG_CONTACT_STR(tech_pvt->profile->url),
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
SOATAG_REUSE_REJECTED(1), SOATAG_REUSE_REJECTED(1),
SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
@ -519,6 +523,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
NUTAG_MEDIA_ENABLE(0), NUTAG_MEDIA_ENABLE(0),
SIPTAG_CONTACT_STR(tech_pvt->profile->url), SIPTAG_CONTACT_STR(tech_pvt->profile->url),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_CONTENT_TYPE_STR("application/sdp"),
SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
@ -1443,6 +1448,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
SIPTAG_PAYLOAD_STR(message), TAG_END()); SIPTAG_PAYLOAD_STR(message), TAG_END());
} else if ((ua && (switch_stristr("polycom", ua)))) { } else if ((ua && (switch_stristr("polycom", ua)))) {
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number); snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number);
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());
} 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); sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
nua_update(tech_pvt->nh, nua_update(tech_pvt->nh,
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)), TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
@ -1683,9 +1696,12 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) && if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) { !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX); char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
nua_respond(tech_pvt->nh, SIP_180_RINGING, nua_respond(tech_pvt->nh, SIP_180_RINGING,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_HEADER_STR(generate_pai_str(session)), SIPTAG_HEADER_STR(generate_pai_str(session)),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)), TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
@ -1701,6 +1717,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
{ {
char *sticky = NULL; char *sticky = NULL;
const char *val = NULL; const char *val = NULL;
const char *call_info = switch_channel_get_variable(channel, "presence_call_info");
if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) { if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
@ -1774,6 +1791,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX); char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
if (sofia_use_soa(tech_pvt)) { if (sofia_use_soa(tech_pvt)) {
nua_respond(tech_pvt->nh, nua_respond(tech_pvt->nh,
SIP_183_SESSION_PROGRESS, SIP_183_SESSION_PROGRESS,
@ -1785,6 +1803,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
SOATAG_ORDERED_USER(1), SOATAG_ORDERED_USER(1),
SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)), TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
@ -1799,6 +1818,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_CONTENT_TYPE_STR("application/sdp"),
SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)), TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),

View File

@ -522,6 +522,7 @@ struct sofia_profile {
uint32_t timer_t4; uint32_t timer_t4;
char *contact_user; char *contact_user;
char *local_network; char *local_network;
uint32_t trans_timeout;
}; };
struct private_object { struct private_object {

View File

@ -284,6 +284,7 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
switch_channel_t *channel; switch_channel_t *channel;
private_object_t *tech_pvt; private_object_t *tech_pvt;
char *extra_headers; char *extra_headers;
const char *call_info = NULL;
#ifdef MANUAL_BYE #ifdef MANUAL_BYE
int cause; int cause;
char st[80] = ""; char st[80] = "";
@ -295,12 +296,12 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
tech_pvt = switch_core_session_get_private(session); tech_pvt = switch_core_session_get_private(session);
#ifdef MANUAL_BYE #ifdef MANUAL_BYE
status = 200; status = 200;
phrase = "OK"; phrase = "OK";
sofia_set_flag_locked(tech_pvt, TFLAG_BYE); sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
call_info = switch_channel_get_variable(channel, "presence_call_info");
if (sip->sip_reason && sip->sip_reason->re_protocol && if (sip->sip_reason && sip->sip_reason->re_protocol &&
(!strcasecmp(sip->sip_reason->re_protocol, "Q.850") (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
@ -328,7 +329,8 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
switch_channel_hangup(channel, cause); switch_channel_hangup(channel, cause);
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
switch_safe_free(extra_headers); switch_safe_free(extra_headers);
@ -948,7 +950,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) { while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) {
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) { if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
if (qsize > 0 && (qsize >= 500 || ++loop_count >= 500)) { if (qsize > 0 && (qsize >= 1024 || ++loop_count >= profile->trans_timeout)) {
switch_size_t newlen; switch_size_t newlen;
uint32_t itterations = 0; uint32_t itterations = 0;
switch_size_t len = 0; switch_size_t len = 0;
@ -2449,6 +2451,8 @@ switch_status_t config_sofia(int reload, char *profile_name)
goto done; goto done;
} }
profile->trans_timeout = 500;
profile->auto_rtp_bugs = RTP_BUG_CISCO_SKIP_MARK_BIT_2833 | RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833; profile->auto_rtp_bugs = RTP_BUG_CISCO_SKIP_MARK_BIT_2833 | RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
profile->pool = pool; profile->pool = pool;
@ -2910,7 +2914,14 @@ switch_status_t config_sofia(int reload, char *profile_name)
sofia_clear_pflag(profile, PFLAG_PASS_CALLEE_ID); sofia_clear_pflag(profile, PFLAG_PASS_CALLEE_ID);
} }
} else if (!strcasecmp(var, "sql-in-transactions")) { } else if (!strcasecmp(var, "sql-in-transactions")) {
int tmp = atoi(val);
if (switch_true(val)) { if (switch_true(val)) {
tmp = 500;
}
if (tmp > 0) {
profile->trans_timeout = tmp;
sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS); sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
} else { } else {
sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS); sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
@ -3376,6 +3387,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
char network_ip[80]; char network_ip[80];
int network_port = 0; int network_port = 0;
switch_caller_profile_t *caller_profile = NULL; switch_caller_profile_t *caller_profile = NULL;
char *call_info = NULL;
sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port); sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
@ -3402,7 +3415,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
} else if (sip->sip_server && sip->sip_server->g_string) { } else if (sip->sip_server && sip->sip_server->g_string) {
switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string); switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string);
} }
sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_PROGRESS_HEADER_PREFIX); sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
sofia_update_callee_id(session, profile, sip, SWITCH_FALSE); sofia_update_callee_id(session, profile, sip, SWITCH_FALSE);
@ -3428,6 +3441,11 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
return; return;
} }
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);
}
if ((br = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { if ((br = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
switch_xml_t root = NULL, domain = NULL; switch_xml_t root = NULL, domain = NULL;
switch_core_session_t *a_session; switch_core_session_t *a_session;
@ -3648,20 +3666,25 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
sql = switch_mprintf("insert into sip_dialogs " sql = switch_mprintf("insert into sip_dialogs "
"(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user," "(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user,"
"contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id, presence_data) " "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')", "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
call_id, call_id,
switch_core_session_get_uuid(session), switch_core_session_get_uuid(session),
to_user, to_host, from_user, from_host, contact_user, to_user, to_host, from_user, from_host, contact_user,
contact_host, astate, "outbound", user_agent, contact_host, astate, "outbound", user_agent,
profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact), profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
switch_str_nil(presence_id), switch_str_nil(presence_data)); switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(call_info));
switch_assert(sql); switch_assert(sql);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
} }
if (call_info) {
su_free(profile->home, call_info);
}
} else if (status == 200 && (profile->pres_type)) { } else if (status == 200 && (profile->pres_type)) {
char *sql = NULL; char *sql = NULL;
const char *presence_data = switch_channel_get_variable(channel, "presence_data"); const char *presence_data = switch_channel_get_variable(channel, "presence_data");
@ -5240,6 +5263,8 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
char acl_token[512] = ""; char acl_token[512] = "";
sofia_transport_t transport; sofia_transport_t transport;
const char *gw_name = NULL; const char *gw_name = NULL;
char *call_info_str = NULL;
nua_handle_t *bnh = NULL;
profile->ib_calls++; profile->ib_calls++;
@ -5799,12 +5824,11 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
} }
if ((call_info = sip_call_info(sip))) { if ((call_info = sip_call_info(sip))) {
char *tmp = sip_header_as_string(profile->home, (void *) call_info); call_info_str = sip_header_as_string(nh->nh_home, (void *) call_info);
if (call_info->ci_params && (msg_params_find(call_info->ci_params , "answer-after=0"))) { if (call_info->ci_params && (msg_params_find(call_info->ci_params , "answer-after=0"))) {
switch_channel_set_variable(channel, "sip_auto_answer_detected", "true"); switch_channel_set_variable(channel, "sip_auto_answer_detected", "true");
} }
switch_channel_set_variable(channel, "sip_call_info", tmp); switch_channel_set_variable(channel, "sip_call_info", call_info_str);
su_free(profile->home, tmp);
} }
if (profile->pres_type) { if (profile->pres_type) {
@ -5857,79 +5881,97 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
} }
} }
if (sip->sip_replaces) { if (call_info_str) {
nua_handle_t *bnh; char *sql;
if ((bnh = nua_handle_by_replaces(nua, sip->sip_replaces))) { char cid[512] = "";
sofia_private_t *b_private = NULL; char *str;
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))) { if (sip->sip_to && sip->sip_to->a_url) {
one_leg = 0; sql = switch_mprintf("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q'",
} else { call_info_str, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
uuid = switch_core_session_get_uuid(b_session);
} if ((str = sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, cid, sizeof(cid)))) {
bnh = nua_handle_by_call_id(nua, str);
if (uuid) {
switch_core_session_t *c_session = NULL;
int do_conf = 0;
uuid = switch_core_session_strdup(b_session, uuid);
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);
}
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);
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);
}
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);
}
dialplan = "inline";
}
}
switch_core_session_rwunlock(b_session);
}
} }
nua_handle_unref(bnh);
free(sql);
} }
} }
if (sip->sip_replaces) {
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;
} else {
uuid = switch_core_session_get_uuid(b_session);
}
if (uuid) {
switch_core_session_t *c_session = NULL;
int do_conf = 0;
uuid = switch_core_session_strdup(b_session, uuid);
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);
}
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);
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);
}
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);
}
dialplan = "inline";
}
}
switch_core_session_rwunlock(b_session);
}
}
nua_handle_unref(bnh);
}
check_decode(displayname, session); check_decode(displayname, session);
tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
from_user, from_user,
@ -6074,20 +6116,26 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact); full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
} }
if (call_info_str) {
switch_channel_set_variable(channel, "presence_call_info", call_info_str);
}
sql = switch_mprintf("insert into sip_dialogs " sql = switch_mprintf("insert into sip_dialogs "
"(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user," "(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user,"
"contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data) " "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')", "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
call_id, call_id,
tech_pvt->sofia_private->uuid, tech_pvt->sofia_private->uuid,
to_user, to_host, dialog_from_user, dialog_from_host, to_user, to_host, dialog_from_user, dialog_from_host,
contact_user, contact_host, "confirmed", "inbound", user_agent, contact_user, contact_host, "confirmed", "inbound", user_agent,
profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact), profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
switch_str_nil(presence_id), switch_str_nil(presence_data)); switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(call_info_str));
switch_assert(sql); switch_assert(sql);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
} }
if (is_nat) { if (is_nat) {

View File

@ -3806,7 +3806,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" hostname VARCHAR(255),\n" " hostname VARCHAR(255),\n"
" contact VARCHAR(255),\n" " contact VARCHAR(255),\n"
" presence_id VARCHAR(255),\n" " presence_id VARCHAR(255),\n"
" presence_data VARCHAR(255)\n" " presence_data VARCHAR(255),\n"
" call_info VARCHAR(255)\n"
");\n"; ");\n";
char sub_sql[] = char sub_sql[] =
@ -3880,7 +3881,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
"create index sr_sip_realm on sip_registrations (sip_realm)", "create index sr_sip_realm on sip_registrations (sip_realm)",
"create index ss_call_id on sip_subscriptions (call_id)", "create index ss_call_id on sip_subscriptions (call_id)",
"create index ss_hostname on sip_subscriptions (hostname)", "create index ss_hostname on sip_subscriptions (hostname)",
"create index ss_hostname on sip_subscriptions (network_ip)", "create index ss_network_ip on sip_subscriptions (network_ip)",
"create index ss_sip_user on sip_subscriptions (sip_user)", "create index ss_sip_user on sip_subscriptions (sip_user)",
"create index ss_sip_host on sip_subscriptions (sip_host)", "create index ss_sip_host on sip_subscriptions (sip_host)",
"create index ss_presence_hosts on sip_subscriptions (presence_hosts)", "create index ss_presence_hosts on sip_subscriptions (presence_hosts)",
@ -3890,11 +3891,13 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
"create index ss_sub_to_host on sip_subscriptions (sub_to_host)", "create index ss_sub_to_host on sip_subscriptions (sub_to_host)",
"create index sd_uuid on sip_dialogs (uuid)", "create index sd_uuid on sip_dialogs (uuid)",
"create index sd_hostname on sip_dialogs (hostname)", "create index sd_hostname on sip_dialogs (hostname)",
"create index sd_presence_data on sip_dialogs (presence_data)",
"create index sd_call_info on sip_dialogs (call_info)",
"create index sp_hostname on sip_presence (hostname)", "create index sp_hostname on sip_presence (hostname)",
"create index sa_nonce on sip_authentication (nonce)", "create index sa_nonce on sip_authentication (nonce)",
"create index sa_hostname on sip_authentication (hostname)", "create index sa_hostname on sip_authentication (hostname)",
"create index ssa_hostname on sip_shared_appearance_subscriptions (hostname)", "create index ssa_hostname on sip_shared_appearance_subscriptions (hostname)",
"create index ssa_hostname on sip_shared_appearance_subscriptions (network_ip)", "create index ssa_network_ip on sip_shared_appearance_subscriptions (network_ip)",
"create index ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)", "create index ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)",
"create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)", "create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
"create index ssa_aor on sip_shared_appearance_subscriptions (aor)", "create index ssa_aor on sip_shared_appearance_subscriptions (aor)",
@ -3959,14 +3962,14 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
} }
free(test_sql); free(test_sql);
test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and contact like '%%'", mod_sofia_globals.hostname); test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and call_info like '%%'", mod_sofia_globals.hostname);
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL); switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL);
switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL); switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL);
} }
test_sql = switch_mprintf("delete from sip_presence where hostname='%q'", mod_sofia_globals.hostname); test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname);
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL); switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL);
@ -4026,11 +4029,11 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_subscriptions", sub_sql); switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
free(test_sql); free(test_sql);
test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and contact like '%%'", mod_sofia_globals.hostname); test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and call_info like '%%'", mod_sofia_globals.hostname);
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_dialogs", dialog_sql); switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_dialogs", dialog_sql);
free(test_sql); free(test_sql);
test_sql = switch_mprintf("delete from sip_presence where hostname='%q'", mod_sofia_globals.hostname); test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname);
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_presence", pres_sql); switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_presence", pres_sql);
free(test_sql); free(test_sql);
@ -4061,7 +4064,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
NULL, NULL, NULL); NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)", switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)",
NULL, NULL, NULL); NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (network_ip)", switch_core_db_exec(db, "create index if not exists ssd_network_ip on sip_shared_appearance_dialogs (network_ip)",
NULL, NULL, NULL); NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)", switch_core_db_exec(db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
NULL, NULL, NULL); NULL, NULL, NULL);
@ -4089,7 +4092,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_core_db_exec(db, "create index if not exists ss_call_id on sip_subscriptions (call_id)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists ss_call_id on sip_subscriptions (call_id)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ss_hostname on sip_subscriptions (hostname)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists ss_hostname on sip_subscriptions (hostname)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ss_hostname on sip_subscriptions (network_ip)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists ss_network_ip on sip_subscriptions (network_ip)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ss_sip_user on sip_subscriptions (sip_user)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists ss_sip_user on sip_subscriptions (sip_user)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ss_sip_host on sip_subscriptions (sip_host)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists ss_sip_host on sip_subscriptions (sip_host)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists ss_presence_hosts on sip_subscriptions (presence_hosts)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists ss_presence_hosts on sip_subscriptions (presence_hosts)", NULL, NULL, NULL);
@ -4100,9 +4103,10 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_core_db_exec(db, "create index if not exists sd_uuid on sip_dialogs (uuid)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists sd_uuid on sip_dialogs (uuid)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists sd_hostname on sip_dialogs (hostname)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists sd_hostname on sip_dialogs (hostname)", NULL, NULL, NULL);
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_contact 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_presence_id 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); 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);
switch_core_db_exec(db, "create index if not exists sp_hostname on sip_presence (hostname)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists sp_hostname on sip_presence (hostname)", NULL, NULL, NULL);
@ -4500,12 +4504,13 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use
nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
nua_notify(nh, nua_notify(nh,
NUTAG_NEWSUB(1), NUTAG_NEWSUB(1),
TAG_IF(dst->route_uri, NUTAG_PROXY(route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), 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(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_EVENT_STR(event), TAG_IF(event, SIPTAG_EVENT_STR(event)),
SIPTAG_CONTENT_TYPE_STR(contenttype), TAG_IF(contenttype, SIPTAG_CONTENT_TYPE_STR(contenttype)),
SIPTAG_PAYLOAD_STR(body), TAG_END()); TAG_IF(body, SIPTAG_PAYLOAD_STR(body)),
TAG_END());
switch_safe_free(contact); switch_safe_free(contact);
switch_safe_free(route_uri); switch_safe_free(route_uri);

View File

@ -41,6 +41,12 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char
static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, char **columnNames); static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, char **columnNames);
static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames); static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames);
static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames); static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames);
static int broadsoft_sla_callback(void *pArg, int argc, char **argv, char **columnNames);
struct resub_helper {
sofia_profile_t *profile;
switch_event_t *event;
};
struct presence_helper { struct presence_helper {
sofia_profile_t *profile; sofia_profile_t *profile;
@ -201,16 +207,18 @@ void sofia_presence_cancel(void)
void sofia_presence_establish_presence(sofia_profile_t *profile) void sofia_presence_establish_presence(sofia_profile_t *profile)
{ {
struct resub_helper h = { 0 };
h.profile = profile;
if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex,
"select sip_user,sip_host,'Registered','unknown','' from sip_registrations", "select sip_user,sip_host,'Registered','unknown','' from sip_registrations",
sofia_presence_resub_callback, profile) != SWITCH_TRUE) { sofia_presence_resub_callback, &h) != SWITCH_TRUE) {
return; return;
} }
if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex,
"select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions " "select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions "
"where proto='ext' or proto='user' or proto='conf'", sofia_presence_resub_callback, profile) != SWITCH_TRUE) { "where proto='ext' or proto='user' or proto='conf'", sofia_presence_resub_callback, &h) != SWITCH_TRUE) {
return; return;
} }
} }
@ -380,8 +388,13 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
char *status = switch_event_get_header(event, "status"); char *status = switch_event_get_header(event, "status");
char *event_type = switch_event_get_header(event, "event_type"); char *event_type = switch_event_get_header(event, "event_type");
char *alt_event_type = switch_event_get_header(event, "alt_event_type"); char *alt_event_type = switch_event_get_header(event, "alt_event_type");
//char *event_subtype = switch_event_get_header(event, "event_subtype");
char *sql = NULL; char *sql = NULL;
char *euser = NULL, *user = NULL, *host = NULL; char *euser = NULL, *user = NULL, *host = NULL;
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 };
if (!mod_sofia_globals.running) { if (!mod_sofia_globals.running) {
return; return;
@ -534,7 +547,8 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s DUMP PRESENCE_PROBE_SQL:\n%s\n", profile->name, sql); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s DUMP PRESENCE_PROBE_SQL:\n%s\n", profile->name, sql);
} }
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_resub_callback, profile); h.profile = profile;
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_resub_callback, &h);
if (mod_sofia_globals.debug_presence > 0) { if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s END_PRESENCE_PROBE_SQL\n\n", profile->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s END_PRESENCE_PROBE_SQL\n\n", profile->name);
} }
@ -574,6 +588,53 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
continue; continue;
} }
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);
}
if ((sql = switch_mprintf( if ((sql = switch_mprintf(
"select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host," "select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
@ -815,7 +876,8 @@ static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, ch
static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames) static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames)
{ {
sofia_profile_t *profile = (sofia_profile_t *) pArg; struct resub_helper *h = (struct resub_helper *) pArg;
sofia_profile_t *profile = h->profile;
char *user = argv[0]; char *user = argv[0];
char *host = argv[1]; char *host = argv[1];
char *status = argv[2]; char *status = argv[2];
@ -828,6 +890,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
char *direction = NULL; char *direction = NULL;
switch_event_t *event; switch_event_t *event;
char to_buf[128] = ""; char to_buf[128] = "";
switch_event_header_t *hp;
if (argc > 5) { if (argc > 5) {
uuid = switch_str_nil(argv[5]); uuid = switch_str_nil(argv[5]);
@ -878,6 +941,15 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", direction); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", direction);
} }
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);
}
}
}
switch_event_fire(&event); switch_event_fire(&event);
} }
@ -1391,6 +1463,114 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char
return 0; return 0;
} }
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;
}
void sofia_presence_handle_sip_i_subscribe(int status, void sofia_presence_handle_sip_i_subscribe(int status,
char const *phrase, char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
@ -1456,7 +1636,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
display = "\"user\""; display = "\"user\"";
} }
} }
} else { } else {
display = "\"user\""; display = "\"user\"";
} }
@ -1494,6 +1674,13 @@ void sofia_presence_handle_sip_i_subscribe(int status,
} }
} }
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;
}
if (is_nat) { if (is_nat) {
contact_host = network_ip; contact_host = network_ip;
switch_snprintf(new_port, sizeof(new_port), ":%d", network_port); switch_snprintf(new_port, sizeof(new_port), ":%d", network_port);
@ -1514,7 +1701,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
ipv6 ? "]" : "", ipv6 ? "]" : "",
new_port, new_port,
contact->m_url->url_params, contact->m_url->url_params,
is_nat ? ";fs_nat" : ""); is_nat ? ";fs_nat=yes" : "");
} else { } else {
contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s>%s", contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s>%s",
display, display,
@ -1523,7 +1710,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
contact_host, contact_host,
ipv6 ? "]" : "", ipv6 ? "]" : "",
new_port, new_port,
is_nat ? ";fs_nat" : ""); is_nat ? ";fs_nat=yes" : "");
} }
@ -1743,8 +1930,134 @@ void sofia_presence_handle_sip_i_subscribe(int status,
TAG_IF(sticky, NUTAG_PROXY(sticky)), TAG_END()); TAG_IF(sticky, NUTAG_PROXY(sticky)), TAG_END());
switch_safe_free(sticky); switch_safe_free(sticky);
}
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);
}
} }
sent_reply++; sent_reply++;
@ -1758,14 +2071,16 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_safe_free(sstr); switch_safe_free(sstr);
if ((sql = switch_mprintf( if (!strcasecmp(event, "message-summary")) {
"select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from," if ((sql = switch_mprintf(
"full_via,expires,user_agent,accept,profile_name,network_ip" "select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
" from sip_subscriptions where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')", "full_via,expires,user_agent,accept,profile_name,network_ip"
to_host, to_user, to_host, to_host))) { " from sip_subscriptions where event='message-summary' and sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_reg_callback, profile); 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);
switch_safe_free(sql);
}
} }
end: end:

View File

@ -467,6 +467,7 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
{ {
switch_event_t *event; switch_event_t *event;
switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN; switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
const char *call_info = NULL;
if (!status) { if (!status) {
type = SWITCH_EVENT_PRESENCE_OUT; type = SWITCH_EVENT_PRESENCE_OUT;
@ -480,6 +481,8 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
return; return;
} }
call_info = switch_channel_get_variable(channel, "presence_call_info");
if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event); switch_channel_event_set_data(channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", __FILE__); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", __FILE__);
@ -494,6 +497,29 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
} }
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
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");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", channel->event_count++); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", channel->event_count++);
switch_event_fire(&event); switch_event_fire(&event);
} }
@ -2191,6 +2217,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
free(stream.data); free(stream.data);
} }
switch_channel_presence(channel, "unknown", "answered", NULL);
switch_channel_audio_sync(channel); switch_channel_audio_sync(channel);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;