diff --git a/.gitignore b/.gitignore index 86ead5d0d3f537002fa1c9682154c2f1f7e2e78a..51406feb2a721e5c31d04a85ebb3f0e60ede0483 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Makefile.in *.so # Binary translation files *.mo +libtool # The test binary *Tester @@ -57,7 +58,8 @@ doc/*.html /libs/dbus-c++/configure /libs/dbus-c++/tools/dbus-c++xx-* /libs/dbus-c++/tools/dbusxx-* -/libs/dbus-c++/dbus-c++-c++-1.pc +/libs/dbus-c++/dbus-c++-1.pc +/libs/dbus-c++/dbus-c++-1-uninstalled.pc /libs/dbus-c++/doc /libs/dbus-c++/INSTALL /libs/dbus-c++/config.guess diff --git a/INSTALL b/INSTALL index 23e5f25d0e5f85798dcfb368ecb2f04f59777f61..d3c5b40a94091285c27361905f591af64c1f7b21 100644 --- a/INSTALL +++ b/INSTALL @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free -Software Foundation, Inc. +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -10,7 +10,10 @@ unlimited permission to copy, distribute and modify it. Basic Installation ================== -These are generic installation instructions. +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses @@ -23,9 +26,9 @@ 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 +the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale -cache files.) +cache files. 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 @@ -35,20 +38,17 @@ some point `config.cache' contains results you don't want to keep, you may remove or edit it. 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'. +`configure' by a program called `autoconf'. You need `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: 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. + `./configure' to configure the package for your system. - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. 2. Type `make' to compile the package. @@ -67,6 +67,9 @@ The simplest way to compile this package is: all sorts of other programs in order to regenerate files that came with the distribution. + 6. Often, you can also type `make uninstall' to remove the installed + files again. + Compilers and Options ===================== @@ -78,7 +81,7 @@ details on some of the pertinent environment variables. by setting variables in the command line or in the environment. Here is an example: - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. @@ -87,17 +90,15 @@ Compiling For Multiple Architectures 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 -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the +own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. - 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. + With a non-GNU `make', it is safer 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. Installation Names ================== @@ -190,12 +191,12 @@ them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc 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: +overridden in the site shell script). - /bin/bash ./configure CONFIG_SHELL=/bin/bash +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== diff --git a/README b/README index fbffc96dcc5b6d2ec1a588dc529b91a6e0479ba5..76b149da40802ab194a8f2260b0571c88395aa4a 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is SFLphone, release 0.8. +This is SFLphone, release 0.9.x Copyright (c) Savoir-faire Linux, Inc 2004-2008 <sflphoneteam@savoirfairelinux.com> diff --git a/configure.ac b/configure.ac index 66e0520e696bd447fcfe37521f6beada19130a0d..30a2ac659b51a66e3f869079e3c196dd7f4bc81f 100644 --- a/configure.ac +++ b/configure.ac @@ -93,7 +93,7 @@ dnl Define C++ as default language AC_LANG(C++) dnl Setup C++ compiler flags -CXXFLAGS="$CXXFLAGS $USE_EXCEPTIONS $USER_INCLUDES" +CXXFLAGS="$CXXFLAGS $USE_EXCEPTIONS $USER_INCLUDES -O0 -g -Wall -Wextra" dnl Check for header files AC_FUNC_ALLOCA @@ -132,22 +132,21 @@ AC_CHECK_FUNCS([bzero floor gethostbyname gethrtime gettimeofday \ inet_ntoa memset mkdir pathconf pow regcomp select setlocale socket \ strchr strdup strerror strrchr strstr strtol utime]) - dnl ***************************************** dnl Check for header files dnl ***************************************** dnl Check for exosip2 LP_CHECK_EXOSIP2 -SFLPHONE_LIBS="$SFLPHONE_LIBS $EXOSIP_LIBS" +SFLPHONE_LIBS="$SFLPHONE_LIBS" dnl Check for GNU ccRTP PKG_PROG_PKG_CONFIG -dnl Check for osip parser -LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION=3.0.0 -PKG_CHECK_MODULES([libosip2], [libosip2 >= ${LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION}], - [LIBOSIP2_CFLAGS=""], [LIBOSIP2_CFLAGS="-DLIBOSIP2_WITHPOINTER"]) -SIP_CFLAGS="$SIP_CFLAGS $LIBOSIP2_CFLAGS"; +#Trying to set PJSIP using pkg-config +PKG_CHECK_MODULES(SIP, libpj, have_libpj=true, have_libpj=false) +if test "x${have_libpj}" = "xfalse" ; then + AC_MSG_ERROR([PJSIP not found. http://www.pjsip.org/download.htm]) +fi AC_SUBST(SIP_CFLAGS) dnl Check for alsa development package - name: libasound2-dev @@ -367,26 +366,6 @@ DBUS_SERVICES_DIR="$datadir/dbus-1/services" AC_SUBST(DBUS_SERVICES_DIR) AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for DBUS is]) - -dnl QT interface -AC_MSG_CHECKING([whether to enable sflphoneqt]) -AC_ARG_ENABLE(sflphoneqt, - AS_HELP_STRING( - [--enable-sflphoneqt], - [enable sflphone-qt compilation @<:@default=no@:>@] - ), - [with_sflphoneqt=$enableval], - [with_sflphoneqt=no] -) -AM_CONDITIONAL(WITH_QT, test "x$with_sflphoneqt" = "xyes") -AM_CONDITIONAL(include_x11, test x$with_sflphoneqt = "xyes") -if test "x$with_sflphoneqt" = "xno"; then - AC_MSG_RESULT(no) -else - AC_MSG_RESULT(yes) - gw_CHECK_QT -fi - # Go! AC_SUBST(SFLPHONE_CFLAGS) AC_SUBST(SFLPHONE_LIBS) diff --git a/globals.mak b/globals.mak index e6897c83ea8def08b4624c053cf2e0935e798238..3ed71e1808ed32ba21f56c777fc33a92964c9e2a 100644 --- a/globals.mak +++ b/globals.mak @@ -2,6 +2,8 @@ src=$(top_srcdir) sflcodecdir=$(libdir)/sflphone/codecs +PJSIP_LIBS = -lpjnath -lpjsua -lpjsip -lpjmedia -lpjsip-simple -lpjsip-ua -lpjmedia-codec -lpjlib-util -lpj + # Preprocessor flags AM_CPPFLAGS = \ -I$(src)/libs \ diff --git a/libs/dbus-c++/INSTALL b/libs/dbus-c++/INSTALL index 23e5f25d0e5f85798dcfb368ecb2f04f59777f61..d3c5b40a94091285c27361905f591af64c1f7b21 100644 --- a/libs/dbus-c++/INSTALL +++ b/libs/dbus-c++/INSTALL @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free -Software Foundation, Inc. +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -10,7 +10,10 @@ unlimited permission to copy, distribute and modify it. Basic Installation ================== -These are generic installation instructions. +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses @@ -23,9 +26,9 @@ 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 +the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale -cache files.) +cache files. 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 @@ -35,20 +38,17 @@ some point `config.cache' contains results you don't want to keep, you may remove or edit it. 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'. +`configure' by a program called `autoconf'. You need `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: 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. + `./configure' to configure the package for your system. - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. 2. Type `make' to compile the package. @@ -67,6 +67,9 @@ The simplest way to compile this package is: all sorts of other programs in order to regenerate files that came with the distribution. + 6. Often, you can also type `make uninstall' to remove the installed + files again. + Compilers and Options ===================== @@ -78,7 +81,7 @@ details on some of the pertinent environment variables. by setting variables in the command line or in the environment. Here is an example: - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. @@ -87,17 +90,15 @@ Compiling For Multiple Architectures 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 -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the +own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. - 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. + With a non-GNU `make', it is safer 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. Installation Names ================== @@ -190,12 +191,12 @@ them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc 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: +overridden in the site shell script). - /bin/bash ./configure CONFIG_SHELL=/bin/bash +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== diff --git a/libs/dbus-c++/autom4te.cache/output.0 b/libs/dbus-c++/autom4te.cache/output.0 index 3c455b542ff58dcfea0e4f3ee7d80740681acf1a..5c527a16b181ccfe3b8d9898ca6c2c9d26d5441f 100644 --- a/libs/dbus-c++/autom4te.cache/output.0 +++ b/libs/dbus-c++/autom4te.cache/output.0 @@ -808,6 +808,7 @@ target_alias INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA +am__isrc CYGPATH_W PACKAGE VERSION @@ -1972,7 +1973,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -am__api_version="1.9" +am__api_version='1.10' + ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -2155,38 +2157,53 @@ else echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi -if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' +{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done +done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" else - mkdir_p='$(install_sh) -d' + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" fi fi +{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +echo "${ECHO_T}$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac for ac_prog in gawk mawk nawk awk do @@ -2269,12 +2286,16 @@ else fi rmdir .tst 2>/dev/null -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } + fi fi # test whether we have cygpath @@ -2317,7 +2338,7 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} -install_sh=${install_sh-"$am_aux_dir/install-sh"} +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right @@ -2421,7 +2442,7 @@ else fi fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" # We need awk for the "check" target. The system "awk" is bad on # some platforms. @@ -3534,9 +3555,7 @@ if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi - - -if test "x$enable_dependency_tracking" != xno; then + if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else @@ -3546,7 +3565,6 @@ fi - depcc="$CC" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 @@ -3614,6 +3632,7 @@ else depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then @@ -3643,9 +3662,7 @@ fi echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - -if + if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= @@ -4087,6 +4104,7 @@ else depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then @@ -4116,9 +4134,7 @@ fi echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - -if + if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= @@ -20228,9 +20244,7 @@ echo "${ECHO_T}yes" >&6; } fi - - -if test 1 = 1; then + if test 1 = 1; then ENABLE_GLIB_TRUE= ENABLE_GLIB_FALSE='#' else @@ -20299,9 +20313,7 @@ fi { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20311,9 +20323,7 @@ fi elif test $pkg_failed = untried; then - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20327,9 +20337,7 @@ else gtkmm_LIBS=$pkg_cv_gtkmm_LIBS { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } - - -if test 1 = 1; then + if test 1 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20341,9 +20349,7 @@ fi else - - -if test 0 = 1; then + if test 0 = 1; then ENABLE_GLIB_TRUE= ENABLE_GLIB_FALSE='#' else @@ -20351,9 +20357,7 @@ else ENABLE_GLIB_FALSE= fi - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20890,9 +20894,7 @@ echo "$as_me: error: Building Doxygen docs explicitly required, but Doxygen not echo "${ECHO_T}yes" >&6; } fi - - -if test "$enable_doxygen_docs" = "yes"; then + if test "$enable_doxygen_docs" = "yes"; then DBUS_DOXYGEN_DOCS_ENABLED_TRUE= DBUS_DOXYGEN_DOCS_ENABLED_FALSE='#' else @@ -20903,9 +20905,7 @@ fi # For the tools/, we need libdbus-c++ for the "build" architecture as well - - -if test "$cross_compiling" = "yes"; then + if test "$cross_compiling" = "yes"; then CROSS_COMPILING_TRUE= CROSS_COMPILING_FALSE='#' else @@ -21460,6 +21460,7 @@ gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -21680,6 +21681,7 @@ target_alias!$target_alias$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim +am__isrc!$am__isrc$ac_delim CYGPATH_W!$CYGPATH_W$ac_delim PACKAGE!$PACKAGE$ac_delim VERSION!$VERSION$ac_delim @@ -21736,7 +21738,6 @@ LN_S!$LN_S$ac_delim ECHO!$ECHO$ac_delim AR!$AR$ac_delim RANLIB!$RANLIB$ac_delim -DSYMUTIL!$DSYMUTIL$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -21778,6 +21779,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +DSYMUTIL!$DSYMUTIL$ac_delim NMEDIT!$NMEDIT$ac_delim CPP!$CPP$ac_delim CXXCPP!$CXXCPP$ac_delim @@ -21808,7 +21810,7 @@ LIB@&t@OBJS!$LIB@&t@OBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 28; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 29; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -22035,6 +22037,11 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -22088,6 +22095,7 @@ s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out @@ -22203,21 +22211,22 @@ echo "$as_me: $ac_file is unchanged" >&6;} fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. +_am_arg=$ac_file _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in - $ac_file | $ac_file:* ) + $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done -echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || -$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X$ac_file : 'X\(//\)[^/]' \| \ - X$ac_file : 'X\(//\)$' \| \ - X$ac_file : 'X\(/\)' \| . 2>/dev/null || -echo X$ac_file | +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -22252,8 +22261,9 @@ echo "$as_me: executing $ac_file commands" >&6;} # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ diff --git a/libs/dbus-c++/autom4te.cache/output.1 b/libs/dbus-c++/autom4te.cache/output.1 index 1b760b8ee5840002f1f9c9b359d59afa1d8caf46..99ee5f8afa68b6d7afc9a2f9e9d6a60934443936 100644 --- a/libs/dbus-c++/autom4te.cache/output.1 +++ b/libs/dbus-c++/autom4te.cache/output.1 @@ -808,6 +808,7 @@ target_alias INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA +am__isrc CYGPATH_W PACKAGE VERSION @@ -1972,7 +1973,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -am__api_version="1.9" +am__api_version='1.10' + ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -2155,38 +2157,53 @@ else echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi -if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' +{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done +done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" else - mkdir_p='$(install_sh) -d' + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" fi fi +{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +echo "${ECHO_T}$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac for ac_prog in gawk mawk nawk awk do @@ -2269,12 +2286,16 @@ else fi rmdir .tst 2>/dev/null -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } + fi fi # test whether we have cygpath @@ -2317,7 +2338,7 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} -install_sh=${install_sh-"$am_aux_dir/install-sh"} +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right @@ -2421,7 +2442,7 @@ else fi fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" # We need awk for the "check" target. The system "awk" is bad on # some platforms. @@ -3534,9 +3555,7 @@ if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi - - -if test "x$enable_dependency_tracking" != xno; then + if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else @@ -3546,7 +3565,6 @@ fi - depcc="$CC" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 @@ -3614,6 +3632,7 @@ else depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then @@ -3643,9 +3662,7 @@ fi echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - -if + if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= @@ -4087,6 +4104,7 @@ else depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then @@ -4116,9 +4134,7 @@ fi echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - -if + if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= @@ -20216,9 +20232,7 @@ echo "${ECHO_T}yes" >&6; } fi - - -if test 1 = 1; then + if test 1 = 1; then ENABLE_GLIB_TRUE= ENABLE_GLIB_FALSE='#' else @@ -20287,9 +20301,7 @@ fi { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20299,9 +20311,7 @@ fi elif test $pkg_failed = untried; then - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20315,9 +20325,7 @@ else gtkmm_LIBS=$pkg_cv_gtkmm_LIBS { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } - - -if test 1 = 1; then + if test 1 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20329,9 +20337,7 @@ fi else - - -if test 0 = 1; then + if test 0 = 1; then ENABLE_GLIB_TRUE= ENABLE_GLIB_FALSE='#' else @@ -20339,9 +20345,7 @@ else ENABLE_GLIB_FALSE= fi - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20878,9 +20882,7 @@ echo "$as_me: error: Building Doxygen docs explicitly required, but Doxygen not echo "${ECHO_T}yes" >&6; } fi - - -if test "$enable_doxygen_docs" = "yes"; then + if test "$enable_doxygen_docs" = "yes"; then DBUS_DOXYGEN_DOCS_ENABLED_TRUE= DBUS_DOXYGEN_DOCS_ENABLED_FALSE='#' else @@ -20891,9 +20893,7 @@ fi # For the tools/, we need libdbus-c++ for the "build" architecture as well - - -if test "$cross_compiling" = "yes"; then + if test "$cross_compiling" = "yes"; then CROSS_COMPILING_TRUE= CROSS_COMPILING_FALSE='#' else @@ -21448,6 +21448,7 @@ gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -21668,6 +21669,7 @@ target_alias!$target_alias$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim +am__isrc!$am__isrc$ac_delim CYGPATH_W!$CYGPATH_W$ac_delim PACKAGE!$PACKAGE$ac_delim VERSION!$VERSION$ac_delim @@ -21724,7 +21726,6 @@ LN_S!$LN_S$ac_delim ECHO!$ECHO$ac_delim AR!$AR$ac_delim RANLIB!$RANLIB$ac_delim -DSYMUTIL!$DSYMUTIL$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -21766,6 +21767,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +DSYMUTIL!$DSYMUTIL$ac_delim NMEDIT!$NMEDIT$ac_delim CPP!$CPP$ac_delim CXXCPP!$CXXCPP$ac_delim @@ -21796,7 +21798,7 @@ LIB@&t@OBJS!$LIB@&t@OBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 28; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 29; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -22023,6 +22025,11 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -22076,6 +22083,7 @@ s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out @@ -22191,21 +22199,22 @@ echo "$as_me: $ac_file is unchanged" >&6;} fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. +_am_arg=$ac_file _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in - $ac_file | $ac_file:* ) + $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done -echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || -$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X$ac_file : 'X\(//\)[^/]' \| \ - X$ac_file : 'X\(//\)$' \| \ - X$ac_file : 'X\(/\)' \| . 2>/dev/null || -echo X$ac_file | +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -22240,8 +22249,9 @@ echo "$as_me: executing $ac_file commands" >&6;} # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ diff --git a/libs/dbus-c++/autom4te.cache/traces.0 b/libs/dbus-c++/autom4te.cache/traces.0 index 0d935bfaf7456bb6d75797148779e08953ac233b..adf056afdabbc38ea04d54c788316f0a46b4dbfb 100644 --- a/libs/dbus-c++/autom4te.cache/traces.0 +++ b/libs/dbus-c++/autom4te.cache/traces.0 @@ -6265,18 +6265,28 @@ else ifelse([$3], , :, [$3]) fi[]dnl ]) -m4trace:/usr/share/aclocal-1.9/amversion.m4:13: -1- AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) -m4trace:/usr/share/aclocal-1.9/amversion.m4:19: -1- AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.9.6])]) -m4trace:/usr/share/aclocal-1.9/auxdir.m4:47: -1- AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. +m4trace:/usr/share/aclocal-1.10/amversion.m4:14: -1- AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.10' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.10.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) +m4trace:/usr/share/aclocal-1.10/amversion.m4:33: -1- AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.10.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) +m4trace:/usr/share/aclocal-1.10/auxdir.m4:47: -1- AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) -m4trace:/usr/share/aclocal-1.9/cond.m4:15: -1- AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl +m4trace:/usr/share/aclocal-1.10/cond.m4:15: -1- AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE]) -AC_SUBST([$1_FALSE]) +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl if $2; then $1_TRUE= $1_FALSE='#' @@ -6289,7 +6299,7 @@ AC_CONFIG_COMMANDS_PRE( AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) -m4trace:/usr/share/aclocal-1.9/depend.m4:29: -1- AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl +m4trace:/usr/share/aclocal-1.10/depend.m4:28: -1- AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl @@ -6297,6 +6307,7 @@ AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) @@ -6362,6 +6373,7 @@ AC_CACHE_CHECK([dependency style of $depcc], depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then @@ -6391,10 +6403,10 @@ AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) -m4trace:/usr/share/aclocal-1.9/depend.m4:138: -1- AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl +m4trace:/usr/share/aclocal-1.10/depend.m4:139: -1- AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) -m4trace:/usr/share/aclocal-1.9/depend.m4:146: -1- AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, +m4trace:/usr/share/aclocal-1.10/depend.m4:147: -1- AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then @@ -6402,9 +6414,10 @@ if test "x$enable_dependency_tracking" != xno; then AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) -m4trace:/usr/share/aclocal-1.9/depout.m4:14: -1- AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [for mf in $CONFIG_FILES; do +m4trace:/usr/share/aclocal-1.10/depout.m4:14: -1- AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [for mf in $CONFIG_FILES; do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. @@ -6412,8 +6425,9 @@ m4trace:/usr/share/aclocal-1.9/depout.m4:14: -1- AC_DEFUN([_AM_OUTPUT_DEPENDENCY # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue @@ -6443,24 +6457,28 @@ m4trace:/usr/share/aclocal-1.9/depout.m4:14: -1- AC_DEFUN([_AM_OUTPUT_DEPENDENCY done done ]) -m4trace:/usr/share/aclocal-1.9/depout.m4:63: -1- AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], +m4trace:/usr/share/aclocal-1.10/depout.m4:64: -1- AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) -m4trace:/usr/share/aclocal-1.9/header.m4:12: -1- AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) -m4trace:/usr/share/aclocal-1.9/header.m4:12: -1- AC_DEFUN([AM_CONFIG_HEADER], [AC_DIAGNOSE([obsolete], [The macro `AM_CONFIG_HEADER' is obsolete. +m4trace:/usr/share/aclocal-1.10/header.m4:12: -1- AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) +m4trace:/usr/share/aclocal-1.10/header.m4:12: -1- AC_DEFUN([AM_CONFIG_HEADER], [AC_DIAGNOSE([obsolete], [The macro `AM_CONFIG_HEADER' is obsolete. You should run autoupdate.])dnl AC_CONFIG_HEADERS($@)]) -m4trace:/usr/share/aclocal-1.9/init.m4:26: -1- AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.58])dnl +m4trace:/usr/share/aclocal-1.10/init.m4:26: -1- AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.60])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi fi # test whether we have cygpath @@ -6480,6 +6498,9 @@ m4_ifval([$2], AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl @@ -6515,23 +6536,28 @@ AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) ]) -m4trace:/usr/share/aclocal-1.9/init.m4:102: -1- AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. +m4trace:/usr/share/aclocal-1.10/init.m4:113: -1- AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. +_am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in - $1 | $1:* ) + $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done -echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) -m4trace:/usr/share/aclocal-1.9/install-sh.m4:11: -1- AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -install_sh=${install_sh-"$am_aux_dir/install-sh"} +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) +m4trace:/usr/share/aclocal-1.10/install-sh.m4:11: -1- AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} AC_SUBST(install_sh)]) -m4trace:/usr/share/aclocal-1.9/lead-dot.m4:12: -1- AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null +m4trace:/usr/share/aclocal-1.10/lead-dot.m4:12: -1- AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. @@ -6540,7 +6566,7 @@ else fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) -m4trace:/usr/share/aclocal-1.9/make.m4:14: -1- AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} +m4trace:/usr/share/aclocal-1.10/make.m4:14: -1- AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo done @@ -6577,10 +6603,11 @@ AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) -m4trace:/usr/share/aclocal-1.9/missing.m4:14: -1- AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) +m4trace:/usr/share/aclocal-1.10/missing.m4:14: -1- AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) -m4trace:/usr/share/aclocal-1.9/missing.m4:24: -1- AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +m4trace:/usr/share/aclocal-1.10/missing.m4:24: -1- AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then @@ -6590,49 +6617,31 @@ else AC_MSG_WARN([`missing' script is too old or missing]) fi ]) -m4trace:/usr/share/aclocal-1.9/mkdirp.m4:30: -1- AC_DEFUN([AM_PROG_MKDIR_P], [if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' - else - mkdir_p='$(install_sh) -d' - fi -fi -AC_SUBST([mkdir_p])]) -m4trace:/usr/share/aclocal-1.9/options.m4:13: -1- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) -m4trace:/usr/share/aclocal-1.9/options.m4:19: -1- AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) -m4trace:/usr/share/aclocal-1.9/options.m4:25: -1- AC_DEFUN([_AM_SET_OPTIONS], [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) -m4trace:/usr/share/aclocal-1.9/options.m4:31: -1- AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -m4trace:/usr/share/aclocal-1.9/runlog.m4:12: -1- AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD +m4trace:/usr/share/aclocal-1.10/mkdirp.m4:11: -1- AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) +m4trace:/usr/share/aclocal-1.10/options.m4:13: -1- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) +m4trace:/usr/share/aclocal-1.10/options.m4:19: -1- AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) +m4trace:/usr/share/aclocal-1.10/options.m4:25: -1- AC_DEFUN([_AM_SET_OPTIONS], [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) +m4trace:/usr/share/aclocal-1.10/options.m4:31: -1- AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) +m4trace:/usr/share/aclocal-1.10/runlog.m4:12: -1- AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) -m4trace:/usr/share/aclocal-1.9/sanity.m4:14: -1- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) +m4trace:/usr/share/aclocal-1.10/sanity.m4:14: -1- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file @@ -6669,7 +6678,7 @@ else Check your system clock]) fi AC_MSG_RESULT(yes)]) -m4trace:/usr/share/aclocal-1.9/strip.m4:17: -1- AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +m4trace:/usr/share/aclocal-1.10/strip.m4:17: -1- AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake @@ -6678,9 +6687,10 @@ dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -m4trace:/usr/share/aclocal-1.9/tar.m4:24: -1- AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. +m4trace:/usr/share/aclocal-1.10/substnot.m4:12: -1- AC_DEFUN([_AM_SUBST_NOTMAKE]) +m4trace:/usr/share/aclocal-1.10/tar.m4:24: -1- AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], @@ -6803,10 +6813,13 @@ m4trace:configure.ac:4: -1- m4_pattern_allow([^target_alias$]) m4trace:configure.ac:6: -1- AM_INIT_AUTOMAKE([libdbus-c++], [0.5.0]) m4trace:configure.ac:6: -1- m4_pattern_allow([^AM_[A-Z]+FLAGS$]) m4trace:configure.ac:6: -1- AM_SET_CURRENT_AUTOMAKE_VERSION -m4trace:configure.ac:6: -1- AM_AUTOMAKE_VERSION([1.9.6]) +m4trace:configure.ac:6: -1- AM_AUTOMAKE_VERSION([1.10.1]) +m4trace:configure.ac:6: -1- _AM_AUTOCONF_VERSION([2.61]) m4trace:configure.ac:6: -1- m4_pattern_allow([^INSTALL_PROGRAM$]) m4trace:configure.ac:6: -1- m4_pattern_allow([^INSTALL_SCRIPT$]) m4trace:configure.ac:6: -1- m4_pattern_allow([^INSTALL_DATA$]) +m4trace:configure.ac:6: -1- m4_pattern_allow([^am__isrc$]) +m4trace:configure.ac:6: -1- _AM_SUBST_NOTMAKE([am__isrc]) m4trace:configure.ac:6: -1- m4_pattern_allow([^CYGPATH_W$]) m4trace:configure.ac:6: -1- m4_pattern_allow([^PACKAGE$]) m4trace:configure.ac:6: -1- m4_pattern_allow([^VERSION$]) @@ -6857,11 +6870,15 @@ AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) m4trace:configure.ac:6: -2- _AM_MANGLE_OPTION([no-dependencies]) m4trace:configure.ac:7: -1- AM_CONFIG_HEADER([include/dbus-c++/config.h]) m4trace:configure.ac:7: -1- _m4_warn([obsolete], [The macro `AM_CONFIG_HEADER' is obsolete. -You should run autoupdate.], [/usr/share/aclocal-1.9/header.m4:12: AM_CONFIG_HEADER is expanded from... +You should run autoupdate.], [/usr/share/aclocal-1.10/header.m4:12: AM_CONFIG_HEADER is expanded from... configure.ac:7: the top level]) m4trace:configure.ac:9: -1- m4_pattern_allow([^build$]) m4trace:configure.ac:9: -1- m4_pattern_allow([^build_cpu$]) @@ -6898,13 +6915,18 @@ m4trace:configure.ac:41: -1- AM_DEP_TRACK m4trace:configure.ac:41: -1- AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) m4trace:configure.ac:41: -1- m4_pattern_allow([^AMDEP_TRUE$]) m4trace:configure.ac:41: -1- m4_pattern_allow([^AMDEP_FALSE$]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([AMDEP_TRUE]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([AMDEP_FALSE]) m4trace:configure.ac:41: -1- m4_pattern_allow([^AMDEPBACKSLASH$]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([AMDEPBACKSLASH]) m4trace:configure.ac:41: -1- m4_pattern_allow([^CCDEPMODE$]) m4trace:configure.ac:41: -1- AM_CONDITIONAL([am__fastdepCC], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3]) m4trace:configure.ac:41: -1- m4_pattern_allow([^am__fastdepCC_TRUE$]) m4trace:configure.ac:41: -1- m4_pattern_allow([^am__fastdepCC_FALSE$]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([am__fastdepCC_TRUE]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([am__fastdepCC_FALSE]) m4trace:configure.ac:42: -1- m4_pattern_allow([^CXX$]) m4trace:configure.ac:42: -1- m4_pattern_allow([^CXXFLAGS$]) m4trace:configure.ac:42: -1- m4_pattern_allow([^LDFLAGS$]) @@ -6919,6 +6941,8 @@ m4trace:configure.ac:42: -1- AM_CONDITIONAL([am__fastdepCXX], [ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3]) m4trace:configure.ac:42: -1- m4_pattern_allow([^am__fastdepCXX_TRUE$]) m4trace:configure.ac:42: -1- m4_pattern_allow([^am__fastdepCXX_FALSE$]) +m4trace:configure.ac:42: -1- _AM_SUBST_NOTMAKE([am__fastdepCXX_TRUE]) +m4trace:configure.ac:42: -1- _AM_SUBST_NOTMAKE([am__fastdepCXX_FALSE]) m4trace:configure.ac:45: -1- m4_pattern_allow([^CXX_FOR_BUILD$]) m4trace:configure.ac:47: -1- AM_PROG_LIBTOOL m4trace:configure.ac:47: -1- AC_PROG_LIBTOOL @@ -9466,24 +9490,26 @@ m4trace:configure.ac:95: -1- m4_pattern_allow([^glib_LIBS$]) m4trace:configure.ac:96: -1- AM_CONDITIONAL([ENABLE_GLIB], [test 1 = 1]) m4trace:configure.ac:96: -1- m4_pattern_allow([^ENABLE_GLIB_TRUE$]) m4trace:configure.ac:96: -1- m4_pattern_allow([^ENABLE_GLIB_FALSE$]) +m4trace:configure.ac:96: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_TRUE]) +m4trace:configure.ac:96: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_FALSE]) m4trace:configure.ac:98: -2- AM_CONDITIONAL([HAVE_GTKMM], [test 1 = 1]) m4trace:configure.ac:98: -2- m4_pattern_allow([^HAVE_GTKMM_TRUE$]) m4trace:configure.ac:98: -2- m4_pattern_allow([^HAVE_GTKMM_FALSE$]) +m4trace:configure.ac:98: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_TRUE]) +m4trace:configure.ac:98: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:99: -2- AM_CONDITIONAL([HAVE_GTKMM], [test 0 = 1]) m4trace:configure.ac:99: -2- m4_pattern_allow([^HAVE_GTKMM_TRUE$]) m4trace:configure.ac:99: -2- m4_pattern_allow([^HAVE_GTKMM_FALSE$]) -m4trace:configure.ac:97: -1- PKG_CHECK_MODULES([gtkmm], [gtkmm-2.4], [ - -if test 1 = 1; then +m4trace:configure.ac:99: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_TRUE]) +m4trace:configure.ac:99: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_FALSE]) +m4trace:configure.ac:97: -1- PKG_CHECK_MODULES([gtkmm], [gtkmm-2.4], [ if test 1 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else HAVE_GTKMM_TRUE='#' HAVE_GTKMM_FALSE= fi -], [ - -if test 0 = 1; then +], [ if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -9502,18 +9528,26 @@ m4trace:configure.ac:102: -1- m4_pattern_allow([^gtkmm_LIBS$]) m4trace:configure.ac:104: -1- AM_CONDITIONAL([ENABLE_GLIB], [test 0 = 1]) m4trace:configure.ac:104: -1- m4_pattern_allow([^ENABLE_GLIB_TRUE$]) m4trace:configure.ac:104: -1- m4_pattern_allow([^ENABLE_GLIB_FALSE$]) +m4trace:configure.ac:104: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_TRUE]) +m4trace:configure.ac:104: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_FALSE]) m4trace:configure.ac:105: -1- AM_CONDITIONAL([HAVE_GTKMM], [test 0 = 1]) m4trace:configure.ac:105: -1- m4_pattern_allow([^HAVE_GTKMM_TRUE$]) m4trace:configure.ac:105: -1- m4_pattern_allow([^HAVE_GTKMM_FALSE$]) +m4trace:configure.ac:105: -1- _AM_SUBST_NOTMAKE([HAVE_GTKMM_TRUE]) +m4trace:configure.ac:105: -1- _AM_SUBST_NOTMAKE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:120: -1- m4_pattern_allow([^xml_CFLAGS$]) m4trace:configure.ac:121: -1- m4_pattern_allow([^xml_LIBS$]) m4trace:configure.ac:140: -1- m4_pattern_allow([^DOXYGEN$]) m4trace:configure.ac:164: -1- AM_CONDITIONAL([DBUS_DOXYGEN_DOCS_ENABLED], [test "$enable_doxygen_docs" = "yes"]) m4trace:configure.ac:164: -1- m4_pattern_allow([^DBUS_DOXYGEN_DOCS_ENABLED_TRUE$]) m4trace:configure.ac:164: -1- m4_pattern_allow([^DBUS_DOXYGEN_DOCS_ENABLED_FALSE$]) +m4trace:configure.ac:164: -1- _AM_SUBST_NOTMAKE([DBUS_DOXYGEN_DOCS_ENABLED_TRUE]) +m4trace:configure.ac:164: -1- _AM_SUBST_NOTMAKE([DBUS_DOXYGEN_DOCS_ENABLED_FALSE]) m4trace:configure.ac:168: -1- AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = "yes"]) m4trace:configure.ac:168: -1- m4_pattern_allow([^CROSS_COMPILING_TRUE$]) m4trace:configure.ac:168: -1- m4_pattern_allow([^CROSS_COMPILING_FALSE$]) +m4trace:configure.ac:168: -1- _AM_SUBST_NOTMAKE([CROSS_COMPILING_TRUE]) +m4trace:configure.ac:168: -1- _AM_SUBST_NOTMAKE([CROSS_COMPILING_FALSE]) m4trace:configure.ac:176: -1- m4_pattern_allow([^BUILD_LIBDBUS_CXX_DIR$]) m4trace:configure.ac:181: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments. You should run autoupdate.], []) diff --git a/libs/dbus-c++/autom4te.cache/traces.1 b/libs/dbus-c++/autom4te.cache/traces.1 index 0056a31cb5e0e2d02984ac4fb9d6108c17de9fb5..5cdcf836744d79486f0d59bc76b60715b765c3af 100644 --- a/libs/dbus-c++/autom4te.cache/traces.1 +++ b/libs/dbus-c++/autom4te.cache/traces.1 @@ -141,7 +141,7 @@ m4trace:configure.ac:4: -1- AC_SUBST_TRACE([target_alias]) m4trace:configure.ac:4: -1- m4_pattern_allow([^target_alias$]) m4trace:configure.ac:6: -1- AM_INIT_AUTOMAKE([libdbus-c++], [0.5.0]) m4trace:configure.ac:6: -1- m4_pattern_allow([^AM_[A-Z]+FLAGS$]) -m4trace:configure.ac:6: -1- AM_AUTOMAKE_VERSION([1.9.6]) +m4trace:configure.ac:6: -1- AM_AUTOMAKE_VERSION([1.10.1]) m4trace:configure.ac:6: -1- AC_REQUIRE_AUX_FILE([install-sh]) m4trace:configure.ac:6: -1- AC_SUBST([INSTALL_PROGRAM]) m4trace:configure.ac:6: -1- AC_SUBST_TRACE([INSTALL_PROGRAM]) @@ -152,6 +152,10 @@ m4trace:configure.ac:6: -1- m4_pattern_allow([^INSTALL_SCRIPT$]) m4trace:configure.ac:6: -1- AC_SUBST([INSTALL_DATA]) m4trace:configure.ac:6: -1- AC_SUBST_TRACE([INSTALL_DATA]) m4trace:configure.ac:6: -1- m4_pattern_allow([^INSTALL_DATA$]) +m4trace:configure.ac:6: -1- AC_SUBST([am__isrc], [' -I$(srcdir)']) +m4trace:configure.ac:6: -1- AC_SUBST_TRACE([am__isrc]) +m4trace:configure.ac:6: -1- m4_pattern_allow([^am__isrc$]) +m4trace:configure.ac:6: -1- _AM_SUBST_NOTMAKE([am__isrc]) m4trace:configure.ac:6: -1- AC_SUBST([CYGPATH_W]) m4trace:configure.ac:6: -1- AC_SUBST_TRACE([CYGPATH_W]) m4trace:configure.ac:6: -1- m4_pattern_allow([^CYGPATH_W$]) @@ -169,6 +173,7 @@ m4trace:configure.ac:6: -1- AC_DEFINE_TRACE_LITERAL([VERSION]) m4trace:configure.ac:6: -1- m4_pattern_allow([^VERSION$]) m4trace:configure.ac:6: -1- AH_OUTPUT([VERSION], [/* Version number of package */ #undef VERSION]) +m4trace:configure.ac:6: -1- AC_REQUIRE_AUX_FILE([missing]) m4trace:configure.ac:6: -1- AC_SUBST([ACLOCAL]) m4trace:configure.ac:6: -1- AC_SUBST_TRACE([ACLOCAL]) m4trace:configure.ac:6: -1- m4_pattern_allow([^ACLOCAL$]) @@ -193,7 +198,8 @@ m4trace:configure.ac:6: -1- m4_pattern_allow([^STRIP$]) m4trace:configure.ac:6: -1- AC_SUBST([INSTALL_STRIP_PROGRAM]) m4trace:configure.ac:6: -1- AC_SUBST_TRACE([INSTALL_STRIP_PROGRAM]) m4trace:configure.ac:6: -1- m4_pattern_allow([^INSTALL_STRIP_PROGRAM$]) -m4trace:configure.ac:6: -1- AC_SUBST([mkdir_p]) +m4trace:configure.ac:6: -1- AC_REQUIRE_AUX_FILE([install-sh]) +m4trace:configure.ac:6: -1- AC_SUBST([mkdir_p], ["$MKDIR_P"]) m4trace:configure.ac:6: -1- AC_SUBST_TRACE([mkdir_p]) m4trace:configure.ac:6: -1- m4_pattern_allow([^mkdir_p$]) m4trace:configure.ac:6: -1- AC_SUBST([AWK]) @@ -215,7 +221,7 @@ m4trace:configure.ac:6: -1- AC_SUBST([am__untar]) m4trace:configure.ac:6: -1- AC_SUBST_TRACE([am__untar]) m4trace:configure.ac:6: -1- m4_pattern_allow([^am__untar$]) m4trace:configure.ac:7: -1- _m4_warn([obsolete], [The macro `AM_CONFIG_HEADER' is obsolete. -You should run autoupdate.], [aclocal.m4:7163: AM_CONFIG_HEADER is expanded from... +You should run autoupdate.], [aclocal.m4:7193: AM_CONFIG_HEADER is expanded from... configure.ac:7: the top level]) m4trace:configure.ac:7: -1- AC_CONFIG_HEADERS([include/dbus-c++/config.h]) m4trace:configure.ac:9: -1- AC_CANONICAL_HOST @@ -304,9 +310,12 @@ m4trace:configure.ac:41: -1- m4_pattern_allow([^AMDEP_TRUE$]) m4trace:configure.ac:41: -1- AC_SUBST([AMDEP_FALSE]) m4trace:configure.ac:41: -1- AC_SUBST_TRACE([AMDEP_FALSE]) m4trace:configure.ac:41: -1- m4_pattern_allow([^AMDEP_FALSE$]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([AMDEP_TRUE]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([AMDEP_FALSE]) m4trace:configure.ac:41: -1- AC_SUBST([AMDEPBACKSLASH]) m4trace:configure.ac:41: -1- AC_SUBST_TRACE([AMDEPBACKSLASH]) m4trace:configure.ac:41: -1- m4_pattern_allow([^AMDEPBACKSLASH$]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([AMDEPBACKSLASH]) m4trace:configure.ac:41: -1- AC_SUBST([CCDEPMODE], [depmode=$am_cv_CC_dependencies_compiler_type]) m4trace:configure.ac:41: -1- AC_SUBST_TRACE([CCDEPMODE]) m4trace:configure.ac:41: -1- m4_pattern_allow([^CCDEPMODE$]) @@ -319,6 +328,8 @@ m4trace:configure.ac:41: -1- m4_pattern_allow([^am__fastdepCC_TRUE$]) m4trace:configure.ac:41: -1- AC_SUBST([am__fastdepCC_FALSE]) m4trace:configure.ac:41: -1- AC_SUBST_TRACE([am__fastdepCC_FALSE]) m4trace:configure.ac:41: -1- m4_pattern_allow([^am__fastdepCC_FALSE$]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([am__fastdepCC_TRUE]) +m4trace:configure.ac:41: -1- _AM_SUBST_NOTMAKE([am__fastdepCC_FALSE]) m4trace:configure.ac:42: -1- AC_SUBST([CXX]) m4trace:configure.ac:42: -1- AC_SUBST_TRACE([CXX]) m4trace:configure.ac:42: -1- m4_pattern_allow([^CXX$]) @@ -352,6 +363,8 @@ m4trace:configure.ac:42: -1- m4_pattern_allow([^am__fastdepCXX_TRUE$]) m4trace:configure.ac:42: -1- AC_SUBST([am__fastdepCXX_FALSE]) m4trace:configure.ac:42: -1- AC_SUBST_TRACE([am__fastdepCXX_FALSE]) m4trace:configure.ac:42: -1- m4_pattern_allow([^am__fastdepCXX_FALSE$]) +m4trace:configure.ac:42: -1- _AM_SUBST_NOTMAKE([am__fastdepCXX_TRUE]) +m4trace:configure.ac:42: -1- _AM_SUBST_NOTMAKE([am__fastdepCXX_FALSE]) m4trace:configure.ac:45: -1- AC_SUBST([CXX_FOR_BUILD]) m4trace:configure.ac:45: -1- AC_SUBST_TRACE([CXX_FOR_BUILD]) m4trace:configure.ac:45: -1- m4_pattern_allow([^CXX_FOR_BUILD$]) @@ -359,38 +372,38 @@ m4trace:configure.ac:47: -1- AC_PROG_LIBTOOL m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:209: AC_HELP_STRING is expanded from... ../../lib/autoconf/general.m4:1364: AC_ARG_ENABLE is expanded from... -aclocal.m4:2049: AC_ENABLE_SHARED is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:2057: AC_ENABLE_SHARED is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:209: AC_HELP_STRING is expanded from... ../../lib/autoconf/general.m4:1364: AC_ARG_ENABLE is expanded from... -aclocal.m4:2088: AC_ENABLE_STATIC is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:2096: AC_ENABLE_STATIC is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:209: AC_HELP_STRING is expanded from... ../../lib/autoconf/general.m4:1364: AC_ARG_ENABLE is expanded from... -aclocal.m4:2127: AC_ENABLE_FAST_INSTALL is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:2135: AC_ENABLE_FAST_INSTALL is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:209: AC_HELP_STRING is expanded from... ../../lib/autoconf/general.m4:1382: AC_ARG_WITH is expanded from... -aclocal.m4:2268: AC_PROG_LD is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:2276: AC_PROG_LD is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- AC_SUBST([SED]) m4trace:configure.ac:47: -1- AC_SUBST_TRACE([SED]) @@ -431,32 +444,32 @@ m4trace:configure.ac:47: -1- m4_pattern_allow([^NMEDIT$]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:209: AC_HELP_STRING is expanded from... ../../lib/autoconf/general.m4:1364: AC_ARG_ENABLE is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:209: AC_HELP_STRING is expanded from... ../../lib/autoconf/general.m4:1382: AC_ARG_WITH is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:2414: AC_TRY_LINK is expanded from... ../../lib/m4sugar/m4sh.m4:516: AS_IF is expanded from... ../../lib/autoconf/general.m4:1898: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:1911: AC_CACHE_CHECK is expanded from... -aclocal.m4:557: _LT_AC_LOCK is expanded from... -aclocal.m4:1177: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from... -aclocal.m4:2801: _LT_AC_LANG_C_CONFIG is expanded from... -aclocal.m4:2800: AC_LIBTOOL_LANG_C_CONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:565: _LT_AC_LOCK is expanded from... +aclocal.m4:1185: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from... +aclocal.m4:2809: _LT_AC_LANG_C_CONFIG is expanded from... +aclocal.m4:2808: AC_LIBTOOL_LANG_C_CONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- AH_OUTPUT([HAVE_DLFCN_H], [/* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H]) @@ -495,23 +508,23 @@ m4trace:configure.ac:47: -1- _LT_AC_TAGCONFIG m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:209: AC_HELP_STRING is expanded from... ../../lib/autoconf/general.m4:1382: AC_ARG_WITH is expanded from... -aclocal.m4:1926: _LT_AC_TAGCONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:1934: _LT_AC_TAGCONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) -m4trace:configure.ac:47: -1- _m4_warn([obsolete], [back quotes and double quotes must not be escaped in: $as_me:$LINENO: error: tag name \"$tagname\" already exists], [aclocal.m4:1926: _LT_AC_TAGCONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +m4trace:configure.ac:47: -1- _m4_warn([obsolete], [back quotes and double quotes must not be escaped in: $as_me:$LINENO: error: tag name \"$tagname\" already exists], [aclocal.m4:1934: _LT_AC_TAGCONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) -m4trace:configure.ac:47: -1- _m4_warn([obsolete], [back quotes and double quotes must not be escaped in: $as_me: error: tag name \"$tagname\" already exists], [aclocal.m4:1926: _LT_AC_TAGCONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +m4trace:configure.ac:47: -1- _m4_warn([obsolete], [back quotes and double quotes must not be escaped in: $as_me: error: tag name \"$tagname\" already exists], [aclocal.m4:1934: _LT_AC_TAGCONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- AC_SUBST([CXXCPP]) m4trace:configure.ac:47: -1- AC_SUBST_TRACE([CXXCPP]) @@ -542,43 +555,43 @@ m4trace:configure.ac:47: -1- AC_SUBST_TRACE([ac_ct_F77]) m4trace:configure.ac:47: -1- m4_pattern_allow([^ac_ct_F77$]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_LANG_SAVE' is obsolete. You should run autoupdate.], [../../lib/autoconf/lang.m4:167: AC_LANG_SAVE is expanded from... -aclocal.m4:4187: _LT_AC_LANG_GCJ_CONFIG is expanded from... -aclocal.m4:4186: AC_LIBTOOL_LANG_GCJ_CONFIG is expanded from... -aclocal.m4:1926: _LT_AC_TAGCONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:4195: _LT_AC_LANG_GCJ_CONFIG is expanded from... +aclocal.m4:4194: AC_LIBTOOL_LANG_GCJ_CONFIG is expanded from... +aclocal.m4:1934: _LT_AC_TAGCONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_LANG_RESTORE' is obsolete. You should run autoupdate.], [../../lib/autoconf/lang.m4:176: AC_LANG_RESTORE is expanded from... -aclocal.m4:4187: _LT_AC_LANG_GCJ_CONFIG is expanded from... -aclocal.m4:4186: AC_LIBTOOL_LANG_GCJ_CONFIG is expanded from... -aclocal.m4:1926: _LT_AC_TAGCONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:4195: _LT_AC_LANG_GCJ_CONFIG is expanded from... +aclocal.m4:4194: AC_LIBTOOL_LANG_GCJ_CONFIG is expanded from... +aclocal.m4:1934: _LT_AC_TAGCONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_LANG_SAVE' is obsolete. You should run autoupdate.], [../../lib/autoconf/lang.m4:167: AC_LANG_SAVE is expanded from... -aclocal.m4:4243: _LT_AC_LANG_RC_CONFIG is expanded from... -aclocal.m4:4242: AC_LIBTOOL_LANG_RC_CONFIG is expanded from... -aclocal.m4:1926: _LT_AC_TAGCONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:4251: _LT_AC_LANG_RC_CONFIG is expanded from... +aclocal.m4:4250: AC_LIBTOOL_LANG_RC_CONFIG is expanded from... +aclocal.m4:1934: _LT_AC_TAGCONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- _m4_warn([obsolete], [The macro `AC_LANG_RESTORE' is obsolete. You should run autoupdate.], [../../lib/autoconf/lang.m4:176: AC_LANG_RESTORE is expanded from... -aclocal.m4:4243: _LT_AC_LANG_RC_CONFIG is expanded from... -aclocal.m4:4242: AC_LIBTOOL_LANG_RC_CONFIG is expanded from... -aclocal.m4:1926: _LT_AC_TAGCONFIG is expanded from... -aclocal.m4:86: AC_LIBTOOL_SETUP is expanded from... -aclocal.m4:66: _AC_PROG_LIBTOOL is expanded from... -aclocal.m4:31: AC_PROG_LIBTOOL is expanded from... -aclocal.m4:6558: AM_PROG_LIBTOOL is expanded from... +aclocal.m4:4251: _LT_AC_LANG_RC_CONFIG is expanded from... +aclocal.m4:4250: AC_LIBTOOL_LANG_RC_CONFIG is expanded from... +aclocal.m4:1934: _LT_AC_TAGCONFIG is expanded from... +aclocal.m4:94: AC_LIBTOOL_SETUP is expanded from... +aclocal.m4:74: _AC_PROG_LIBTOOL is expanded from... +aclocal.m4:39: AC_PROG_LIBTOOL is expanded from... +aclocal.m4:6566: AM_PROG_LIBTOOL is expanded from... configure.ac:47: the top level]) m4trace:configure.ac:47: -1- AC_SUBST([LIBTOOL]) m4trace:configure.ac:47: -1- AC_SUBST_TRACE([LIBTOOL]) @@ -638,6 +651,8 @@ m4trace:configure.ac:96: -1- m4_pattern_allow([^ENABLE_GLIB_TRUE$]) m4trace:configure.ac:96: -1- AC_SUBST([ENABLE_GLIB_FALSE]) m4trace:configure.ac:96: -1- AC_SUBST_TRACE([ENABLE_GLIB_FALSE]) m4trace:configure.ac:96: -1- m4_pattern_allow([^ENABLE_GLIB_FALSE$]) +m4trace:configure.ac:96: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_TRUE]) +m4trace:configure.ac:96: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_FALSE]) m4trace:configure.ac:98: -2- AM_CONDITIONAL([HAVE_GTKMM], [test 1 = 1]) m4trace:configure.ac:98: -2- AC_SUBST([HAVE_GTKMM_TRUE]) m4trace:configure.ac:98: -2- AC_SUBST_TRACE([HAVE_GTKMM_TRUE]) @@ -645,6 +660,8 @@ m4trace:configure.ac:98: -2- m4_pattern_allow([^HAVE_GTKMM_TRUE$]) m4trace:configure.ac:98: -2- AC_SUBST([HAVE_GTKMM_FALSE]) m4trace:configure.ac:98: -2- AC_SUBST_TRACE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:98: -2- m4_pattern_allow([^HAVE_GTKMM_FALSE$]) +m4trace:configure.ac:98: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_TRUE]) +m4trace:configure.ac:98: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:99: -2- AM_CONDITIONAL([HAVE_GTKMM], [test 0 = 1]) m4trace:configure.ac:99: -2- AC_SUBST([HAVE_GTKMM_TRUE]) m4trace:configure.ac:99: -2- AC_SUBST_TRACE([HAVE_GTKMM_TRUE]) @@ -652,6 +669,8 @@ m4trace:configure.ac:99: -2- m4_pattern_allow([^HAVE_GTKMM_TRUE$]) m4trace:configure.ac:99: -2- AC_SUBST([HAVE_GTKMM_FALSE]) m4trace:configure.ac:99: -2- AC_SUBST_TRACE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:99: -2- m4_pattern_allow([^HAVE_GTKMM_FALSE$]) +m4trace:configure.ac:99: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_TRUE]) +m4trace:configure.ac:99: -2- _AM_SUBST_NOTMAKE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:97: -1- AC_SUBST([gtkmm_CFLAGS]) m4trace:configure.ac:97: -1- AC_SUBST_TRACE([gtkmm_CFLAGS]) m4trace:configure.ac:97: -1- m4_pattern_allow([^gtkmm_CFLAGS$]) @@ -671,6 +690,8 @@ m4trace:configure.ac:104: -1- m4_pattern_allow([^ENABLE_GLIB_TRUE$]) m4trace:configure.ac:104: -1- AC_SUBST([ENABLE_GLIB_FALSE]) m4trace:configure.ac:104: -1- AC_SUBST_TRACE([ENABLE_GLIB_FALSE]) m4trace:configure.ac:104: -1- m4_pattern_allow([^ENABLE_GLIB_FALSE$]) +m4trace:configure.ac:104: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_TRUE]) +m4trace:configure.ac:104: -1- _AM_SUBST_NOTMAKE([ENABLE_GLIB_FALSE]) m4trace:configure.ac:105: -1- AM_CONDITIONAL([HAVE_GTKMM], [test 0 = 1]) m4trace:configure.ac:105: -1- AC_SUBST([HAVE_GTKMM_TRUE]) m4trace:configure.ac:105: -1- AC_SUBST_TRACE([HAVE_GTKMM_TRUE]) @@ -678,6 +699,8 @@ m4trace:configure.ac:105: -1- m4_pattern_allow([^HAVE_GTKMM_TRUE$]) m4trace:configure.ac:105: -1- AC_SUBST([HAVE_GTKMM_FALSE]) m4trace:configure.ac:105: -1- AC_SUBST_TRACE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:105: -1- m4_pattern_allow([^HAVE_GTKMM_FALSE$]) +m4trace:configure.ac:105: -1- _AM_SUBST_NOTMAKE([HAVE_GTKMM_TRUE]) +m4trace:configure.ac:105: -1- _AM_SUBST_NOTMAKE([HAVE_GTKMM_FALSE]) m4trace:configure.ac:108: -1- AH_OUTPUT([HAVE_EXPAT_H], [/* Define to 1 if you have the <expat.h> header file. */ #undef HAVE_EXPAT_H]) m4trace:configure.ac:120: -1- AC_SUBST([xml_CFLAGS]) @@ -698,6 +721,8 @@ m4trace:configure.ac:164: -1- m4_pattern_allow([^DBUS_DOXYGEN_DOCS_ENABLED_TRUE$ m4trace:configure.ac:164: -1- AC_SUBST([DBUS_DOXYGEN_DOCS_ENABLED_FALSE]) m4trace:configure.ac:164: -1- AC_SUBST_TRACE([DBUS_DOXYGEN_DOCS_ENABLED_FALSE]) m4trace:configure.ac:164: -1- m4_pattern_allow([^DBUS_DOXYGEN_DOCS_ENABLED_FALSE$]) +m4trace:configure.ac:164: -1- _AM_SUBST_NOTMAKE([DBUS_DOXYGEN_DOCS_ENABLED_TRUE]) +m4trace:configure.ac:164: -1- _AM_SUBST_NOTMAKE([DBUS_DOXYGEN_DOCS_ENABLED_FALSE]) m4trace:configure.ac:168: -1- AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = "yes"]) m4trace:configure.ac:168: -1- AC_SUBST([CROSS_COMPILING_TRUE]) m4trace:configure.ac:168: -1- AC_SUBST_TRACE([CROSS_COMPILING_TRUE]) @@ -705,6 +730,8 @@ m4trace:configure.ac:168: -1- m4_pattern_allow([^CROSS_COMPILING_TRUE$]) m4trace:configure.ac:168: -1- AC_SUBST([CROSS_COMPILING_FALSE]) m4trace:configure.ac:168: -1- AC_SUBST_TRACE([CROSS_COMPILING_FALSE]) m4trace:configure.ac:168: -1- m4_pattern_allow([^CROSS_COMPILING_FALSE$]) +m4trace:configure.ac:168: -1- _AM_SUBST_NOTMAKE([CROSS_COMPILING_TRUE]) +m4trace:configure.ac:168: -1- _AM_SUBST_NOTMAKE([CROSS_COMPILING_FALSE]) m4trace:configure.ac:176: -1- AC_SUBST([BUILD_LIBDBUS_CXX_DIR]) m4trace:configure.ac:176: -1- AC_SUBST_TRACE([BUILD_LIBDBUS_CXX_DIR]) m4trace:configure.ac:176: -1- m4_pattern_allow([^BUILD_LIBDBUS_CXX_DIR$]) @@ -740,3 +767,4 @@ m4trace:configure.ac:181: -1- AC_SUBST_TRACE([builddir]) m4trace:configure.ac:181: -1- AC_SUBST_TRACE([abs_builddir]) m4trace:configure.ac:181: -1- AC_SUBST_TRACE([abs_top_builddir]) m4trace:configure.ac:181: -1- AC_SUBST_TRACE([INSTALL]) +m4trace:configure.ac:181: -1- AC_SUBST_TRACE([MKDIR_P]) diff --git a/libs/dbus-c++/configure b/libs/dbus-c++/configure index 48123fda540424a6d1b09fa6b4a7ac3f6e40a710..589d261d54f4511560e32fc7659c37c43a5643be 100755 --- a/libs/dbus-c++/configure +++ b/libs/dbus-c++/configure @@ -808,6 +808,7 @@ target_alias INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA +am__isrc CYGPATH_W PACKAGE VERSION @@ -1972,7 +1973,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -am__api_version="1.9" +am__api_version='1.10' + ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -2155,38 +2157,53 @@ else echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi -if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' +{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done +done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" else - mkdir_p='$(install_sh) -d' + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" fi fi +{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +echo "${ECHO_T}$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac for ac_prog in gawk mawk nawk awk do @@ -2269,12 +2286,16 @@ else fi rmdir .tst 2>/dev/null -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } + fi fi # test whether we have cygpath @@ -2317,7 +2338,7 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} -install_sh=${install_sh-"$am_aux_dir/install-sh"} +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right @@ -2421,7 +2442,7 @@ else fi fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" # We need awk for the "check" target. The system "awk" is bad on # some platforms. @@ -3534,9 +3555,7 @@ if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi - - -if test "x$enable_dependency_tracking" != xno; then + if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else @@ -3546,7 +3565,6 @@ fi - depcc="$CC" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 @@ -3614,6 +3632,7 @@ else depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then @@ -3643,9 +3662,7 @@ fi echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - -if + if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= @@ -4087,6 +4104,7 @@ else depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then @@ -4116,9 +4134,7 @@ fi echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - -if + if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= @@ -4859,7 +4875,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4862 "configure"' > conftest.$ac_ext + echo '#line 4878 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7443,11 +7459,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7446: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7462: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7450: \$? = $ac_status" >&5 + echo "$as_me:7466: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7733,11 +7749,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7736: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7752: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7740: \$? = $ac_status" >&5 + echo "$as_me:7756: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7837,11 +7853,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7840: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7856: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7844: \$? = $ac_status" >&5 + echo "$as_me:7860: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10214,7 +10230,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 10217 "configure" +#line 10233 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10314,7 +10330,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 10317 "configure" +#line 10333 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12715,11 +12731,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12718: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12734: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12722: \$? = $ac_status" >&5 + echo "$as_me:12738: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12819,11 +12835,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12822: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12838: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12826: \$? = $ac_status" >&5 + echo "$as_me:12842: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14417,11 +14433,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14420: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14436: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14424: \$? = $ac_status" >&5 + echo "$as_me:14440: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14521,11 +14537,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14524: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14540: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14528: \$? = $ac_status" >&5 + echo "$as_me:14544: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16741,11 +16757,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16744: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16760: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16748: \$? = $ac_status" >&5 + echo "$as_me:16764: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -17031,11 +17047,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17034: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17050: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:17038: \$? = $ac_status" >&5 + echo "$as_me:17054: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -17135,11 +17151,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17138: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17154: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:17142: \$? = $ac_status" >&5 + echo "$as_me:17158: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -20216,9 +20232,7 @@ echo "${ECHO_T}yes" >&6; } fi - - -if test 1 = 1; then + if test 1 = 1; then ENABLE_GLIB_TRUE= ENABLE_GLIB_FALSE='#' else @@ -20287,9 +20301,7 @@ fi { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20299,9 +20311,7 @@ fi elif test $pkg_failed = untried; then - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20315,9 +20325,7 @@ else gtkmm_LIBS=$pkg_cv_gtkmm_LIBS { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } - - -if test 1 = 1; then + if test 1 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20329,9 +20337,7 @@ fi else - - -if test 0 = 1; then + if test 0 = 1; then ENABLE_GLIB_TRUE= ENABLE_GLIB_FALSE='#' else @@ -20339,9 +20345,7 @@ else ENABLE_GLIB_FALSE= fi - - -if test 0 = 1; then + if test 0 = 1; then HAVE_GTKMM_TRUE= HAVE_GTKMM_FALSE='#' else @@ -20878,9 +20882,7 @@ echo "$as_me: error: Building Doxygen docs explicitly required, but Doxygen not echo "${ECHO_T}yes" >&6; } fi - - -if test "$enable_doxygen_docs" = "yes"; then + if test "$enable_doxygen_docs" = "yes"; then DBUS_DOXYGEN_DOCS_ENABLED_TRUE= DBUS_DOXYGEN_DOCS_ENABLED_FALSE='#' else @@ -20891,9 +20893,7 @@ fi # For the tools/, we need libdbus-c++ for the "build" architecture as well - - -if test "$cross_compiling" = "yes"; then + if test "$cross_compiling" = "yes"; then CROSS_COMPILING_TRUE= CROSS_COMPILING_FALSE='#' else @@ -21448,6 +21448,7 @@ gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -21668,6 +21669,7 @@ target_alias!$target_alias$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim +am__isrc!$am__isrc$ac_delim CYGPATH_W!$CYGPATH_W$ac_delim PACKAGE!$PACKAGE$ac_delim VERSION!$VERSION$ac_delim @@ -21724,7 +21726,6 @@ LN_S!$LN_S$ac_delim ECHO!$ECHO$ac_delim AR!$AR$ac_delim RANLIB!$RANLIB$ac_delim -DSYMUTIL!$DSYMUTIL$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -21766,6 +21767,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +DSYMUTIL!$DSYMUTIL$ac_delim NMEDIT!$NMEDIT$ac_delim CPP!$CPP$ac_delim CXXCPP!$CXXCPP$ac_delim @@ -21796,7 +21798,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 28; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 29; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -22023,6 +22025,11 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -22076,6 +22083,7 @@ s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out @@ -22191,21 +22199,22 @@ echo "$as_me: $ac_file is unchanged" >&6;} fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. +_am_arg=$ac_file _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in - $ac_file | $ac_file:* ) + $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done -echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || -$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X$ac_file : 'X\(//\)[^/]' \| \ - X$ac_file : 'X\(//\)$' \| \ - X$ac_file : 'X\(/\)' \| . 2>/dev/null || -echo X$ac_file | +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -22240,8 +22249,9 @@ echo "$as_me: executing $ac_file commands" >&6;} # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ diff --git a/libs/dbus-c++/depcomp b/libs/dbus-c++/depcomp index 04701da536f33a7c39d7bb01b87a70ae3a776df5..e5f9736c7239301c765e2d7abefb9bb9b9237ac5 100755 --- a/libs/dbus-c++/depcomp +++ b/libs/dbus-c++/depcomp @@ -1,9 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2005-07-09.11 +scriptversion=2007-03-29.01 -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software +# Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -91,7 +92,20 @@ gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" stat=$? if test $stat -eq 0; then : else @@ -201,34 +215,39 @@ aix) # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. - stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u "$@" -M fi stat=$? - if test -f "$tmpdepfile"; then : - else - stripped=`echo "$stripped" | sed 's,^.*/,,'` - tmpdepfile="$stripped.u" - fi - if test $stat -eq 0; then : else - rm -f "$tmpdepfile" + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done if test -f "$tmpdepfile"; then - outname="$stripped.o" # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile @@ -276,6 +295,46 @@ icc) rm -f "$tmpdepfile" ;; +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. @@ -288,13 +347,13 @@ tru64) if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a - # static library. This mecanism is used in libtool 1.4 series to + # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in in $dir.libs/$base.o.d and + # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is diff --git a/libs/dbus-c++/include/dbus-c++/server.h b/libs/dbus-c++/include/dbus-c++/server.h index 590452b57c174d27ca1d3d6297bfe00015c54a78..adc6edef264612c1f42b93cbbd32161304e9961b 100644 --- a/libs/dbus-c++/include/dbus-c++/server.h +++ b/libs/dbus-c++/include/dbus-c++/server.h @@ -63,7 +63,7 @@ public: protected: - Server(const Server &s) + Server(const Server & /* s */) {} virtual void on_new_connection(Connection &c) = 0; diff --git a/libs/dbus-c++/install-sh b/libs/dbus-c++/install-sh index 4d4a9519eaf88b18fb157dfe5fae59c1c5d005c7..a5897de6ea7f74f83fd793474bb4738d32884719 100755 --- a/libs/dbus-c++/install-sh +++ b/libs/dbus-c++/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2005-05-14.22 +scriptversion=2006-12-25.00 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -39,38 +39,68 @@ scriptversion=2005-05-14.22 # when there is no Makefile. # # This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. +# from scratch. + +nl=' +' +IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi -# put in absolute paths if you don't have them in your path; or use env. vars. +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" +posix_mkdir= + +# Desired mode of installed file. +mode=0755 -chmodcmd="$chmodprog 0755" -chowncmd= chgrpcmd= -stripcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog rmcmd="$rmprog -f" -mvcmd="$mvprog" +stripcmd= + src= dst= dir_arg= -dstarg= +dst_arg= + +copy_on_change=false no_target_directory= -usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... @@ -80,81 +110,86 @@ In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --c (ignored) --d create directories instead of installing files. --g GROUP $chgrpprog installed files to GROUP. --m MODE $chmodprog installed files to MODE. --o USER $chownprog installed files to USER. --s $stripprog installed files. --t DIRECTORY install into DIRECTORY. --T report an error if DSTFILE is a directory. ---help display this help and exit. ---version display version info and exit. + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG " -while test -n "$1"; do +while test $# -ne 0; do case $1 in - -c) shift - continue;; + -c) ;; + + -C) copy_on_change=true;; - -d) dir_arg=true - shift - continue;; + -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; + shift;; --help) echo "$usage"; exit $?;; - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift - shift - continue;; + shift;; - -s) stripcmd=$stripprog - shift - continue;; + -s) stripcmd=$stripprog;; - -t) dstarg=$2 - shift - shift - continue;; + -t) dst_arg=$2 + shift;; - -T) no_target_directory=true - shift - continue;; + -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; - *) # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - test -n "$dir_arg$dstarg" && break - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dstarg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dstarg" - shift # fnord - fi - shift # arg - dstarg=$arg - done + --) shift break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; esac + shift done -if test -z "$1"; then +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 @@ -164,24 +199,47 @@ if test -z "$1"; then exit 0 fi +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + for src do # Protect names starting with `-'. case $src in - -*) src=./$src ;; + -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src - src= - - if test -d "$dst"; then - mkdircmd=: - chmodcmd= - else - mkdircmd=$mkdirprog - fi + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. @@ -190,71 +248,199 @@ do exit 1 fi - if test -z "$dstarg"; then + if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi - dst=$dstarg + dst=$dst_arg # Protect names starting with `-'. case $dst in - -*) dst=./$dst ;; + -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then - echo "$0: $dstarg: Is a directory" >&2 + echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi - dst=$dst/`basename "$src"` + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? fi fi - # This sed command emulates the dirname command. - dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac - # Make sure that the destination directory exists. + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else - # Skip lots of stat calls in the usual case. - if test ! -d "$dstdir"; then - defaultIFS=' - ' - IFS="${IFS-$defaultIFS}" + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. - oIFS=$IFS - # Some sh's can't handle IFS=/ for some reason. - IFS='%' - set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` - shift - IFS=$oIFS + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac - pathcomp= + eval "$initialize_posix_glob" - while test $# -ne 0 ; do - pathcomp=$pathcomp$1 + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir shift - if test ! -d "$pathcomp"; then - $mkdirprog "$pathcomp" - # mkdir can fail with a `File exist' error in case several - # install-sh are creating the directory concurrently. This - # is OK. - test -d "$pathcomp" || exit + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi - pathcomp=$pathcomp/ - done + fi fi if test -n "$dir_arg"; then - $doit $mkdircmd "$dst" \ - && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } - + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else - dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ @@ -262,10 +448,9 @@ do # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. - $doit $cpprog "$src" "$dsttmp" && + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # @@ -273,48 +458,59 @@ do # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && - - # Now rename the file to the real destination. - { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ - || { - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - if test -f "$dstdir/$dstfile"; then - $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ - || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ - || { - echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 - (exit 1); exit 1 - } - else - : - fi - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" - } - } - fi || { (exit 1); exit 1; } + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi done -# The final little trick to "correctly" pass the exit status to the exit trap. -{ - (exit 0); exit 0 -} - # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" diff --git a/libs/dbus-c++/missing b/libs/dbus-c++/missing index 894e786e16c1d0d94dfc08d6b475270fe1418d6a..1c8ff7049d8f3aaa9741c53e7f3145d9b76a77d8 100755 --- a/libs/dbus-c++/missing +++ b/libs/dbus-c++/missing @@ -1,9 +1,9 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2005-06-08.21 +scriptversion=2006-05-10.23 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 # Free Software Foundation, Inc. # Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. @@ -33,6 +33,8 @@ if test $# -eq 0; then fi run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. @@ -44,7 +46,7 @@ fi msg="missing on your system" -case "$1" in +case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= @@ -77,6 +79,7 @@ Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c @@ -106,7 +109,7 @@ esac # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). -case "$1" in +case $1 in lex|yacc) # Not GNU programs, they don't have --version. ;; @@ -135,7 +138,7 @@ esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. -case "$1" in +case $1 in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if @@ -164,7 +167,7 @@ WARNING: \`$1' is $msg. You should only need it if test -z "$files" && files="config.h" touch_files= for f in $files; do - case "$f" in + case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; @@ -192,8 +195,8 @@ WARNING: \`$1' is needed, but is $msg. You can get \`$1' as part of \`Autoconf' from any GNU archive site." - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else @@ -214,25 +217,25 @@ WARNING: \`$1' $msg. You should only need it if in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then + if test $# -ne 1; then eval LASTARG="\${$#}" - case "$LASTARG" in + case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi - if [ ! -f y.tab.h ]; then + if test ! -f y.tab.h; then echo >y.tab.h fi - if [ ! -f y.tab.c ]; then + if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; @@ -244,18 +247,18 @@ WARNING: \`$1' is $msg. You should only need it if in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c - if [ $# -ne 1 ]; then + if test $# -ne 1; then eval LASTARG="\${$#}" - case "$LASTARG" in + case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi - if [ ! -f lex.yy.c ]; then + if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; @@ -267,11 +270,9 @@ WARNING: \`$1' is $msg. You should only need it if \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then touch $file else test -z "$file" || exec >$file @@ -289,11 +290,17 @@ WARNING: \`$1' is $msg. You should only need it if DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi @@ -317,13 +324,13 @@ WARNING: \`$1' is $msg. You should only need it if fi firstarg="$1" if shift; then - case "$firstarg" in + case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac - case "$firstarg" in + case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 diff --git a/sflphone-gtk/src/accountwindow.c b/sflphone-gtk/src/accountwindow.c index b220c4f91962982ea6b3758083a857d0f5793292..e1ceb3cf81e479c5a41780a3c9f1c5c51321371b 100644 --- a/sflphone-gtk/src/accountwindow.c +++ b/sflphone-gtk/src/accountwindow.c @@ -327,6 +327,7 @@ show_account_window (account_t * a) g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_HOST), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryHostname)))); + g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_USER), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryUsername)))); diff --git a/sflphone-gtk/src/assistant.c b/sflphone-gtk/src/assistant.c index 613716e89ffe491601aa9e008e92b20a49b3f293..c7ae8e956c16210b81b52b2a8747e2ff71829f9a 100644 --- a/sflphone-gtk/src/assistant.c +++ b/sflphone-gtk/src/assistant.c @@ -83,6 +83,7 @@ sip_apply_callback( void ) g_hash_table_insert(current->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup("888")); g_hash_table_insert(current->properties, g_strdup(ACCOUNT_TYPE), g_strdup("SIP")); g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_HOST), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_server)))); + //g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_PORT), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_port)))); g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_PASSWORD), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_password)))); g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_USER), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_username)))); g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), g_strdup((gchar *)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->enable))? "TRUE":"FALSE")); diff --git a/sflphone-gtk/src/configurationmanager-glue.h b/sflphone-gtk/src/configurationmanager-glue.h index 9e54d25286f1a14972ad48274a89bc1fa26f3075..ba2d46b61d762461b715f06ee93ec4d07afd6ede 100644 --- a/sflphone-gtk/src/configurationmanager-glue.h +++ b/sflphone-gtk/src/configurationmanager-glue.h @@ -1926,6 +1926,81 @@ org_sflphone_SFLphone_ConfigurationManager_get_pulse_app_volume_control_async (D stuff->userdata = userdata; return dbus_g_proxy_begin_call (proxy, "getPulseAppVolumeControl", org_sflphone_SFLphone_ConfigurationManager_get_pulse_app_volume_control_async_callback, stuff, g_free, G_TYPE_INVALID); } +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_ConfigurationManager_set_sip_port (DBusGProxy *proxy, const gint IN_port, GError **error) + +{ + return dbus_g_proxy_call (proxy, "setSipPort", error, G_TYPE_INT, IN_port, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_sip_port_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_set_sip_port_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_set_sip_port_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_set_sip_port_async (DBusGProxy *proxy, const gint IN_port, org_sflphone_SFLphone_ConfigurationManager_set_sip_port_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setSipPort", org_sflphone_SFLphone_ConfigurationManager_set_sip_port_async_callback, stuff, g_free, G_TYPE_INT, IN_port, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_ConfigurationManager_get_sip_port (DBusGProxy *proxy, gint* OUT_port, GError **error) + +{ + return dbus_g_proxy_call (proxy, "getSipPort", error, G_TYPE_INVALID, G_TYPE_INT, OUT_port, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_sip_port_reply) (DBusGProxy *proxy, gint OUT_port, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gint OUT_port; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INT, &OUT_port, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_sip_port_reply)data->cb) (proxy, OUT_port, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_sip_port_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "getSipPort", org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async_callback, stuff, g_free, G_TYPE_INVALID); +} #endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_sflphone_SFLphone_ConfigurationManager */ G_END_DECLS diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index bd5ffe20a94d954177d1ea203ae433c923827134..9081ef06e9a7434d5b4dfb899b5b8b80828aa89f 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -36,6 +36,7 @@ /** * Local variables */ +gboolean accDialogOpen = FALSE; gboolean dialogOpen = FALSE; gboolean ringtoneEnabled = TRUE; @@ -69,7 +70,7 @@ enum { void config_window_fill_account_list() { - if(dialogOpen) + if(accDialogOpen) { GtkTreeIter iter; @@ -313,6 +314,11 @@ set_pulse_app_volume_control( void ) dbus_set_pulse_app_volume_control(); } +static void update_port( GtkSpinButton *button, void *ptr ) +{ + dbus_set_sip_port(gtk_spin_button_get_value_as_int((GtkSpinButton *)(ptr))); +} + /** * Account settings tab */ @@ -446,9 +452,11 @@ create_general_settings () GtkWidget *frame; GtkWidget *vbox; + GtkWidget *hbox; GtkWidget *value; GtkWidget *label; GtkWidget *cleanButton; + GtkWidget *entryPort; // Main widget ret = gtk_vbox_new(FALSE, 10); @@ -534,6 +542,34 @@ create_general_settings () gtk_box_pack_start( GTK_BOX(vbox) , widg , TRUE , TRUE , 1); g_signal_connect(G_OBJECT( widg ) , "clicked" , G_CALLBACK( set_pulse_app_volume_control ) , NULL); + /** SIP port information */ + int curPort = dbus_get_sip_port(); + if(curPort <= 0 || curPort > 65535) + curPort = 5060; + + frame = gtk_frame_new( _("SIP Port")); + gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); + gtk_widget_show( frame ); + + hbox = gtk_hbox_new(FALSE, 10); + gtk_widget_show( hbox ); + gtk_container_add( GTK_CONTAINER(frame) , hbox); + + GtkWidget *applyButton = gtk_button_new_with_label(_("Apply")); + gtk_widget_set_size_request(applyButton, 60, 35); + + label = gtk_label_new(_("Port:")); + + entryPort = gtk_spin_button_new_with_range(1, 65535, 1); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPort); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(entryPort), curPort); + + gtk_box_pack_start( GTK_BOX(hbox) , label , TRUE , TRUE , 1); + gtk_box_pack_start( GTK_BOX(hbox) , entryPort , TRUE , TRUE , 1); + gtk_box_pack_start( GTK_BOX(hbox) , applyButton , FALSE , FALSE , 1); + + g_signal_connect( G_OBJECT( applyButton) , "clicked" , G_CALLBACK( update_port ) , entryPort); + gtk_widget_show_all(ret); return ret; @@ -599,7 +635,7 @@ show_accounts_window( void ) GtkWidget * accountFrame; GtkWidget * tab; - dialogOpen = TRUE; + accDialogOpen = TRUE; dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Accounts"), GTK_WINDOW(get_main_window()), @@ -625,7 +661,7 @@ show_accounts_window( void ) gtk_dialog_run( dialog ); - dialogOpen=FALSE; + accDialogOpen=FALSE; gtk_widget_destroy(GTK_WIDGET(dialog)); if( account_list_get_size() >0 && account_list_get_current()==NULL ) account_list_set_current_pos(0); diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 2246666d1c983b1876ae4cbf4474c6d3c8eff228..2303dc6489ceca7d832806cb2ceb0452a3eeded8 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -1480,3 +1480,34 @@ dbus_get_pulse_app_volume_control( void ) return state; } +void +dbus_set_sip_port( const guint portNum ) +{ + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_sip_port( + configurationManagerProxy, + portNum, + &error); + if(error) + { + g_error_free(error); + } +} + +guint +dbus_get_sip_port( void ) +{ + GError* error = NULL; + gint portNum; + org_sflphone_SFLphone_ConfigurationManager_get_sip_port( + configurationManagerProxy, + &portNum, + &error); + if(error) + { + g_error_free(error); + } + g_print("GET MAX CALLS = %i\n" , portNum); + return (guint)portNum; +} + diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index 4714a0e4df133006fbbed5b5d89ef0cf2c18aecc..4989443f06897300ebcd52e6cea87c6721cbcc58 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -425,4 +425,8 @@ void dbus_register( int pid, gchar * name); */ void dbus_unregister(int pid); +void dbus_set_sip_port(const guint portNum); + +guint dbus_get_sip_port(); + #endif diff --git a/src/Makefile.am b/src/Makefile.am index 49cee0a536eae9c800020b9a7411470f09e19ce6..d87ca8153a824bd53485b518592774559a00e603 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,13 +39,15 @@ sflphoned_SOURCES = \ sipvoiplink.cpp \ call.cpp \ sipcall.cpp \ - $(IAXSOURCES) + $(IAXSOURCES) \ + useragent.cpp sflphoned_CXXFLAGS = \ -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" \ $(ZEROCONFFLAGS) \ $(IAX_FLAGS) + # Add here the dynamic libraries sflphoned should be linked against sflphoned_LDADD = \ ./libsflphone.la \ @@ -53,12 +55,12 @@ sflphoned_LDADD = \ @CCEXT2_LIBS@ \ $(ZEROCONFLIB) \ $(IAX_LIBS) \ - $(EXOSIP_LIBS) \ + $(PJSIP_LIBS) \ @DBUSCPP_LIBS@ \ @CCRTP_LIBS@ \ @ALSA_LIBS@ \ @PULSEAUDIO_LIBS@ \ - @SAMPLERATE_LIBS@ + @SAMPLERATE_LIBS@ noinst_LTLIBRARIES = libsflphone.la @@ -76,7 +78,8 @@ noinst_HEADERS = \ accountcreator.h \ sipvoiplink.h \ call.h \ - sipcall.h + sipcall.h \ + useragent.h libsflphone_la_LIBADD = \ $(src)/libs/stund/libstun.la \ diff --git a/src/account.cpp b/src/account.cpp index 0fc25638d07b771a01c07754a10cb819f693b5db..88fdf99fda109f291d4d476ff2e830d1a6628edd 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -23,10 +23,8 @@ #include <string> -Account::Account(const AccountID& accountID) : _accountID(accountID) +Account::Account(const AccountID& accountID) : _accountID(accountID), _link(NULL), _enabled(false) { - _link = NULL; - _enabled = false; } Account::~Account() @@ -85,7 +83,7 @@ Account::subscribeContactsPresence() } void -Account::publishPresence(std::string presenceStatus) +Account::publishPresence(std::string presenceStatus UNUSED) { /* if(_link->isContactPresenceSupported()) diff --git a/src/account.h b/src/account.h index a7b782a03bd380ea7f19d745700e240e7d0c5504..d099e965c6bd6c00612efef690fff34ba20ae5b9 100644 --- a/src/account.h +++ b/src/account.h @@ -73,7 +73,8 @@ class Account{ * Virtual destructor */ virtual ~Account(); - + + /** * Load the settings for this account. */ @@ -133,6 +134,12 @@ class Account{ private: + // copy constructor + Account(const Account& rh); + + // assignment operator + Account& operator=(const Account& rh); + protected: /** * Account ID are assign in constructor and shall not changed diff --git a/src/audio/alsalayer.cpp b/src/audio/alsalayer.cpp index e0278d7b134909fef117d48a113e172ca90e6673..e1ba97a377118d7bcb8b8b0b6bb4a9a05c07b3e7 100644 --- a/src/audio/alsalayer.cpp +++ b/src/audio/alsalayer.cpp @@ -24,11 +24,17 @@ // Constructor AlsaLayer::AlsaLayer( ManagerImpl* manager ) : AudioLayer( manager , ALSA ) - , _PlaybackHandle(NULL) - , _CaptureHandle(NULL) + , _PlaybackHandle(NULL) + , _CaptureHandle(NULL) + , _periodSize() + , _AsyncHandler(NULL) + , _audioPlugin() + , _inChannel() + , _outChannel() + , _defaultVolume(100) + , IDSoundCards() { _debug(" Constructor of AlsaLayer called\n"); - _defaultVolume = 100; } // Destructor @@ -99,7 +105,7 @@ AlsaLayer::startStream(void) snd_pcm_start( _CaptureHandle ) ; snd_pcm_prepare( _PlaybackHandle ); - if( err = snd_pcm_start( _PlaybackHandle) < 0 ) _debugAlsa(" Cannot start (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_start( _PlaybackHandle)) < 0 ) _debugAlsa(" Cannot start (%s)\n", snd_strerror(err)); } } @@ -132,7 +138,7 @@ AlsaLayer::fillHWBuffer( void) short s1, s2; int periodSize = 128 ; int frames = periodSize >> 2 ; - _debug("frames = %d\n"); + _debug("frames = %d\n", frames); data = (unsigned char*)malloc(periodSize); for(l1 = 0; l1 < 100; l1++) { @@ -286,7 +292,7 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) int dir = 0; snd_pcm_uframes_t period_size_in = getFrameSize() * getSampleRate() / 1000 * 2 ; snd_pcm_uframes_t buffer_size_in = period_size_in * 4 ; - snd_pcm_uframes_t threshold = 1024 ; + //snd_pcm_uframes_t threshold = 1024 ; snd_pcm_uframes_t period_size_out = getFrameSize() * getSampleRate() / 1000 * 2;//1024 ; snd_pcm_uframes_t buffer_size_out = period_size_out * 4 ; @@ -296,41 +302,41 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) if(flag == SFL_PCM_BOTH || flag == SFL_PCM_CAPTURE) { _debugAlsa("Opening capture device %s\n", pcm_c.c_str()); - if(err = snd_pcm_open(&_CaptureHandle, pcm_c.c_str(), SND_PCM_STREAM_CAPTURE, 0) < 0){ + if( (err = snd_pcm_open(&_CaptureHandle, pcm_c.c_str(), SND_PCM_STREAM_CAPTURE, 0)) < 0){ _debugAlsa("Error while opening capture device %s\n", pcm_c.c_str()); setErrorMessage( ALSA_CAPTURE_DEVICE ); return false; } - if( err = snd_pcm_hw_params_malloc( &hwParams ) < 0 ) { + if( (err = snd_pcm_hw_params_malloc( &hwParams )) < 0 ) { _debugAlsa(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err)); return false; } - if( err = snd_pcm_hw_params_any(_CaptureHandle, hwParams) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_access( _CaptureHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_format( _CaptureHandle, hwParams, SND_PCM_FORMAT_S16_LE) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_rate_near( _CaptureHandle, hwParams, &rate_in, &dir) < 0) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_channels( _CaptureHandle, hwParams, 1) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_period_time_near( _CaptureHandle, hwParams, &period_time , &dir) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_buffer_time_near( _CaptureHandle, hwParams, &buffer_time , &dir) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_period_size( hwParams, &period_size_in , &dir) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_in ) < 0) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params( _CaptureHandle, hwParams ) < 0) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); - _debug("buffer size = %d\n" , period_size_in); - _debug("period size = %d\n" , buffer_size_in); + if( (err = snd_pcm_hw_params_any(_CaptureHandle, hwParams)) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_access( _CaptureHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_format( _CaptureHandle, hwParams, SND_PCM_FORMAT_S16_LE)) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_rate_near( _CaptureHandle, hwParams, &rate_in, &dir) < 0)) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_channels( _CaptureHandle, hwParams, 1)) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_period_time_near( _CaptureHandle, hwParams, &period_time , &dir)) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_buffer_time_near( _CaptureHandle, hwParams, &buffer_time , &dir)) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_period_size( hwParams, &period_size_in , &dir) < 0)) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_in ) < 0)) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params( _CaptureHandle, hwParams ) < 0)) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); + _debug("buffer size = %d\n" , (int) period_size_in); + _debug("period size = %d\n" , (int) buffer_size_in); snd_pcm_hw_params_free( hwParams ); snd_pcm_uframes_t val ; snd_pcm_sw_params_malloc( &swparams ); snd_pcm_sw_params_current( _CaptureHandle, swparams ); - if( err = snd_pcm_sw_params_set_start_threshold( _CaptureHandle, swparams, period_size_out) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_sw_params_set_start_threshold( _CaptureHandle, swparams, period_size_out)) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); snd_pcm_sw_params_get_start_threshold( swparams , &val); - _debug("Start threshold = %d\n" ,val); - if( err = snd_pcm_sw_params_set_avail_min( _CaptureHandle, swparams, period_size_out) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); + _debug("Start threshold = %d\n" ,(int)val); + if( (err = snd_pcm_sw_params_set_avail_min( _CaptureHandle, swparams, period_size_out)) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); snd_pcm_sw_params_get_avail_min( swparams , &val); - _debug("Min available = %d\n" ,val); - if( err = snd_pcm_sw_params( _CaptureHandle, swparams ) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); + _debug("Min available = %d\n" ,(int)val); + if( (err = snd_pcm_sw_params( _CaptureHandle, swparams )) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); snd_pcm_sw_params_free( swparams ); deviceClosed = false; } @@ -339,26 +345,26 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) { _debugAlsa(" Opening playback device %s\n", pcm_p.c_str()); - if(err = snd_pcm_open(&_PlaybackHandle, pcm_p.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK ) < 0){ + if((err = snd_pcm_open(&_PlaybackHandle, pcm_p.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK )) < 0){ _debugAlsa("Error while opening playback device %s\n", pcm_p.c_str()); setErrorMessage( ALSA_PLAYBACK_DEVICE ); return false; } - if( err = snd_pcm_hw_params_malloc( &hwParams ) < 0 ) { + if( (err = snd_pcm_hw_params_malloc( &hwParams )) < 0 ) { _debugAlsa(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err)); return false; } - if( err = snd_pcm_hw_params_any( _PlaybackHandle,hwParams) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_access( _PlaybackHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); + if(( err = snd_pcm_hw_params_any( _PlaybackHandle,hwParams)) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); + if(( err = snd_pcm_hw_params_set_access( _PlaybackHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); //if( err = snd_pcm_hw_params_set_access( _PlaybackHandle, hwParams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_format( _PlaybackHandle, hwParams, SND_PCM_FORMAT_S16_LE) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_rate( _PlaybackHandle, hwParams, rate_out, dir) < 0) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_channels( _PlaybackHandle, hwParams, 1) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_buffer_time_near( _PlaybackHandle, hwParams, &buffer_time , &dir) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_period_time_near( _PlaybackHandle, hwParams, &period_time , &dir) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_period_size( hwParams, &_periodSize , &dir) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_out ) < 0) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params( _PlaybackHandle, hwParams ) < 0) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_format( _PlaybackHandle, hwParams, SND_PCM_FORMAT_S16_LE)) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_rate( _PlaybackHandle, hwParams, rate_out, dir)) < 0) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_channels( _PlaybackHandle, hwParams, 1)) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_buffer_time_near( _PlaybackHandle, hwParams, &buffer_time , &dir)) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_period_time_near( _PlaybackHandle, hwParams, &period_time , &dir)) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_period_size( hwParams, &_periodSize , &dir)) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_out )) < 0) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params( _PlaybackHandle, hwParams )) < 0) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); snd_pcm_hw_params_free( hwParams ); @@ -367,23 +373,23 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) snd_pcm_sw_params_malloc( &swparams ); snd_pcm_sw_params_current( _PlaybackHandle, swparams ); - if( err = snd_pcm_sw_params_set_start_threshold( _PlaybackHandle, swparams, period_size_out) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); + if((err = snd_pcm_sw_params_set_start_threshold( _PlaybackHandle, swparams, period_size_out)) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); snd_pcm_sw_params_get_start_threshold( swparams , &val); - _debug("Start threshold = %d\n" ,val); + _debug("Start threshold = %d\n" ,(int)val); //if( err = snd_pcm_sw_params_set_stop_threshold( _PlaybackHandle, swparams, buffer_size_out ) < 0 ) _debugAlsa(" Cannot set stop threshold (%s)\n", snd_strerror(err)); //snd_pcm_sw_params_get_stop_threshold( swparams , &val); //_debug("Stop threshold = %d\n" ,val); - if( err = snd_pcm_sw_params_set_avail_min( _PlaybackHandle, swparams, period_size_out) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); - if( err = snd_pcm_sw_params_set_xfer_align( _PlaybackHandle, swparams, 1) < 0) _debugAlsa(" Cannot set xfer align (%s)\n" , snd_strerror(err)); + if((err = snd_pcm_sw_params_set_avail_min( _PlaybackHandle, swparams, period_size_out)) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); + if((err = snd_pcm_sw_params_set_xfer_align( _PlaybackHandle, swparams, 1)) < 0) _debugAlsa(" Cannot set xfer align (%s)\n" , snd_strerror(err)); snd_pcm_sw_params_get_avail_min( swparams , &val); - _debug("Min available = %d\n" ,val); + _debug("Min available = %d\n" ,(int)val); //if( err = snd_pcm_sw_params_set_silence_threshold( _PlaybackHandle, swparams, period_size_out) < 0) _debugAlsa(" Cannot set silence threshold (%s)\n" , snd_strerror(err)); //snd_pcm_sw_params_get_silence_threshold( swparams , &val); // _debug("Silence threshold = %d\n" ,val); - if( err = snd_pcm_sw_params( _PlaybackHandle, swparams ) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); + if(( err = snd_pcm_sw_params( _PlaybackHandle, swparams )) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); snd_pcm_sw_params_free( swparams ); - if ( err = snd_async_add_pcm_handler( &_AsyncHandler, _PlaybackHandle , AlsaCallBack, this ) < 0) _debugAlsa(" Unable to install the async callback handler (%s)\n", snd_strerror(err)); + if (( err = snd_async_add_pcm_handler( &_AsyncHandler, _PlaybackHandle , AlsaCallBack, this ) < 0)) _debugAlsa(" Unable to install the async callback handler (%s)\n", snd_strerror(err)); deviceClosed = false; } //fillHWBuffer(); @@ -421,8 +427,8 @@ AlsaLayer::write(void* buffer, int length) break; } - if( err >=0 && err < frames ) - _debugAlsa("Short write : %d out of %d\n", err , frames); + if( ( err >=0 ) && ( err < (int)frames ) ) + _debugAlsa("Short write : %d out of %d\n", err , (int)frames); return ( err > 0 )? err : 0 ; } @@ -439,7 +445,7 @@ AlsaLayer::read( void* buffer, int toCopy) snd_pcm_start( _CaptureHandle ); } snd_pcm_uframes_t frames = snd_pcm_bytes_to_frames( _CaptureHandle, toCopy ); - if( err = snd_pcm_mmap_readi( _CaptureHandle, buffer, frames) < 0 ) { + if(( err = snd_pcm_mmap_readi( _CaptureHandle, buffer, frames)) < 0 ) { switch(err){ case EPERM: _debugAlsa(" Capture EPERM (%s)\n", snd_strerror(err)); @@ -469,8 +475,12 @@ AlsaLayer::read( void* buffer, int toCopy) } int -AlsaLayer::putInCache( char code, void *buffer, int toCopy ) -{} +AlsaLayer::putInCache( char code UNUSED, + void *buffer UNUSED, + int toCopy UNUSED ) +{ + return 1; +} void AlsaLayer::handle_xrun_capture( void ) @@ -497,7 +507,7 @@ AlsaLayer::handle_xrun_playback( void ) snd_pcm_status_t* status; snd_pcm_status_alloca( &status ); - if( state = snd_pcm_status( _PlaybackHandle, status ) < 0 ) _debugAlsa(" Error: Cannot get playback handle status (%s)\n" , snd_strerror( state ) ); + if( (state = snd_pcm_status( _PlaybackHandle, status )) < 0 ) _debugAlsa(" Error: Cannot get playback handle status (%s)\n" , snd_strerror( state ) ); else { state = snd_pcm_status_get_state( status ); @@ -541,7 +551,6 @@ AlsaLayer::getSoundCardsInfo( int stream ) snd_pcm_info_alloca( &pcminfo ); int numCard = -1 ; - int err; std::string description; if(snd_card_next( &numCard ) < 0 || numCard < 0) @@ -624,7 +633,7 @@ AlsaLayer::soundCardIndexExist( int card , int stream ) int AlsaLayer::soundCardGetIndex( std::string description ) { - int i; + unsigned int i; for( i = 0 ; i < IDSoundCards.size() ; i++ ) { HwIDPair p = IDSoundCards[i]; diff --git a/src/audio/alsalayer.h b/src/audio/alsalayer.h index fb5def1fa6d4e8e81ebfad4e152dd1f876f08eb9..78a51988e9877093fecfb230cec6ff87389443e0 100644 --- a/src/audio/alsalayer.h +++ b/src/audio/alsalayer.h @@ -203,6 +203,12 @@ class AlsaLayer : public AudioLayer { void setPlaybackVolume( double volume ); private: + + // Copy Constructor + AlsaLayer(const AlsaLayer& rh); + + // Assignment Operator + AlsaLayer& operator=( const AlsaLayer& rh); /** * Drop the pending frames and close the capture device diff --git a/src/audio/audiodevice.cpp b/src/audio/audiodevice.cpp index a4672da846bd13b1b2e369824ae9d007fc73690a..f82ce075a2757dffef338decb534c39097c4be24 100644 --- a/src/audio/audiodevice.cpp +++ b/src/audio/audiodevice.cpp @@ -23,7 +23,7 @@ const double AudioDevice::DEFAULT_RATE = 8000.0; AudioDevice::AudioDevice(int id, const std::string& name) : - _id(id), _name(name) + _id(id), _name(name), _rate(DEFAULT_RATE) { _rate = DEFAULT_RATE; } diff --git a/src/audio/audiofile.cpp b/src/audio/audiofile.cpp index d06fe1745716920704ce83058ec37f1532b8f811..2224e3e8f6ee87606e46cd3a3839caed5649a3ee 100644 --- a/src/audio/audiofile.cpp +++ b/src/audio/audiofile.cpp @@ -27,10 +27,12 @@ #include <samplerate.h> AudioFile::AudioFile() - : AudioLoop() + : AudioLoop(), + _filename(), + _codec(NULL), + _start(false) + { - // could vary later ... - _start = false; } AudioFile::~AudioFile() @@ -45,7 +47,7 @@ AudioFile::loadFile(const std::string& filename, AudioCodec* codec , unsigned in // if the filename was already load, with the same samplerate // we do nothing - if (_filename == filename && _sampleRate == sampleRate) { + if ( strcmp(_filename.c_str(), filename.c_str()) == 0 && _sampleRate == (int)sampleRate) { return true; } else { // reset to 0 @@ -87,7 +89,7 @@ AudioFile::loadFile(const std::string& filename, AudioCodec* codec , unsigned in // expandedsize is the number of bytes, not the number of int // expandedsize should be exactly two time more, else failed int16 monoBuffer[length]; - unsigned int expandedsize = _codec->codecDecode (monoBuffer, (unsigned char *) fileBuffer, length); + int expandedsize = (int)_codec->codecDecode (monoBuffer, (unsigned char *) fileBuffer, length); if (expandedsize != length*2) { _debug("Audio file error on loading audio file!"); return false; diff --git a/src/audio/audiofile.h b/src/audio/audiofile.h index 1de076de13f992ee77ebf2112a51fa5b0a3548be..a016289ed6989d0d533d5b865e2d9c7dde6bed2b 100644 --- a/src/audio/audiofile.h +++ b/src/audio/audiofile.h @@ -45,6 +45,7 @@ public: */ ~AudioFile(); + /** * Load a sound file in memory * @param filename The absolute path to the file @@ -72,6 +73,12 @@ public: bool isStarted() { return _start; } private: + // Copy Constructor + AudioFile(const AudioFile& rh); + + // Assignment Operator + AudioFile& operator=( const AudioFile& rh); + /** The absolute path to the sound file */ std::string _filename; diff --git a/src/audio/audiolayer.h b/src/audio/audiolayer.h index 690542f5e08ddf0ba8eb006352289449c3ccd888..44a4d4d15f8c30c8644b48e42383c417d6a23ecf 100644 --- a/src/audio/audiolayer.h +++ b/src/audio/audiolayer.h @@ -46,22 +46,38 @@ */ class AudioLayer { + + private: + + //copy constructor + AudioLayer(const AudioLayer& rh); + + // assignment operator + AudioLayer& operator=(const AudioLayer& rh); + public: /** * Constructor * @param manager An instance of managerimpl */ AudioLayer( ManagerImpl* manager , int type ) - : _manager(manager) + : _layerType( type ) + , _manager(manager) , _urgentBuffer( SIZEBUF ) - , _layerType( type ) + , _talk ( false ) + , deviceClosed ( true ) + , _indexIn ( 0 ) + , _indexOut ( 0 ) + , _sampleRate ( 0 ) + , _frameSize ( 0 ) + , _inChannel( 1 ) + , _outChannel ( 1 ) + , _errorMessage ( 0 ) + , _mutex () { - _inChannel = 1; // don't put in stereo - _outChannel = 1; // don't put in stereo - - deviceClosed = true; } + /** * Destructor diff --git a/src/audio/audioloop.cpp b/src/audio/audioloop.cpp index 383d4aa72dc067a81076c0e2debdb2ad7ea93661..63bfefac4e8b17fd777ebaf2623602a3857566b2 100644 --- a/src/audio/audioloop.cpp +++ b/src/audio/audioloop.cpp @@ -23,12 +23,8 @@ #include "audioloop.h" #include <math.h> -AudioLoop::AudioLoop() +AudioLoop::AudioLoop():_buffer(0), _size(0), _pos(0), _sampleRate(0) { - _buffer = 0; - _pos = 0; - _size = 0; - _sampleRate = 0; } AudioLoop::~AudioLoop() diff --git a/src/audio/audioloop.h b/src/audio/audioloop.h index 1e950c2ac75a0e0a7fe3ee0b41a428cd700accbc..e5f7984100aa5534270cf7509477d9ed5fc85ac7 100644 --- a/src/audio/audioloop.h +++ b/src/audio/audioloop.h @@ -64,7 +64,6 @@ public: unsigned int getSize() { return _size; } - protected: /** The data buffer */ SFLDataFormat* _buffer; @@ -76,7 +75,15 @@ protected: int _pos; /** Sample rate */ - int _sampleRate; + int _sampleRate; + +private: + + // Copy Constructor + AudioLoop(const AudioLoop& rh); + + // Assignment Operator + AudioLoop& operator=( const AudioLoop& rh); }; #endif // __AUDIOLOOP_H__ diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index 2c7da7d7e29938a5dee72d21d79af4b908069300..c69828e9185c93da9ad594af72bba20d8d0b734d 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -42,9 +42,8 @@ //////////////////////////////////////////////////////////////////////////////// // AudioRtp //////////////////////////////////////////////////////////////////////////////// -AudioRtp::AudioRtp () +AudioRtp::AudioRtp() :_RTXThread(0), _symmetric(), _threadMutex() { - _RTXThread = 0; } AudioRtp::~AudioRtp (void) { @@ -94,12 +93,11 @@ AudioRtp::closeRtpSession () { //////////////////////////////////////////////////////////////////////////////// // AudioRtpRTX Class // //////////////////////////////////////////////////////////////////////////////// -AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym) +AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym) : time(new ost::Time()), _ca(sipcall), _sessionSend(NULL), _sessionRecv(NULL), _session(NULL), _start(), + _sym(sym), micData(NULL), micDataConverted(NULL), micDataEncoded(NULL), spkrDataDecoded(NULL), spkrDataConverted(NULL), + converter(NULL), _layerSampleRate(),_codecSampleRate(), _layerFrameSize(), _audiocodec(NULL) { setCancel(cancelDeferred); - time = new ost::Time(); - _ca = sipcall; - _sym = sym; // AudioRtpRTX should be close if we change sample rate // TODO: Change bind address according to user settings. // TODO: this should be the local ip not the external (router) IP @@ -324,7 +322,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) //buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes int nbInt16 = expandedSize / sizeof(int16); //nbInt16 represents the number of samples we just decoded - if (nbInt16 > max) { + if ((unsigned int)nbInt16 > max) { _debug("We have decoded an RTP packet larger than expected: %d VS %d. Cropping.\n", nbInt16, max); nbInt16=max; } diff --git a/src/audio/audiortp.h b/src/audio/audiortp.h index a0cb003bf35566a6251361edf0b0a3b5ef0a5ce5..030840f94ee3f19041e27914e6b633e737fd75f1 100644 --- a/src/audio/audiortp.h +++ b/src/audio/audiortp.h @@ -65,6 +65,13 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort { virtual void run (); private: + + // copy constructor + AudioRtpRTX(const AudioRtpRTX& rh); + + // assignment operator + AudioRtpRTX& operator=(const AudioRtpRTX& rh); + /** A SIP call */ SIPCall* _ca; @@ -169,6 +176,12 @@ class AudioRtp { void closeRtpSession( void ); private: + // copy constructor + AudioRtp(const AudioRtp& rh); + + // assignment operator + AudioRtp& operator=(const AudioRtp& rh); + /** The RTP thread */ AudioRtpRTX* _RTXThread; diff --git a/src/audio/audiostream.cpp b/src/audio/audiostream.cpp index 55478be095c268f2665fe8cb6b394e2414dd4a58..89c6b29b0203416e6870bc072bf14d10fca7d7d7 100644 --- a/src/audio/audiostream.cpp +++ b/src/audio/audiostream.cpp @@ -22,14 +22,12 @@ static pa_channel_map channel_map ; AudioStream::AudioStream( pa_context* context, int type, std::string desc, double vol ) + : _audiostream(NULL), _streamType(type), _streamDescription(desc), flag(PA_STREAM_AUTO_TIMING_UPDATE), sample_spec(), _volume() { - _streamType = type; - _streamDescription = desc; sample_spec.format = PA_SAMPLE_S16LE; sample_spec.rate = 44100; sample_spec.channels = 1; channel_map.channels = 1; - flag = PA_STREAM_AUTO_TIMING_UPDATE ; pa_cvolume_set( &_volume , 1 , PA_VOLUME_MUTED ) ; // * vol / 100 ; _audiostream = createStream( context ); @@ -76,7 +74,7 @@ AudioStream::stream_state_callback( pa_stream* s, void* user_data ) AudioStream::createStream( pa_context* c ) { pa_stream* s; - pa_cvolume cv; + //pa_cvolume cv; assert(pa_sample_spec_valid(&sample_spec)); assert(pa_channel_map_valid(&channel_map)); diff --git a/src/audio/audiostream.h b/src/audio/audiostream.h index 7645f2bd51c8c05127ccd82c4c4b07a38d0d084d..121b87ad9c70a4f5ef09c7865a9af2ac166c06d3 100644 --- a/src/audio/audiostream.h +++ b/src/audio/audiostream.h @@ -95,6 +95,13 @@ class AudioStream { pa_cvolume getVolume( void ) { return _volume; } private: + + // Copy Constructor + AudioStream(const AudioStream& rh); + + // Assignment Operator + AudioStream& operator=( const AudioStream& rh); + /** * Create the audio stream into the given context * @param c The pulseaudio context diff --git a/src/audio/codecDescriptor.cpp b/src/audio/codecDescriptor.cpp index ba6ca1e681b1219f2f61895335ac53766cb76a7a..6dc3ead7f84e16b25f75abb406cf816cd044eff9 100644 --- a/src/audio/codecDescriptor.cpp +++ b/src/audio/codecDescriptor.cpp @@ -24,7 +24,7 @@ #include "codecDescriptor.h" -CodecDescriptor::CodecDescriptor() +CodecDescriptor::CodecDescriptor() : _CodecsMap(), _codecOrder(), _Cache(), _nbCodecs(), _CodecInMemory() { } @@ -36,7 +36,7 @@ CodecDescriptor::~CodecDescriptor() CodecDescriptor::deleteHandlePointer( void ) { int i; - for( i = 0 ; i < _CodecInMemory.size() ; i++) + for( i = 0 ; (unsigned int)i < _CodecInMemory.size() ; i++) { unloadCodec( _CodecInMemory[i] ); } @@ -97,7 +97,7 @@ CodecDescriptor::getCodec(AudioCodecType payload) CodecDescriptor::isActive(AudioCodecType payload) { int i; - for(i=0 ; i < _codecOrder.size() ; i++) + for(i=0 ; (unsigned int)i < _codecOrder.size() ; i++) { if(_codecOrder[i] == payload) return true; @@ -106,12 +106,12 @@ CodecDescriptor::isActive(AudioCodecType payload) } void -CodecDescriptor::removeCodec(AudioCodecType payload) +CodecDescriptor::removeCodec(AudioCodecType payload UNUSED) { } void -CodecDescriptor::addCodec(AudioCodecType payload) +CodecDescriptor::addCodec(AudioCodecType payload UNUSED) { } @@ -164,7 +164,7 @@ CodecDescriptor::saveActiveCodecs(const std::vector<std::string>& list) int i=0; int payload; size_t size = list.size(); - while( i < size ) + while( (unsigned int)i < size ) { payload = std::atoi(list[i].data()); if( isCodecLoaded( payload ) ) { @@ -188,7 +188,7 @@ CodecDescriptor::scanCodecDirectory( void ) dirToScan.push_back(homeDir); dirToScan.push_back(libDir); - for( i = 0 ; i < dirToScan.size() ; i++ ) + for( i = 0 ; (unsigned int)i < dirToScan.size() ; i++ ) { std::string dirStr = dirToScan[i]; _debug("Scanning %s to find audio codecs....\n", dirStr.c_str()); @@ -196,7 +196,7 @@ CodecDescriptor::scanCodecDirectory( void ) AudioCodec* audioCodec; if( dir ){ dirent *dirStruct; - while( dirStruct = readdir( dir )) { + while( (dirStruct = readdir( dir )) ) { tmp = dirStruct -> d_name ; if( tmp == CURRENT_DIR || tmp == PARENT_DIR){} else{ @@ -241,7 +241,6 @@ CodecDescriptor::unloadCodec( CodecHandlePointer p ) { // _debug("Unload codec %s\n", p.first->getCodecName().c_str()); using std::cerr; - int i; destroy_t* destroyCodec = (destroy_t*)dlsym( p.second , "destroy"); if(dlerror()) cerr << dlerror() << '\n'; @@ -311,7 +310,7 @@ CodecDescriptor::seemsValid( std::string lib) CodecDescriptor::alreadyInCache( std::string lib ) { int i; - for( i = 0 ; i < _Cache.size() ; i++ ) + for( i = 0 ; (unsigned int)i < _Cache.size() ; i++ ) { if( _Cache[i] == lib ){ return true;} @@ -322,7 +321,6 @@ CodecDescriptor::alreadyInCache( std::string lib ) bool CodecDescriptor::isCodecLoaded( int payload ) { - int i; CodecsMap::iterator iter = _CodecsMap.begin(); while( iter != _CodecsMap.end()) { diff --git a/src/audio/codecs/audiocodec.h b/src/audio/codecs/audiocodec.h index 378e52a5e757b353fd70d717b23fd26205055692..3b7101a1967cdf3ba2c264ad53c8b92e54c0a394 100644 --- a/src/audio/codecs/audiocodec.h +++ b/src/audio/codecs/audiocodec.h @@ -28,13 +28,15 @@ private: public: AudioCodec(int payload, const std::string &codecName) - : _codecName(codecName) { - _payload = payload; - _clockRate = 8000; // default - _channel = 1; // default + : _codecName(codecName), _clockRate(8000), _channel(1), _bitrate(0.0),_bandwidth(0),_payload(payload), _hasDynamicPayload(false),_state(true) { + + _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; +} - _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; - _state = true; + AudioCodec( const AudioCodec& codec ) + : _codecName(codec._codecName), _clockRate(codec._clockRate), _channel(codec._channel), _bitrate(codec._bitrate),_bandwidth(codec._bandwidth),_payload(codec._payload), _hasDynamicPayload(false),_state(true) { + + _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; } virtual ~AudioCodec() { diff --git a/src/audio/codecs/gsmcodec.cpp b/src/audio/codecs/gsmcodec.cpp index cf0f3bdf1448e3e630578082b995645f05c9b572..4fc94e30ed3a62e5ad951f9183be3a24aabc7a96 100644 --- a/src/audio/codecs/gsmcodec.cpp +++ b/src/audio/codecs/gsmcodec.cpp @@ -30,7 +30,7 @@ extern "C"{ class Gsm : public AudioCodec { public: // _payload should be 3 - Gsm (int payload=3): AudioCodec(payload, "GSM"){ + Gsm (int payload=3): AudioCodec(payload, "GSM"), _decode_gsmhandle(NULL), _encode_gsmhandle(NULL){ _clockRate = 8000; _channel = 1; _bitrate = 13.3; @@ -42,6 +42,10 @@ public: printf("AudioCodec: ERROR: encode_gsm_create\n"); } + Gsm( const Gsm& ); + + Gsm& operator=( const Gsm& ); + virtual ~Gsm (void){ gsm_destroy(_decode_gsmhandle); gsm_destroy(_encode_gsmhandle); diff --git a/src/audio/codecs/speexcodec.cpp b/src/audio/codecs/speexcodec.cpp index eed9b1344c2989a09d6c5244e86027eadeb31bd0..d6bfdb340107d2f219cb0191c44d256ce3fc1822 100644 --- a/src/audio/codecs/speexcodec.cpp +++ b/src/audio/codecs/speexcodec.cpp @@ -25,7 +25,13 @@ class Speex : public AudioCodec{ public: Speex(int payload=0) - : AudioCodec(payload, "speex") + : AudioCodec(payload, "speex"), + _speexModePtr(NULL), + _speex_dec_bits(), + _speex_enc_bits(), + _speex_dec_state(), + _speex_enc_state(), + _speex_frame_size() { _clockRate = 8000; _channel = 1; @@ -34,6 +40,9 @@ public: initSpeex(); } + Speex( const Speex& ); + Speex& operator=(const Speex&); + void initSpeex() { /* if (_clockRate < 16000 ) { diff --git a/src/audio/dtmf.cpp b/src/audio/dtmf.cpp index faabf1d69aad7fe79369b669e157756066534d15..c6ba907aae2cd16c24d38b581fd05318c25a8fd7 100644 --- a/src/audio/dtmf.cpp +++ b/src/audio/dtmf.cpp @@ -24,10 +24,8 @@ #include "dtmf.h" DTMF::DTMF (unsigned int sampleRate) -: dtmfgenerator(sampleRate) +: currentTone(0), newTone(0), dtmfgenerator(sampleRate) { - currentTone = 0; - newTone = 0; } DTMF::~DTMF (void) diff --git a/src/audio/dtmfgenerator.cpp b/src/audio/dtmfgenerator.cpp index 749b18cc27b1034bbb0de276e6b8c72a6785beb3..f35f1e50ace125f943a921ba25d0068dccd3214a 100644 --- a/src/audio/dtmfgenerator.cpp +++ b/src/audio/dtmfgenerator.cpp @@ -51,9 +51,8 @@ const DTMFGenerator::DTMFTone DTMFGenerator::tones[NUM_TONES] = { }; -DTMFException::DTMFException(const char* _reason) throw() +DTMFException::DTMFException(const char* _reason) throw() : reason(_reason) { - reason = _reason; } @@ -61,7 +60,6 @@ DTMFException::~DTMFException() throw() { } - const char* DTMFException::what() const throw() { return reason; @@ -72,9 +70,8 @@ const char* DTMFException::what() const throw() /* * Initialize the generator */ -DTMFGenerator::DTMFGenerator(unsigned int sampleRate) : tone("", sampleRate) +DTMFGenerator::DTMFGenerator(unsigned int sampleRate) : state(), _sampleRate(sampleRate), tone("", sampleRate) { - _sampleRate = sampleRate; state.offset = 0; state.sample = 0; @@ -90,7 +87,6 @@ DTMFGenerator::~DTMFGenerator() { } } - /* * Get n samples of the signal of code code */ diff --git a/src/audio/dtmfgenerator.h b/src/audio/dtmfgenerator.h index 376d31ce82b6b93ec974127b4f1c2edb87f7c4e2..a4bed7498389af90048c89732ad78155f06aa9f7 100644 --- a/src/audio/dtmfgenerator.h +++ b/src/audio/dtmfgenerator.h @@ -39,6 +39,7 @@ class DTMFException : public std::exception { private: + /** Message */ const char* reason; public: @@ -52,7 +53,13 @@ class DTMFException : public std::exception * Destructor */ virtual ~DTMFException() throw(); +/* + // Copy Constructor + DTMFException(const DTMFException& rh) throw(); + // Assignment Operator + DTMFException& operator=( const DTMFException& rh) throw(); +*/ /** * @return const char* The error */ @@ -107,6 +114,13 @@ class DTMFGenerator */ ~DTMFGenerator(); + + // Copy Constructor + DTMFGenerator(const DTMFGenerator& rh); + + // Assignment Operator + DTMFGenerator& operator=( const DTMFGenerator& rh); + /* * Get n samples of the signal of code code * @param buffer a SFLDataFormat pointer to an allocated buffer @@ -124,6 +138,7 @@ class DTMFGenerator void getNextSamples(SFLDataFormat* buffer, size_t n) throw (DTMFException); private: + /** * Generate samples for a specific dtmf code * @param code The code diff --git a/src/audio/pulselayer.cpp b/src/audio/pulselayer.cpp index 41af80b5e1a25332d360de754f5f6b3da40e70cb..aeedc33a4badc4f508140493a826c27bee8209a3 100644 --- a/src/audio/pulselayer.cpp +++ b/src/audio/pulselayer.cpp @@ -22,10 +22,15 @@ int framesPerBuffer = 2048; PulseLayer::PulseLayer(ManagerImpl* manager) - : AudioLayer( manager , PULSEAUDIO ) + : AudioLayer( manager , PULSEAUDIO ) + , _mainSndRingBuffer( SIZEBUF ) , _urgentRingBuffer( SIZEBUF) - ,_mainSndRingBuffer( SIZEBUF ) - ,_micRingBuffer( SIZEBUF ) + , _micRingBuffer( SIZEBUF ) + , context(NULL) + , m(NULL) + , playback() + , record() + , cache() { _debug("Pulse audio constructor: Create context\n"); } @@ -53,7 +58,6 @@ PulseLayer::closeLayer( void ) PulseLayer::connectPulseAudioServer( void ) { pa_context_flags_t flag = PA_CONTEXT_NOAUTOSPAWN ; - int ret = 1; pa_threaded_mainloop_lock( m ); @@ -87,7 +91,6 @@ void PulseLayer::context_state_callback( pa_context* c, void* user_data ) _debug("Waiting....\n"); break; case PA_CONTEXT_READY: - pa_cvolume cv; pulse->createStreams( c ); _debug("Connection to PulseAudio server established\n"); break; @@ -127,7 +130,7 @@ PulseLayer::createStreams( pa_context* c ) } bool -PulseLayer::openDevice(int indexIn, int indexOut, int sampleRate, int frameSize , int stream, std::string plugin) +PulseLayer::openDevice(int indexIn UNUSED, int indexOut UNUSED, int sampleRate, int frameSize , int stream UNUSED, std::string plugin UNUSED) { _sampleRate = sampleRate; _frameSize = frameSize; @@ -148,6 +151,7 @@ PulseLayer::openDevice(int indexIn, int indexOut, int sampleRate, int frameSize connectPulseAudioServer(); _debug("Connection Done!! \n"); + return true; } void @@ -161,7 +165,7 @@ PulseLayer::closePlaybackStream( void ) } int -PulseLayer::playSamples(void* buffer, int toCopy, bool isTalking) +PulseLayer::playSamples(void* buffer, int toCopy, bool isTalking UNUSED) { int a = _mainSndRingBuffer.AvailForPut(); if ( a >= toCopy ) { @@ -245,16 +249,16 @@ PulseLayer::audioCallback ( pa_stream* s, size_t bytes, void* userdata ) } void -PulseLayer::underflow ( pa_stream* s, void* userdata ) +PulseLayer::underflow ( pa_stream* s UNUSED, void* userdata UNUSED ) { _debug("Buffer Underflow\n"); } void -PulseLayer::overflow ( pa_stream* s, void* userdata ) +PulseLayer::overflow ( pa_stream* s, void* userdata UNUSED ) { - PulseLayer* pulse = (PulseLayer*) userdata; + //PulseLayer* pulse = (PulseLayer*) userdata; pa_stream_drop( s ); pa_stream_trigger( s, NULL, NULL); } @@ -310,7 +314,7 @@ void PulseLayer::writeToSpeaker( void ) } if ( (tone=_manager->getTelephoneFile()) != 0 ) { toGet = framesPerBuffer; - toPlay = ( toGet * sizeof(SFLDataFormat)> framesPerBuffer )? framesPerBuffer : toGet * sizeof(SFLDataFormat) ; + toPlay = ( (int)(toGet * sizeof(SFLDataFormat)) > framesPerBuffer )? framesPerBuffer : toGet * sizeof(SFLDataFormat) ; out = (SFLDataFormat*)pa_xmalloc(toPlay); tone->getNext(out, toPlay/2 , 100); pa_stream_write( playback->pulseStream() , out , toPlay , pa_xfree, 0 , PA_SEEK_RELATIVE) ; @@ -350,14 +354,15 @@ void PulseLayer::readFromMic( void ) } int -PulseLayer::putInCache( char code, void *buffer, int toCopy ) +PulseLayer::putInCache( char code UNUSED, void *buffer UNUSED, int toCopy UNUSED ) { _debug("Put the DTMF in cache\n"); //pa_stream_write( cache->pulseStream() , buffer , toCopy , pa_xfree, 0 , PA_SEEK_RELATIVE); //pa_stream_finish_upload( cache->pulseStream() ); + return 1; } -static void retrieve_server_info(pa_context *c, const pa_server_info *i, void *userdata) +static void retrieve_server_info(pa_context *c UNUSED, const pa_server_info *i, void *userdata UNUSED) { _debug("Server Info: Process owner : %s\n" , i->user_name); _debug("\t\tServer name : %s - Server version = %s\n" , i->server_name, i->server_version); @@ -365,6 +370,7 @@ static void retrieve_server_info(pa_context *c, const pa_server_info *i, void *u _debug("\t\tDefault source name : %s\n" , i->default_source_name); } +/* static void retrieve_client_list(pa_context *c, const pa_client_info *i, int eol, void *userdata) { _debug("end of list = %i\n", eol); @@ -373,8 +379,9 @@ static void retrieve_client_list(pa_context *c, const pa_client_info *i, int eol _debug("\t\tOwner module : %i\n" , i->owner_module); _debug("\t\tDriver : %s\n" , i->driver); } +*/ -static void reduce_sink_list(pa_context *c, const pa_sink_input_info *i, int eol, void *userdata) +static void reduce_sink_list(pa_context *c UNUSED, const pa_sink_input_info *i, int eol, void *userdata) { PulseLayer* pulse = (PulseLayer*) userdata; AudioStream* s = pulse->getPlaybackStream(); @@ -389,10 +396,10 @@ static void reduce_sink_list(pa_context *c, const pa_sink_input_info *i, int eol } } -static void restore_sink_list(pa_context *c, const pa_sink_input_info *i, int eol, void *userdata) +static void restore_sink_list(pa_context *c UNUSED, const pa_sink_input_info *i, int eol, void *userdata) { PulseLayer* pulse = (PulseLayer*) userdata; - AudioStream* s = pulse->getPlaybackStream(); + //AudioStream* s = pulse->getPlaybackStream(); if( !eol ){ _debug("Sink Info: index : %i\n" , i->index); _debug("\t\tSink name : -%s-\n" , i->name); @@ -422,7 +429,7 @@ PulseLayer::serverinfo( void ) pa_context_get_server_info( context , retrieve_server_info , NULL ); } -static void on_success(pa_context *c, int success, void *userdata) +static void on_success(pa_context *c UNUSED, int success UNUSED, void *userdata UNUSED) { _debug("Operation successfull \n"); } diff --git a/src/audio/pulselayer.h b/src/audio/pulselayer.h index 122b267753edb7ebfd70adc3d8e53042377cf647..bcdf055163d978982dc3166ba221b3afc1e5403d 100644 --- a/src/audio/pulselayer.h +++ b/src/audio/pulselayer.h @@ -110,7 +110,7 @@ class PulseLayer : public AudioLayer { /** * UNUSED in pulseaudio layer */ - std::vector<std::string> getSoundCardsInfo( int stream ) { + std::vector<std::string> getSoundCardsInfo( int stream UNUSED ) { std::vector<std::string> tmp; return tmp; } @@ -118,12 +118,12 @@ class PulseLayer : public AudioLayer { /** * UNUSED in pulseaudio layer */ - bool soundCardIndexExist( int card , int stream ) { return true; } + bool soundCardIndexExist( int card UNUSED, int stream UNUSED ) { return true; } /** * UNUSED in pulseaudio layer */ - int soundCardGetIndex( std::string description ) { return 0;} + int soundCardGetIndex( std::string description UNUSED ) { return 0;} /** * UNUSED in pulseaudio layer @@ -173,6 +173,12 @@ class PulseLayer : public AudioLayer { void setPlaybackVolume( double volume ); private: + // Copy Constructor + PulseLayer(const PulseLayer& rh); + + // Assignment Operator + PulseLayer& operator=( const PulseLayer& rh); + /** * Drop the pending frames and close the capture device */ diff --git a/src/audio/ringbuffer.cpp b/src/audio/ringbuffer.cpp index a98519d8d3b4c8ea679fb8253d7aeed8f2d145e7..f56e8ec0e93e5f85ec0e59d8c1ba7235fcafa66f 100644 --- a/src/audio/ringbuffer.cpp +++ b/src/audio/ringbuffer.cpp @@ -30,19 +30,18 @@ #define MIN_BUFFER_SIZE 1280 // Create a ring buffer with 'size' bytes -RingBuffer::RingBuffer(int size) { - mBufferSize = (size > MIN_BUFFER_SIZE ? size : MIN_BUFFER_SIZE); - mStart = 0; - mEnd = 0; - mBuffer = new unsigned char[mBufferSize]; - assert (mBuffer != NULL); +RingBuffer::RingBuffer(int size): mStart( 0 ), mEnd( 0 ) + , mBufferSize( size > MIN_BUFFER_SIZE ? size : MIN_BUFFER_SIZE ) + , mBuffer (new unsigned char[mBufferSize]) +{ + assert (mBuffer != NULL); } // Free memory on object deletion RingBuffer::~RingBuffer() { delete[] mBuffer; mBuffer = NULL; } - + void RingBuffer::flush (void) { mStart = 0; diff --git a/src/audio/ringbuffer.h b/src/audio/ringbuffer.h index b6ae54473a8e3db2d8f44f83bb1fba48c4fba3a0..27db3e31b3deaa8a195c02e1c82a7f876f054418 100644 --- a/src/audio/ringbuffer.h +++ b/src/audio/ringbuffer.h @@ -38,6 +38,7 @@ class RingBuffer { */ ~RingBuffer(); + /** * Reset the counters to 0 */ @@ -92,6 +93,11 @@ class RingBuffer { void debug(); private: + // Copy Constructor + RingBuffer(const RingBuffer& rh); + + // Assignment operator + RingBuffer& operator=(const RingBuffer& rh); /** Pointer on the first data */ int mStart; diff --git a/src/audio/samplecache.cpp b/src/audio/samplecache.cpp index 2d15d82c64a682c892ddf003039bff5926a64fb8..7f73642506ed1b71e3b12187847d4e8910b62f9b 100644 --- a/src/audio/samplecache.cpp +++ b/src/audio/samplecache.cpp @@ -19,9 +19,9 @@ #include <samplecache.h> -SampleCache::SampleCache( pa_stream* s ) +SampleCache::SampleCache( pa_stream* s ):_stream(s) { - _stream = s ; + //_stream = s ; } SampleCache::~SampleCache() @@ -30,8 +30,9 @@ SampleCache::~SampleCache() } bool -SampleCache::uploadSample( SFLDataFormat* buffer , size_t size ) +SampleCache::uploadSample( SFLDataFormat* buffer UNUSED, size_t size UNUSED ) { //pa_stream_write( pulse->caching , buffer , size , pa_xfree, 0 , PA_SEEK_RELATIVE); //pa_stream_finish_upload( pulse->caching ); + return true; } diff --git a/src/audio/samplecache.h b/src/audio/samplecache.h index 655f791197134d2dddc60736e40d6ebd266de4d1..4c07d558b4e0b0f9c421376e0136a32462dc0f67 100644 --- a/src/audio/samplecache.h +++ b/src/audio/samplecache.h @@ -29,11 +29,18 @@ class SampleCache { SampleCache( pa_stream* stream ); ~SampleCache(); + bool uploadSample( SFLDataFormat* buffer, size_t size ); bool removeSample( ); bool isSampleCached( ); private: + // Copy Constructor + SampleCache(const SampleCache& rh); + + // Assignment Operator + SampleCache& operator=( const SampleCache& rh); + pa_stream* _stream; }; diff --git a/src/audio/tone.cpp b/src/audio/tone.cpp index d015abed7fd1f3b96248917007a33b4df486217f..646dae56a5c2d0dcac9c9cb835d07e2537c97f0d 100644 --- a/src/audio/tone.cpp +++ b/src/audio/tone.cpp @@ -26,9 +26,8 @@ #include "tone.h" #include <math.h> -Tone::Tone(const std::string& definition, unsigned int sampleRate) : AudioLoop() +Tone::Tone(const std::string& definition, unsigned int sampleRate) : AudioLoop(), _sampleRate(sampleRate) { - _sampleRate = sampleRate; genBuffer(definition); // allocate memory with definition parameter } diff --git a/src/audio/tonegenerator.cpp b/src/audio/tonegenerator.cpp index 37cfd1eaaab1def74be072e130876ce41b129873..e5a29cd078f231af539627d704f2f9e2a707de00 100644 --- a/src/audio/tonegenerator.cpp +++ b/src/audio/tonegenerator.cpp @@ -31,8 +31,8 @@ int AMPLITUDE = 32767; // ToneGenerator implementation /////////////////////////////////////////////////////////////////////////////// -ToneGenerator::ToneGenerator (unsigned int sampleRate) { - _sampleRate = sampleRate; +ToneGenerator::ToneGenerator (unsigned int sampleRate): sample(NULL), freq1(), freq2(), time(), totalbytes(), _sampleRate(sampleRate) +{ } ToneGenerator::~ToneGenerator (void) { diff --git a/src/audio/tonegenerator.h b/src/audio/tonegenerator.h index 062caebd518387c129a363a70702ce454331e764..8fae9ea29f034d1b1bcbfd91b8db38caa4e87bd2 100644 --- a/src/audio/tonegenerator.h +++ b/src/audio/tonegenerator.h @@ -63,6 +63,12 @@ class ToneGenerator { int totalbytes; private: + // Copy Constructor + ToneGenerator(const ToneGenerator& rh); + + // Assignment Operator + ToneGenerator& operator=( const ToneGenerator& rh); + /* * Initialisation of the supported tones according to the countries. */ diff --git a/src/audio/tonelist.cpp b/src/audio/tonelist.cpp index 2ffb068ce9ea0a42de6de930092a60c3cb897036..e3c739e3f5cd6bc265808d231a1a0ef925dd9f7b 100644 --- a/src/audio/tonelist.cpp +++ b/src/audio/tonelist.cpp @@ -21,11 +21,9 @@ */ #include "tonelist.h" -ToneList::ToneList() { - _nbTone = TONE_NBTONE; // could be dynamic - _nbCountry = TONE_NBCOUNTRY; // could be dynamic - - _defaultCountryId = ZID_NORTH_AMERICA; +ToneList::ToneList() : _nbTone( TONE_NBTONE ) , + _nbCountry( TONE_NBCOUNTRY ), + _defaultCountryId( ZID_NORTH_AMERICA ){ initToneDefinition(); } @@ -104,14 +102,16 @@ ToneList::getCountryId(const std::string& countryName) } } -TelephoneTone::TelephoneTone(const std::string& countryName, unsigned int sampleRate) { +TelephoneTone::TelephoneTone(const std::string& countryName, unsigned int sampleRate) : + _currentTone( Tone::TONE_NULL ), + _toneList() +{ ToneList::COUNTRYID countryId = _toneList.getCountryId(countryName); _tone[Tone::TONE_DIALTONE] = new Tone(_toneList.getDefinition(countryId, Tone::TONE_DIALTONE), sampleRate); _tone[Tone::TONE_BUSY] = new Tone(_toneList.getDefinition(countryId, Tone::TONE_BUSY), sampleRate); _tone[Tone::TONE_RINGTONE] = new Tone(_toneList.getDefinition(countryId, Tone::TONE_RINGTONE), sampleRate); _tone[Tone::TONE_CONGESTION] = new Tone(_toneList.getDefinition(countryId, Tone::TONE_CONGESTION), sampleRate); - _currentTone = Tone::TONE_NULL; } TelephoneTone::~TelephoneTone() diff --git a/src/audio/tonelist.h b/src/audio/tonelist.h index a381193c025b9d4cad54a4a527bbdc84c34397ed..849af15477a3d18e0d8f906bb324769fe7e32d4f 100644 --- a/src/audio/tonelist.h +++ b/src/audio/tonelist.h @@ -40,6 +40,7 @@ public: */ ~ToneList(); + /** Countries */ enum COUNTRYID { ZID_NORTH_AMERICA = 0, @@ -73,6 +74,13 @@ public: int getNbTone() { return _nbTone; } private: + + // Copy Constructor + ToneList(const ToneList& rh); + + // Assignment Operator + ToneList& operator=( const ToneList& rh); + void initToneDefinition(); std::string _toneZone[TONE_NBCOUNTRY][TONE_NBTONE]; int _nbTone; @@ -89,6 +97,7 @@ public: TelephoneTone(const std::string& countryName, unsigned int sampleRate); ~TelephoneTone(); + /** send TONE::ZT_TONE_NULL to stop the playing */ void setCurrentTone(Tone::TONEID toneId); @@ -102,6 +111,12 @@ public: bool shouldPlay(); private: + // Copy Constructor + TelephoneTone(const TelephoneTone& rh); + + // Assignment Operator + TelephoneTone& operator=( const TelephoneTone& rh); + Tone* _tone[TONE_NBTONE]; Tone::TONEID _currentTone; ToneList _toneList; diff --git a/src/call.cpp b/src/call.cpp index 7d27f026c80fe5b3a4d8eb18af73ef2451023ded..a29c60adfa092110ec1f2372d09e7f62ddc0c984 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -19,16 +19,23 @@ */ #include "call.h" -Call::Call(const CallID& id, Call::CallType type) : _id(id), _type(type), - _localIPAddress(""), - _remoteIPAddress("") +Call::Call(const CallID& id, Call::CallType type) + : _callMutex() + , _codecMap() + , _audioCodec() + , _audioStarted(false) + , _localIPAddress("") + , _localAudioPort(0) + , _localExternalAudioPort(0) + , _remoteIPAddress("") + , _remoteAudioPort(0) + , _id(id) + , _type(type) + , _connectionState(Call::Disconnected) + , _callState(Call::Inactive) + , _peerName() + , _peerNumber() { - _connectionState = Call::Disconnected; - _callState = Call::Inactive; - //_audioCodec = 0; - _localAudioPort = 0; - _localExternalAudioPort = 0; - _remoteAudioPort = 0; } diff --git a/src/config/config.cpp b/src/config/config.cpp index 4a7346986cc7c4a9ef61bc4e28cfcb3ce7c7fb62..700f70484e7cb918a11f8f6f90d5284b5ae68f44 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -25,7 +25,7 @@ namespace Conf { // ctor -ConfigTree::ConfigTree() +ConfigTree::ConfigTree():_sections() { } diff --git a/src/config/config.h b/src/config/config.h index 5bcb9aa216987771f491e44c88ca42012a125b13..e929426b5e29c394fc080dd1f1bfce876d949f35 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -73,7 +73,10 @@ namespace Conf { private: friend class ConfigTree; - ConfigTreeIterator(ConfigTree *configTree) : _tree(configTree) {} + ConfigTreeIterator(ConfigTree *configTree) : _tree(configTree), _endToken(), _iter(), _iterItem() {} + + ConfigTreeIterator(const Conf::ConfigTreeIterator&); + ConfigTreeIterator& operator=(const Conf::ConfigTreeIterator&); ConfigTree* _tree; TokenList _endToken; @@ -151,7 +154,7 @@ namespace Conf { class ConfigTreeItem { public: - ConfigTreeItem() : _defaultValue(""), _type("string") {} + ConfigTreeItem() : _name(""), _value(""), _defaultValue(""), _type("string") {} // defaultvalue = value ConfigTreeItem(const std::string& name, const std::string& value, const std::string& type) : _name(name), _value(value), diff --git a/src/dbus/callmanager.cpp b/src/dbus/callmanager.cpp index 6d447a5c2b13f8d9535a5f0a8d8e7f8332eea54b..31929f2983df4d2e8af68239fd678c0e4f63e143 100644 --- a/src/dbus/callmanager.cpp +++ b/src/dbus/callmanager.cpp @@ -114,7 +114,7 @@ CallManager::getVolume( const std::string& device ) } std::map< std::string, std::string > -CallManager::getCallDetails( const std::string& callID ) +CallManager::getCallDetails( const std::string& callID UNUSED ) { _debug("CallManager::getCallDetails received\n"); std::map<std::string, std::string> a; diff --git a/src/dbus/configurationmanager-glue.h b/src/dbus/configurationmanager-glue.h index 8061b8ede0f61d6c02331dbec0c11912dbc17574..292756cdb7e2c1c6b476b25432d1d56ac29322df 100644 --- a/src/dbus/configurationmanager-glue.h +++ b/src/dbus/configurationmanager-glue.h @@ -71,6 +71,8 @@ public: register_method(ConfigurationManager_adaptor, switchPopupMode, _switchPopupMode_stub); register_method(ConfigurationManager_adaptor, setPulseAppVolumeControl, _setPulseAppVolumeControl_stub); register_method(ConfigurationManager_adaptor, getPulseAppVolumeControl, _getPulseAppVolumeControl_stub); + register_method(ConfigurationManager_adaptor, setSipPort, _setSipPort_stub); + register_method(ConfigurationManager_adaptor, getSipPort, _getSipPort_stub); } ::DBus::IntrospectedInterface *const introspect() const @@ -326,6 +328,16 @@ public: { "state", "i", false }, { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument setSipPort_args[] = + { + { "port", "i", true }, + { 0, 0, 0 } + }; + static ::DBus::IntrospectedArgument getSipPort_args[] = + { + { "port", "i", false }, + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument parametersChanged_args[] = { { "list", "a{ss}", false }, @@ -393,6 +405,8 @@ public: { "switchPopupMode", switchPopupMode_args }, { "setPulseAppVolumeControl", setPulseAppVolumeControl_args }, { "getPulseAppVolumeControl", getPulseAppVolumeControl_args }, + { "setSipPort", setSipPort_args }, + { "getSipPort", getSipPort_args }, { 0, 0 } }; static ::DBus::IntrospectedMethod ConfigurationManager_adaptor_signals[] = @@ -478,6 +492,8 @@ public: virtual void switchPopupMode() = 0; virtual void setPulseAppVolumeControl() = 0; virtual int32_t getPulseAppVolumeControl() = 0; + virtual void setSipPort(const int32_t& port) = 0; + virtual int32_t getSipPort() = 0; public: @@ -992,6 +1008,25 @@ private: wi << argout1; return reply; } + ::DBus::Message _setSipPort_stub(const ::DBus::CallMessage &call) + { + ::DBus::MessageIter ri = call.reader(); + + int32_t argin1; ri >> argin1; + setSipPort(argin1); + ::DBus::ReturnMessage reply(call); + return reply; + } + ::DBus::Message _getSipPort_stub(const ::DBus::CallMessage &call) + { + ::DBus::MessageIter ri = call.reader(); + + int32_t argout1 = getSipPort(); + ::DBus::ReturnMessage reply(call); + ::DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; + } }; } } } diff --git a/src/dbus/configurationmanager-introspec.xml b/src/dbus/configurationmanager-introspec.xml index 624260b76321a161920d1b359bb8b0afc257be6b..df72d96e79c6ecf77b4c47ca27c2a4a90b94106c 100644 --- a/src/dbus/configurationmanager-introspec.xml +++ b/src/dbus/configurationmanager-introspec.xml @@ -210,6 +210,14 @@ <arg type="i" name="state" direction="out"/> </method> + <method name="setSipPort"> + <arg type="i" name="port" direction="in"/> + </method> + + <method name="getSipPort"> + <arg type="i" name="port" direction="out"/> + </method> + <!-- ///////////////////////////// --> <signal name="parametersChanged"> <arg type="a{ss}" name="list" direction="out"/> diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp index 67f12260b52276a27cd930cc708438a0faa6966a..547afded01e9912d0e65923bf0ce193ba8830cce 100644 --- a/src/dbus/configurationmanager.cpp +++ b/src/dbus/configurationmanager.cpp @@ -80,8 +80,9 @@ ConfigurationManager::getAccountList( ) std::vector< std::string > ConfigurationManager::getToneLocaleList( ) { + std::vector< std::string > ret; _debug("ConfigurationManager::getToneLocaleList received\n"); - + return ret; } @@ -89,7 +90,9 @@ ConfigurationManager::getToneLocaleList( ) std::string ConfigurationManager::getVersion( ) { + std::string ret(""); _debug("ConfigurationManager::getVersion received\n"); + return ret; } @@ -97,8 +100,9 @@ ConfigurationManager::getVersion( ) std::vector< std::string > ConfigurationManager::getRingtoneList( ) { + std::vector< std::string > ret; _debug("ConfigurationManager::getRingtoneList received\n"); - + return ret; } @@ -208,14 +212,17 @@ ConfigurationManager::getCurrentAudioOutputPlugin( void ) std::vector< std::string > ConfigurationManager::getPlaybackDeviceList( ) { + std::vector< std::string > ret; _debug("ConfigurationManager::getPlaybackDeviceList received\n"); - + return ret; } std::vector< std::string > ConfigurationManager::getRecordDeviceList( ) { + std::vector< std::string > ret; _debug("ConfigurationManager::getRecordDeviceList received\n"); + return ret; } @@ -375,3 +382,16 @@ ConfigurationManager::setPulseAppVolumeControl( void ) Manager::instance().setPulseAppVolumeControl(); } +int32_t +ConfigurationManager::getSipPort( void ) +{ + return Manager::instance().getSipPort(); +} + +void +ConfigurationManager::setSipPort( const int32_t& portNum ) +{ + _debug("Manager received setSipPort: %d\n", portNum); + Manager::instance().setSipPort(portNum); +} + diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index 3ff93f778e3681291906e55b99f4416feccaa566..86c6ee7dec89ae7352a8ea423ea401cfa4edab8f 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -95,6 +95,8 @@ public: void setMailNotify( void ); int32_t getPulseAppVolumeControl( void ); void setPulseAppVolumeControl( void ); + int32_t getSipPort( void ); + void setSipPort( const int32_t& portNum ); }; diff --git a/src/dbus/contactmanager.cpp b/src/dbus/contactmanager.cpp index ac7af8b1d0ffd230458c22e86f6a96dd703c767f..885585c40ec05bfdf682b9263a78abf9b9222032 100644 --- a/src/dbus/contactmanager.cpp +++ b/src/dbus/contactmanager.cpp @@ -23,25 +23,27 @@ const char* ContactManager::SERVER_PATH = "/org/sflphone/SFLphone/ContactManager"; std::map< std::string, std::string > -ContactManager::getContacts( const std::string& accountID ) +ContactManager::getContacts( const std::string& accountID UNUSED) { - // TODO + // TODO + std::map< std::string, std::string > ret; + return ret; } void -ContactManager::setContacts( const std::string& accountID, const std::map< std::string, std::string >& details ) +ContactManager::setContacts( const std::string& accountID UNUSED, const std::map< std::string UNUSED, std::string >& details UNUSED) { // TODO } void -ContactManager::setPresence( const std::string& accountID, const std::string& presence, const std::string& additionalInfo ) +ContactManager::setPresence( const std::string& accountID UNUSED, const std::string& presence UNUSED, const std::string& additionalInfo UNUSED) { // TODO } void -ContactManager::setContactPresence( const std::string& accountID, const std::string& presence, const std::string& additionalInfo ) +ContactManager::setContactPresence( const std::string& accountID UNUSED, const std::string& presence UNUSED, const std::string& additionalInfo UNUSED) { // TODO } diff --git a/src/dbus/instance.cpp b/src/dbus/instance.cpp index 4eca2b269ecee9998444db87c5b0d19c4a33df17..0b4ace62a55e9d70271f5a0505cce61dacb19087 100644 --- a/src/dbus/instance.cpp +++ b/src/dbus/instance.cpp @@ -29,8 +29,8 @@ Instance::Instance( DBus::Connection& connection ) } void -Instance::Register( const int32_t& pid, - const std::string& name ) +Instance::Register( const int32_t& pid UNUSED, + const std::string& name UNUSED) { _debug("Instance::register received\n"); count++; @@ -38,7 +38,7 @@ Instance::Register( const int32_t& pid, void -Instance::Unregister( const int32_t& pid ) +Instance::Unregister( const int32_t& pid UNUSED) { _debug("Instance::unregister received\n"); count --; diff --git a/src/eventthread.cpp b/src/eventthread.cpp index aabdd755bad9d6b1452e806ff0f86c297dbc8f4a..1ec4363470bf3533683541a56f9dcfbcdc43eddb 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -21,11 +21,10 @@ #include "eventthread.h" #include "voiplink.h" -EventThread::EventThread (VoIPLink* link) : Thread () + +EventThread::EventThread (VoIPLink* link) : Thread (), _linkthread(link), stopIt(false) { - _linkthread = link; setCancel(cancelDeferred); - stopIt = false; } EventThread::~EventThread (void) diff --git a/src/eventthread.h b/src/eventthread.h index 21f43a897ac87fc9c639d7c9089acd98bff49a93..8772c72043fec8d719b7c50aecf706dbdb241396 100644 --- a/src/eventthread.h +++ b/src/eventthread.h @@ -37,14 +37,16 @@ public: */ EventThread (VoIPLink*); ~EventThread (void); - virtual void run (); virtual void stop(); virtual void startLoop(); bool isStopped(); private: - /** VoIPLink is the object being called by getEvents() method */ + EventThread(const EventThread& rh); // copy constructor + EventThread& operator=(const EventThread& rh); // assignment operator + + /** VoIPLink is the object being called by getEvents() method */ VoIPLink* _linkthread; bool stopIt; }; diff --git a/src/global.h b/src/global.h index afdbdaf05d53919b587b39a8569b9a41b8fbdf55..b68c72671df938dedfe1ad271fe8c83f1f8f040c 100644 --- a/src/global.h +++ b/src/global.h @@ -126,4 +126,6 @@ typedef short int16; #define PULSEAUDIO 1 #define CHECK_INTERFACE( layer , api ) (layer == api) +#define UNUSED __attribute__((__unused__)) + #endif // __GLOBAL_H__ diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index ce32f5a3d7f9b805fe052405e7d5673ec1558e09..c2dd947035948a02b73df1965921eb6b4b98be71 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -26,7 +26,7 @@ #include <cstdlib> #include <iostream> #include <fstream> - +#include <sstream> #include <sys/types.h> // mkdir(2) #include <sys/stat.h> // mkdir(2) @@ -37,16 +37,20 @@ #include "manager.h" #include "account.h" +#include "sipaccount.h" #include "audio/audiolayer.h" #include "audio/alsalayer.h" #include "audio/pulselayer.h" #include "audio/tonelist.h" #include "accountcreator.h" // create new account -#include "voiplink.h" +#include "sipvoiplink.h" + +#include "useragent.h" #include "user_cfg.h" +#define DEFAULT_SIP_PORT 5060 #ifdef USE_ZEROCONF #include "zeroconf/DNSService.h" @@ -58,31 +62,52 @@ #define fill_config_int(name, value) \ (_config.addConfigTreeItem(section, Conf::ConfigTreeItem(std::string(name), std::string(value), type_int))) -ManagerImpl::ManagerImpl (void) +ManagerImpl::ManagerImpl (void) + : _hasTriedToRegister(false) + , _config() + , _currentCallId2() + , _currentCallMutex() + , _codecBuilder(NULL) + , _audiodriver(NULL) + , _dtmfKey(NULL) + , _codecDescriptorMap() + , _toneMutex() + , _telephoneTone(NULL) + , _audiofile() + , _spkr_volume(0) + , _mic_volume(0) + , _mutex() + , _dbus(NULL) + , _waitingCall() + , _waitingCallMutex() + , _nbIncomingWaitingCall(0) + , _path("") + , _exist(0) + , _setupLoaded(false) + , _firewallPort() + , _firewallAddr("") + , _hasZeroconf(false) + , _callAccountMap() + , _callAccountMapMutex() + , _accountMap() + , _userAgent(NULL) + , _userAgentInitlized(false) + , _sipThreadStop() + { - // Init private variables - _hasZeroconf = false; + /* Init private variables + setup: _path, _exist, _setupLoaded , _dbus + sound: _audiodriver, _dtmfKey, + _spkr_volume,_mic_volume = 0; // Initialize after by init() -> initVolume() + Call: _nbIncomingWaitingCall, _hasTriedToRegister + SIP Link: _userAgent, _userAgentInitlized + */ + #ifdef USE_ZEROCONF _hasZeroconf = true; _DNSService = new DNSService(); #endif - // setup - _path = ""; - _exist = 0; - _setupLoaded = false; - _dbus = NULL; - - // sound - _audiodriver = NULL; - _dtmfKey = 0; - _spkr_volume = 0; // Initialize after by init() -> initVolume() - _mic_volume = 0; // Initialize after by init() -> initVolume() - - // Call - _nbIncomingWaitingCall=0; - _hasTriedToRegister = false; - // initialize random generator for call id srand (time(NULL)); @@ -114,6 +139,12 @@ ManagerImpl::init() { // Load accounts, init map loadAccountMap(); + + //Initialize sip manager + if(_userAgentInitlized) { + _userAgent->sipCreate(); + _userAgent->sipInit(); + } initVolume(); @@ -144,6 +175,7 @@ ManagerImpl::init() // initRegisterAccounts was here, but we doing it after the gui loaded... // the stun detection is long, so it's a better idea to do it after getEvents initZeroconf(); + } void ManagerImpl::terminate() @@ -151,6 +183,12 @@ void ManagerImpl::terminate() saveConfig(); unloadAccountMap(); + + if(_userAgentInitlized) { + delete _userAgent; + _userAgent = NULL; + _userAgentInitlized = false; + } _debug("Unload DTMF Key\n"); delete _dtmfKey; @@ -229,6 +267,7 @@ ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const ManagerImpl::answerCall(const CallID& id) { stopTone(false); + _debug("Try to answer call: %s\n", id.data()); AccountID accountid = getAccountFromCall( id ); if (accountid == AccountNULL) { _debug("Answering Call: Call doesn't exists\n"); @@ -273,12 +312,14 @@ ManagerImpl::hangupCall(const CallID& id) } bool returnValue = getAccountLink(accountid)->hangup(id); + _debug("After voip link hungup!\n"); removeCallAccount(id); switchCall(""); if( getConfigInt( PREFERENCES , CONFIG_PA_VOLUME_CTRL ) ) _audiodriver->restorePulseAppsVolume(); + _debug("Before hungup return!\n"); return returnValue; } @@ -511,7 +552,7 @@ ManagerImpl::playDtmf(char code, bool isTalking) if( CHECK_INTERFACE( layer , PULSEAUDIO )) { // Cache the samples on the sound server - (PulseLayer*)audiolayer->putInCache( code, _buf , size * sizeof(SFLDataFormat) ); + // (PulseLayer*)audiolayer->putInCache( code, _buf , size * sizeof(SFLDataFormat) ); } delete[] _buf; _buf = 0; @@ -558,7 +599,7 @@ ManagerImpl::isWaitingCall(const CallID& id) { bool ManagerImpl::incomingCall(Call* call, const AccountID& accountId) { - _debug("Incoming call\n"); + _debug("Incoming call %s\n", call->getCallId().data()); associateCallToAccount(call->getCallId(), accountId); @@ -582,8 +623,9 @@ ManagerImpl::incomingCall(Call* call, const AccountID& accountId) from.append(number); from.append(">"); } + _dbus->getCallManager()->incomingCall(accountId, call->getCallId(), from); - + // Reduce volume of the other pulseaudio-connected audio applications if( getConfigInt( PREFERENCES , CONFIG_PA_VOLUME_CTRL ) ) _audiodriver->reducePulseAppsVolume(); @@ -672,9 +714,9 @@ ManagerImpl::callFailure(const CallID& id) //THREAD=VoIP void -ManagerImpl::startVoiceMessageNotification(const AccountID& accountId, const std::string& nb_msg) +ManagerImpl::startVoiceMessageNotification(const AccountID& accountId, int nb_msg) { - if (_dbus) _dbus->getCallManager()->voiceMailNotify(accountId, atoi(nb_msg.c_str()) ); + if (_dbus) _dbus->getCallManager()->voiceMailNotify(accountId, nb_msg) ; } //THREAD=VoIP @@ -690,7 +732,7 @@ ManagerImpl::registrationSucceed(const AccountID& accountid) //THREAD=VoIP void -ManagerImpl::unregistrationSucceed(const AccountID& accountid) +ManagerImpl::unregistrationSucceed(const AccountID& accountid UNUSED) { _debug("UNREGISTRATION SUCCEED\n"); if (_dbus) _dbus->getConfigurationManager()->accountsChanged(); @@ -785,6 +827,7 @@ ManagerImpl::stopTone(bool stopAudio=true) { ManagerImpl::playTone() { playATone(Tone::TONE_DIALTONE); + return true; } /** @@ -794,6 +837,7 @@ ManagerImpl::playTone() ManagerImpl::playToneWithMessage() { playATone(Tone::TONE_CONGESTION); + return true; } /** @@ -948,7 +992,7 @@ ManagerImpl::behindNat(const std::string& svr, int port) } // Firewall address - //_debug("STUN server: %s\n", svr.data()); + _debug("STUN server: %s\n", svr.data()); return getStunInfo(stunSvrAddr, port); } @@ -1026,6 +1070,7 @@ ManagerImpl::initConfigFile ( bool load_user_value ) fill_config_int(REGISTRATION_EXPIRE , DFT_EXPIRE_VALUE); fill_config_int(CONFIG_AUDIO , DFT_AUDIO_MANAGER); fill_config_int(CONFIG_PA_VOLUME_CTRL , YES_STR); + fill_config_int(CONFIG_SIP_PORT, DFT_SIP_PORT); // Loads config from ~/.sflphone/sflphonedrc or so.. if (createSettingsPath() == 1 && load_user_value) { @@ -1087,7 +1132,7 @@ ManagerImpl::setActiveCodecList(const std::vector< std::string >& list) std::string ManagerImpl::serialize(std::vector<std::string> v) { - int i; + unsigned int i; std::string res; for(i=0;i<v.size();i++) { @@ -1103,7 +1148,7 @@ ManagerImpl::getActiveCodecList( void ) _debug("Get Active codecs list\n"); std::vector< std::string > v; CodecOrder active = _codecDescriptorMap.getActiveCodecs(); - int i=0; + unsigned int i=0; size_t size = active.size(); while(i<size) { @@ -1224,7 +1269,7 @@ ManagerImpl::setInputAudioPlugin(const std::string& audioPlugin) void ManagerImpl::setOutputAudioPlugin(const std::string& audioPlugin) { - int layer = _audiodriver -> getLayerType(); + //int layer = _audiodriver -> getLayerType(); _debug("Set output audio plugin\n"); _audiodriver -> setErrorMessage( -1 ); _audiodriver -> openDevice( _audiodriver -> getIndexIn(), @@ -1255,7 +1300,7 @@ ManagerImpl::getAudioOutputDeviceList(void) void ManagerImpl::setAudioOutputDevice(const int index) { - int layer = _audiodriver -> getLayerType(); + //int layer = _audiodriver -> getLayerType(); _debug("Set audio output device: %i\n", index); _audiodriver -> setErrorMessage( -1 ); _audiodriver->openDevice(_audiodriver->getIndexIn(), @@ -1286,7 +1331,7 @@ ManagerImpl::getAudioInputDeviceList(void) void ManagerImpl::setAudioInputDevice(const int index) { - int layer = _audiodriver -> getLayerType(); + //int layer = _audiodriver -> getLayerType(); _debug("Set audio input device %i\n", index); _audiodriver -> setErrorMessage( -1 ); _audiodriver->openDevice(index, @@ -1752,7 +1797,7 @@ ManagerImpl::detachZeroconfEvents(Pattern::Observer& observer) * Main Thread */ bool -ManagerImpl::getCallStatus(const std::string& sequenceId) +ManagerImpl::getCallStatus(const std::string& sequenceId UNUSED) { if (!_dbus) { return false; } ost::MutexLock m(_callAccountMapMutex); @@ -2033,6 +2078,8 @@ ManagerImpl::setAccountDetails( const std::string& accountID, // Update account details if (_dbus) _dbus->getConfigurationManager()->accountsChanged(); + + //restartPjsip(); } void @@ -2068,7 +2115,24 @@ ManagerImpl::addAccount(const std::map< std::string, std::string >& details) /** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */ if (accountType == "SIP") { - newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID); + if(!_userAgentInitlized) { + // Initialize the SIP Manager + _userAgent = new UserAgent(); + _userAgent->setSipPort(Manager::instance().getConfigInt(PREFERENCES , CONFIG_SIP_PORT)); + } + + newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID); + + // Determine whether to use stun for the current account or not + if((*details.find(SIP_USE_STUN)).second == "TRUE") { + _userAgent->setStunServer((*details.find(SIP_STUN_SERVER)).second.data()); + } + + if(!_userAgentInitlized) { + _userAgentInitlized = true; + _userAgent->sipCreate(); + _userAgent->sipInit(); + } } else if (accountType == "IAX") { newAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, newAccountID); @@ -2083,6 +2147,8 @@ ManagerImpl::addAccount(const std::map< std::string, std::string >& details) saveConfig(); if (_dbus) _dbus->getConfigurationManager()->accountsChanged(); + + //restartPjsip(); } void @@ -2113,6 +2179,7 @@ ManagerImpl::associateCallToAccount(const CallID& callID, const AccountID& accou if ( accountExists(accountID) ) { // account id exist in AccountMap ost::MutexLock m(_callAccountMapMutex); _callAccountMap[callID] = accountID; + _debug("Associate Call %s with Account %s\n", callID.data(), accountID.data()); return true; } else { return false; @@ -2160,6 +2227,20 @@ ManagerImpl::getNewCallID() return random_id.str(); } + void +ManagerImpl::restartPjsip() +{ + if ( _userAgentInitlized ){ + unregisterCurSIPAccounts(); + _userAgent->sipDestory(); + //_userAgent->setSipPort(Manager::instance().getConfigInt(PREFERENCES , CONFIG_SIP_PORT)); + + _userAgent->sipCreate(); + _userAgent->sipInit(); + registerCurSIPAccounts(); + } +} + short ManagerImpl::loadAccountMap() { @@ -2168,18 +2249,42 @@ ManagerImpl::loadAccountMap() TokenList sections = _config.getSections(); std::string accountType; Account* tmpAccount; + std::string port; + unsigned int iPort; TokenList::iterator iter = sections.begin(); while(iter != sections.end()) { + _debug("***************** In Load account: into while\n"); // Check if it starts with "Account:" (SIP and IAX pour le moment) - if (iter->find("Account:") == -1) { + if ((int)(iter->find("Account:")) == -1) { iter++; continue; } accountType = getConfigString(*iter, CONFIG_ACCOUNT_TYPE); if (accountType == "SIP") { + if(!_userAgentInitlized) { + // Initialize the SIP Manager + _userAgent = new UserAgent(); + _userAgentInitlized = true; + _userAgent->setSipPort(Manager::instance().getConfigInt(PREFERENCES , CONFIG_SIP_PORT)); + } + tmpAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, *iter); + + // Determine whether to use stun for the current account or not + int useStun = Manager::instance().getConfigInt(tmpAccount->getAccountID(),SIP_USE_STUN); + + if(useStun == 1) { + _userAgent->setStunServer(Manager::instance().getConfigString(tmpAccount->getAccountID(), SIP_STUN_SERVER).data()); + } + + /*// Set registration port for all accounts, The last non-5060 port will be recorded in _userAgent. + port = Manager::instance().getConfigString(tmpAccount->getAccountID(), SIP_PORT); + std::istringstream is(port); + is >> iPort; + if (iPort != DEFAULT_SIP_PORT) + _userAgent->setRegPort(iPort); */ } else if (accountType == "IAX") { tmpAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, *iter); @@ -2235,6 +2340,34 @@ ManagerImpl::getAccount(const AccountID& accountID) return iter->second; } +AccountID +ManagerImpl::getAccountIdFromNameAndServer(const std::string& userName, const std::string& server) +{ + AccountMap::iterator iter; + SIPAccount *account; + + // Try to find the account id from username and server name by full match + for(iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) { + account = dynamic_cast<SIPAccount *>(iter->second); + if (account != NULL){ + if(account->fullMatch(userName, server)) + return iter->first; + } + } + + // We failed! Then only match the username + for(iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) { + account = dynamic_cast<SIPAccount *>(iter->second); + if ( account != NULL ) { + if(account->userMatch(userName)) + return iter->first; + } + } + + // Failed again! return AccountNULL + return AccountNULL; +} + VoIPLink* ManagerImpl::getAccountLink(const AccountID& accountID) { @@ -2245,6 +2378,70 @@ ManagerImpl::getAccountLink(const AccountID& accountID) return 0; } +pjsip_regc +*getSipRegcFromID(const AccountID& id UNUSED) +{ + /*SIPAccount *tmp = dynamic_cast<SIPAccount *>getAccount(id); + if(tmp != NULL) + return tmp->getSipRegc(); + else*/ + return NULL; +} + + +/** + * Return the instance of sip manager + */ +UserAgent *ManagerImpl::getUserAgent() +{ + return _userAgent; +} + +int +ManagerImpl::getSipPort() +{ + return _userAgent->getSipPort(); +} + +void +ManagerImpl::setSipPort(int portNum) +{ + if(portNum != _userAgent->getSipPort()) { + _userAgent->setSipPort(portNum); + restartPjsip(); + setConfig( PREFERENCES , CONFIG_SIP_PORT , portNum ); + } +} + +void ManagerImpl::unregisterCurSIPAccounts() +{ + AccountMap::iterator iter = _accountMap.begin(); + while( iter != _accountMap.end() ) { + if ( iter->second) { + std::string p = Manager::instance().getConfigString( iter->first , CONFIG_ACCOUNT_TYPE ); + if ( iter->second->isEnabled() && p == "SIP") { + // NOW + iter->second->unregisterVoIPLink(); + } + } + iter++; + } +} + +void ManagerImpl::registerCurSIPAccounts() +{ + AccountMap::iterator iter = _accountMap.begin(); + while( iter != _accountMap.end() ) { + if ( iter->second) { + std::string p = Manager::instance().getConfigString( iter->first , CONFIG_ACCOUNT_TYPE ); + if ( iter->second->isEnabled() && p == "SIP") { + // NOW + iter->second->registerVoIPLink(); + } + } + iter++; + } +} #ifdef TEST /** diff --git a/src/managerimpl.h b/src/managerimpl.h index 55afeafa5eca837fcd212299b8960969c2d32fa5..6eb1bea63e9be004178e882086abae75c678c75e 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -47,6 +47,7 @@ class CodecDescriptor; class GuiFramework; class TelephoneTone; class VoIPLink; +class UserAgent; #ifdef USE_ZEROCONF class DNSService; @@ -259,7 +260,7 @@ class ManagerImpl { * @param accountId The account identifier * @param nb_msg The number of messages */ - void startVoiceMessageNotification(const AccountID& accountId, const std::string& nb_msg); + void startVoiceMessageNotification(const AccountID& accountId, int nb_msg); /** * Notify the user that registration succeeded @@ -810,7 +811,23 @@ class ManagerImpl { */ bool isCurrentCall(const CallID& callId); + /** + * Restart PJSIP + * @param void + * @return void + */ + void restartPjsip(); + + int getSipPort(); + + void setSipPort(int port); + + void unregisterCurSIPAccounts(); + + void registerCurSIPAccounts(); + private: + /** * Create .PROGNAME directory in home user and create * configuration tree from the settings file if this file exists. @@ -964,13 +981,6 @@ class ManagerImpl { */ bool associateCallToAccount(const CallID& callID, const AccountID& accountID); - /** Return the AccountID from a CallID - * Protected by mutex - * @param callID the CallID in the list - * @return AccountID The accountID associated or "" if the callID is not found - */ - AccountID getAccountFromCall(const CallID& callID); - /** Remove a CallID/AccountID association * Protected by mutex * @param callID the CallID to remove @@ -1000,6 +1010,7 @@ class ManagerImpl { */ bool accountExists(const AccountID& accountID); +public: /** * Get an account pointer * @param accountID account ID to get @@ -1007,6 +1018,13 @@ class ManagerImpl { */ Account* getAccount(const AccountID& accountID); + /** Return the AccountID from a CallID + * Protected by mutex + * @param callID the CallID in the list + * @return AccountID The accountID associated or "" if the callID is not found + */ + AccountID getAccountFromCall(const CallID& callID); + /** * Get the voip link from the account pointer * @param accountID Account ID to get @@ -1014,12 +1032,42 @@ class ManagerImpl { */ VoIPLink* getAccountLink(const AccountID& accountID); + AccountID getAccountIdFromNameAndServer(const std::string& userName, const std::string& server); + +private: + + // Copy Constructor + ManagerImpl(const ManagerImpl& rh); + + // Assignment Operator + ManagerImpl& operator=( const ManagerImpl& rh); + + /** + * The UserAgent provides sip operation facilities for all sip accounts + */ + UserAgent *_userAgent; + + /** Whether the _UserAgent has been initialized */ + bool _userAgentInitlized; + + bool _sipThreadStop; + #ifdef TEST bool testCallAccountMap(); bool testAccountMap(); #endif friend class ConfigurationTest; + +public: + /** + * Retuun the instance of sip manager + */ + UserAgent *getUserAgent(); + + void setSipThreadStatus(bool status) {_sipThreadStop = status;} + + bool getSipThreadStatus() {return _sipThreadStop;} }; #endif // __MANAGER_H__ diff --git a/src/samplerateconverter.cpp b/src/samplerateconverter.cpp index 126c5d957cf7a9712bfbf4b105a0d817d6f653aa..3c6d0ed90db1902bc1e1ee0f29224f1e767453b4 100644 --- a/src/samplerateconverter.cpp +++ b/src/samplerateconverter.cpp @@ -18,19 +18,31 @@ #include "samplerateconverter.h" -SamplerateConverter::SamplerateConverter( void ) { - // Default values - _frequence = Manager::instance().getConfigInt( AUDIO , ALSA_SAMPLE_RATE ); // 44100; - _framesize = Manager::instance().getConfigInt( AUDIO , ALSA_FRAME_SIZE ); - +SamplerateConverter::SamplerateConverter( void ) + : _frequence(Manager::instance().getConfigInt( AUDIO , ALSA_SAMPLE_RATE )) //44100 + , _framesize(Manager::instance().getConfigInt( AUDIO , ALSA_FRAME_SIZE )) + , _floatBufferDownMic(NULL) + , _floatBufferUpMic(NULL) + , _src_state_mic(NULL) + , _floatBufferDownSpkr(NULL) + , _floatBufferUpSpkr(NULL) + , _src_state_spkr(NULL) + , _src_err(0) +{ init(); } -SamplerateConverter::SamplerateConverter( int freq , int fs ) { - - _frequence = freq ; - _framesize = fs ; - +SamplerateConverter::SamplerateConverter( int freq , int fs ) + : _frequence(freq) + , _framesize(fs) + , _floatBufferDownMic(NULL) + , _floatBufferUpMic(NULL) + , _src_state_mic(NULL) + , _floatBufferDownSpkr(NULL) + , _floatBufferUpSpkr(NULL) + , _src_state_spkr(NULL) + , _src_err(0) +{ init(); } diff --git a/src/samplerateconverter.h b/src/samplerateconverter.h index 86ea175319c44fd36660d3fdf8b33a7ef9de1e46..f6423197fadcf268ae851fd0f1d9c88167ffddd2 100644 --- a/src/samplerateconverter.h +++ b/src/samplerateconverter.h @@ -58,6 +58,12 @@ class SamplerateConverter { int getFramesize( void ) { return _framesize; } private: + // Copy Constructor + SamplerateConverter(const SamplerateConverter& rh); + + // Assignment Operator + SamplerateConverter& operator=( const SamplerateConverter& rh); + void init( void ); /** Audio layer caracteristics */ diff --git a/src/sipaccount.cpp b/src/sipaccount.cpp index 766d6d397e6dcc5906199d28053f021eeec128ba..f7a156ed960c227c5293bcee1414f8cdc8f26680 100644 --- a/src/sipaccount.cpp +++ b/src/sipaccount.cpp @@ -1,3 +1,6 @@ + +#include "voiplink.h" + /* * Copyright (C) 2006-2007 Savoir-Faire Linux inc. * Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com> @@ -21,9 +24,14 @@ #include "sipvoiplink.h" #include "manager.h" #include "user_cfg.h" +#include "useragent.h" SIPAccount::SIPAccount(const AccountID& accountID) : Account(accountID) + , _userName("") + , _server("") + , _cred(NULL) + , _contact("") { _link = new SIPVoIPLink(accountID); } @@ -33,6 +41,8 @@ SIPAccount::~SIPAccount() { delete _link; _link = NULL; + delete _cred; + _cred = NULL; } void @@ -44,12 +54,16 @@ SIPAccount::registerVoIPLink() SIPVoIPLink* thislink = dynamic_cast<SIPVoIPLink*> (_link); thislink->setStunServer(Manager::instance().getConfigString(_accountID,SIP_STUN_SERVER)); thislink->setUseStun( useStun!=0 ? true : false); - + + //SIPVoIPLink* thislink = dynamic_cast<SIPVoIPLink*> (_link); _link->init(); + // Stuff needed for SIP registration. thislink->setProxy (Manager::instance().getConfigString(_accountID,SIP_PROXY)); thislink->setAuthName(Manager::instance().getConfigString(_accountID,SIP_USER)); thislink->setPassword(Manager::instance().getConfigString(_accountID,SIP_PASSWORD)); + thislink->setSipServer(Manager::instance().getConfigString(_accountID,SIP_HOST)); + _link->sendRegister(); } @@ -71,3 +85,16 @@ SIPAccount::loadConfig() // SIP specific //none } + +bool +SIPAccount::fullMatch(const std::string& userName, const std::string& server) +{ + return (userName == _userName && server == _server); +} + +bool +SIPAccount::userMatch(const std::string& userName) +{ + return (userName == _userName); +} + diff --git a/src/sipaccount.h b/src/sipaccount.h index e542032b02cd4ede155d3548d120aaf4e9c5cb6d..5c32f1e50acb6a65015c6f8501d6e18c2a28694c 100644 --- a/src/sipaccount.h +++ b/src/sipaccount.h @@ -22,6 +22,9 @@ #include "account.h" +struct pjsip_cred_info; + +class SIPVoIPLink; /** * @file sipaccount.h @@ -37,6 +40,12 @@ public: */ SIPAccount(const AccountID& accountID); + /* Copy Constructor */ + SIPAccount(const SIPAccount& rh); + + /* Assignment Operator */ + SIPAccount& operator=( const SIPAccount& rh); + /** * Virtual destructor */ @@ -57,7 +66,32 @@ public: */ void unregisterVoIPLink(); + + void setUserName(const std::string &name) {_userName = name;} + + std::string getUserName() {return _userName;} + + void setServer(const std::string &server) {_server = server;} + + std::string getServer() {return _server;} + + void setCredInfo(pjsip_cred_info *cred) {_cred = cred;} + + pjsip_cred_info *getCredInfo() {return _cred;} + + void setContact(const std::string contact) {_contact = contact;} + + std::string getContact() {return _contact;} + + bool fullMatch(const std::string& userName, const std::string& server); + + bool userMatch(const std::string& userName); + private: + std::string _userName; + std::string _server; + pjsip_cred_info *_cred; + std::string _contact; }; #endif diff --git a/src/sipcall.cpp b/src/sipcall.cpp index 6ca79249b5f8a451ac57698acdacc0a1ff8c5a1c..c5e33a7cb30c0cf4dcf48e8233b0082865cc911d 100644 --- a/src/sipcall.cpp +++ b/src/sipcall.cpp @@ -23,16 +23,22 @@ #include "sipcall.h" #include "global.h" // for _debug #include <sstream> // for media buffer +#include <string> #define _SENDRECV 0 #define _SENDONLY 1 #define _RECVONLY 2 SIPCall::SIPCall(const CallID& id, Call::CallType type) : Call(id, type) + , _cid(0) + , _did(0) + , _tid(0) + , _localSDP(NULL) + , _negociator(NULL) + , _ipAddr("") + , _xferSub(NULL) + , _invSession(NULL) { - _cid = 0; - _did = 0; - _tid = 0; } SIPCall::~SIPCall() @@ -41,572 +47,276 @@ SIPCall::~SIPCall() bool -SIPCall::SIPCallInvite(eXosip_event_t *event) +SIPCall::SIPCallInvite(pjsip_rx_data *rdata, pj_pool_t *pool) { - if (event->cid < 1 && event->did < 1) { - _debug("SIP Failure: Invalid cid and did\n"); + pj_status_t status; + + pjmedia_sdp_session* remote_sdp = getRemoteSDPFromRequest(rdata); + if (remote_sdp == 0) { return false; } - if (event->request == NULL) { - _debug("SIP Failure: No request into the event\n"); + // Have to do some stuff here with the SDP + // We retrieve the remote sdp offer in the rdata struct to begin the negociation + _localSDP = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session); + _localSDP->conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn); + + _localSDP->origin.version = 0; + sdpAddOrigin(); + _localSDP->name = pj_str((char*)"sflphone"); + sdpAddConnectionInfo(); + _localSDP->time.start = _localSDP->time.stop = 0; + sdpAddMediaDescription(pool); + + _debug("Before validate SDP!\n"); + status = pjmedia_sdp_validate( _localSDP ); + if (status != PJ_SUCCESS) { + _debug("Can not generate valid local sdp\n"); return false; } - - setCid(event->cid); - setDid(event->did); - setTid(event->tid); - - setPeerInfoFromRequest(event); - sdp_message_t* remote_sdp = getRemoteSDPFromRequest(event); - if (remote_sdp == 0) { - return false; + _debug("Before create negociator!\n"); + status = pjmedia_sdp_neg_create_w_remote_offer(pool, _localSDP, remote_sdp, &_negociator); + if (status != PJ_SUCCESS) { + _debug("Can not create negociator\n"); + return false; } - - sdp_media_t* remote_med = getRemoteMedia(event->tid, remote_sdp); + _debug("After create negociator!\n"); + + pjmedia_sdp_media* remote_med = getRemoteMedia(remote_sdp); if (remote_med == 0) { - sdp_message_free (remote_sdp); + _debug("SIP Failure: unable to get remote media\n"); return false; } - if (!setRemoteAudioFromSDP(remote_med, remote_sdp)) { + _debug("Before set audio!\n"); + if (!setRemoteAudioFromSDP(remote_sdp, remote_med)) { _debug("SIP Failure: unable to set IP address and port from SDP\n"); - sdp_message_free (remote_sdp); return false; } - if (!setAudioCodecFromSDP(remote_med, event->tid)) { + _debug("Before set codec!\n"); + if (!setAudioCodecFromSDP(remote_med)) { _debug("SIP Failure: unable to set audio codecs from the remote SDP\n"); - sdp_message_free (remote_sdp); return false; } - osip_message_t *answer = 0; - eXosip_lock(); - _debug("< Building Answer 183\n"); - if (0 == eXosip_call_build_answer (event->tid, 183, &answer)) { - if ( 0 != sdp_complete_message(remote_sdp, answer)) { - osip_message_free(answer); - // Send 415 Unsupported media type - _debug("< Sending Answer 415 : unsupported media type\n"); - eXosip_call_send_answer (event->tid, 415, NULL); - } else { - sdp_message_t *local_sdp = eXosip_get_sdp_info(answer); - sdp_media_t *local_med = NULL; - if (local_sdp != NULL) { - local_med = eXosip_get_audio_media(local_sdp); - } - if (local_sdp != NULL && local_med != NULL) { - /* search if stream is sendonly or recvonly */ - int _remote_sendrecv = sdp_analyse_attribute (remote_sdp, remote_med); - int _local_sendrecv = sdp_analyse_attribute (local_sdp, local_med); - _debug(" Remote SendRecv: %d\n", _remote_sendrecv); - _debug(" Local SendRecv: %d\n", _local_sendrecv); - if (_local_sendrecv == _SENDRECV) { - if (_remote_sendrecv == _SENDONLY) { _local_sendrecv = _RECVONLY; } - else if (_remote_sendrecv == _RECVONLY) { _local_sendrecv = _SENDONLY; } - } - _debug(" Final Local SendRecv: %d\n", _local_sendrecv); - sdp_message_free (local_sdp); - } - _debug("< Sending answer 183\n"); - //if (0 != eXosip_call_send_answer (event->tid, 183, answer)) { - //_debug("SipCall::newIncomingCall: cannot send 183 progress?\n"); - //} - } - } - eXosip_unlock (); - - sdp_message_free (remote_sdp); return true; } -bool -SIPCall::SIPCallReinvite(eXosip_event_t *event) +bool +SIPCall::SIPCallAnsweredWithoutHold(pjsip_rx_data *rdata) { - if (event->cid < 1 && event->did < 1) { - _debug("SIP Failure: Invalid cid and did\n"); - return false; - } - - if (event->request == NULL) { - _debug("SIP Failure: No request into the event\n"); - return false; - } - - setCid(event->cid); - setDid(event->did); - setTid(event->tid); - - setPeerInfoFromRequest(event); - - sdp_message_t* remote_sdp = getRemoteSDPFromRequest(event); - if (remote_sdp == 0) { + pjmedia_sdp_session* remote_sdp = getRemoteSDPFromRequest(rdata); + if (remote_sdp == NULL) { + _debug("SIP Failure: no remote sdp\n"); return false; } - sdp_media_t* remote_med = getRemoteMedia(event->tid, remote_sdp); - if (remote_med == 0) { - sdp_message_free (remote_sdp); + pjmedia_sdp_media* remote_med = getRemoteMedia(remote_sdp); + if (remote_med==NULL) { return false; } - - if (!setRemoteAudioFromSDP(remote_med, remote_sdp)) { + + _debug("Before set audio!\n"); + if (!setRemoteAudioFromSDP(remote_sdp, remote_med)) { _debug("SIP Failure: unable to set IP address and port from SDP\n"); - sdp_message_free (remote_sdp); return false; } - if (!setAudioCodecFromSDP(remote_med, event->tid)) { - sdp_message_free (remote_sdp); + _debug("Before set codec!\n"); + if (!setAudioCodecFromSDP(remote_med)) { + _debug("SIP Failure: unable to set audio codecs from the remote SDP\n"); return false; } - osip_message_t *answer = 0; - eXosip_lock(); - _debug("< Building Answer 200\n"); - if (0 == eXosip_call_build_answer (event->tid, 200, &answer)) { - if ( 0 != sdp_complete_message(remote_sdp, answer)) { - osip_message_free(answer); - // Send 415 Unsupported media type - eXosip_call_send_answer (event->tid, 415, NULL); - _debug("< Sending Answer 415\n"); - } else { - - sdp_message_t *local_sdp = eXosip_get_sdp_info(answer); - sdp_media_t *local_med = NULL; - if (local_sdp != NULL) { - local_med = eXosip_get_audio_media(local_sdp); - } - if (local_sdp != NULL && local_med != NULL) { - /* search if stream is sendonly or recvonly */ - int _remote_sendrecv = sdp_analyse_attribute (remote_sdp, remote_med); - int _local_sendrecv = sdp_analyse_attribute (local_sdp, local_med); - _debug(" Remote SendRecv: %d\n", _remote_sendrecv); - _debug(" Local SendRecv: %d\n", _local_sendrecv); - if (_local_sendrecv == _SENDRECV) { - if (_remote_sendrecv == _SENDONLY) { _local_sendrecv = _RECVONLY; } - else if (_remote_sendrecv == _RECVONLY) { _local_sendrecv = _SENDONLY; } - } - _debug(" Final Local SendRecv: %d\n", _local_sendrecv); - sdp_message_free (local_sdp); - } - _debug("< Sending answer 200\n"); - if (0 != eXosip_call_send_answer (event->tid, 200, answer)) { - _debug("SipCall::newIncomingCall: cannot send 200 OK?\n"); - } - } - } - eXosip_unlock (); - sdp_message_free (remote_sdp); return true; } -bool -SIPCall::SIPCallAnswered(eXosip_event_t *event) + +pjmedia_sdp_session* +SIPCall::getRemoteSDPFromRequest(pjsip_rx_data *rdata) { - if (event->cid < 1 && event->did < 1) { - _debug("SIP Failure: Invalid cid and did\n"); - return false; - } + pjmedia_sdp_session *sdp; + pjsip_msg *msg; + pjsip_msg_body *body; - if (event->request == NULL) { - _debug("SIP Failure: No request into the event\n"); - return false; - } + msg = rdata->msg_info.msg; + body = msg->body; - setCid(event->cid); - setDid(event->did); - - //setPeerInfoFromResponse() - - eXosip_lock (); - { - osip_message_t *ack = NULL; - int i; - i = eXosip_call_build_ack (event->did, &ack); - if (i != 0) { - _debug("SipCall::answeredCall: Cannot build ACK for call!\n"); - } else { - sdp_message_t *local_sdp = NULL; - sdp_message_t *remote_sdp = NULL; - - if (event->request != NULL && event->response != NULL) { - local_sdp = eXosip_get_sdp_info (event->request); - remote_sdp = eXosip_get_sdp_info (event->response); - } - if (local_sdp == NULL && remote_sdp != NULL) { - /* sdp in ACK */ - i = sdp_complete_message (remote_sdp, ack); - if (i != 0) { - _debug("SipCall::answeredCall: Cannot complete ACK with sdp body?!\n"); - } - } - sdp_message_free (local_sdp); - sdp_message_free (remote_sdp); - - _debug("< Send ACK\n"); - eXosip_call_send_ack (event->did, ack); - } - } - eXosip_unlock (); - return true; -} + pjmedia_sdp_parse( rdata->tp_info.pool, (char*)body->data, body->len, &sdp ); + return sdp; +} bool -SIPCall::SIPCallAnsweredWithoutHold(eXosip_event_t* event) +SIPCall::setRemoteAudioFromSDP(pjmedia_sdp_session* remote_sdp, pjmedia_sdp_media *remote_med) { - if (event->response == NULL || event->request == NULL) { return false; } + std::string remoteIP(remote_sdp->conn->addr.ptr, remote_sdp->conn->addr.slen); + _debug(" Remote Audio IP: %s\n", remoteIP.data()); + setRemoteIP(remoteIP); + int remotePort = remote_med->desc.port; + _debug(" Remote Audio Port: %d\n", remotePort); + setRemoteAudioPort(remotePort); - eXosip_lock(); - sdp_message_t* remote_sdp = eXosip_get_sdp_info (event->response); - eXosip_unlock(); - if (remote_sdp == NULL) { - _debug("SIP Failure: no remote sdp\n"); - sdp_message_free(remote_sdp); - return false; - } + return true; +} - sdp_media_t* remote_med = getRemoteMedia(event->tid, remote_sdp); - if (remote_med==NULL) { - sdp_message_free(remote_sdp); - return false; +bool +SIPCall::setAudioCodecFromSDP(pjmedia_sdp_media* remote_med) +{ + // Remote Payload + int payLoad = -1; + int codecCount = remote_med->desc.fmt_count; + for(int i = 0; i < codecCount; i++) { + payLoad = atoi(remote_med->desc.fmt[i].ptr); + if (_codecMap.isActive((AudioCodecType)payLoad)) + break; + + payLoad = -1; } - if ( ! setRemoteAudioFromSDP(remote_med, remote_sdp) ) { - sdp_message_free(remote_sdp); + + if(payLoad != -1) { + _debug(" Payload: %d\n", payLoad); + setAudioCodec((AudioCodecType)payLoad); + } else return false; - } - -#ifdef LIBOSIP2_WITHPOINTER - char *tmp = (char*) osip_list_get (remote_med->m_payloads, 0); -#else - char *tmp = (char*) osip_list_get (&(remote_med->m_payloads), 0); -#endif - setAudioCodec((AudioCodecType)-1); - if (tmp != NULL) { - int payload = atoi (tmp); - _debug(" Remote Payload: %d\n", payload); - //setAudioCodec(_codecMap.getCodecName((AudioCodecType)payload)); // codec builder for the mic - setAudioCodec((AudioCodecType)payload); // codec builder for the mic - } - -/* - // search if stream is sendonly or recvonly - _remote_sendrecv = sdp_analyse_attribute (remote_sdp, remote_med); - _local_sendrecv = sdp_analyse_attribute (local_sdp, local_med); - if (_local_sendrecv == _SENDRECV) { - if (_remote_sendrecv == _SENDONLY) - _local_sendrecv = _RECVONLY; - else if (_remote_sendrecv == _RECVONLY) - _local_sendrecv = _SENDONLY; - } - _debug(" Remote Sendrecv: %d\n", _remote_sendrecv); - _debug(" Local Sendrecv: %d\n", _local_sendrecv); -*/ - sdp_message_free (remote_sdp); + return true; } - -int -SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg) +void SIPCall::sdpAddOrigin( void ) { - // Format port to a char* - if (remote_sdp == NULL) { - _debug("SipCall::sdp_complete_message: No remote SDP body found for call\n"); - return -1; - } - if (msg == NULL) { - _debug("SipCall::sdp_complete_message: No message to complete\n"); - return -1; - } - - std::ostringstream media; - - // for each medias - int iMedia = 0; - char *tmp = NULL; - #ifdef LIBOSIP2_WITHPOINTER - const osip_list_t* remote_sdp_m_medias = remote_sdp->m_medias; // old abi - #else - const osip_list_t* remote_sdp_m_medias = &(remote_sdp->m_medias); - #endif - osip_list_t* remote_med_m_payloads = 0; - - while (!osip_list_eol(remote_sdp_m_medias, iMedia)) { - sdp_media_t *remote_med = (sdp_media_t *)osip_list_get(remote_sdp_m_medias, iMedia); - if (remote_med == 0) { continue; } - - if (0 != osip_strcasecmp (remote_med->m_media, "audio")) { - // if this is not an "audio" media, we set it to 0 - media << "m=" << remote_med->m_media << " 0 " << remote_med->m_proto << " \r\n"; - } else { - std::ostringstream listCodec; - std::ostringstream listRtpMap; - - // search for compatible codec: foreach payload - int iPayload = 0; - #ifdef LIBOSIP2_WITHPOINTER - remote_med_m_payloads = remote_med->m_payloads; // old abi - #else - remote_med_m_payloads = &(remote_med->m_payloads); - #endif - - //while (!osip_list_eol(remote_med_m_payloads, iPayload) && iPayload < 2) { - while (!osip_list_eol(remote_med_m_payloads, iPayload)) { - tmp = (char *)osip_list_get(remote_med_m_payloads, iPayload); - if (tmp!=NULL) { - int payload = atoi(tmp); - _debug("remote payload = %s\n", tmp); - AudioCodecType audiocodec = (AudioCodecType)payload; - if (audiocodec != (AudioCodecType)-1 && _codecMap.isActive(audiocodec)) { - listCodec << payload << " "; - //listRtpMap << "a=rtpmap:" << payload << " " << audiocodec->getCodecName() << "/" << audiocodec->getClockRate(); - listRtpMap << "a=rtpmap:" << payload << " " << _codecMap.getCodecName(audiocodec) << "/" << _codecMap.getSampleRate(audiocodec); - if (_codecMap.getChannel(audiocodec) != 1) { - listRtpMap << "/" << _codecMap.getChannel(audiocodec); - } - listRtpMap << "\r\n"; - } - } - iPayload++; - } - if (listCodec.str().empty()) { - media << "m=" << remote_med->m_media << " 0 " << remote_med->m_proto << " \r\n"; - } else { - // we add the media line + a=rtpmap list - media << "m=" << remote_med->m_media << " " << getLocalExternAudioPort() << " RTP/AVP " << listCodec.str() << "\r\n"; - media << listRtpMap.str(); - } - } - iMedia++; - } - char buf[4096]; - snprintf (buf, 4096, - "v=0\r\n" - "o=user 0 0 IN IP4 %s\r\n" - "s=session\r\n" - "c=IN IP4 %s\r\n" - "t=0 0\r\n" - "%s\n", getLocalIp().c_str(), getLocalIp().c_str(), media.str().c_str()); - - osip_message_set_body (msg, buf, strlen (buf)); - osip_message_set_content_type (msg, "application/sdp"); - _debug(" sdp: %s", buf); - return 0; + pj_time_val tv; + pj_gettimeofday(&tv); + + _localSDP->origin.user = pj_str(pj_gethostname()->ptr); + // Use Network Time Protocol format timestamp to ensure uniqueness. + _localSDP->origin.id = tv.sec + 2208988800UL; + // The type of network ( IN for INternet ) + _localSDP->origin.net_type = pj_str((char*)"IN"); //STR_IN; + // The type of address + _localSDP->origin.addr_type = pj_str((char*)"IP4"); //STR_IP4; + // The address of the machine from which the session was created + _localSDP->origin.addr = pj_str( (char*)_ipAddr.c_str() ); } - - -int -SIPCall::sdp_analyse_attribute (sdp_message_t * sdp, sdp_media_t * med) +void SIPCall::sdpAddConnectionInfo( void ) { - int pos; - int pos_media; - - /* test media attributes */ - pos = 0; - #ifdef LIBOSIP2_WITHPOINTER - const osip_list_t* med_a_attributes = med->a_attributes; // old abi - #else - const osip_list_t* med_a_attributes = &(med->a_attributes); - #endif - while (!osip_list_eol (med_a_attributes, pos)) { - sdp_attribute_t *at; - - at = (sdp_attribute_t *) osip_list_get (med_a_attributes, pos); - if (at->a_att_field != NULL && - 0 == strcmp (at->a_att_field, "sendonly")) { - return _SENDONLY; - } else if (at->a_att_field != NULL && - 0 == strcmp (at->a_att_field, "recvonly")) { - return _RECVONLY; - } else if (at->a_att_field != NULL && - 0 == strcmp (at->a_att_field, "sendrecv")) { - return _SENDRECV; - } - pos++; - } - - /* test global attributes */ - pos_media = -1; - pos = 0; - #ifdef LIBOSIP2_WITHPOINTER - const osip_list_t* sdp_a_attributes = sdp->a_attributes; // old abi - #else - const osip_list_t* sdp_a_attributes = &(sdp->a_attributes); - #endif - while (!osip_list_eol (sdp_a_attributes, pos)) { - sdp_attribute_t *at; - - at = (sdp_attribute_t *) osip_list_get (sdp_a_attributes, pos); - if (at->a_att_field != NULL && - 0 == strcmp (at->a_att_field, "sendonly")) { - return _SENDONLY; - } else if (at->a_att_field != NULL && - 0 == strcmp (at->a_att_field, "recvonly")) { - return _RECVONLY; - } else if (at->a_att_field != NULL && - 0 == strcmp (at->a_att_field, "sendrecv")) { - return _SENDRECV; - } - pos++; - } - - return _SENDRECV; + _localSDP->conn->net_type = _localSDP->origin.net_type; + _localSDP->conn->addr_type = _localSDP->origin.addr_type; + _localSDP->conn->addr = _localSDP->origin.addr; } -bool -SIPCall::setPeerInfoFromRequest(eXosip_event_t *event) +void SIPCall::sdpAddMediaDescription(pj_pool_t* pool) { - // event->request should not be NULL! - char remote_uri[256] = ""; - std::string name(""); - std::string number(""); - - char *tmp = NULL; - osip_from_to_str(event->request->from, &tmp); - if (tmp != NULL) { - snprintf (remote_uri, 255, "%s", tmp); - remote_uri[255] = '\0'; - osip_free (tmp); - - // Get the name/number - osip_from_t *from; - osip_from_init(&from); - osip_from_parse(from, remote_uri); - char *tmpname = osip_from_get_displayname(from); - if ( tmpname != NULL ) { - name = tmpname; + pjmedia_sdp_media* med; + pjmedia_sdp_attr *attr; + //int nbMedia, i; + + med = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media); + //nbMedia = getSDPMediaList().size(); + _localSDP->media_count = 1; + + med->desc.media = pj_str((char*)"audio"); + med->desc.port_count = 1; + med->desc.port = getLocalExternAudioPort(); + med->desc.transport = pj_str((char*)"RTP/AVP"); + + CodecsMap::iterator itr; + itr = _codecMap.getCodecsMap().begin(); + int count = _codecMap.getCodecsNumber(); + med->desc.fmt_count = count; + + int i = 0; + while(itr != _codecMap.getCodecsMap().end()) { + std::ostringstream format; + format << (*itr).first; + pj_strdup2(pool, &med->desc.fmt[i], format.str().data()); + + AudioCodec *codec = (*itr).second; + pjmedia_sdp_rtpmap rtpMap; + rtpMap.pt = med->desc.fmt[i]; + rtpMap.enc_name = pj_str((char *)codec->getCodecName().data()); + rtpMap.clock_rate = codec->getClockRate(); + if(codec->getChannel() > 1) { + std::ostringstream channel; + channel << codec->getChannel(); + rtpMap.param = pj_str((char *)channel.str().data()); + } else + rtpMap.param.slen = 0; + + pjmedia_sdp_rtpmap_to_attr( pool, &rtpMap, &attr ); + med->attr[i] = attr; + i++; + itr++; } - osip_uri_t* url = osip_from_get_url(from); - if ( url != NULL && url->username != NULL) { - number = url->username; - } - osip_from_free(from); - } - - _debug(" Name: %s\n", name.c_str()); - _debug(" Number: %s\n", number.c_str()); - _debug(" Remote URI: %s\n", remote_uri); - - setPeerName(name); - setPeerNumber(number); - return true; + + //FIXME! Add the direction stream + attr = (pjmedia_sdp_attr*)pj_pool_zalloc( pool, sizeof(pjmedia_sdp_attr) ); + pj_strdup2( pool, &attr->name, "sendrecv"); + med->attr[ i++] = attr; + med->attr_count = i; + + _localSDP->media[0] = med; + /*for( i=0; i<nbMedia; i++ ){ + getMediaDescriptorLine( getSDPMediaList()[i], pool, &med ); + this->_local_offer->media[i] = med; + } */ + } -sdp_message_t* -SIPCall::getRemoteSDPFromRequest(eXosip_event_t *event) +pjmedia_sdp_media* SIPCall::getRemoteMedia(pjmedia_sdp_session *remote_sdp) { - // event->request should not be null! - /* negotiate payloads */ - sdp_message_t *remote_sdp = NULL; - if (event->request != NULL) { - eXosip_lock(); - remote_sdp = eXosip_get_sdp_info (event->request); - eXosip_unlock(); - } - if (remote_sdp == NULL) { - _debug("SIP Failure: No SDP into the request\n"); - _debug("< Sending 400 Bad Request (no SDP)\n"); - eXosip_lock(); - eXosip_call_send_answer (event->tid, 400, NULL); - eXosip_unlock(); - return 0; - } - return remote_sdp; + int count, i; + + count = remote_sdp->media_count; + for(i = 0; i < count; ++i) { + if(pj_stricmp2(&remote_sdp->media[i]->desc.media, "audio") == 0) + return remote_sdp->media[i]; + } + + return NULL; } -sdp_media_t* -SIPCall::getRemoteMedia(int tid, sdp_message_t* remote_sdp) +bool SIPCall::startNegociation(pj_pool_t *pool) { - // Remote Media Port - eXosip_lock(); - sdp_media_t *remote_med = eXosip_get_audio_media(remote_sdp); - eXosip_unlock(); - - if (remote_med == NULL || remote_med->m_port == NULL) { - // no audio media proposed - _debug("SIP Failure: unsupported media\n"); - _debug("< Sending 415 Unsupported media type\n"); - eXosip_lock(); - eXosip_call_send_answer (tid, 415, NULL); - eXosip_unlock(); - sdp_message_free (remote_sdp); - return 0; - } - return remote_med; + pj_status_t status; + _debug("Before negotiate!\n"); + status = pjmedia_sdp_neg_negotiate(pool, _negociator, 0); + + return (status == PJ_SUCCESS); } -bool -SIPCall::setRemoteAudioFromSDP(sdp_media_t* remote_med, sdp_message_t* remote_sdp) +bool SIPCall::createInitialOffer(pj_pool_t *pool) { - // Remote Media IP - eXosip_lock(); - sdp_connection_t *conn = eXosip_get_audio_connection(remote_sdp); - eXosip_unlock(); - if (conn != NULL && conn->c_addr != NULL) { - char _remote_sdp_audio_ip[50] = ""; - snprintf (_remote_sdp_audio_ip, 49, "%s", conn->c_addr); - _remote_sdp_audio_ip[49] = '\0'; - _debug(" Remote Audio IP: %s\n", _remote_sdp_audio_ip); - setRemoteIP(_remote_sdp_audio_ip); - if (_remote_sdp_audio_ip[0] == '\0') { - setRemoteAudioPort(0); - return false; - } - } - - // Remote port - int _remote_sdp_audio_port = atoi(remote_med->m_port); - _debug(" Remote Audio Port: %d\n", _remote_sdp_audio_port); - setRemoteAudioPort(_remote_sdp_audio_port); + pj_status_t status; - if (_remote_sdp_audio_port == 0) { + // Have to do some stuff here with the SDP + _localSDP = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session); + _localSDP->conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn); + + _localSDP->origin.version = 0; + sdpAddOrigin(); + _localSDP->name = pj_str((char*)"sflphone"); + sdpAddConnectionInfo(); + _localSDP->time.start = _localSDP->time.stop = 0; + sdpAddMediaDescription(pool); + + _debug("Before validate SDP!\n"); + status = pjmedia_sdp_validate( _localSDP ); + if (status != PJ_SUCCESS) { + _debug("Can not generate valid local sdp %d\n", status); return false; } - return true; -} + + _debug("Before create negociator!\n"); + // Create the SDP negociator instance with local offer + status = pjmedia_sdp_neg_create_w_local_offer( pool, _localSDP, &_negociator); + //state = pjmedia_sdp_neg_get_state( _negociator ); -bool -SIPCall::setAudioCodecFromSDP(sdp_media_t* remote_med, int tid) -{ - // Remote Payload - char *tmp = NULL; - int pos = 0; - #ifdef LIBOSIP2_WITHPOINTER - const osip_list_t* remote_med_m_payloads = remote_med->m_payloads; // old abi - #else - const osip_list_t* remote_med_m_payloads = &(remote_med->m_payloads); - #endif - while (!osip_list_eol (remote_med_m_payloads, pos)) { - tmp = (char *) osip_list_get (remote_med_m_payloads, pos); - if (tmp != NULL ) { - int payload = atoi(tmp); - // stop if we find a correct codec - if (_codecMap.isActive((AudioCodecType)payload)){ - break; - } - } - tmp = NULL; - pos++; - } + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); - setAudioCodec((AudioCodecType)-1); - if (tmp != NULL) { - int payload = atoi (tmp); - _debug(" Payload: %d\n", payload); - setAudioCodec((AudioCodecType)payload); // codec builder for the mic - } - if (getAudioCodec() == (AudioCodecType) -1) { - _debug("SIPCall Failure: Unable to set codec\n"); - _debug("< Sending 415 Unsupported media type\n"); - eXosip_lock(); - eXosip_call_send_answer(tid, 415, NULL); - eXosip_unlock(); - return false; - } return true; + } diff --git a/src/sipcall.h b/src/sipcall.h index a74885500707958e326a034690f66c20d119a52c..fe23553d5dcdd5edda45b80c6466ea3d6b124725 100644 --- a/src/sipcall.h +++ b/src/sipcall.h @@ -23,7 +23,7 @@ #include "call.h" #include "audio/codecDescriptor.h" -#include <eXosip2/eXosip.h> +#include "useragent.h" class AudioCodec; @@ -50,101 +50,106 @@ class SIPCall : public Call /** * Call Identifier - * @return int SIP call id : protected by eXosip lock + * @return int SIP call id */ int getCid() { return _cid; } /** * Call Identifier - * @param cid SIP call id : protected by eXosip lock + * @param cid SIP call id */ void setCid(int cid) { _cid = cid ; } /** * Domain identifier - * @return int SIP domain id : protected by eXosip lock + * @return int SIP domain id */ int getDid() { return _did; } /** * Domain identifier - * @param did SIP domain id : protected by eXosip lock + * @param did SIP domain id */ void setDid(int did) { _did = did; } /** * Transaction identifier - * @return int SIP transaction id : protected by eXosip lock + * @return int SIP transaction id */ int getTid() { return _tid; } /** * Transaction identifier - * @param tid SIP transaction id : protected by eXosip lock + * @param tid SIP transaction id */ void setTid(int tid) { _tid = tid; } /** * Setup incoming call, and verify for errors, before ringing the user. - * @param event eXosip Event + * @param pjsip_rx_data *rdata + * @param pj_pool_t *pool * @return bool True on success * false otherwise */ - bool SIPCallInvite(eXosip_event_t *event); + bool SIPCallInvite(pjsip_rx_data *rdata, pj_pool_t *pool); + bool SIPCallAnsweredWithoutHold(pjsip_rx_data *rdata); + /** - * newReinviteCall is called when the IP-Phone user receives a change in the call - * it's almost an newIncomingCall but we send a 200 OK - * See: 3.7. Session with re-INVITE (IP Address Change) - * @param event eXosip Event - * @return bool True if ok + * Save IP Address + * @param ip std::string + * @return void */ - bool SIPCallReinvite(eXosip_event_t *event); + void setIp(std::string ip) {_ipAddr = ip;} /** - * Peer answered to a call (on hold or not) - * @param event eXosip Event + * Get the local SDP + * @param void + * @return _localSDP pjmedia_sdp_session + */ + pjmedia_sdp_session* getLocalSDPSession( void ) { return _localSDP; } + + /** + * Begin negociation of media information between caller and callee + * @param pj_pool_t *pool * @return bool True if ok */ - bool SIPCallAnswered(eXosip_event_t *event); + bool startNegociation(pj_pool_t *pool); /** - * We retreive final SDP info if they changed - * @param event eXosip Event - * @return bool True if ok (change / no change) or false on error + * Create the localSDP, media negociation and codec information + * @param pj_pool_t *pool + * @return void */ - bool SIPCallAnsweredWithoutHold(eXosip_event_t *event); - - //TODO: humm? - int sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg); - - + bool createInitialOffer(pj_pool_t *pool); + + void setXferSub(pjsip_evsub* sub) {_xferSub = sub;} + pjsip_evsub *getXferSub() {return _xferSub;} + + void setInvSession(pjsip_inv_session* inv) {_invSession = inv;} + pjsip_inv_session *getInvSession() {return _invSession;} + private: - // TODO: hum??? - int sdp_analyse_attribute (sdp_message_t * sdp, sdp_media_t * med); - - /** - * Set peer name and number with event->request->from - * @param event eXosip event - * @return bool False if the event is invalid - */ - bool setPeerInfoFromRequest(eXosip_event_t *event); + // Copy Constructor + SIPCall(const SIPCall& rh); + + // Assignment Operator + SIPCall& operator=( const SIPCall& rh); /** * Get a valid remote SDP or return a 400 bad request response if invalid - * @param event eXosip event - * @return sdp_message_t* A valid remote_sdp or 0 + * @param + * @return */ - sdp_message_t* getRemoteSDPFromRequest(eXosip_event_t *event); + pjmedia_sdp_session* getRemoteSDPFromRequest(pjsip_rx_data *rdata); /** - * Get a valid remote media or return a 415 unsupported media type - * @param tid transaction id - * @param remote_sdp Remote SDP pointer - * @return sdp_media_t* A valid sdp_media_t or 0 + * Get a valid remote media + * @param remote_sdp pjmedia_sdp_session* + * @return pjmedia_sdp_media*. A valid sdp_media_t or 0 */ - sdp_media_t* getRemoteMedia(int tid, sdp_message_t* remote_sdp); + pjmedia_sdp_media* getRemoteMedia(pjmedia_sdp_session *remote_sdp); /** * Set Audio Port and Audio IP from Remote SDP Info @@ -152,14 +157,14 @@ class SIPCall : public Call * @param remote_sdp Remote SDP pointer * @return bool True if everything is set correctly */ - bool setRemoteAudioFromSDP(sdp_media_t* remote_med, sdp_message_t* remote_sdp); + bool setRemoteAudioFromSDP(pjmedia_sdp_session* remote_sdp, pjmedia_sdp_media* remote_med); /** * Set Audio Codec with the remote choice * @param remote_med Remote Media info * @return bool True if everything is set correctly */ - bool setAudioCodecFromSDP(sdp_media_t* remote_med, int tid); + bool setAudioCodecFromSDP(pjmedia_sdp_media* remote_med); /** SIP call id */ int _cid; @@ -170,6 +175,33 @@ class SIPCall : public Call /** SIP transaction id */ int _tid; + /** Local SDP */ + pjmedia_sdp_session *_localSDP; + + /** negociator */ + pjmedia_sdp_neg *_negociator; + + /** + * Set origin information for local SDP + */ + void sdpAddOrigin( void ); + + /** + * Set connection information for local SDP + */ + void sdpAddConnectionInfo( void ); + /** + * Set media information including codec for localSDP + * @param pj_pool_t* pool + * @return void + */ + void sdpAddMediaDescription(pj_pool_t* pool); + + /** IP address */ + std::string _ipAddr; + + pjsip_evsub *_xferSub; + pjsip_inv_session *_invSession; }; #endif diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 3334bf226a7cd5efc9e2da79889e07f04d18c085..fcf568fcf99b5cf52f3fc0c1077ebe765754eb64 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -23,9 +23,11 @@ #include "sipvoiplink.h" #include "eventthread.h" #include "sipcall.h" -#include <sstream> // for ostringstream +#include <sstream> // for istringstream #include "sipaccount.h" - +#include "useragent.h" +#include "audio/audiortp.h" + #include "manager.h" #include "user_cfg.h" // SIGNALISATION / PULSE #define @@ -34,37 +36,29 @@ #define RANDOM_SIP_PORT rand() % 64000 + 1024 #define RANDOM_LOCAL_PORT ((rand() % 27250) + 5250)*2 -#define EXOSIP_ERROR_NO 0 -#define EXOSIP_ERROR_STD -1 -#define EXOSIP_ERROR_BUILDING -2 - -// for registration -//#define EXPIRES_VALUE 180 - // 1XX responses #define DIALOG_ESTABLISHED 101 // see: osip_const.h -// FOR VOICE Message handling -#define VOICE_MSG "Voice-Message" -#define LENGTH_VOICE_MSG 15 - // need for hold/unhold #define INVITE_METHOD "INVITE" - SIPVoIPLink::SIPVoIPLink(const AccountID& accountID) - : VoIPLink(accountID), _localExternAddress("") , eXosip_running( false ) + : VoIPLink(accountID) + , _initDone(false) + , _nbTryListenAddr(2) // number of times to try to start SIP listener + , _useStun(false) + , _stunServer("") + , _localExternAddress("") + , _localExternPort(0) + , _proxy("") + , _authname("") + , _password("") + , _audiortp(new AudioRtp()) + , _regc() + , _server("") + , _bRegister(false) { - _evThread = new EventThread(this); - - - _nMsgVoicemail = 0; - _eXosipRegID = EXOSIP_ERROR_STD; - - _nbTryListenAddr = 2; // number of times to try to start SIP listener - _localExternPort = 0; - // to get random number for RANDOM_PORT srand (time(NULL)); } @@ -72,100 +66,20 @@ SIPVoIPLink::SIPVoIPLink(const AccountID& accountID) SIPVoIPLink::~SIPVoIPLink() { terminate(); - delete _evThread; _evThread = 0; } bool SIPVoIPLink::init() { - if( eXosip_running ){ - delete _evThread; - _evThread=0; - _evThread= new EventThread( this ); - eXosip_quit(); - } - - if (!_initDone) { - if (0 != eXosip_init()) { - _debug("! SIP Failure: Could not initialize eXosip\n"); - return false; - } - - // Pour éviter qu'on refasse l'init sans avoir considéré l'erreur, - // s'il y en a une ? - _initDone = true; - // check networking capabilities - if ( !checkNetwork() ) { - _debug("! SIP FAILURE: Unable to determine network capabilities\n"); - return false; - } - - // if we useStun and we failed to receive something on port 5060, we try a random port - // If use STUN server, firewall address setup - int errExosip = 0; - int port = DEFAULT_SIP_PORT; - - int iTry = 1; // try number.. - - do { - if (_useStun && !Manager::instance().behindNat(_stunServer, port)) { - port = RANDOM_SIP_PORT; - if (!Manager::instance().behindNat(_stunServer, port)) { - _debug("! SIP Failure: Unable to check NAT setting\n"); - return false; // hoho we can't use the random sip port too... - } - } - - // second parameter, NULL is "::" for ipv6 and "0.0.0.0" for ipv4, we can put INADDR_ANY - errExosip = eXosip_listen_addr(IPPROTO_UDP, INADDR_ANY, port, AF_INET, 0); - if (errExosip != 0) { - _debug("* SIP Info: [%d/%d] could not initialize SIP listener on port %d\n", iTry, _nbTryListenAddr, port); - port = RANDOM_SIP_PORT; - } - } while ( errExosip != 0 && iTry < _nbTryListenAddr ); - - if ( errExosip != 0 ) { // we didn't succeeded - _debug("! SIP Failure: SIP failed to listen on port %d\n", port); - return false; - } - _localPort = port; - _debug(" SIP Init: listening on port %d\n", port); - - if (_useStun) { - // This method is used to replace contact address with the public address of your NAT - // it should be call after eXosip_listen_addr - // set by last behindNat() call (ish)... - _localExternAddress = Manager::instance().getFirewallAddress(); - _localExternPort = Manager::instance().getFirewallPort(); - eXosip_masquerade_contact(_localExternAddress.data(), _localExternPort); - } else { - _localExternAddress = _localIPAddress; - _localExternPort = _localPort; - } - - // Set user agent - std::string tmp = std::string(PROGNAME_GLOBAL) + "/" + std::string(SFLPHONED_VERSION); - eXosip_set_user_agent(tmp.data()); - - _debug(" SIP Init: starting loop thread (SIP events)\n" ); - _evThread->start(); - } - + _regc = NULL; _initDone = true; - eXosip_running = true; - // Useless return true; } void SIPVoIPLink::terminate() { - terminateSIPCall(); - // TODO The next line makes the daemon crash on - // account delete if at least one account is registered. - // It should called only when the last account - // is deleted/unregistered. - _initDone = false; + _initDone = false; } void @@ -178,10 +92,7 @@ SIPVoIPLink::terminateSIPCall() while( iter != _callMap.end() ) { call = dynamic_cast<SIPCall*>(iter->second); if (call) { - // Release SIP stack. - eXosip_lock(); - eXosip_call_terminate(call->getCid(), call->getDid() ); - eXosip_unlock(); + //TODO terminate the sip call delete call; call = 0; } iter++; @@ -201,16 +112,16 @@ SIPVoIPLink::loadSIPLocalIP() { bool returnValue = true; if (_localIPAddress == "127.0.0.1") { - char* myIPAddress = new char[65]; - if (eXosip_guess_localip(AF_INET, myIPAddress, 64) == EXOSIP_ERROR_STD) { + pj_sockaddr ip_addr; + if (pj_gethostip(pj_AF_INET(), &ip_addr) != PJ_SUCCESS) { // Update the registration state if no network capabilities found + _debug("Get host ip failed!\n"); setRegistrationState( ErrorNetwork ); returnValue = false; } else { - _localIPAddress = std::string(myIPAddress); - _debug(" SIP Info: Checking network, setting local IP address to: %s\n", myIPAddress); + _localIPAddress = std::string(pj_inet_ntoa(ip_addr.ipv4.sin_addr)); + _debug(" SIP Info: Checking network, setting local IP address to: %s\n", _localIPAddress.data()); } - delete [] myIPAddress; myIPAddress = NULL; } return returnValue; } @@ -218,292 +129,31 @@ SIPVoIPLink::loadSIPLocalIP() void SIPVoIPLink::getEvent() { - char* tmp2; - eXosip_event_t* event = eXosip_event_wait(0, 50); - eXosip_lock(); - eXosip_automatic_action(); - eXosip_unlock(); - - if ( event == NULL ) { - return; - } - - - _debug("> SIP Event: [cdt=%4d:%4d:%4d] type=#%03d %s \n", event->cid, event->did, event->tid, event->type, event->textinfo); - switch (event->type) { - /* REGISTER related events */ - case EXOSIP_REGISTRATION_NEW: /** 00 < announce new registration. */ - _debugMid(" !EXOSIP_REGISTRATION_NEW event is not implemented\n"); - break; - case EXOSIP_REGISTRATION_SUCCESS: /** 01 < user is successfully registred. */ - _debugMid(" !EXOSIP_REGISTRATION_SUCCESS ---> %s\n" , getAccountID().c_str()); - if(_eXosipRegID == EXOSIP_ERROR_STD){ - _debug("Successfully Unregister account ID = %s\n" , getAccountID().c_str()); - setRegistrationState(Unregistered); - } - else{ - _debug("Successfully Register account ID = %s\n" , getAccountID().c_str()); - setRegistrationState(Registered); - } - break; - case EXOSIP_REGISTRATION_FAILURE: /** 02 < user is not registred. */ - SIPRegistrationFailure( event ); - _debugMid(" !EXOSIP_REGISTRATION_FAILURE\n"); - break; - case EXOSIP_REGISTRATION_REFRESHED: /** 03 < registration has been refreshed. */ - _debugMid(" !EXOSIP_REGISTRATION_REFRESHED event is not implemented\n"); - break; - case EXOSIP_REGISTRATION_TERMINATED: /** 04 < UA is not registred any more. */ - //setRegistrationState(Unregistered, "Registration terminated by remote host"); - setRegistrationState(Unregistered); - _debugMid(" !EXOSIP_REGISTRATION_TERMINATED event is not implemented\n"); - break; - - /* INVITE related events within calls */ - case EXOSIP_CALL_INVITE: /** 05 < announce a new call */ - _debugMid(" !EXOSIP_CALL_INVITE\n"); - SIPCallInvite(event); - break; - case EXOSIP_CALL_REINVITE: /** 06 < announce a new INVITE within call */ - SIPCallReinvite(event); - _debugMid(" !EXOSIP_REGISTRATION_TERMINATED event is not implemented\n"); - break; - - /* CALL related events */ - case EXOSIP_CALL_NOANSWER: /** 07 < announce no answer within the timeout */ - _debugMid(" !EXOSIP_CALL_NOANSWER event is not implemented\n"); - break; - case EXOSIP_CALL_PROCEEDING: /** 08 < announce processing by a remote app */ - _debugMid(" !EXOSIP_CALL_PROCEEDING event is not implemented\n"); - break; - case EXOSIP_CALL_RINGING: /** 09 < announce ringback */ - _debugMid(" !EXOSIP_CALL_RINGING\n"); - SIPCallRinging(event); - break; - case EXOSIP_CALL_ANSWERED: /** 10 < announce start of call */ - _debugMid(" !EXOSIP_CALL_ANSWERED\n"); - SIPCallAnswered(event); - break; - case EXOSIP_CALL_REDIRECTED: /** 11 < announce a redirection */ - _debugMid(" !EXOSIP_CALL_REDIRECTED event is not implemented\n"); - break; - case EXOSIP_CALL_REQUESTFAILURE: /** 12 < announce a request failure */ - _debugMid(" !EXOSIP_CALL_REQUESTFAILURE"); - SIPCallRequestFailure(event); - break; - case EXOSIP_CALL_SERVERFAILURE: /** 13 < announce a server failure */ - _debugMid(" !EXOSIP_CALL_SERVERFAILURE"); - SIPCallServerFailure(event); - break; - case EXOSIP_CALL_GLOBALFAILURE: /** 14 < announce a global failure */ - _debugMid(" !EXOSIP_CALL_GLOBALFAILURE\n"); - SIPCallServerFailure(event); - break; - case EXOSIP_CALL_ACK: /** 15 < ACK received for 200ok to INVITE */ - _debugMid(" !EXOSIP_CALL_ACK\n"); - SIPCallAck(event); - break; - case EXOSIP_CALL_CANCELLED: /** 16 < announce that call has been cancelled */ - _debugMid(" !EXOSIP_CALL_CANCELLED\n"); - break; - case EXOSIP_CALL_TIMEOUT: /** 17 < announce that call has failed */ - _debugMid(" !EXOSIP_CALL_TIMEOUT\n"); - break; - - /* Request related events within calls (except INVITE) */ - case EXOSIP_CALL_MESSAGE_NEW: /** 18 < announce new incoming MESSAGE. */ - _debugMid(" !EXOSIP_CALL_MESSAGE_NEW\n"); - SIPCallMessageNew(event); - break; - case EXOSIP_CALL_MESSAGE_PROCEEDING: /** 19 < announce a 1xx for MESSAGE. */ - _debugMid(" !EXOSIP_CALL_MESSAGE_PROCEEDING\n"); - break; - case EXOSIP_CALL_MESSAGE_ANSWERED: /** 20 < announce a 200ok */ - // 200 OK - _debugMid(" !EXOSIP_CALL_MESSAGE_ANSWERED\n"); - break; - case EXOSIP_CALL_MESSAGE_REDIRECTED: /** 21 < announce a failure. */ - _debugMid(" !EXOSIP_CALL_MESSAGE_REDIRECTED\n"); - break; - case EXOSIP_CALL_MESSAGE_REQUESTFAILURE: /** 22 < announce a failure. */ - _debugMid(" !EXOSIP_CALL_MESSAGE_REQUESTFAILURE\n"); - break; - case EXOSIP_CALL_MESSAGE_SERVERFAILURE: /** 23 < announce a failure. */ - _debugMid(" !EXOSIP_CALL_MESSAGE_SERVERFAILURE\n"); - break; - case EXOSIP_CALL_MESSAGE_GLOBALFAILURE: /** 24 < announce a failure. */ - _debugMid(" !EXOSIP_CALL_MESSAGE_GLOBALFAILURE\n"); - break; - - case EXOSIP_CALL_CLOSED: /** 25 < a BYE was received for this call */ - _debugMid(" !EXOSIP_CALL_CLOSED\n"); - SIPCallClosed(event); - break; - - /* For both UAS & UAC events */ - case EXOSIP_CALL_RELEASED: /** 26 < call context is cleared. */ - _debugMid(" !EXOSIP_CALL_RELEASED\n"); - SIPCallReleased(event); - break; - - /* Response received for request outside calls */ - case EXOSIP_MESSAGE_NEW: /** 27 < announce new incoming MESSAGE. */ - _debugMid(" !EXOSIP_MESSAGE_NEW\n"); - if (event->request == NULL) { break; } - SIPMessageNew(event); - break; - case EXOSIP_MESSAGE_PROCEEDING: /** 28 < announce a 1xx for MESSAGE. */ - _debugMid(" !EXOSIP_MESSAGE_PROCEEDING\n"); - break; - case EXOSIP_MESSAGE_ANSWERED: /** 29 < announce a 200ok */ - _debugMid(" !EXOSIP_MESSAGE_ANSWERED\n"); - break; - case EXOSIP_MESSAGE_REDIRECTED: /** 30 < announce a failure. */ - _debugMid(" !EXOSIP_MESSAGE_REDIRECTED\n"); - break; - - case EXOSIP_MESSAGE_REQUESTFAILURE: /** 31 < announce a failure. */ - _debugMid(" !EXOSIP_MESSAGE_REQUESTFAILURE\n"); - if (event->response !=0 && event->response->status_code == SIP_METHOD_NOT_ALLOWED) - Manager::instance().incomingMessage(getAccountID(), "Message are not allowed"); - break; - case EXOSIP_MESSAGE_SERVERFAILURE: /** 32 < announce a failure. */ - _debugMid(" !EXOSIP_MESSAGE_SERVERFAILURE\n"); - break; - case EXOSIP_MESSAGE_GLOBALFAILURE: /** 33 < announce a failure. */ - _debugMid(" !EXOSIP_MESSAGE_GLOBALFAILURE\n"); - break; - - /* Presence and Instant Messaging */ - case EXOSIP_SUBSCRIPTION_UPDATE: /** 34 < announce incoming SUBSCRIBE. */ - _debugMid(" !EXOSIP_SUBSCRIPTION_UPDATE\n"); - break; - case EXOSIP_SUBSCRIPTION_CLOSED: /** 35 < announce end of subscription. */ - _debugMid(" !EXOSIP_SUBSCRIPTION_CLOSED\n"); - break; - - case EXOSIP_SUBSCRIPTION_NOANSWER: /** 37 < announce no answer */ - _debugMid(" !EXOSIP_SUBSCRIPTION_NOANSWER\n"); - break; - case EXOSIP_SUBSCRIPTION_PROCEEDING: /** 38 < announce a 1xx */ - _debugMid(" !EXOSIP_SUBSCRIPTION_PROCEEDING\n"); - break; - case EXOSIP_SUBSCRIPTION_ANSWERED: /** 39 < announce a 200ok */ - _debugMid(" !EXOSIP_SUBSCRIPTION_ANSWERED\n"); - eXosip_lock(); - eXosip_automatic_action(); - eXosip_unlock(); - break; - - case EXOSIP_SUBSCRIPTION_REDIRECTED: /** 40 < announce a redirection */ - _debugMid(" !EXOSIP_SUBSCRIPTION_REDIRECTED\n"); - break; - case EXOSIP_SUBSCRIPTION_REQUESTFAILURE: /** 41 < announce a request failure */ - _debugMid(" !EXOSIP_SUBSCRIPTION_REQUESTFAILURE\n"); - break; - case EXOSIP_SUBSCRIPTION_SERVERFAILURE: /** 42 < announce a server failure */ - _debugMid(" !EXOSIP_SUBSCRIPTION_REQUESTFAILURE\n"); - break; - case EXOSIP_SUBSCRIPTION_GLOBALFAILURE: /** 43 < announce a global failure */ - _debugMid(" !EXOSIP_SUBSCRIPTION_GLOBALFAILURE\n"); - break; - case EXOSIP_SUBSCRIPTION_NOTIFY: /** 44 < announce new NOTIFY request */ - _debugMid(" !EXOSIP_SUBSCRIPTION_NOTIFY\n"); - osip_body_t* body; - osip_from_to_str(event->request->from, &tmp2); - osip_message_get_body(event->request, 0, &body); - if (body != NULL && body->body != NULL) { -// printf("\n---------------------------------\n"); -// printf ("(%i) from: %s\n %s\n", event->tid, tmp2, body->body); -// printf("---------------------------------\n"); - } - osip_free(tmp2); - break; - case EXOSIP_SUBSCRIPTION_RELEASED: /** 45 < call context is cleared. */ - _debugMid(" !EXOSIP_SUBSCRIPTION_RELEASED\n"); - break; - - case EXOSIP_IN_SUBSCRIPTION_NEW: /** 46 < announce new incoming SUBSCRIBE.*/ - _debugMid(" !EXOSIP_IN_SUBSCRIPTION_NEW\n"); - break; - case EXOSIP_IN_SUBSCRIPTION_RELEASED: /** 47 < announce end of subscription. */ - _debugMid(" !EXOSIP_IN_SUBSCRIPTION_RELEASED\n"); - break; - - case EXOSIP_EVENT_COUNT: /** 48 < MAX number of events */ - _debugMid(" !EXOSIP_EVENT_COUNT : SHOULD NEVER HAPPEN!!!!!\n"); - break; - default: - printf("received eXosip event (type, did, cid) = (%d, %d, %d)", event->type, event->did, event->cid); - break; - } - eXosip_event_free(event); + // Nothing anymore. PJSIP is based on asynchronous events } bool SIPVoIPLink::sendRegister() { - int expire_value = Manager::instance().getRegistrationExpireValue(); - _debug("SIP Registration Expire Value = %i\n" , expire_value); - - if (_eXosipRegID != EXOSIP_ERROR_STD) { - return false; - } - - std::string hostname = getHostName(); - if (hostname.empty()) { - return false; - } - - if (_authname.empty()) { - return false; - } - - std::string proxy = "sip:" + _proxy; - hostname = "sip:" + hostname; - std::string from = SIPFromHeader(_authname, getHostName()); + AccountID id; + pj_status_t status; - osip_message_t *reg = NULL; - eXosip_lock(); - if (!_proxy.empty()) { - _debug("* SIP Info: Register from: %s to %s\n", from.data(), proxy.data()); - _eXosipRegID = eXosip_register_build_initial_register(from.data(), - proxy.data(), NULL, expire_value, ®); - } else { - _debug("* SIP Info: Register from: %s to %s\n", from.data(), hostname.data()); - _eXosipRegID = eXosip_register_build_initial_register(from.data(), - hostname.data(), NULL, expire_value, ®); - } - eXosip_unlock(); - if (_eXosipRegID < EXOSIP_ERROR_NO ) { - return false; - } + id = getAccountID(); - if (!sendSIPAuthentification()) { - _debug("* SIP Info: register without authentication\n"); - return false; + if(_regc) { + status = pjsip_regc_destroy(_regc); + _regc = NULL; + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); } - osip_message_set_header (reg, "Event", "Registration"); - osip_message_set_header (reg, "Allow-Events", "presence"); - - eXosip_lock(); - int eXosipErr = eXosip_register_send_register(_eXosipRegID, reg); - if (eXosipErr == EXOSIP_ERROR_BUILDING) { - _debug("! SIP Failure: Cannot build registration, check the setup\n"); - eXosip_unlock(); - return false; - } - if (eXosipErr == EXOSIP_ERROR_STD) { - _debug("! SIP Failure: Registration sending failed\n"); - eXosip_unlock(); - return false; - } + _bRegister = true; + + int expire_value = Manager::instance().getRegistrationExpireValue(); + _debug("SIP Registration Expire Value = %i\n" , expire_value); setRegistrationState(Trying); - eXosip_unlock(); - return true; + return Manager::instance().getUserAgent()->addAccount(id, &_regc, _server, _authname, _password, expire_value); } std::string @@ -524,45 +174,22 @@ SIPVoIPLink::sendSIPAuthentification() /** @todo Même chose ici ? */ return false; } - eXosip_lock(); - int returnValue = eXosip_add_authentication_info(login.data(), login.data(), _password.data(), NULL, NULL); - eXosip_unlock(); - return (returnValue != EXOSIP_ERROR_STD ? true : false); + return true; } bool SIPVoIPLink::sendUnregister() { _debug("SEND UNREGISTER for account %s\n" , getAccountID().c_str()); - if ( _eXosipRegID == EXOSIP_ERROR_STD) return false; - int eXosipErr = EXOSIP_ERROR_NO; - osip_message_t *reg = NULL; - - eXosip_lock(); - eXosipErr = eXosip_register_build_register (_eXosipRegID, 0, ®); - eXosip_unlock(); - - if (eXosipErr != EXOSIP_ERROR_NO) { - _debug("! SIP Failure: Unable to build registration for sendUnregister"); - return false; - } - - eXosip_lock(); - _debug("< Sending REGISTER (expire=0)\n"); - eXosipErr = eXosip_register_send_register (_eXosipRegID, reg); - if (eXosipErr == EXOSIP_ERROR_BUILDING) { - _debug("! SIP Failure: Cannot build registration (unregister), check the setup\n"); - eXosip_unlock(); - return false; - } - if (eXosipErr == EXOSIP_ERROR_STD) { - _debug("! SIP Failure: Unable to send registration (unregister)\n"); - } - _eXosipRegID = EXOSIP_ERROR_STD; - eXosip_unlock(); - + if(!_bRegister) + return true; + + _bRegister = false; + + Manager::instance().getUserAgent()->removeAccount(_regc); + return true; } @@ -572,6 +199,7 @@ SIPVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl) SIPCall* call = new SIPCall(id, Call::Outgoing); if (call) { call->setPeerNumber(toUrl); + _debug("Try to make a call to: %s with call ID: %s\n", toUrl.data(), id.data()); // we have to add the codec before using it in SIPOutgoingInvite... call->setCodecMap(Manager::instance().getCodecDescriptorMap()); if ( SIPOutgoingInvite(call) ) { @@ -596,38 +224,15 @@ SIPVoIPLink::answer(const CallID& id) return false; } - // Send 200 OK - osip_message_t *answerMessage = NULL; - eXosip_lock(); - int i = eXosip_call_build_answer(call->getTid(), SIP_OK, &answerMessage); + int i = Manager::instance().getUserAgent()->answer(call); + if (i != 0) { _debug("< SIP Building Error: send 400 Bad Request\n"); - eXosip_call_send_answer (call->getTid(), SIP_BAD_REQUEST, NULL); } else { // use exosip, bug locked i = 0; - sdp_message_t *remote_sdp = eXosip_get_remote_sdp(call->getDid()); - if (remote_sdp!=NULL) { - i = call->sdp_complete_message(remote_sdp, answerMessage); - if (i!=0) { - osip_message_free(answerMessage); - } - sdp_message_free(remote_sdp); - } - if (i != 0) { - _debug("< SIP Error: send 415 Unsupported Media Type\n"); - eXosip_call_send_answer (call->getTid(), SIP_UNSUPPORTED_MEDIA_TYPE, NULL); - } else { - _debug("< SIP send 200 OK\n"); - eXosip_call_send_answer (call->getTid(), SIP_OK, answerMessage); - } - } - eXosip_unlock(); - - if(i==0) { - // Incoming call is answered, start the sound thread. _debug("* SIP Info: Starting AudioRTP when answering\n"); - if (_audiortp.createNewSession(call) >= 0) { + if (_audiortp->createNewSession(call) >= 0) { call->setAudioStart(true); call->setConnectionState(Call::Connected); call->setState(Call::Active); @@ -646,16 +251,12 @@ SIPVoIPLink::hangup(const CallID& id) SIPCall* call = getSIPCall(id); if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } - _debug("- SIP Action: Hang up call %s [cd: %3d %3d]\n", id.data(), call->getCid(), call->getDid()); - // Release SIP stack. - eXosip_lock(); - eXosip_call_terminate(call->getCid(), call->getDid()); - eXosip_unlock(); - + Manager::instance().getUserAgent()->hangup(call); + // Release RTP thread if (Manager::instance().isCurrentCall(id)) { _debug("* SIP Info: Stopping AudioRTP for hangup\n"); - _audiortp.closeRtpSession(); + _audiortp->closeRtpSession(); } removeCall(id); return true; @@ -668,12 +269,9 @@ SIPVoIPLink::cancel(const CallID& id) if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } _debug("- SIP Action: Cancel call %s [cid: %3d]\n", id.data(), call->getCid()); - // Release SIP stack. - eXosip_lock(); - eXosip_call_terminate(call->getCid(), -1); - eXosip_unlock(); removeCall(id); + return true; } @@ -683,67 +281,15 @@ SIPVoIPLink::onhold(const CallID& id) SIPCall* call = getSIPCall(id); if (call==0) { _debug("! SIP Error: call doesn't exist\n"); return false; } + // Stop sound call->setAudioStart(false); call->setState(Call::Hold); _debug("* SIP Info: Stopping AudioRTP for onhold action\n"); - _audiortp.closeRtpSession(); - - - int did = call->getDid(); - - eXosip_lock (); - sdp_message_t *local_sdp = eXosip_get_local_sdp(did); - eXosip_unlock (); - - if (local_sdp == NULL) { - _debug("! SIP Failure: unable to find local_sdp\n"); - return false; - } - - // Build INVITE_METHOD for put call on-hold - osip_message_t *invite = NULL; - eXosip_lock (); - int exosipErr = eXosip_call_build_request (did, INVITE_METHOD, &invite); - eXosip_unlock (); - - if (exosipErr != 0) { - sdp_message_free(local_sdp); - _debug("! SIP Failure: unable to build invite method to hold call\n"); - return false; - } + _audiortp->closeRtpSession(); - /* add sdp body */ - { - char *tmp = NULL; + Manager::instance().getUserAgent()->onhold(call); - int i = sdp_hold_call(local_sdp); - if (i != 0) { - sdp_message_free (local_sdp); - osip_message_free (invite); - _debug("! SIP Failure: Unable to hold call in SDP\n"); - return false; - } - - i = sdp_message_to_str(local_sdp, &tmp); - sdp_message_free(local_sdp); - if (i != 0) { - osip_message_free (invite); - osip_free (tmp); - _debug("! SIP Failure: Unable to translate sdp message to string\n"); - return false; - } - osip_message_set_body (invite, tmp, strlen (tmp)); - osip_free (tmp); - osip_message_set_content_type (invite, "application/sdp"); - } - - // send request - _debug("< SIP: Send on hold request\n"); - eXosip_lock (); - exosipErr = eXosip_call_send_request (did, invite); - eXosip_unlock (); - return true; } @@ -751,64 +297,15 @@ bool SIPVoIPLink::offhold(const CallID& id) { SIPCall* call = getSIPCall(id); - if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } - - int did = call->getDid(); - - eXosip_lock (); - sdp_message_t *local_sdp = eXosip_get_local_sdp(did); - eXosip_unlock (); - - if (local_sdp == NULL) { - _debug("! SIP Failure: unable to find local_sdp\n"); - return false; - } - - // Build INVITE_METHOD for put call off-hold - osip_message_t *invite; - eXosip_lock (); - int exosipErr = eXosip_call_build_request (did, INVITE_METHOD, &invite); - eXosip_unlock (); + if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } - if (exosipErr != 0) { - sdp_message_free(local_sdp); - return EXOSIP_ERROR_STD; - } - - /* add sdp body */ - { - char *tmp = NULL; - - int i = sdp_off_hold_call (local_sdp); - if (i != 0) { - sdp_message_free (local_sdp); - osip_message_free (invite); - return false; - } - - i = sdp_message_to_str (local_sdp, &tmp); - sdp_message_free (local_sdp); - if (i != 0) { - osip_message_free (invite); - osip_free (tmp); - return false; - } - osip_message_set_body (invite, tmp, strlen (tmp)); - osip_free (tmp); - osip_message_set_content_type (invite, "application/sdp"); - } - - // Send request - _debug("< Send off hold request\n"); - eXosip_lock (); - exosipErr = eXosip_call_send_request (did, invite); - eXosip_unlock (); + Manager::instance().getUserAgent()->offhold(call); // Enable audio _debug("* SIP Info: Starting AudioRTP when offhold\n"); call->setState(Call::Active); // it's sure that this is the current call id... - if (_audiortp.createNewSession(call) < 0) { + if (_audiortp->createNewSession(call) < 0) { _debug("! SIP Failure: Unable to start sound (%s:%d)\n", __FILE__, __LINE__); return false; } @@ -826,23 +323,22 @@ SIPVoIPLink::transfer(const CallID& id, const std::string& to) tmp_to = tmp_to + "@" + getHostName(); } - osip_message_t *refer; - eXosip_lock(); - // Build transfer request - int exosipErr = eXosip_call_build_refer(call->getDid(), (char*)tmp_to.data(), &refer); - if (exosipErr == 0) { - // Send transfer request - _debug("< SIP send transfer request to %s\n", tmp_to.data()); - exosipErr = eXosip_call_send_request(call->getDid(), refer); - } - eXosip_unlock(); + _debug("In transfer, tmp_to is %s\n", tmp_to.data()); + + Manager::instance().getUserAgent()->transfer(call, tmp_to); - _audiortp.closeRtpSession(); + //_audiortp->closeRtpSession(); // shall we delete the call? //removeCall(id); return true; } +bool SIPVoIPLink::transferStep2() +{ + _audiortp->closeRtpSession(); + return true; +} + bool SIPVoIPLink::refuse (const CallID& id) { @@ -856,31 +352,23 @@ SIPVoIPLink::refuse (const CallID& id) return false; } - - osip_message_t *answerMessage = NULL; - eXosip_lock(); - // not BUSY.. where decline the invitation! - int exosipErr = eXosip_call_build_answer(call->getTid(), SIP_DECLINE, &answerMessage); - if (exosipErr == 0) { - exosipErr = eXosip_call_send_answer(call->getTid(), SIP_DECLINE, answerMessage); - } - eXosip_unlock(); + Manager::instance().getUserAgent()->refuse(call); + return true; } bool -SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code) +SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code UNUSED) { SIPCall* call = getSIPCall(id); if (call==0) { _debug("Call doesn't exist\n"); return false; } - int duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH); - osip_message_t *info; - const int body_len = 1000; - int i; + Manager::instance().getUserAgent()->carryingDTMFdigits(call); + //int duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH); - char *dtmf_body = new char[body_len]; + // TODO Add DTMF with pjsip - INFO method + /* eXosip_lock(); // Build info request i = eXosip_call_build_info(call->getDid(), &info); @@ -892,144 +380,22 @@ SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code) i = eXosip_call_send_request(call->getDid(), info); } eXosip_unlock(); - - delete[] dtmf_body; dtmf_body = NULL; + */ + return true; } bool -SIPVoIPLink::sendMessage(const std::string& to, const std::string& body) +SIPVoIPLink::sendMessage(const std::string& to UNUSED, const std::string& body UNUSED) { - bool returnValue = false; - - // fast return - if (body.empty()) {return returnValue; } - - osip_message_t* message = 0; - const char* method = "MESSAGE"; - - std::string sipFrom = getSipFrom(); - std::string sipTo = getSipTo(to); - std::string sipRoute = getSipRoute(); - - if (!SIPCheckUrl(sipFrom)) { - return returnValue; - } - if (!SIPCheckUrl(sipTo)) { - return returnValue; - } - - int eXosipError = EXOSIP_ERROR_STD; - eXosip_lock(); - if ( sipRoute.empty() ) { - eXosipError = eXosip_message_build_request(&message, method, sipTo.c_str(), sipFrom.c_str(), NULL); - } else { - eXosipError = eXosip_message_build_request(&message, method, sipTo.c_str(), sipFrom.c_str(), sipRoute.c_str()); - } - - if (eXosipError == EXOSIP_ERROR_NO) { - // add body - // add message - // src: http://www.atosc.org/pipermail/public/osip/2005-October/006007.html - osip_message_set_expires(message, "120"); - osip_message_set_body(message, body.c_str(), body.length()); - osip_message_set_content_type(message, "text/plain"); - - eXosipError = eXosip_message_send_request(message); - if (eXosipError == EXOSIP_ERROR_NO) { - // correctly send the message - returnValue = true; - } - } - eXosip_unlock(); - return returnValue; + return true; } // NOW bool SIPVoIPLink::isContactPresenceSupported() { - return true; -} - -/* -void -SIPVoIPLink::subscribePresenceForContact(Contact* contact) -{ - osip_message_t* subscription; - - int i; - - std::string to = contact->getUrl().data(); - std::ostringstream from; - - // Build URL of sender - from << "sip:" << _authname.data() << "@" << getHostName().data(); - - // Subscribe for changes on server but also polls at every 5000 interval - i = eXosip_subscribe_build_initial_request(&subscription, - to.data(), - from.str().c_str(), - NULL, - "presence", 5000); - if(i!=0) return; - - // We want to receive presence in the PIDF XML format in SIP messages - osip_message_set_accept(subscription, "application/pidf+xml"); - - // Send subscription - eXosip_lock(); - i = eXosip_subscribe_send_initial_request(subscription); - if(i!=0) _debug("Sending of subscription tp %s failed\n", to.data()); - eXosip_unlock(); -} -*/ - -void -SIPVoIPLink::publishPresenceStatus(std::string status) -{ - _debug("Publishing presence status\n"); - char buf[4096]; - int i; - osip_message_t* publication; - - std::ostringstream url; - std::string basic; - std::string note; - - // Build URL of sender - url << "sip:" << _authname.data() << "@" << getHostName().data(); - - // TODO - // Call function to convert status in basic and note - // tags that are integrated in the publication - basic = "open"; - note = "ready"; - - snprintf(buf, 4096, -"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\ -<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\ - xmlns:es=\"urn:ietf:params:xml:ns:pidf:status:rpid-status\"\n\ - entity=\"%s\">\n\ - <tuple id=\"sg89ae\">\n\ - <status>\n\ - <basic>%s</basic>\n\ - <es:activities>\n\ - <es:activity>in-transit</es:activity>\n\ - </es:activities>\n\ - </status>\n\ - <contact priority=\"0.8\">%s</contact>\n\ - <note>%s</note>\n\ - </tuple>\n\ -</presence>" - , url.str().c_str(), basic.data(), url.str().c_str(), note.data()); - - // Build publish request in PIDF - i = eXosip_build_publish(&publication, url.str().c_str(), url.str().c_str(), NULL, "presence", "1800", "application/pidf+xml", buf); - - eXosip_lock(); - i = eXosip_publish(publication, url.str().c_str()); - eXosip_unlock(); + return true; } bool @@ -1044,106 +410,27 @@ SIPVoIPLink::SIPOutgoingInvite(SIPCall* call) } bool -SIPVoIPLink::SIPStartCall(SIPCall* call, const std::string& subject) +SIPVoIPLink::SIPStartCall(SIPCall* call, const std::string& subject UNUSED) { if (!call) return false; std::string to = getSipTo(call->getPeerNumber()); - std::string from = getSipFrom(); std::string route = getSipRoute(); - _debug(" From: %s\n", from.data()); + _debug(" To: %s\n", to.data()); _debug(" Route: %s\n", route.data()); - if (!SIPCheckUrl(from)) { + /*if (!SIPCheckUrl(from)) { _debug("! SIP Error: Source address is invalid %s\n", from.data()); return false; } if (!SIPCheckUrl(to)) { return false; - } + }*/ - osip_message_t *invite; - eXosip_lock(); - int eXosipError = eXosip_call_build_initial_invite (&invite, (char*)to.data(), - (char*)from.data(), - (char*)route.data(), - (char*)subject.data()); - - if (eXosipError != 0) { - eXosip_unlock(); - return false; // error when building the invite - } + //setCallAudioLocal(call); + AccountID accId = getAccountID(); - setCallAudioLocal(call); - - std::ostringstream media_audio; - std::ostringstream rtpmap_attr; - AudioCodecType payload; - int nbChannel; - int iter; - - // Set rtpmap according to the supported codec order - //CodecMap map = call->getCodecMap().getCodecMap(); - CodecOrder map = call->getCodecMap().getActiveCodecs(); - - for(iter=0 ; iter < map.size() ; iter++){ - if(map[iter] != -1){ - payload = map[iter]; - // add each payload in the list of payload - media_audio << payload << " "; - - rtpmap_attr << "a=rtpmap:" << payload << " " << - call->getCodecMap().getCodecName(payload) << "/" << call->getCodecMap().getSampleRate(payload); - - //TODO add channel infos - nbChannel = call->getCodecMap().getChannel(payload); - if (nbChannel!=1) { - rtpmap_attr << "/" << nbChannel; - } - rtpmap_attr << "\r\n"; - } - // go to next codec - //*iter++; - } - - // http://www.antisip.com/documentation/eXosip2/group__howto1__initialize.html - // tell sip if we support SIP extension like 100rel - // osip_message_set_supported (invite, "100rel"); - - /* add sdp body */ - { - char tmp[4096]; - snprintf (tmp, 4096, - "v=0\r\n" - "o=SFLphone 0 0 IN IP4 %s\r\n" - "s=call\r\n" - "c=IN IP4 %s\r\n" - "t=0 0\r\n" - "m=audio %d RTP/AVP %s\r\n" - "%s", - _localExternAddress.c_str(), _localExternAddress.c_str(), call->getLocalExternAudioPort(), media_audio.str().c_str(), rtpmap_attr.str().c_str()); - // media_audio should be one, two or three numbers? - osip_message_set_body (invite, tmp, strlen (tmp)); - osip_message_set_content_type (invite, "application/sdp"); - _debug("SDP send: %s", tmp); - } - - _debug("> INVITE To <%s>\n", to.data()); - int cid = eXosip_call_send_initial_invite(invite); - - // Keep the cid in case of cancelling - call->setCid(cid); - - if (cid <= 0) { - eXosip_unlock(); - return false ; - } else { - _debug("* SIP Info: Outgoing callID is %s, cid=%d\n", call->getCallId().data(), cid); - eXosip_call_set_reference (cid, NULL); - } - eXosip_unlock(); - - return true; + return Manager::instance().getUserAgent()->makeOutgoingCall(to, call, accId); } std::string @@ -1160,10 +447,10 @@ SIPVoIPLink::getSipFrom() { std::string SIPVoIPLink::getSipTo(const std::string& to_url) { // Form the From header field basis on configuration panel - bool isRegistered = (_eXosipRegID == EXOSIP_ERROR_STD) ? false : true; + //bool isRegistered = (_eXosipRegID == EXOSIP_ERROR_STD) ? false : true; // add a @host if we are registered and there is no one inside the url - if (to_url.find("@") == std::string::npos && isRegistered) { + if (to_url.find("@") == std::string::npos) {// && isRegistered) { std::string host = getHostName(); if(!host.empty()) { return SIPToHeader(to_url + "@" + host); @@ -1192,24 +479,8 @@ SIPVoIPLink::SIPToHeader(const std::string& to) } bool -SIPVoIPLink::SIPCheckUrl(const std::string& url) +SIPVoIPLink::SIPCheckUrl(const std::string& url UNUSED) { - int i; - - osip_from_t *to; - i = osip_from_init(&to); - if (i != 0) { - _debug("! SIP Warning: Cannot initialize osip parser\n"); - return false; - } - i = osip_from_parse(to, url.data()); - if (i != 0) { - _debug("! SIP Warning: Cannot parse url %s\n", url.data()); - return false; - } - - // Free memory - osip_from_free (to); return true; } @@ -1237,280 +508,50 @@ SIPVoIPLink::setCallAudioLocal(SIPCall* call) } void -SIPVoIPLink::SIPCallInvite(eXosip_event_t *event) -{ - _debug("> INVITE (receive)\n"); - CallID id = Manager::instance().getNewCallID(); - - SIPCall* call = new SIPCall(id, Call::Incoming); - if (!call) { - _debug("! SIP Failure: unable to create an incoming call"); - return; - } - - setCallAudioLocal(call); - call->setCodecMap(Manager::instance().getCodecDescriptorMap()); - call->setConnectionState(Call::Progressing); - if (call->SIPCallInvite(event)) { - if (Manager::instance().incomingCall(call, getAccountID())) { - addCall(call); - } else { - delete call; call = 0; - } - } else { - delete call; call = 0; - } - // Send 180 RINGING - _debug("< Send 180 Ringing\n"); - eXosip_lock (); - eXosip_call_send_answer(event->tid, 180, NULL); - eXosip_unlock (); - call->setConnectionState(Call::Ringing); -} - -void -SIPVoIPLink::SIPCallReinvite(eXosip_event_t *event) -{ - _debug("> REINVITE (receive)\n"); - SIPCall* call = findSIPCallWithCidDid(event->cid, event->did); - if (call == 0) { - _debug("! SIP Failure: unknown call\n"); - _debug("< Send 488 Not Acceptable Here"); - eXosip_lock(); - eXosip_call_send_answer(event->tid, 488, NULL); - eXosip_unlock(); - return; - } - if ( call->getCallId() == Manager::instance().getCurrentCallId()) { - // STOP tone - Manager::instance().stopTone(true); - // STOP old rtp session - _debug("* SIP Info: Stopping AudioRTP when reinvite\n"); - _audiortp.closeRtpSession(); - call->setAudioStart(false); - } - call->SIPCallReinvite(event); -} - -void -SIPVoIPLink::SIPCallRinging(eXosip_event_t *event) -{ - - SIPCall* call = findSIPCallWithCid(event->cid); - if (!call) { - _debug("! SIP Failure: unknown call\n"); - return; - } - // we could set the cid/did/tid and get the FROM here... - // but we found the call with the cid/did already, why setting it again? - // call->ringingCall(event); - call->setDid(event->did); - call->setConnectionState(Call::Ringing); - Manager::instance().peerRingingCall(call->getCallId()); -} - -void -SIPVoIPLink::SIPCallAnswered(eXosip_event_t *event) -{ - SIPCall* call = findSIPCallWithCid(event->cid); - if (!call) { - _debug("! SIP Failure: unknown call\n"); - return; - } - call->setDid(event->did); - - if (call->getConnectionState() != Call::Connected) { - call->SIPCallAnswered(event); - call->SIPCallAnsweredWithoutHold(event); - - call->setConnectionState(Call::Connected); - call->setState(Call::Active); - - Manager::instance().peerAnsweredCall(call->getCallId()); - if (Manager::instance().isCurrentCall(call->getCallId())) { - _debug("* SIP Info: Starting AudioRTP when answering\n"); - if ( _audiortp.createNewSession(call) < 0) { - _debug("RTP Failure: unable to create new session\n"); - } else { - call->setAudioStart(true); - } - } - } else { - _debug("* SIP Info: Answering call (on/off hold to send ACK)\n"); - call->SIPCallAnswered(event); - } -} - -void -SIPVoIPLink::SIPCallRequestFailure(eXosip_event_t *event) -{ - if (!event->response) { return; } - // 404 error - _debug(" Request Failure, receive code %d\n", event->response->status_code); - // Handle 4XX errors - switch (event->response->status_code) { - case SIP_PROXY_AUTHENTICATION_REQUIRED: - _debug("- SIP Action: Server ask required authentification: logging...\n"); - sendSIPAuthentification(); - eXosip_lock(); - eXosip_automatic_action(); - eXosip_unlock(); - break; - case SIP_UNAUTHORIZED: - _debug("- SIP Action: Request is unauthorized. SIP Server ask authentification: logging...\n"); - sendSIPAuthentification(); - break; - - case SIP_BUSY_HERE: // 486 - { - SIPCall* call = findSIPCallWithCid(event->cid); - if (call!=0) { - CallID& id = call->getCallId(); - call->setConnectionState(Call::Connected); - call->setState(Call::Busy); - Manager::instance().callBusy(id); - removeCall(id); - } - } - break; - case SIP_REQUEST_TERMINATED: // 487 - break; - - default: - /*case SIP_BAD_REQUEST: - case SIP_FORBIDDEN: - case SIP_NOT_FOUND: - case SIP_METHOD_NOT_ALLOWED: - case SIP_406_NOT_ACCEPTABLE: - case SIP_REQ_TIME_OUT: - case SIP_TEMPORARILY_UNAVAILABLE: - case SIP_ADDRESS_INCOMPLETE: - case SIP_NOT_ACCEPTABLE_HERE: // 488 */ - // Display error on the screen phone - { - SIPCall* call = findSIPCallWithCid(event->cid); - if (call!=0) { - CallID& id = call->getCallId(); - call->setConnectionState(Call::Connected); - call->setState(Call::Error); - Manager::instance().callFailure(id); - removeCall(id); - } - } - } -} - -void -SIPVoIPLink::SIPCallServerFailure(eXosip_event_t *event) -{ - if (!event->response) { return; } - switch(event->response->status_code) { - case SIP_SERVICE_UNAVAILABLE: // 500 - case SIP_BUSY_EVRYWHERE: // 600 - case SIP_DECLINE: // 603 - SIPCall* call = findSIPCallWithCid(event->cid); +SIPVoIPLink::SIPCallServerFailure(SIPCall *call) +{ + //if (!event->response) { return; } + //switch(event->response->status_code) { + //case SIP_SERVICE_UNAVAILABLE: // 500 + //case SIP_BUSY_EVRYWHERE: // 600 + //case SIP_DECLINE: // 603 + //SIPCall* call = findSIPCallWithCid(event->cid); if (call != 0) { + _debug("Server error!\n"); CallID id = call->getCallId(); Manager::instance().callFailure(id); removeCall(id); } - break; - } -} - -void -SIPVoIPLink::SIPRegistrationFailure( eXosip_event_t* event ) -{ - if(!event->response){ - setRegistrationState(ErrorHost); - return ; - } - - switch( event->response->status_code ) { - case SIP_FORBIDDEN: - _debug("SIP forbidden\n"); - setRegistrationState(ErrorAuth); - break; - case SIP_UNAUTHORIZED: - _debug("SIP unauthorized\n"); - setRegistrationState(Error); - break; - default: - setRegistrationState(ErrorAuth); - //_debug("Unknown error: %s\n" , event->response->status_code); - } -} - -void -SIPVoIPLink::SIPCallAck(eXosip_event_t *event) -{ - SIPCall* call = findSIPCallWithCidDid(event->cid, event->did); - if (!call) { return; } - if (!call->isAudioStarted()) { - if (Manager::instance().isCurrentCall(call->getCallId())) { - _debug("* SIP Info: Starting AudioRTP when ack\n"); - if ( _audiortp.createNewSession(call) ) { - call->setAudioStart(true); - } - } - } -} - -void -SIPVoIPLink::SIPCallMessageNew(eXosip_event_t *event) -{ - if (0 == event->request) return; - - _debug(" > SIP Event: Receive a call message\n"); - - if (MSG_IS_INFO(event->request)) { - _debug("* SIP Info: It's a Request Info\n"); - osip_content_type_t* c_t = event->request->content_type; - if (c_t != 0 && c_t->type != 0 && c_t->subtype != 0 ) { - _debug("* SIP Info: Content Type of the message: %s/%s\n", c_t->type, c_t->subtype); - // application/dtmf-relay - if (strcmp(c_t->type, "application") == 0 && strcmp(c_t->subtype, "dtmf-relay") == 0) { - handleDtmfRelay(event); - } - } - } - - osip_message_t *answerOKNewMessage; - eXosip_lock(); - if ( 0 == eXosip_call_build_answer(event->tid, SIP_OK, &answerOKNewMessage)) { - _debug("< SIP Sending 200 OK\n"); - eXosip_call_send_answer(event->tid, SIP_OK, answerOKNewMessage); - } else { - _debug("! SIP Failure: Could not sent an OK message\n"); - } - eXosip_unlock(); - + //break; + //} } void -SIPVoIPLink::SIPCallClosed(eXosip_event_t *event) +SIPVoIPLink::SIPCallClosed(SIPCall *call) { // it was without did before - SIPCall* call = findSIPCallWithCid(event->cid); + //SIPCall* call = findSIPCallWithCid(event->cid); if (!call) { return; } CallID id = call->getCallId(); - call->setDid(event->did); + //call->setDid(event->did); if (Manager::instance().isCurrentCall(id)) { call->setAudioStart(false); _debug("* SIP Info: Stopping AudioRTP when closing\n"); - _audiortp.closeRtpSession(); + _audiortp->closeRtpSession(); } + _debug("After close RTP\n"); Manager::instance().peerHungupCall(id); removeCall(id); + _debug("After remove call ID\n"); } void -SIPVoIPLink::SIPCallReleased(eXosip_event_t *event) +SIPVoIPLink::SIPCallReleased(SIPCall *call) { // do cleanup if exists // only cid because did is always 0 in these case.. - SIPCall* call = findSIPCallWithCid(event->cid); + //SIPCall* call = findSIPCallWithCid(event->cid); if (!call) { return; } // if we are here.. something when wrong before... @@ -1521,83 +562,35 @@ SIPVoIPLink::SIPCallReleased(eXosip_event_t *event) } void -SIPVoIPLink::SIPMessageNew(eXosip_event_t *event) +SIPVoIPLink::SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata) { - if (MSG_IS_OPTIONS(event->request)) { - // old handling was - // - send 200 OK if call id is not found - // - send nothing if call id is found - eXosip_lock(); - eXosip_options_send_answer (event->tid, SIP_OK, NULL); - eXosip_unlock(); + //SIPCall* call = dynamic_cast<SIPCall *>(theCall);//findSIPCallWithCid(event->cid); + if (!call) { + _debug("! SIP Failure: unknown call\n"); + return; } - // Voice message - else if (MSG_IS_NOTIFY(event->request)){ - int ii; - osip_body_t *body = NULL; - // Get the message body - ii = osip_message_get_body(event->request, 0, &body); - if (ii != 0) { - _debug("! SIP Error: Cannot get body in a new EXOSIP_MESSAGE_NEW event\n"); - return; - } + //call->setDid(event->did); - // Analyse message body - if (!body || !body->body) { - return; - } - std::string str(body->body); - std::string::size_type pos; - std::string::size_type pos_slash; - pos = str.find(VOICE_MSG); - - if (pos == std::string::npos) { - // If the string is not found - return; - } - - pos_slash = str.find ("/"); - std::string nb_msg = str.substr(pos + LENGTH_VOICE_MSG, - pos_slash - (pos + LENGTH_VOICE_MSG)); - - // Set the number of voice-message - int msgVoicemail = atoi(nb_msg.data()); - _debug(" > NOTIFY -> %i voice message for account %s\n" , msgVoicemail , getAccountID().c_str()); - - if (msgVoicemail != 0) { - // If there is at least one voice-message, start notification - Manager::instance().startVoiceMessageNotification(getAccountID(), nb_msg); - } - // http://www.jdrosen.net/papers/draft-ietf-simple-im-session-00.txt - } else if (MSG_IS_MESSAGE(event->request)) { - _debug("> MESSAGE received\n"); - // osip_content_type_t* osip_message::content_type - osip_content_type_t* c_t = event->request->content_type; - if (c_t != 0 && c_t->type != 0 && c_t->subtype != 0 ) { - _debug("* SIP Info: Content Type of the message: %s/%s\n", c_t->type, c_t->subtype); - - osip_body_t *body = NULL; - // Get the message body - if (0 == osip_message_get_body(event->request, 0, &body)) { - _debug("* SIP Info: Body length: %d\n", body->length); - if (body->body!=0 && - strcmp(c_t->type,"text") == 0 && - strcmp(c_t->subtype,"plain") == 0 - ) { - _debug("* SIP Info: Text body: %s\n", body->body); - Manager::instance().incomingMessage(getAccountID(), body->body); - } + if (call->getConnectionState() != Call::Connected) { + //call->SIPCallAnswered(event); + call->SIPCallAnsweredWithoutHold(rdata); + + call->setConnectionState(Call::Connected); + call->setState(Call::Active); + + Manager::instance().peerAnsweredCall(call->getCallId()); + if (Manager::instance().isCurrentCall(call->getCallId())) { + _debug("* SIP Info: Starting AudioRTP when answering\n"); + if ( _audiortp->createNewSession(call) < 0) { + _debug("RTP Failure: unable to create new session\n"); + } else { + call->setAudioStart(true); } } - osip_message_t *answerOK; - eXosip_lock(); - if ( 0 == eXosip_message_build_answer(event->tid, SIP_OK, &answerOK)) { - _debug("< Sending 200 OK\n"); - eXosip_message_send_answer(event->tid, SIP_OK, answerOK); - } - eXosip_unlock(); + } else { + _debug("* SIP Info: Answering call (on/off hold to send ACK)\n"); + //call->SIPCallAnswered(event); } - } SIPCall* @@ -1649,7 +642,7 @@ SIPVoIPLink::getSIPCall(const CallID& id) } return NULL; } - +/* bool SIPVoIPLink::handleDtmfRelay(eXosip_event_t* event) { @@ -1684,7 +677,7 @@ SIPVoIPLink::handleDtmfRelay(eXosip_event_t* event) { returnValue = true; } } -/* + // we receive the duration, but we use our configuration... posStart = dtmfBody.find("Duration="); @@ -1698,95 +691,45 @@ SIPVoIPLink::handleDtmfRelay(eXosip_event_t* event) { _debug("Duration value: %s\n", duration.c_str()); returnValue = true; } -*/ + } } return returnValue; } - +*/ /////////////////////////////////////////////////////////////////////////////// // Private functions /////////////////////////////////////////////////////////////////////////////// -int -SIPVoIPLink::sdp_hold_call (sdp_message_t * sdp) -{ - int pos; - int pos_media = -1; - char *rcvsnd; - int recv_send = -1; - - pos = 0; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - while (rcvsnd != NULL) { - if (rcvsnd != NULL && 0 == strcmp (rcvsnd, "sendonly")) { - recv_send = 0; - } else if (rcvsnd != NULL && (0 == strcmp (rcvsnd, "recvonly") - || 0 == strcmp (rcvsnd, "sendrecv"))) { - recv_send = 0; - sprintf (rcvsnd, "sendonly"); - } - pos++; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - } - - pos_media = 0; - while (!sdp_message_endof_media (sdp, pos_media)) { - pos = 0; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - while (rcvsnd != NULL) { - if (rcvsnd != NULL && 0 == strcmp (rcvsnd, "sendonly")) { - recv_send = 0; - } else if (rcvsnd != NULL && (0 == strcmp (rcvsnd, "recvonly") - || 0 == strcmp (rcvsnd, "sendrecv"))) { - recv_send = 0; - sprintf (rcvsnd, "sendonly"); - } - pos++; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - } - pos_media++; - } - if (recv_send == -1) { - /* we need to add a global attribute with a field set to "sendonly" */ - sdp_message_a_attribute_add (sdp, -1, osip_strdup ("sendonly"), NULL); - } - - return 0; +void SIPVoIPLink::setAuthName(const std::string& authname) +{ + _authname = authname; + //_cred.username = pj_str((char *)authname.data()); } -int -SIPVoIPLink::sdp_off_hold_call (sdp_message_t * sdp) +void SIPVoIPLink::setPassword(const std::string& password) { - int pos; - int pos_media = -1; - char *rcvsnd; - - pos = 0; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - while (rcvsnd != NULL) { - if (rcvsnd != NULL && (0 == strcmp (rcvsnd, "sendonly") - || 0 == strcmp (rcvsnd, "recvonly"))) { - sprintf (rcvsnd, "sendrecv"); - } - pos++; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - } - - pos_media = 0; - while (!sdp_message_endof_media (sdp, pos_media)) { - pos = 0; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - while (rcvsnd != NULL) { - if (rcvsnd != NULL && (0 == strcmp (rcvsnd, "sendonly") - || 0 == strcmp (rcvsnd, "recvonly"))) { - sprintf (rcvsnd, "sendrecv"); - } - pos++; - rcvsnd = sdp_message_a_att_field_get (sdp, pos_media, pos); - } - pos_media++; - } + _password = password; + /*_cred.data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; + _cred.data = pj_str((char *)password.data()); + _cred.realm = pj_str("*"); + _cred.scheme = pj_str("digest");*/ +} + +void SIPVoIPLink::setSipServer(const std::string& sipServer) +{ + //std::string tmp; + _debug("Set sip server %s\n", sipServer.data()); + _server = sipServer; + //_registrar = pj_str((char *)tmp.data()); + //_user = "<sip:" + _authname + "@" + sipServer + ">"; + //_user = pj_str((char *)tmp.data()); +} - return 0; +pj_str_t SIPVoIPLink::string2PJStr(const std::string &value) +{ + char tmp[256]; + + strcpy(tmp, value.data()); + return pj_str(tmp); } diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h index 441e34b2c69e68f2e46138703c4d2db6f1f67114..2b4c6b99c145c07d0640af87cd46b1414fbeed8b 100644 --- a/src/sipvoiplink.h +++ b/src/sipvoiplink.h @@ -23,12 +23,21 @@ #include "voiplink.h" #include <string> -#include <eXosip2/eXosip.h> -#include "audio/audiortp.h" -#include <osip2/osip_mt.h> +#include <pjsip.h> +#include <pjlib-util.h> +#include <pjlib.h> +#include <pjnath/stun_config.h> + +//TODO Remove this include if we don't need anything from it +#include <pjsip_simple.h> + +#include <pjsip_ua.h> +#include <pjmedia/sdp.h> +#include <pjmedia/sdp_neg.h> class EventThread; class SIPCall; +class AudioRtp; /** * @file sipvoiplink.h @@ -50,10 +59,14 @@ class SIPVoIPLink : public VoIPLink */ ~SIPVoIPLink(); - int eXosip_running; + /* Copy Constructor */ + SIPVoIPLink(const SIPVoIPLink& rh); + /* Assignment Operator */ + SIPVoIPLink& operator=( const SIPVoIPLink& rh); + /** - * Try to initiate the eXosip engine/thread and set config + * Try to initiate the pjsip engine/thread and set config * @return bool True if OK */ bool init(void); @@ -139,6 +152,9 @@ class SIPVoIPLink : public VoIPLink */ bool transfer(const CallID& id, const std::string& to); + /** Handle the incoming refer msg, not finished yet */ + bool transferStep2(); + /** * Refuse the call * @param id The call identifier @@ -158,10 +174,6 @@ class SIPVoIPLink : public VoIPLink bool isContactPresenceSupported(); - //void subscribePresenceForContact(Contact* contact); - - void publishPresenceStatus(std::string status); - // TODO Not used yet void sendMessageToContact(const CallID& id, const std::string& message); @@ -187,15 +199,21 @@ class SIPVoIPLink : public VoIPLink * Set the authentification name * @param authname The authentification name */ - void setAuthName(const std::string& authname) { _authname = authname; } + void setAuthName(const std::string& authname); //{ _authname = authname; } /** * Set the password * @param password Password */ - void setPassword(const std::string& password) { _password = password; } + void setPassword(const std::string& password); //{ _password = password; } + + void setSipServer(const std::string& sipServer); + + bool isRegister() {return _bRegister;} + + void setRegister(bool result) {_bRegister = result;} - private: + public: /** * Terminate every call not hangup | brutal | Protected by mutex @@ -203,7 +221,7 @@ class SIPVoIPLink : public VoIPLink void terminateSIPCall(); /** - * Get the local Ip by eXosip + * Get the local Ip * only if the local ip address is to his default value: 127.0.0.1 * setLocalIpAdress * @return bool false if not found @@ -282,88 +300,33 @@ class SIPVoIPLink : public VoIPLink */ bool setCallAudioLocal(SIPCall* call); - /** - * Create a new call and send a incoming call notification to the user - * @param event eXosip Event - */ - void SIPCallInvite(eXosip_event_t *event); - - /** - * Use a exisiting call to restart the audio - * @param event eXosip Event - */ - void SIPCallReinvite(eXosip_event_t *event); - - /** - * Tell the user that the call is ringing - * @param event eXosip Event - */ - void SIPCallRinging(eXosip_event_t *event); - /** * Tell the user that the call was answered - * @param event eXosip Event + * @param */ - void SIPCallAnswered(eXosip_event_t *event); - - /** - * Handling 4XX error - * @param event eXosip Event - */ - void SIPCallRequestFailure(eXosip_event_t *event); - + void SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata); + /** * Handling 5XX/6XX error - * @param event eXosip Event + * @param */ - void SIPCallServerFailure(eXosip_event_t *event); - - /** - * Handle registration failure cases ( SIP_FORBIDDEN , SIP_UNAUTHORIZED ) - * @param event eXosip event - */ - void SIPRegistrationFailure( eXosip_event_t *event ); - - /** - * Handling ack (restart audio if reinvite) - * @param event eXosip Event - */ - void SIPCallAck(eXosip_event_t *event); - - /** - * Handling message inside a call (like dtmf) - * @param event eXosip Event - */ - void SIPCallMessageNew(eXosip_event_t *event); - - /** - * Handle an INFO with application/dtmf-relay content-type - * @param event eXosip Event - */ - bool handleDtmfRelay(eXosip_event_t *event); + void SIPCallServerFailure(SIPCall *call); /** * Peer close the connection - * @param event eXosip Event + * @param */ - void SIPCallClosed(eXosip_event_t *event); + void SIPCallClosed(SIPCall *call); /** * The call pointer was released * If the call was not cleared before, report an error - * @param event eXosip Event + * @param */ - void SIPCallReleased(eXosip_event_t *event); + void SIPCallReleased(SIPCall *call); /** - * Receive a new Message request - * Option/Notify/Message - * @param event eXosip Event - */ - void SIPMessageNew(eXosip_event_t *event); - - /** - * Find a SIPCall with cid from eXosip Event + * Find a SIPCall with cid * Explication there is no DID when the dialog is not establish... * @param cid call ID * @return SIPCall* SIPCall pointer or 0 @@ -371,7 +334,7 @@ class SIPVoIPLink : public VoIPLink SIPCall* findSIPCallWithCid(int cid); /** - * Find a SIPCall with cid and did from eXosip Event + * Find a SIPCall with cid and did * @param cid call ID * @param did domain ID * @return SIPCall* SIPCall pointer or 0 @@ -385,24 +348,9 @@ class SIPVoIPLink : public VoIPLink */ SIPCall* getSIPCall(const CallID& id); - /** To build sdp when call is on-hold */ - int sdp_hold_call (sdp_message_t * sdp); - - /** To build sdp when call is off-hold */ - int sdp_off_hold_call (sdp_message_t * sdp); - - /** EventThread get every incoming events */ - EventThread* _evThread; - - /** Tell if eXosip was stared (eXosip_init) */ + /** Tell if the initialisation was done */ bool _initDone; - /** Registration identifier, needed by unregister to build message */ - int _eXosipRegID; - - /** Number of voicemail */ - int _nMsgVoicemail; - /** when we init the listener, how many times we try to bind a port? */ int _nbTryListenAddr; @@ -428,7 +376,13 @@ class SIPVoIPLink : public VoIPLink std::string _password; /** Starting sound */ - AudioRtp _audiortp; + AudioRtp* _audiortp; + + pj_str_t string2PJStr(const std::string &value); +private: + pjsip_regc *_regc; + std::string _server; + bool _bRegister; }; #endif diff --git a/src/user_cfg.h b/src/user_cfg.h index 25a0cc953b959d9dbe41d5f11aa169bde5f4c8c0..57201f084be7353e84750920d6b4aa74909b64f6 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -61,6 +61,7 @@ #define REGISTRATION_EXPIRE "Registration.expire" /** Registration expire value */ #define CONFIG_AUDIO "Audio.api" /** Audio manager (ALSA or pulseaudio) */ #define CONFIG_PA_VOLUME_CTRL "Pulseaudio.volumeCtrl" /** Whether or not PA should modify volume of other applications on the same sink */ +#define CONFIG_SIP_PORT "SIP.portNum" #define SIGNALISATION "VoIPLink" /** Section Signalisation */ #define PLAY_DTMF "DTMF.playDtmf" /** Whether or not should play dtmf */ @@ -87,7 +88,7 @@ #define DFT_MAX_CALLS "20" /** Default maximum calls in history */ #define DFT_EXPIRE_VALUE "180" /** Default expire value for registration */ #define DFT_AUDIO_MANAGER "1" /** Default audio manager */ - +#define DFT_SIP_PORT "5060" #ifdef USE_ZEROCONF #define CONFIG_ZEROCONF_DEFAULT_STR "1" /** Default Zero configuration networking module value */ diff --git a/src/useragent.cpp b/src/useragent.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b703186c540d26eed3ab64f48a127be4016889d3 --- /dev/null +++ b/src/useragent.cpp @@ -0,0 +1,1626 @@ +/* + * Copyright (C) 2004-2005 Savoir-Faire Linux inc. + * Author: Yun Liu <yun.liu@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <string> + + +#include <iostream> + +#include "manager.h" +#include "sipcall.h" +#include "useragent.h" +#include "sipvoiplink.h" +#include "sipaccount.h" + +#define DEFAULT_SIP_PORT 5060 +#define RANDOM_SIP_PORT rand() % 64000 + 1024 +#define RANDOM_LOCAL_PORT ((rand() % 27250) + 5250)*2 + +UserAgent *UserAgent::_current; + +UserAgent::UserAgent():_endpt(NULL) ,_sock(NULL), _cp(), _pool(NULL), _mutex(NULL), _mod(), _options_handler(), _useStun(false), _stunHost(), + _stunServer(""), _localExternAddress(""), _localIPAddress("127.0.0.1"), _localExternPort(0), _localPort(0), _regPort(DEFAULT_SIP_PORT), _thread(NULL) { + //_useStun = false; + //_localIPAddress = "127.0.0.1"; + UserAgent::_current = this; +} + +UserAgent::~UserAgent() { + _debug("UserAgent: In dtor!\n"); + sipDestory(); +} + +pj_status_t UserAgent::sipCreate() { + + pj_status_t status; + + // Init PJLIB: must be called before any call to the pjsip library + status = pj_init(); + // Use pjsip macros for sanity check + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Init PJLIB-UTIL library + status = pjlib_util_init(); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Set the pjsip log level + pj_log_set_level( PJ_LOG_LEVEL ); + + // Init PJNATH + status = pjnath_init(); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Create a pool factory to allocate memory + pj_caching_pool_init(&_cp, &pj_pool_factory_default_policy, 0); + + // Create memory pool for application. + _pool = pj_pool_create(&_cp.factory, "sflphone", 4000, 4000, NULL); + + if (!_pool) { + _debug("UserAgent: Could not initialize memory pool\n"); + return PJ_ENOMEM; + } + + // Create a recursive mutex. Simple wrapper for pj_mutex_create + status = pj_mutex_create_recursive(_pool, "sflphone", &_mutex); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Create the SIP endpoint + status = pjsip_endpt_create(&_cp.factory, pj_gethostname()->ptr, &_endpt); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + return PJ_SUCCESS; +} + +pj_status_t UserAgent::sipInit() { + + pj_status_t status; + + /* Init SIP UA: */ + + //FIXME! DNS initialize here! */ + + /* Start resolving STUN server */ + // if we useStun and we failed to receive something on port 5060, we try a random port + // If use STUN server, firewall address setup + if (!loadSIPLocalIP()) { + _debug("UserAgent: Unable to determine network capabilities\n"); + return false; + } + int errPjsip = 0; + int port = _regPort; + + //_debug("stun host is %s\n", _stunHost.ptr); + if (_useStun && !Manager::instance().behindNat(_stunServer, port)) { + port = RANDOM_SIP_PORT; + if (!Manager::instance().behindNat(_stunServer, port)) { + _debug("UserAgent: Unable to check NAT setting\n"); + return false; // hoho we can't use the random sip port too... + } + } + + _localPort = port; + if (_useStun) { + // set by last behindNat() call (ish)... + stunServerResolve(); + _localExternAddress = Manager::instance().getFirewallAddress(); + _localExternPort = Manager::instance().getFirewallPort(); + errPjsip = createUDPServer(); + if (errPjsip != 0) { + _debug("UserAgent: Could not initialize SIP listener on port %d\n", port); + return errPjsip; + } + } else { + _localExternAddress = _localIPAddress; + _localExternPort = _localPort; + errPjsip = createUDPServer(); + if (errPjsip != 0) { + _debug("UserAgent: Could not initialize SIP listener on port %d\n", _localExternPort); + _localExternPort = _localPort = RANDOM_SIP_PORT; + _debug("UserAgent: Try to initialize SIP listener on port %d\n", _localExternPort); + errPjsip = createUDPServer(); + if (errPjsip != 0) { + _debug("UserAgent: Fail to initialize SIP listener on port %d\n", _localExternPort); + return errPjsip; + } + } + } + + _debug("UserAgent: SIP Init -- listening on port %d\n", _localExternPort); + + // Initialize transaction layer + status = pjsip_tsx_layer_init_module(_endpt); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Initialize UA layer module + status = pjsip_ua_init_module(_endpt, NULL); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Initialize Replaces support. See the Replaces specification in RFC 3891 + status = pjsip_replaces_init_module(_endpt); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Initialize 100rel support + status = pjsip_100rel_init_module(_endpt); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Initialize and register sflphone module + { + const pjsip_module mod_initializer ={ + NULL, NULL, // prev, next. + { (char*)"mod-sflphone", 9}, // Name. + -1, // Id + PJSIP_MOD_PRIORITY_APPLICATION, // Priority + NULL, // load() + NULL, // start() + NULL, // stop() + NULL, // unload() + &mod_on_rx_request, // on_rx_request() + &mod_on_rx_response, // on_rx_response() + NULL, // on_tx_request. + NULL, // on_tx_response() + NULL, // on_tsx_state() + }; + + _mod = mod_initializer; + + status = pjsip_endpt_register_module(_endpt, &_mod); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + } + + // Init the event subscription module. + // It extends PJSIP by supporting SUBSCRIBE and NOTIFY methods + status = pjsip_evsub_init_module(_endpt); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Init presence module. + // TODO We probably do not need that extension + status = pjsip_pres_init_module(_endpt, pjsip_evsub_instance()); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Init PUBLISH module + // Provide an implementation of SIP Extension for Event State Publication (RFC 3903) + // TODO Check if it is necessary + status = pjsip_publishc_init_module(_endpt); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Init xfer/REFER module + status = pjsip_xfer_init_module(_endpt); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + /*{ + const pjsip_module handler ={ + NULL, NULL, // prev, next. + { (char*)"mod-sflphone-options", 20},//9}, // Name. + -1, // Id + PJSIP_MOD_PRIORITY_APPLICATION, // Priority + NULL, // load() + NULL, // start() + NULL, // stop() + NULL, // unload() + &options_on_rx_request, // on_rx_request() + NULL, // on_tx_request. + NULL, // on_tx_response() + NULL, // on_tsx_state() + }; + + _options_handler = handler; + } + + // Register the OPTIONS module + status = pjsip_endpt_register_module(_endpt, &_options_handler); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); + + // Add OPTIONS in Allow header + status = pjsip_endpt_add_capability(_endpt, + NULL, + PJSIP_H_ALLOW, + NULL, 1, + &STR_OPTIONS); + PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 );*/ + + + // Initialize invite session module + // These callbacks will be called on incoming requests, media session state, etc. + { + pjsip_inv_callback inv_cb; + + // Init the callback for INVITE session: + pj_bzero(&inv_cb, sizeof (inv_cb)); + + inv_cb.on_state_changed = &call_on_state_changed; + inv_cb.on_new_session = &call_on_forked; + inv_cb.on_media_update = &call_on_media_update; + inv_cb.on_tsx_state_changed = &call_on_tsx_changed; + + _debug("UserAgent: VOIP callbacks initialized\n"); + + // Initialize session invite module + status = pjsip_inv_usage_init(_endpt, &inv_cb); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + } + + + // Add endpoint capabilities (INFO, OPTIONS, etc) for this UA + { + pj_str_t allowed[] = { + {(char*)"INFO", 4}, + {(char*)"REGISTER", 8} + }; // //{"INVITE", 6}, {"ACK",3}, {"BYE",3}, {"CANCEL",6}, {"OPTIONS", 7}, + pj_str_t accepted = {(char*)"application/sdp", 15}; + + // Register supported methods + pjsip_endpt_add_capability(_endpt, &_mod, PJSIP_H_ALLOW, NULL, PJ_ARRAY_SIZE(allowed), allowed); + + // Register "application/sdp" in ACCEPT header + pjsip_endpt_add_capability(_endpt, &_mod, PJSIP_H_ACCEPT, NULL, 1, &accepted); + } + + _debug("UserAgent: sflphone version %s for %s initialized\n", pj_get_version(), PJ_OS_NAME); + + Manager::instance().setSipThreadStatus(false); + + // Create the secondary thread to poll sip events + status = pj_thread_create(_pool, "sflphone", &start_thread, NULL, PJ_THREAD_DEFAULT_STACK_SIZE, 0, + &_thread); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + + /* Done! */ + return PJ_SUCCESS; + +} + +void UserAgent::sipDestory() { + /* Signal threads to quit: */ + Manager::instance().setSipThreadStatus(true); + + /* Wait worker thread to quit: */ + if (_thread) { + pj_thread_join(_thread); + pj_thread_destroy(_thread); + _thread = NULL; + } + + if (_endpt) { + /* Terminate all presence subscriptions. */ + //pjsua_pres_shutdown(); + + /* Wait for some time to allow unregistration to complete: */ + _debug("UserAgent: Shutting down...\n"); + busy_sleep(1000); + } + + /* Destroy endpoint. */ + if (_endpt) { + pjsip_endpt_destroy(_endpt); + _endpt = NULL; + } + + /* Destroy mutex */ + if (_mutex) { + pj_mutex_destroy(_mutex); + _mutex = NULL; + } + + /* Destroy pool and pool factory. */ + if (_pool) { + pj_pool_release(_pool); + _pool = NULL; + pj_caching_pool_destroy(&_cp); + + /* Shutdown PJLIB */ + pj_shutdown(); + } + + /* Done. */ +} + +void UserAgent::busy_sleep(unsigned msec) +{ +#if defined(PJ_SYMBIAN) && PJ_SYMBIAN != 0 + /* Ideally we shouldn't call pj_thread_sleep() and rather + * CActiveScheduler::WaitForAnyRequest() here, but that will + * drag in Symbian header and it doesn't look pretty. + */ + pj_thread_sleep(msec); +#else + pj_time_val timeout, now, tv; + + pj_gettimeofday(&timeout); + timeout.msec += msec; + pj_time_val_normalize(&timeout); + + tv.sec = 0; + tv.msec = 10; + pj_time_val_normalize(&tv); + + do { + pjsip_endpt_handle_events(_endpt, &tv); + pj_gettimeofday(&now); + } while (PJ_TIME_VAL_LT(now, timeout)); +#endif +} + +bool UserAgent::addAccount(AccountID id, pjsip_regc **regc2, const std::string& server, const std::string& user, const std::string& passwd, + const int& timeout UNUSED) { + pj_status_t status; + AccountID *currentId = new AccountID(id); + char contactTmp[256]; + pjsip_regc *regc; + pj_str_t svr; + pj_str_t aor; + pj_str_t contact; + + pj_mutex_lock(_mutex); + std::string tmp; + + SIPAccount *account; + + status = pjsip_regc_create(_endpt, (void *) currentId, ®c_cb, ®c); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create regc.\n"); + return status; + } + + tmp = "sip:" + server; + pj_strdup2(_pool, &svr, tmp.data()); + + tmp = "<sip:" + user + "@" + server + ">"; + pj_strdup2(_pool, &aor, tmp.data()); + + + sprintf(contactTmp, "<sip:%s@%s:%d>", user.data(), _localExternAddress.data(), _localExternPort); + pj_strdup2(_pool, &contact, contactTmp); + + //_debug("UserAgent: Get in %s %d %s\n", svr.ptr, svr.slen, aor.ptr); + _debug("UserAgent: Contact is %s\n", contact.ptr); + status = pjsip_regc_init(regc, &svr, &aor, &aor, 1, &contact, 600); //timeout); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to initialize regc. %d\n", status); //, regc->str_srv_url.ptr); + return status; + } + + + account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount(id)); + pjsip_cred_info *cred = account->getCredInfo(); + + if(!cred) + cred = new pjsip_cred_info(); + + pj_bzero(cred, sizeof (pjsip_cred_info)); + pj_strdup2(_pool, &cred->username, user.data()); + cred->data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; + pj_strdup2(_pool, &cred->data, passwd.data()); + pj_strdup2(_pool, &cred->realm, "*"); + pj_strdup2(_pool, &cred->scheme, "digest"); + pjsip_regc_set_credentials(regc, 1, cred); + + account->setCredInfo(cred); + + pjsip_tx_data *tdata; + status = pjsip_regc_register(regc, PJ_TRUE, &tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to register regc.\n"); + return status; + } + + status = pjsip_regc_send(regc, tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to send regc request.\n"); + return status; + } + + account->setUserName(user); + account->setServer(server); + account->setContact(contactTmp); + + // associate regc with account + *regc2 = regc; + + pj_mutex_unlock(_mutex); + return true; +} + +bool UserAgent::removeAccount(pjsip_regc *regc) +{ + pj_status_t status = 0; + pjsip_tx_data *tdata = NULL; + + pj_mutex_lock(_mutex); + + if(regc) { + status = pjsip_regc_unregister(regc, &tdata); + if(status != PJ_SUCCESS) { + _debug("UserAgent: Unable to unregister regc.\n"); + pj_mutex_unlock(_mutex); + return false; + } + + status = pjsip_regc_send( regc, tdata ); + if(status != PJ_SUCCESS) { + _debug("UserAgent: Unable to send regc request.\n"); + pj_mutex_unlock(_mutex); + return false; + } + } else { + _debug("UserAgent: regc is null!\n"); + pj_mutex_unlock(_mutex); + return false; + } + + pj_mutex_unlock(_mutex); + return true; +} + +pj_str_t UserAgent::buildContact(char *userName) { + //pj_str_t contact; + char tmp[256]; + + //FIXME: IPV6 issue!! + _debug("In build Contact %s %s %d\n", userName, _localExternAddress.data(), _localExternPort); + sprintf(tmp, "<sip:%s@%s:%d>", userName, _localExternAddress.data(), _localExternPort); + //_debug("get tmp\n"); + return pj_str(tmp); +} + +pj_status_t UserAgent::stunServerResolve() { + pj_str_t stun_adr; + pj_hostent he; + pj_stun_config stunCfg; + pj_status_t stun_status; + pj_sockaddr stun_srv; + + // Initialize STUN configuration + pj_stun_config_init(&stunCfg, &_cp.factory, 0, pjsip_endpt_get_ioqueue(_endpt), pjsip_endpt_get_timer_heap(_endpt)); + + stun_status = PJ_EPENDING; + + // Init STUN socket + size_t pos = _stunServer.find(':'); + if(pos == std::string::npos) { + pj_strdup2(_pool, &stun_adr, _stunServer.data()); + stun_status = pj_sockaddr_in_init(&stun_srv.ipv4, &stun_adr, (pj_uint16_t) 3478); + } else { + std::string serverName = _stunServer.substr(0, pos); + std::string serverPort = _stunServer.substr(pos + 1); + int nPort = atoi(serverPort.data()); + pj_strdup2(_pool, &stun_adr, serverName.data()); + stun_status = pj_sockaddr_in_init(&stun_srv.ipv4, &stun_adr, (pj_uint16_t) nPort); + } + + if (stun_status != PJ_SUCCESS) { + _debug("UserAgent: Unresolved stun server!\n"); + stun_status = pj_gethostbyname(&stun_adr, &he); + + if (stun_status == PJ_SUCCESS) { + pj_sockaddr_in_init(&stun_srv.ipv4, NULL, 0); + stun_srv.ipv4.sin_addr = *(pj_in_addr*) he.h_addr; + stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t) 3478); + } + } + + return stun_status; +} + +int UserAgent::createUDPServer() { + pj_status_t status; + //pj_str_t ipAddr; + pj_sockaddr_in bound_addr; + pjsip_host_port a_name; + char tmpIP[32]; + + // Init bound address to ANY + pj_memset(&bound_addr, 0, sizeof (bound_addr)); + bound_addr.sin_addr.s_addr = PJ_INADDR_ANY; + + // Create UDP server socket + status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &_sock); + if (status != PJ_SUCCESS) { + _debug("UserAgent: (%d) UDP socket() error\n", status); + return status; + } + + status = pj_sock_bind_in(_sock, pj_ntohl(bound_addr.sin_addr.s_addr), (pj_uint16_t) _localPort); + if (status != PJ_SUCCESS) { + _debug("UserAgent: (%d) UDP bind() error\n", status); + pj_sock_close(_sock); + return status; + } + + _debug("UserAgent: Use IP: %s\n", _localExternAddress.data()); + + // Create UDP-Server (default port: 5060) + strcpy(tmpIP, _localExternAddress.data()); + pj_strdup2(_pool, &a_name.host, tmpIP); + a_name.port = (pj_uint16_t) _localExternPort; + + status = pjsip_udp_transport_attach(_endpt, _sock, &a_name, 1, NULL); + if (status != PJ_SUCCESS) { + _debug("UserAgent: (%d) Unable to start UDP transport!\n", status); + return -1; + } else { + _debug("UserAgent: UDP server listening on port %d\n", _localExternPort); + } + + return 0; +} + +void UserAgent::setStunServer(const char *server) { + _stunServer = std::string(server); + _useStun = true; +} + +void UserAgent::regc_cb(struct pjsip_regc_cbparam *param) { + + AccountID *id = static_cast<AccountID *> (param->token); + SIPVoIPLink *voipLink; + + _debug("UserAgent: Account ID is %s, Register result: %d, Status: %d\n", id->data(), param->status, param->code); + voipLink = dynamic_cast<SIPVoIPLink *>(Manager::instance().getAccountLink(*id)); + if(!voipLink) + return; + + if (param->status == PJ_SUCCESS) { + if (param->code < 0 || param->code >= 300) { + /* Sometimes, the status is OK, but we still failed. + * So checking the code for real result + */ + Manager::instance().getAccountLink(*id)->setRegistrationState(VoIPLink::Error); + voipLink->setRegister(false); + } else { + // Registration/Unregistration is success + + if(voipLink->isRegister()) + Manager::instance().getAccountLink(*id)->setRegistrationState(VoIPLink::Registered); + else { + Manager::instance().getAccountLink(*id)->setRegistrationState(VoIPLink::Unregistered); + voipLink->setRegister(false); + } + } + } else { + Manager::instance().getAccountLink(*id)->setRegistrationState(VoIPLink::Error); + voipLink->setRegister(false); + } +} + +bool +UserAgent::loadSIPLocalIP() { + bool returnValue = true; + if (_localIPAddress == "127.0.0.1") { + pj_sockaddr ip_addr; + if (pj_gethostip(pj_AF_INET(), &ip_addr) != PJ_SUCCESS) { + // Update the registration state if no network capabilities found + _debug("UserAgent: Get host ip failed!\n"); + returnValue = false; + } else { + _localIPAddress = std::string(pj_inet_ntoa(ip_addr.ipv4.sin_addr)); + _debug("UserAgent: Checking network, setting local IP address to: %s\n", _localIPAddress.data()); + } + } + return returnValue; +} + +/* Thread entry point function. */ +int UserAgent::start_thread(void *arg) { + + PJ_UNUSED_ARG(arg); + + // FIXME! maybe we should add a flag for exiting! + // TODO Add the flag. We have to stop the thread when destroying the instance + while (!Manager::instance().getSipThreadStatus()) { + pj_time_val timeout = {0, 10}; + pjsip_endpt_handle_events(getInstance()->getEndPoint(), &timeout); + } + + return 0; +} + +void UserAgent::set_voicemail_info( AccountID account, pjsip_msg_body *body ){ + + int voicemail, pos_begin, pos_end; + std::string voice_str = "Voice-Message: "; + std::string delimiter = "/"; + std::string msg_body, voicemail_str; + + _debug("UserAgent: checking the voice message!\n"); + // The voicemail message is formated like that: + // Voice-Message: 1/0 . 1 is the number we want to retrieve in this case + + // We get the notification body + msg_body = (char*)body->data; + + // We need the position of the first character of the string voice_str + pos_begin = msg_body.find(voice_str); + // We need the position of the delimiter + pos_end = msg_body.find(delimiter); + + // So our voicemail number between the both index + try { + + voicemail_str = msg_body.substr(pos_begin + voice_str.length(), pos_end - ( pos_begin + voice_str.length())); + std::cout << "voicemail number : " << voicemail_str << std::endl; + voicemail = atoi( voicemail_str.c_str() ); + } + catch( std::out_of_range& e ){ + std::cerr << e.what() << std::endl; + } + + // We need now to notify the manager + if( voicemail != 0 ) + Manager::instance().startVoiceMessageNotification(account, voicemail); +} + + +pj_bool_t UserAgent::mod_on_rx_request(pjsip_rx_data *rdata) { + + pj_status_t status; + pj_str_t reason; + unsigned options = 0; + pjsip_dialog* dialog; + pjsip_tx_data *tdata; + //pjmedia_sdp_session *r_sdp; + AccountID account_id; + + // voicemail part + std::string method_name; + std::string request; + + // Handle the incoming call invite in this function + _debug("UserAgent: Callback on_rx_request is involved!\n"); + + /* First, let's got the username and server name from the invite. + * We will use them to detect which account is the callee. + */ + pjsip_uri *uri = rdata->msg_info.to->uri; + pjsip_sip_uri *sip_uri = (pjsip_sip_uri *) pjsip_uri_get_uri(uri); + + std::string userName = std::string(sip_uri->user.ptr, sip_uri->user.slen); + std::string server = std::string(sip_uri->host.ptr, sip_uri->host.slen); + + // Get the account id of callee from username and server + account_id = Manager::instance().getAccountIdFromNameAndServer(userName, server); + if(account_id == AccountNULL) { + _debug("UserAgent: Username %s doesn't match any account!\n",userName.c_str()); + return PJ_FALSE; + } + _debug("UserAgent: The receiver is : %s@%s\n", userName.data(), server.data()); + _debug("UserAgent: The callee account id is %s\n", account_id.c_str()); + + /* Now, it is the time to find the information of the caller */ + uri = rdata->msg_info.from->uri; + sip_uri = (pjsip_sip_uri *) pjsip_uri_get_uri(uri); + + std::string caller = std::string(sip_uri->user.ptr, sip_uri->user.slen); + std::string callerServer = std::string(sip_uri->host.ptr, sip_uri->host.slen); + std::string peerNumber = caller + "@" + callerServer; + + + // Get the server voicemail notification + // Catch the NOTIFY message + if( rdata->msg_info.msg->line.req.method.id == PJSIP_OTHER_METHOD ) + { + method_name = "NOTIFY"; + // Retrieve all the message. Should contains only the method name but ... + request = rdata->msg_info.msg->line.req.method.name.ptr; + // Check if the message is a notification + if( request.find( method_name ) != (size_t)-1 ) { + set_voicemail_info( account_id, rdata->msg_info.msg->body ); + } + pjsip_endpt_respond_stateless(getInstance()->getEndPoint(), rdata, PJSIP_SC_OK, NULL, NULL, NULL); + return PJ_SUCCESS; + } + + // Respond statelessly any non-INVITE requests with 500 + if (rdata->msg_info.msg->line.req.method.id != PJSIP_INVITE_METHOD) { + if (rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD) { + pj_strdup2(getInstance()->getAppPool(), &reason, "user agent unable to handle this request "); + pjsip_endpt_respond_stateless(getInstance()->getEndPoint(), rdata, PJSIP_SC_METHOD_NOT_ALLOWED, &reason, NULL, + NULL); + return PJ_TRUE; + } + } + + // Verify that we can handle the request + status = pjsip_inv_verify_request(rdata, &options, NULL, NULL, getInstance()->getEndPoint(), NULL); + if (status != PJ_SUCCESS) { + pj_strdup2(getInstance()->getAppPool(), &reason, "user agent unable to handle this INVITE "); + pjsip_endpt_respond_stateless(getInstance()->getEndPoint(), rdata, PJSIP_SC_METHOD_NOT_ALLOWED, &reason, NULL, + NULL); + return PJ_TRUE; + } + + // Generate a new call ID for the incoming call! + CallID id = Manager::instance().getNewCallID(); + + _debug("UserAgent: The call id of the incoming call is %s\n", id.c_str()); + SIPCall* call = new SIPCall(id, Call::Incoming); + if (!call) { + _debug("UserAgent: unable to create an incoming call"); + return PJ_FALSE; + } + + // Set the codec map, IP, peer number and so on... for the SIPCall object + getInstance()->setCallAudioLocal(call); + call->setCodecMap(Manager::instance().getCodecDescriptorMap()); + call->setConnectionState(Call::Progressing); + call->setIp(getInstance()->getLocalIP()); + call->setPeerNumber(peerNumber); + + /* Call the SIPCallInvite function to generate the local sdp, + * remote sdp and negociator. + * This function is also used to set the parameters of audio RTP, including: + * local IP and port number + * remote IP and port number + * possilbe audio codec will be used in this call + */ + if (call->SIPCallInvite(rdata, getInstance()->getAppPool())) { + + // Notify UI there is an incoming call + if (Manager::instance().incomingCall(call, account_id)) { + // Add this call to the callAccountMap in ManagerImpl + Manager::instance().getAccountLink(account_id)->addCall(call); + _debug("UserAgent: Notify UI success!\n"); + } else { + // Fail to notify UI + delete call; + call = NULL; + _debug("UserAgent: Fail to notify UI!\n"); + return PJ_FALSE; + } + } else { + // Fail to collect call information + delete call; + call = NULL; + _debug("UserAgent: Call SIPCallInvite failed!\n"); + return PJ_FALSE; + } + + /* Create the local dialog (UAS) */ + status = pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dialog); + if (status != PJ_SUCCESS) { + pjsip_endpt_respond_stateless(getInstance()->getEndPoint(), rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, &reason, NULL, + NULL); + return PJ_TRUE; + } + + // Specify media capability during invite session creation + pjsip_inv_session *inv; + status = pjsip_inv_create_uas(dialog, rdata, call->getLocalSDPSession(), 0, &inv); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + + // Associate the call in the invite session + inv->mod_data[getInstance()->getModId()] = call; + + // Send a 180/Ringing response + status = pjsip_inv_initial_answer(inv, rdata, PJSIP_SC_RINGING, NULL, NULL, &tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + status = pjsip_inv_send_msg(inv, tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + + // Associate invite session to the current call + call->setInvSession(inv); + + // Update the connection state + call->setConnectionState(Call::Ringing); + + /* Done */ + return PJ_SUCCESS; +} + +bool UserAgent::setCallAudioLocal(SIPCall* call) { + // Firstly, we use the local IP and port number + unsigned int callLocalAudioPort = RANDOM_LOCAL_PORT; + unsigned int callLocalExternAudioPort = callLocalAudioPort; + + if (_useStun) { + // If use Stun server, modify them + if (Manager::instance().behindNat(_stunServer, callLocalAudioPort)) { + callLocalExternAudioPort = Manager::instance().getFirewallPort(); + } + } + _debug("UserAgent: Setting local audio port to: %d\n", callLocalAudioPort); + _debug("UserAgent: Setting local audio port (external) to: %d\n", callLocalExternAudioPort); + + // Set local audio port for SIPCall(id) + call->setLocalIp(_localIPAddress); + call->setLocalAudioPort(callLocalAudioPort); + call->setLocalExternAudioPort(callLocalExternAudioPort); + + return true; +} + +int UserAgent::answer(SIPCall *call) { + pj_status_t status; + pjsip_tx_data *tdata; + + // User answered the incoming call, tell peer this news + if (call->startNegociation(_pool)) { + // Create and send a 200(OK) response + _debug("UserAgent: Negociation success!\n"); + status = pjsip_inv_answer(call->getInvSession(), PJSIP_SC_OK, NULL, NULL, &tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + status = pjsip_inv_send_msg(call->getInvSession(), tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + + return 0; + } + + return 1; +} + +bool UserAgent::makeOutgoingCall(const std::string& strTo, SIPCall* call, const AccountID& id) { + pj_status_t status; + pjsip_dialog *dialog; + pjsip_tx_data *tdata; + pj_str_t from, to, contact; + + _debug("*******************AccountId is %s\n", id.data()); + // Get the basic information about the callee account + SIPAccount* account = dynamic_cast<SIPAccount *>(Manager::instance().getAccount(id)); + + // Generate the from URI + std::string strFrom = "sip:" + account->getUserName() + "@" + account->getServer(); + + _debug("UserAgent: Make a new call from:%s to %s. Contact is %s\n", + strFrom.data(), strTo.data(), account->getContact().data()); + + // pjsip need the from and to information in pj_str_t format + pj_strdup2(_pool, &from, strFrom.data()); + pj_strdup2(_pool, &to, strTo.data()); + pj_strdup2(_pool, &contact, account->getContact().data()); + + // create the dialog (UAC) + status = pjsip_dlg_create_uac(pjsip_ua_instance(), &from, + &contact, + &to, + NULL, + &dialog); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + + setCallAudioLocal(call); + call->setIp(getInstance()->getLocalIP()); + + // Building the local SDP offer + call->createInitialOffer(_pool); + + // Create the invite session for this call + pjsip_inv_session *inv; + status = pjsip_inv_create_uac(dialog, call->getLocalSDPSession(), 0, &inv); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + + // Set auth information + pjsip_auth_clt_set_credentials(&dialog->auth_sess, 1, account->getCredInfo()); + + // Associate current call in the invite session + inv->mod_data[_mod.id] = call; + + status = pjsip_inv_invite(inv, &tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + + // Associate current invite session in the call + call->setInvSession(inv); + + status = pjsip_inv_send_msg(inv, tdata); + //PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + if(status != PJ_SUCCESS) { + return false; + } + + return true; +} + +void UserAgent::call_on_forked(pjsip_inv_session *inv, pjsip_event *e) { + PJ_UNUSED_ARG(inv); + PJ_UNUSED_ARG(e); +} + +void UserAgent::call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e) { + + pjsip_rx_data *rdata; + AccountID accId; + SIPCall *call; + SIPVoIPLink *link; + pjsip_msg *msg; + + _debug("UserAgent: TSX Changed! The tsx->state is %d; tsx->role is %d; code is %d; method id is %.*s.\n", + tsx->state, tsx->role, tsx->status_code, tsx->method.name.slen, tsx->method.name.ptr); + + //Retrieve the body message + rdata = e->body.tsx_state.src.rdata; + + if (tsx->role == PJSIP_ROLE_UAC) { + switch (tsx->state) { + case PJSIP_TSX_STATE_TERMINATED: + if (tsx->status_code == 200 && + pjsip_method_cmp(&tsx->method, pjsip_get_refer_method()) != 0) { + // Peer answered the outgoing call + _debug("UserAgent: Peer answered the outgoing call!\n"); + call = reinterpret_cast<SIPCall *> (inv->mod_data[getInstance()->getModId()]); + if (call == NULL) + return; + + //_debug("UserAgent: The call id is %s\n", call->getCallId().data()); + + accId = Manager::instance().getAccountFromCall(call->getCallId()); + link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink(accId)); + if (link) + link->SIPCallAnswered(call, rdata); + } else if (tsx->status_code / 100 == 5) { + _debug("UserAgent: 5xx error message received\n"); + } + break; + case PJSIP_TSX_STATE_PROCEEDING: + // Peer is ringing for the outgoing call + msg = rdata->msg_info.msg; + + call = reinterpret_cast<SIPCall *> (inv->mod_data[getInstance()->getModId()]); + if (call == NULL) + return; + + if (msg->line.status.code == 180) { + _debug("UserAgent: Peer is ringing!\n"); + + call->setConnectionState(Call::Ringing); + Manager::instance().peerRingingCall(call->getCallId()); + } + break; + case PJSIP_TSX_STATE_COMPLETED: + if (tsx->status_code == 407) + break; + if (tsx->status_code / 100 == 6 || tsx->status_code / 100 == 4) { + // We get error message of outgoing call from server + _debug("UserAgent: Server error message is received!\n"); + call = reinterpret_cast<SIPCall *> (inv->mod_data[getInstance()->getModId()]); + if (call == NULL) { + _debug("UserAgent: Call has been removed!\n"); + return; + } + accId = Manager::instance().getAccountFromCall(call->getCallId()); + link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink(accId)); + if (link) { + link->SIPCallServerFailure(call); + } + } + break; + default: + break; + } // end of switch + + } else { + switch (tsx->state) { + case PJSIP_TSX_STATE_TRYING: + if (pjsip_method_cmp(&tsx->method, pjsip_get_refer_method()) == 0) { + // Peer ask me to transfer call to another number. + _debug("UserAgent: Incoming REFER request!\n"); + getInstance()->onCallTransfered(inv, e->body.tsx_state.src.rdata); + } + break; + case PJSIP_TSX_STATE_COMPLETED: + if (tsx->status_code == 200 && tsx->method.id == PJSIP_BYE_METHOD) { + // Peer hangup the call + _debug("UserAgent: Peer hangup(bye) message is received!\n"); + call = reinterpret_cast<SIPCall *> (inv->mod_data[getInstance()->getModId()]); + if (call == NULL) { + _debug("UserAgent: Call has been removed!\n"); + return; + } + accId = Manager::instance().getAccountFromCall(call->getCallId()); + link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink(accId)); + if (link) { + link->SIPCallClosed(call); + } + } else if (tsx->status_code == 200 && tsx->method.id == PJSIP_CANCEL_METHOD) { + // Peer refuse the call + _debug("UserAgent: Cancel message is received!\n"); + call = reinterpret_cast<SIPCall *> (inv->mod_data[getInstance()->getModId()]); + if (call == NULL) { + _debug("UserAgent: Call has been removed!\n"); + return; + } + + accId = Manager::instance().getAccountFromCall(call->getCallId()); + link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink(accId)); + if (link) { + link->SIPCallClosed(call); + } + } + break; + default: + break; + } // end of switch + } + +} + +void UserAgent::call_on_state_changed(pjsip_inv_session *inv, pjsip_event *e) { + + PJ_UNUSED_ARG(inv); + + SIPCall *call = reinterpret_cast<SIPCall*> (inv->mod_data[getInstance()->getModId()]); + if(!call) + return; + + /* If this is an outgoing INVITE that was created because of + * REFER/transfer, send NOTIFY to transferer. + */ + if (call->getXferSub() && e->type==PJSIP_EVENT_TSX_STATE) { + int st_code = -1; + pjsip_evsub_state ev_state = PJSIP_EVSUB_STATE_ACTIVE; + + + switch (call->getInvSession()->state) { + case PJSIP_INV_STATE_NULL: + case PJSIP_INV_STATE_CALLING: + /* Do nothing */ + break; + + case PJSIP_INV_STATE_EARLY: + case PJSIP_INV_STATE_CONNECTING: + st_code = e->body.tsx_state.tsx->status_code; + ev_state = PJSIP_EVSUB_STATE_ACTIVE; + break; + + case PJSIP_INV_STATE_CONFIRMED: + /* When state is confirmed, send the final 200/OK and terminate + * subscription. + */ + st_code = e->body.tsx_state.tsx->status_code; + ev_state = PJSIP_EVSUB_STATE_TERMINATED; + break; + + case PJSIP_INV_STATE_DISCONNECTED: + st_code = e->body.tsx_state.tsx->status_code; + ev_state = PJSIP_EVSUB_STATE_TERMINATED; + break; + + case PJSIP_INV_STATE_INCOMING: + /* Nothing to do. Just to keep gcc from complaining about + * unused enums. + */ + break; + } + + if (st_code != -1) { + pjsip_tx_data *tdata; + pj_status_t status; + + status = pjsip_xfer_notify( call->getXferSub(), + ev_state, st_code, + NULL, &tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create NOTIFY -- %d\n", status); + } else { + status = pjsip_xfer_send_request(call->getXferSub(), tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to send NOTIFY -- %d\n", status); + } + } + } + } + +} + +bool UserAgent::onhold(SIPCall *call) { + _debug("UserAgent: Before onhold pjsip_inv_reinite begins!\n"); + pj_status_t status; + pjsip_tx_data *tdata; + pjmedia_sdp_attr *attr; + + + /* Create re-INVITE with new offer */ + pjmedia_sdp_media_remove_all_attr(call->getLocalSDPSession()->media[0], "sendrecv"); + attr = pjmedia_sdp_attr_create(_pool, "sendonly", NULL); + pjmedia_sdp_media_add_attr(call->getLocalSDPSession()->media[0], attr); + + status = pjsip_inv_reinvite( call->getInvSession(), NULL, call->getLocalSDPSession(), &tdata); + /* Send the request */ + status = pjsip_inv_send_msg( call->getInvSession(), tdata); + + _debug("UserAgent: After pjsip_inv_reinite begins!\n"); + return (status == PJ_SUCCESS); +} + +bool UserAgent::offhold(SIPCall *call) { + _debug("UserAgent: Before offhold pjsip_inv_reinite begins!\n"); + pj_status_t status; + pjsip_tx_data *tdata; + pjmedia_sdp_attr *attr; + + + /* Create re-INVITE with new offer */ + pjmedia_sdp_media_remove_all_attr(call->getLocalSDPSession()->media[0], "sendonly"); + attr = pjmedia_sdp_attr_create(_pool, "sendrecv", NULL); + pjmedia_sdp_media_add_attr(call->getLocalSDPSession()->media[0], attr); + + status = pjsip_inv_reinvite( call->getInvSession(), NULL, call->getLocalSDPSession(), &tdata); + /* Send the request */ + status = pjsip_inv_send_msg( call->getInvSession(), tdata); + + _debug("UserAgent: After pjsip_inv_reinite begins!\n"); + return (status == PJ_SUCCESS); +} + +bool UserAgent::hangup(SIPCall* call) { + pj_status_t status; + pjsip_tx_data *tdata; + + // User hangup current call. Notify peer + status = pjsip_inv_end_session(call->getInvSession(), 404, NULL, &tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, false); + + status = pjsip_inv_send_msg(call->getInvSession(), tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, false); + + call->getInvSession()->mod_data[getInstance()->getModId()] = NULL; + return true; +} + +bool UserAgent::refuse(SIPCall* call) +{ + pj_status_t status; + pjsip_tx_data *tdata; + + // User refuse current call. Notify peer + status = pjsip_inv_end_session(call->getInvSession(), PJSIP_SC_DECLINE, NULL, &tdata); //603 + PJ_ASSERT_RETURN(status == PJ_SUCCESS, false); + + status = pjsip_inv_send_msg(call->getInvSession(), tdata); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, false); + + call->getInvSession()->mod_data[getInstance()->getModId()] = NULL; + return true; +} + +bool UserAgent::carryingDTMFdigits(SIPCall* call) +{ + return true; +} + +bool UserAgent::transfer(SIPCall *call, const std::string& to) +{ + pjsip_evsub *sub; + pjsip_tx_data *tdata; + //pjsip_dialog *dlg; + //pjsip_generic_string_hdr *gs_hdr; + //const pj_str_t str_ref_by = { (char*)"Referred-By", 11 }; + struct pjsip_evsub_user xfer_cb; + pj_status_t status; + pj_str_t dest; + + pj_strdup2(_pool, &dest, to.data()); + + /* Create xfer client subscription. */ + pj_bzero(&xfer_cb, sizeof(xfer_cb)); + xfer_cb.on_evsub_state = &xfer_func_cb; + + status = pjsip_xfer_create_uac(call->getInvSession()->dlg, &xfer_cb, &sub); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create xfer -- %d\n", status); + return false; + } + + /* Associate this voiplink of call with the client subscription + * We can not just associate call with the client subscription + * because after this function, we can not find the cooresponding + * voiplink from the call any more. But the voiplink is useful! + */ + AccountID accId = Manager::instance().getAccountFromCall(call->getCallId()); + SIPVoIPLink *link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink(accId)); + pjsip_evsub_set_mod_data(sub, _mod.id, link); + + /* + * Create REFER request. + */ + status = pjsip_xfer_initiate(sub, &dest, &tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create REFER request -- %d\n", status); + return false; + } + + /* Send. */ + status = pjsip_xfer_send_request(sub, tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to send REFER request -- %d\n", status); + return false; + } + + return true; +} + +void UserAgent::xfer_func_cb( pjsip_evsub *sub, pjsip_event *event) +{ + PJ_UNUSED_ARG(event); + + _debug("UserAgent: Transfer callback is involved!\n"); + /* + * When subscription is accepted (got 200/OK to REFER), check if + * subscription suppressed. + */ + if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_ACCEPTED) { + + pjsip_rx_data *rdata; + pjsip_generic_string_hdr *refer_sub; + const pj_str_t REFER_SUB = {(char*)"Refer-Sub", 9 }; + + SIPVoIPLink *link = reinterpret_cast<SIPVoIPLink *> (pjsip_evsub_get_mod_data(sub, + getInstance()->getModId())); + + /* Must be receipt of response message */ + pj_assert(event->type == PJSIP_EVENT_TSX_STATE && + event->body.tsx_state.type == PJSIP_EVENT_RX_MSG); + rdata = event->body.tsx_state.src.rdata; + + /* Find Refer-Sub header */ + refer_sub = (pjsip_generic_string_hdr*) + pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, + &REFER_SUB, NULL); + + /* Check if subscription is suppressed */ + if (refer_sub && pj_stricmp2(&refer_sub->hvalue, "false")==0) { + /* Since no subscription is desired, assume that call has been + * transfered successfully. + */ + if (link) { + // It's the time to stop the RTP + link->transferStep2(); + } + + /* Yes, subscription is suppressed. + * Terminate our subscription now. + */ + _debug("UserAgent: Xfer subscription suppressed, terminating event subcription...\n"); + pjsip_evsub_terminate(sub, PJ_TRUE); + + } else { + /* Notify application about call transfer progress. + * Initially notify with 100/Accepted status. + */ + _debug("UserAgent: Xfer subscription 100/Accepted received...\n"); + } + } + /* + * On incoming NOTIFY, notify application about call transfer progress. + */ + else if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_ACTIVE || + pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) + { + pjsip_msg *msg; + pjsip_msg_body *body; + pjsip_status_line status_line; + pj_bool_t is_last; + pj_bool_t cont; + pj_status_t status; + + SIPVoIPLink *link = reinterpret_cast<SIPVoIPLink *> (pjsip_evsub_get_mod_data(sub, + getInstance()->getModId())); + + /* When subscription is terminated, clear the xfer_sub member of + * the inv_data. + */ + if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) { + pjsip_evsub_set_mod_data(sub, getInstance()->getModId(), NULL); + _debug("UserAgent: Xfer client subscription terminated\n"); + + } + + if (!link || !event) { + /* Application is not interested with call progress status */ + _debug("UserAgent: Either link or event is empty!\n"); + return; + } + + // Get current call + SIPCall *call = dynamic_cast<SIPCall *>(link->getCall(Manager::instance().getCurrentCallId())); + if(!call) { + _debug("UserAgent: Call doesn't exit!\n"); + return; + } + + /* This better be a NOTIFY request */ + if (event->type == PJSIP_EVENT_TSX_STATE && + event->body.tsx_state.type == PJSIP_EVENT_RX_MSG) + { + pjsip_rx_data *rdata; + + rdata = event->body.tsx_state.src.rdata; + + /* Check if there's body */ + msg = rdata->msg_info.msg; + body = msg->body; + if (!body) { + _debug("UserAgent: Warning! Received NOTIFY without message body\n"); + return; + } + + /* Check for appropriate content */ + if (pj_stricmp2(&body->content_type.type, "message") != 0 || + pj_stricmp2(&body->content_type.subtype, "sipfrag") != 0) + { + _debug("UserAgent: Warning! Received NOTIFY with non message/sipfrag content\n"); + return; + } + + /* Try to parse the content */ + status = pjsip_parse_status_line((char*)body->data, body->len, + &status_line); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Warning! Received NOTIFY with invalid message/sipfrag content\n"); + return; + } + + } else { + _debug("UserAgent: Set code to 500!\n"); + status_line.code = 500; + status_line.reason = *pjsip_get_status_text(500); + } + + /* Notify application */ + is_last = (pjsip_evsub_get_state(sub)==PJSIP_EVSUB_STATE_TERMINATED); + cont = !is_last; + + if(status_line.code/100 == 2) { + _debug("UserAgent: Try to stop rtp!\n"); + pjsip_tx_data *tdata; + + status = pjsip_inv_end_session(call->getInvSession(), PJSIP_SC_GONE, NULL, &tdata); + if(status != PJ_SUCCESS) { + _debug("UserAgent: Fail to create end session msg!\n"); + } else { + status = pjsip_inv_send_msg(call->getInvSession(), tdata); + if(status != PJ_SUCCESS) + _debug("UserAgent: Fail to send end session msg!\n"); + } + + link->transferStep2(); + cont = PJ_FALSE; + } + + if (!cont) { + pjsip_evsub_set_mod_data(sub, getInstance()->getModId(), NULL); + } + } + +} + +void UserAgent::onCallTransfered(pjsip_inv_session *inv, pjsip_rx_data *rdata) +{ + pj_status_t status; + pjsip_tx_data *tdata; + SIPCall *existing_call; + const pj_str_t str_refer_to = { (char*)"Refer-To", 8}; + const pj_str_t str_refer_sub = { (char*)"Refer-Sub", 9 }; + const pj_str_t str_ref_by = { (char*)"Referred-By", 11 }; + pjsip_generic_string_hdr *refer_to; + pjsip_generic_string_hdr *refer_sub; + pjsip_hdr *ref_by_hdr; + pj_bool_t no_refer_sub = PJ_FALSE; + char *uri; + std::string tmp; + pjsip_status_code code; + pjsip_evsub *sub; + + existing_call = (SIPCall *) inv->mod_data[getInstance()->getModId()]; + + /* Find the Refer-To header */ + refer_to = (pjsip_generic_string_hdr*) + pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL); + + if (refer_to == NULL) { + /* Invalid Request. + * No Refer-To header! + */ + _debug("UserAgent: Received REFER without Refer-To header!\n"); + pjsip_dlg_respond( inv->dlg, rdata, 400, NULL, NULL, NULL); + return; + } + + /* Find optional Refer-Sub header */ + refer_sub = (pjsip_generic_string_hdr*) + pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_sub, NULL); + + if (refer_sub) { + if (!pj_strnicmp2(&refer_sub->hvalue, "true", 4)==0) + no_refer_sub = PJ_TRUE; + } + + /* Find optional Referred-By header (to be copied onto outgoing INVITE + * request. + */ + ref_by_hdr = (pjsip_hdr*) + pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_ref_by, + NULL); + + /* Notify callback */ + code = PJSIP_SC_ACCEPTED; + + _debug("UserAgent: Call to %.*s is being transfered to %.*s\n", + (int)inv->dlg->remote.info_str.slen, + inv->dlg->remote.info_str.ptr, + (int)refer_to->hvalue.slen, + refer_to->hvalue.ptr); + + if (no_refer_sub) { + /* + * Always answer with 2xx. + */ + pjsip_tx_data *tdata; + const pj_str_t str_false = { (char*)"false", 5}; + pjsip_hdr *hdr; + + status = pjsip_dlg_create_response(inv->dlg, rdata, code, NULL, + &tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create 2xx response to REFER -- %d\n", status); + return; + } + + /* Add Refer-Sub header */ + hdr = (pjsip_hdr*) + pjsip_generic_string_hdr_create(tdata->pool, &str_refer_sub, + &str_false); + pjsip_msg_add_hdr(tdata->msg, hdr); + + + /* Send answer */ + status = pjsip_dlg_send_response(inv->dlg, pjsip_rdata_get_tsx(rdata), + tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create 2xx response to REFER -- %d\n", status); + return; + } + + /* Don't have subscription */ + sub = NULL; + + } else { + struct pjsip_evsub_user xfer_cb; + pjsip_hdr hdr_list; + + /* Init callback */ + pj_bzero(&xfer_cb, sizeof(xfer_cb)); + xfer_cb.on_evsub_state = &xfer_svr_cb; + + /* Init addiTHIS_FILE, THIS_FILE, tional header list to be sent with REFER response */ + pj_list_init(&hdr_list); + + /* Create transferee event subscription */ + status = pjsip_xfer_create_uas( inv->dlg, &xfer_cb, rdata, &sub); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create xfer uas -- %d\n", status); + pjsip_dlg_respond( inv->dlg, rdata, 500, NULL, NULL, NULL); + return; + } + + /* If there's Refer-Sub header and the value is "true", send back + * Refer-Sub in the response with value "true" too. + */ + if (refer_sub) { + const pj_str_t str_true = { (char*)"true", 4 }; + pjsip_hdr *hdr; + + hdr = (pjsip_hdr*) + pjsip_generic_string_hdr_create(inv->dlg->pool, + &str_refer_sub, + &str_true); + pj_list_push_back(&hdr_list, hdr); + + } + + /* Accept the REFER request, send 2xx. */ + pjsip_xfer_accept(sub, rdata, code, &hdr_list); + + /* Create initial NOTIFY request */ + status = pjsip_xfer_notify( sub, PJSIP_EVSUB_STATE_ACTIVE, + 100, NULL, &tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create NOTIFY to REFER -- %d", status); + return; + } + + /* Send initial NOTIFY request */ + status = pjsip_xfer_send_request( sub, tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to send NOTIFY to REFER -- %d\n", status); + return; + } + } + + /* We're cheating here. + * We need to get a null terminated string from a pj_str_t. + * So grab the pointer from the hvalue and NULL terminate it, knowing + * that the NULL position will be occupied by a newline. + */ + uri = refer_to->hvalue.ptr; + uri[refer_to->hvalue.slen] = '\0'; + + /* Now make the outgoing call. */ + tmp = std::string(uri); + + if(existing_call == NULL) { + _debug("UserAgent: Call doesn't exist!\n"); + return; + } + + AccountID accId = Manager::instance().getAccountFromCall(existing_call->getCallId()); + CallID newCallId = Manager::instance().getNewCallID(); + + if(!Manager::instance().outgoingCall(accId, newCallId, tmp)) { + + /* Notify xferer about the error (if we have subscription) */ + if (sub) { + status = pjsip_xfer_notify(sub, PJSIP_EVSUB_STATE_TERMINATED, + 500, NULL, &tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to create NOTIFY to REFER -- %d\n", status); + return; + } + status = pjsip_xfer_send_request(sub, tdata); + if (status != PJ_SUCCESS) { + _debug("UserAgent: Unable to send NOTIFY to REFER -- %d\n", status); + return; + } + } + return; + } + + SIPCall* newCall; + SIPVoIPLink *link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink(accId)); + if(link) { + newCall = dynamic_cast<SIPCall *>(link->getCall(newCallId)); + if(!newCall) { + _debug("UserAgent: can not find the call from sipvoiplink!\n"); + return; + } + } + + if (sub) { + /* Put the server subscription in inv_data. + * Subsequent state changed in pjsua_inv_on_state_changed() will be + * reported back to the server subscription. + */ + newCall->setXferSub(sub); + + /* Put the invite_data in the subscription. */ + pjsip_evsub_set_mod_data(sub, _mod.id, + newCall); + } +} + +void UserAgent::xfer_svr_cb(pjsip_evsub *sub, pjsip_event *event) +{ + PJ_UNUSED_ARG(event); + + /* + * When subscription is terminated, clear the xfer_sub member of + * the inv_data. + */ + if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) { + SIPCall *call; + + call = (SIPCall*) pjsip_evsub_get_mod_data(sub, getInstance()->getModId()); + if (!call) + return; + + pjsip_evsub_set_mod_data(sub, getInstance()->getModId(), NULL); + call->setXferSub(NULL); + + _debug("UserAgent: Xfer server subscription terminated\n"); + } +} diff --git a/src/useragent.h b/src/useragent.h new file mode 100644 index 0000000000000000000000000000000000000000..a1bb0b02cb6a8b8d92b1d215f9ccd02239b51323 --- /dev/null +++ b/src/useragent.h @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2004-2005 Savoir-Faire Linux inc. + * Author: Yun Liu <yun.liu@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#ifndef _SIPMANAGER_H +#define _SIPMANAGER_H + +#include <pjsip.h> +#include <pjlib-util.h> +#include <pjlib.h> +#include <pjnath/stun_config.h> + +//TODO Remove this include if we don't need anything from it +#include <pjsip_simple.h> + +#include <pjsip_ua.h> +#include <pjmedia/sdp.h> +#include <pjmedia/sdp_neg.h> + +#include <string> +#include <vector> + +#define PJ_LOG_LEVEL 5 + +typedef std::string AccountID; + +class SIPCall; + +class UserAgent +{ +private: + /** PJSIP Endpoint */ + pjsip_endpoint *_endpt; + pj_sock_t _sock; + //pjsip_module _appMod; + pj_caching_pool _cp; + pj_pool_t *_pool; + pj_mutex_t *_mutex; /** Mutex protection for this data */ + pjsip_module _mod; /** PJSIP module. */ + pjsip_module _options_handler; + bool _useStun; + pj_str_t _stunHost; + std::string _stunServer; + + /** Local Extern Address is the IP address seen by peers for SIP listener */ + std::string _localExternAddress; + std::string _localIPAddress; + + /** Local Extern Port is the port seen by peers for SIP listener */ + unsigned int _localExternPort; + unsigned int _localPort; + + /** For registration use only */ + int _regPort; + + pj_thread_t *_thread; + + static UserAgent *_current; + + /* Sleep with polling */ + void busy_sleep(unsigned msec); +public: + UserAgent(); + ~UserAgent(); + + pj_status_t sipCreate(); + + /** + * This method is used to initialize the pjsip + */ + pj_status_t sipInit(); + + + void sipDestory(); + + /** Create SIP UDP Listener */ + int createUDPServer(); + + /** Set whether it will use stun server */ + void setStunServer(const char *server); + + /** Set the port number user designated */ + void setSipPort(int port) { _regPort = port; } + + int getSipPort() { return _regPort; } + + pj_str_t getStunServer() { return _stunHost; } + + bool addAccount(AccountID id, pjsip_regc **regc, const std::string& server, const std::string& user, const std::string& passwd + , const int& timeout); + bool removeAccount(pjsip_regc *regc); + + pj_str_t buildContact(char *userName); + + bool loadSIPLocalIP(); + + pj_status_t stunServerResolve(); + + pjsip_endpoint* getEndPoint() {return _endpt;} + + std::string getLocalIP() {return _localExternAddress;} + + int getModId() {return _mod.id;} + + bool setCallAudioLocal(SIPCall* call); + + int answer(SIPCall* call); + + bool hangup(SIPCall* call); + + bool refuse(SIPCall* call); + + bool onhold(SIPCall *call); + bool offhold(SIPCall *call); + + bool transfer(SIPCall *call, const std::string& to); + + void onCallTransfered(pjsip_inv_session *inv, pjsip_rx_data *rdata); + + bool makeOutgoingCall(const std::string& to, SIPCall* call, const AccountID& id); + + bool carryingDTMFdigits(SIPCall* call); + + pj_pool_t *getAppPool() {return _pool;} + static pj_bool_t mod_on_rx_request(pjsip_rx_data *rdata); + static pj_bool_t mod_on_rx_response(pjsip_rx_data *rdata UNUSED) {return PJ_SUCCESS;} + static void regc_cb(struct pjsip_regc_cbparam *param); + static void xfer_func_cb( pjsip_evsub *sub, pjsip_event *event); + static void xfer_svr_cb(pjsip_evsub *sub, pjsip_event *event); + static void call_on_media_update( pjsip_inv_session *inv UNUSED, pj_status_t status UNUSED) {} + static void call_on_state_changed( pjsip_inv_session *inv, pjsip_event *e); + static void call_on_forked(pjsip_inv_session *inv, pjsip_event *e); + static void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e); + static int start_thread(void *arg); + static UserAgent* getInstance() {return _current;} + + static void set_voicemail_info( AccountID account, pjsip_msg_body *body ); +private: + + // Copy Constructor + UserAgent(const UserAgent& rh); + + // Assignment Operator + UserAgent& operator=( const UserAgent& rh); +}; + + +#endif /* _SIPMANAGER_H */ + diff --git a/src/voiplink.cpp b/src/voiplink.cpp index 1a762036ed9a44f0c84b2b0458da5dfabc09d22e..5b0dea44f75d4203bf1c2055f197cf121cdc5415 100644 --- a/src/voiplink.cpp +++ b/src/voiplink.cpp @@ -135,7 +135,7 @@ VoIPLink::subscribePresenceForContact(Contact* contact) }*/ void -VoIPLink::publishPresenceStatus(std::string status) +VoIPLink::publishPresenceStatus(std::string status UNUSED) { // Nothing to do if presence is not supported // or the function will be overidden diff --git a/src/voiplink.h b/src/voiplink.h index 72eb61462aa3b5f0bef7bf8adf0d9c390b51202d..c260cdee4ae8787f88935272e8628e59e73cfd9c 100644 --- a/src/voiplink.h +++ b/src/voiplink.h @@ -29,6 +29,8 @@ class AudioCodec; +struct pjsip_rx_data; + /** Define AccountID type */ typedef std::string AccountID; @@ -64,7 +66,7 @@ class VoIPLink { /** * Virtual method - * Try to initiate the eXosip engine/thread and set config + * Try to initiate the pjsip engine/thread and set config * @return bool True if OK */ virtual bool init (void) = 0; @@ -277,7 +279,8 @@ class VoIPLink { */ int _registrationError; - protected: + //protected: +public: /** Add a call to the call map (protected by mutex) * @param call A call pointer with a unique pointer * @return bool True if the call was unique and added @@ -295,7 +298,9 @@ class VoIPLink { * @return bool True on success */ bool clearCallMap(); - + + +protected: /** Contains all the calls for this Link, protected by mutex */ CallMap _callMap; diff --git a/test/Makefile.am b/test/Makefile.am index 3107ed9e569121bfd85e0955c2de0ad5033de296..14411aa140bbc3264308b27f0cd418287544821c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -15,6 +15,7 @@ OBJECT_FILES= \ ../src/sflphoned-sipaccount.o \ ../src/sflphoned-iaxaccount.o \ ../src/sflphoned-eventthread.o \ + ../src/sflphoned-useragent.o \ ../src/sflphoned-samplerateconverter.o configurationTester_SOURCES = \ @@ -24,7 +25,7 @@ configurationTester_SOURCES = \ configurationTester_LDADD = \ ../src/libsflphone.la \ - $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) $(EXOSIP_LIBS) \ + $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) \ @ALSA_LIBS@ \ @PULSEAUDIO_LIBS@ \ @CPPUNIT_LIBS@ \ @@ -33,5 +34,6 @@ configurationTester_LDADD = \ @CCRTP_LIBS@ \ @DBUSCPP_LIBS@ \ @SAMPLERATE_LIBS@ \ + $(PJSIP_LIBS) \ $(OBJECT_FILES)