diff --git a/.gitignore b/.gitignore index 38beb5d7dae69d41a269a0fed6c93a4e2bab2ff9..123da9aae877b89bf3a2d1f659a422bf1fe292c4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ *.Po *.Plo *.loT -*.m4 *.Tpo Makefile.in Makefile diff --git a/daemon/.gitignore b/daemon/.gitignore index 01bcf84a048c656b051dc1a8621adf1c628b4b83..33f0a2cc742f82740882b07dbd8c45d49cc824f3 100644 --- a/daemon/.gitignore +++ b/daemon/.gitignore @@ -1,3 +1,4 @@ +aclocal.m4 src/dbus/org.sflphone.SFLphone.service src/sflphoned diff --git a/daemon/configure.ac b/daemon/configure.ac index b0c4d019ac33306c52496abe1c1749398b92a89f..6fdc2ce37c15ff153bbcd221c9ab6d0cb17cc17d 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -22,28 +22,6 @@ AC_PROG_MAKE_SET dnl Where to find configure files AC_CONFIG_MACRO_DIR([m4]) -dnl What to generate -AC_CONFIG_FILES([Makefile]) -AC_CONFIG_FILES([libs/Makefile \ - libs/utilspp/Makefile \ - libs/utilspp/singleton/Makefile \ - libs/iax2/Makefile]) - -AC_CONFIG_FILES([src/Makefile \ - src/sip/Makefile \ - src/im/Makefile \ - src/iax/Makefile \ - src/audio/Makefile \ - src/audio/audiortp/Makefile \ - src/audio/pulseaudio/Makefile \ - src/audio/alsa/Makefile \ - src/audio/sound/Makefile \ - src/audio/codecs/Makefile \ - src/config/Makefile \ - src/dbus/Makefile \ - src/hooks/Makefile \ - src/history/Makefile]) - dnl Unit tests section AC_CONFIG_FILES([test/Makefile]) @@ -96,17 +74,17 @@ AC_FUNC_MALLOC AC_FUNC_MEMCMP AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES - AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. +AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([#include <sys/types.h> #include <signal.h> ], - [return *(signal (0, 0)) (0) == 1;])], - [ac_cv_type_signal=int], - [ac_cv_type_signal=void])]) + [return *(signal (0, 0)) (0) == 1;])], + [ac_cv_type_signal=int], + [ac_cv_type_signal=void])]) AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers - (`int' or `void').]) + (`int' or `void').]) AC_FUNC_STAT AC_FUNC_UTIME_NULL @@ -122,6 +100,9 @@ dnl Check for uuid development package - name: uuid-dev UUID_MIN_VERSION=1.0 PKG_CHECK_MODULES(UUID, uuid >= ${UUID_MIN_VERSION}, HAVE_UUID=true, HAVE_UUID=false); +AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [AC_SUBST(YAML_LIBS, -lyaml)], [ + AC_MSG_ERROR([Unable to find yaml development files])]) + LIBCRYPTO_MIN_VERSION=1.0 PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= ${LIBCRYPTO_MIN_VERSION}, HAVE_LIBCRYPTO=true, HAVE_LIBCRYPTO=false); @@ -158,119 +139,87 @@ dnl pkg-config doesn't like 0.6.0-pre1 version number, it assumes that it is dnl more recent than (unreleased) 0.6.0 DBUS_CPP_REQUIRED_VERSION=0.6.0-pre1 PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,, - AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSION or better)])) - -CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -Weffc++ -Wfatal-errors" - -AC_CHECK_LIB([expat], XML_ParserCreate_MM, - [AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false)], - have_expat=false) - -test "$have_expat" = false && AC_MSG_ERROR([libexpat development files missing]) - -xml_CFLAGS= -xml_LIBS=-lexpat - -AC_SUBST(xml_CFLAGS) -AC_SUBST(xml_LIBS) - -AC_CHECK_LIB([yaml], yaml_parser_initialize, - [AC_CHECK_HEADERS(yaml.h, have_yaml=true, have_yaml=false)], - have_yaml=false) - -test "$have_yaml" = "false" && AC_MSG_ERROR([libyaml development files missing]) +AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSION or better)])) -yaml_CFLAGS= -yaml_LIBS=-lyaml -AC_SUBST(yaml_CFLAGS) -AC_SUBST(yaml_LIBS) +AX_LIB_EXPAT -AC_CHECK_LIB([pthread], pthread_create, - [AC_CHECK_HEADERS(pthread.h, have_pthread=true, have_pthread=false)], - have_pthread=false) +AX_PTHREAD -test "$have_pthread" = "false" && AC_MSG_ERROR([You need the POSIX Thread library (pthreads)]) - -AC_CHECK_LIB([pcre], pcre_free, - [AC_CHECK_HEADERS(pcre.h, have_pcre=true, have_pcre=false)], - have_pcre=false) - -test "$have_pcre" = "false" && AC_MSG_ERROR([You need the Perl-Compatible Regular Expressions library (pcre)]) - -PCRE_LIBS=-lpcre -PCRE_CFLAGS= -AC_SUBST(PCRE_LIBS) -AC_SUBST(PCRE_CFLAGS) +AX_PATH_LIB_PCRE dnl Check for libcppunit-dev CPPUNIT_MIN_VERSION=1.12 PKG_CHECK_MODULES(CPPUNIT, cppunit >= ${CPPUNIT_MIN_VERSION}, AM_CONDITIONAL(BUILD_TEST, test 1 = 1 ), AM_CONDITIONAL(BUILD_TEST, test 0 = 1 )) -# check for libgsm1 (doesn't use pkg-config) - dnl Check for libgsm +dnl check for libgsm1 (doesn't use pkg-config) +dnl Check for libgsm AC_ARG_WITH([gsm], [AS_HELP_STRING([--without-gsm], - [disable support for gsm codec])], [], [with_gsm=yes]) + [disable support for gsm codec])], [], [with_gsm=yes]) LIBGSM= AS_IF([test "x$with_gsm" != xno], - [AC_CHECK_HEADER([gsm/gsm.h], , AC_MSG_FAILURE([Unable to find the libgsm1 headers (you may need to install the dev package). You may use --without-gsm to compile without gsm codec support.]))] - [AC_CHECK_LIB([gsm], [gsm_decode], - [], - [AC_MSG_FAILURE( - [libgsm link test failed. You may use --without-gsm to compile without gsm codec support.])] - ) - ] - ) + [AC_CHECK_HEADER([gsm/gsm.h], , AC_MSG_FAILURE([Unable to find the libgsm1 headers (you may need to install the dev package). You may use --without-gsm to compile without gsm codec support.]))] + [AC_CHECK_LIB([gsm], [gsm_decode], [], [ + AC_MSG_FAILURE([libgsm link test failed. You may use --without-gsm to compile without gsm codec support.]) + ]) + ]) AC_DEFINE_UNQUOTED([HAVE_GSM], `if test "x$with_gsm" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libgsm]) AM_CONDITIONAL(BUILD_GSM, test "x$with_gsm" = "xyes" ) dnl Check for libspeex AC_ARG_WITH([speex], - [AS_HELP_STRING([--without-speex], - [disable support for speex codec])], - [], - [with_speex=yes]) + [AS_HELP_STRING([--without-speex], + [disable support for speex codec])], + [], + [with_speex=yes]) AS_IF([test "x$with_speex" != xno], - [AC_CHECK_HEADER([speex/speex.h], , AC_MSG_FAILURE([Unable to find the libspeex headers (you may need to install the dev package). You may use --without-speex to compile without speex codec support.]))] - [AC_CHECK_LIB([speex], [speex_decode_int], - [], - [AC_MSG_FAILURE([libspeex link test failed. You may use --without-speex to compile without speex codec support.])]) - ]) - + [AC_CHECK_HEADER([speex/speex.h], , AC_MSG_FAILURE([Unable to find the libspeex headers (you may need to install the dev package). You may use --without-speex to compile without speex codec support.]))] + [AC_CHECK_LIB([speex], [speex_decode_int], + [], + [AC_MSG_FAILURE([libspeex link test failed. You may use --without-speex to compile without speex codec support.])]) + ]) + AC_DEFINE_UNQUOTED([HAVE_SPEEX], `if test "x$with_speex" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeex]) AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" ) dnl check in case the libspeexdsp is not installed AC_CHECK_HEADER([speex/speex_preprocess.h], , AC_MSG_FAILURE([Unable to find the libspeexdsp headers (you may need to install the libspeexdsp-dev package) used for Noise Suppression and Automatic Gain Control.])) -AC_CHECK_LIB(speexdsp, speex_preprocess_run, [], [], []) +AC_SEARCH_LIBS([speex_preprocess_run], [speexdsp], [], [ + AC_MSG_ERROR([Unable to find speexdsp development files]) +]) # check for libcelt -AC_ARG_WITH([celt], - [AS_HELP_STRING([--without-celt], - [disable support for celt codec])], - [], - [with_celt=yes]) +AC_ARG_WITH([celt], [AS_HELP_STRING([--without-celt], + [disable support for celt codec])], [], [with_celt=yes]) AS_IF([test "x$with_celt" != xno], - [PKG_CHECK_MODULES(CELT, celt >= 0.9.1, - [ - with_celt_91=yes; AC_MSG_NOTICE([Using celt 0.9.1]) - ], - [ - PKG_CHECK_MODULES(CELT, celt >= 0.7.1, + [PKG_CHECK_MODULES(CELT, celt >= 0.9.1, + [ + with_celt_91=yes; AC_MSG_NOTICE([Using celt 0.9.1]) + ], + [ + PKG_CHECK_MODULES(CELT, celt >= 0.7.1, [ with_celt_71=yes; AC_MSG_NOTICE([Using celt 0.7.1]) ], [ - AC_MSG_FAILURE([libcelt link test failed. You may use --without-celt to compile without celt codec support.]) - ]) - ])] +dnl celt071 is how certain distros package celt + PKG_CHECK_MODULES(CELT, celt071 >= 0.7.1, + [ + with_celt_071=yes; AC_MSG_NOTICE([Using celt071]) + ], + [ + AC_MSG_FAILURE([libcelt link test failed. You may use --without-celt to compile without celt codec support.]) + ]) + ]) + ])] ) AM_CONDITIONAL(BUILD_CELT_91, test "x$with_celt_91" = "xyes" ) AM_CONDITIONAL(BUILD_CELT_71, test "x$with_celt_71" = "xyes" ) +AM_CONDITIONAL(BUILD_CELT_071, test "x$with_celt_071" = "xyes" ) dnl Check for IAX AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2], @@ -279,9 +228,9 @@ AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2], AC_DEFINE_UNQUOTED([HAVE_IAX], `if test "x$with_iax2" = "xyes"; then echo 1; else echo 0;fi`, [Define if you have libiax2]) AM_CONDITIONAL(USE_IAX, test "x$with_iax2" = "xyes" ) - dnl Check for network-manager + dnl Check for network-manager AC_ARG_WITH([networkmanager], [AS_HELP_STRING([--without-networkmanager], - [disable support for network-manager events])], [], + [disable support for network-manager events])], [], [with_networkmanager=yes]) AM_CONDITIONAL(USE_NETWORKMANAGER, test "x$with_networkmanager" = "xyes" ) @@ -298,11 +247,36 @@ AC_DEFUN([BB_ENABLE_DOXYGEN], AC_PATH_PROG(DOT, dot, , $PATH) test x$DOT = x -a "x$enable_dot" = xyes && AC_MSG_ERROR([could not find dot]) fi - AM_CONDITIONAL(ENABLE_DOXYGEN, test x$DOXYGEN = xyes) + AM_CONDITIONAL(ENABLE_DOXYGEN, test x$DOXYGEN = xyes) ]) # Acutally perform the doxygen check BB_ENABLE_DOXYGEN +CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -Weffc++ -Wfatal-errors" + +dnl What to generate +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([libs/Makefile \ + libs/utilspp/Makefile \ + libs/utilspp/singleton/Makefile \ + libs/iax2/Makefile]) + +AC_CONFIG_FILES([src/Makefile \ + src/sip/Makefile \ + src/im/Makefile \ + src/iax/Makefile \ + src/audio/Makefile \ + src/audio/audiortp/Makefile \ + src/audio/pulseaudio/Makefile \ + src/audio/alsa/Makefile \ + src/audio/sound/Makefile \ + src/audio/codecs/Makefile \ + src/config/Makefile \ + src/dbus/Makefile \ + src/hooks/Makefile \ + src/history/Makefile]) + + # Go! AC_OUTPUT diff --git a/daemon/m4/.gitignore b/daemon/m4/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..464ba5caa6814008d91053646b3d634a4323f2e9 --- /dev/null +++ b/daemon/m4/.gitignore @@ -0,0 +1,5 @@ +libtool.m4 +lt~obsolete.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 diff --git a/daemon/m4/ax_lib_expat.m4 b/daemon/m4/ax_lib_expat.m4 new file mode 100644 index 0000000000000000000000000000000000000000..16e66de5d79b39884772eafaa66266ea267e7ee2 --- /dev/null +++ b/daemon/m4/ax_lib_expat.m4 @@ -0,0 +1,275 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_lib_expat.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIB_EXPAT([MINIMUM-VERSION]) +# +# DESCRIPTION +# +# This macro provides tests of availability of Expat XML Parser of +# particular version or newer. This macro checks for Expat XML Parser +# headers and libraries and defines compilation flags +# +# Macro supports following options and their values: +# +# 1) Single-option usage: +# +# --with-expat -- yes, no, or path to Expat XML Parser +# installation prefix +# +# 2) Three-options usage (all options are required): +# +# --with-expat=yes +# --with-expat-inc -- path to base directory with Expat headers +# --with-expat-lib -- linker flags for Expat +# +# This macro calls: +# +# AC_SUBST(EXPAT_CFLAGS) +# AC_SUBST(EXPAT_LIBS) +# AC_SUBST(EXPAT_VERSION) -- only if version requirement is used +# +# And sets: +# +# HAVE_EXPAT +# +# LICENSE +# +# Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 9 + +AC_DEFUN([AX_LIB_EXPAT], +[ + AC_ARG_WITH([expat], + AS_HELP_STRING([--with-expat=@<:@ARG@:>@], + [use Expat XML Parser from given prefix (ARG=path); check standard prefixes (ARG=yes); disable (ARG=no)] + ), + [ + if test "$withval" = "yes"; then + if test -f /usr/local/include/expat.h ; then + expat_prefix=/usr/local + elif test -f /usr/include/expat.h ; then + expat_prefix=/usr + else + expat_prefix="" + fi + expat_requested="yes" + elif test -d "$withval"; then + expat_prefix="$withval" + expat_requested="yes" + else + expat_prefix="" + expat_requested="no" + fi + ], + [ + dnl Default behavior is implicit yes + if test -f /usr/local/include/expat.h ; then + expat_prefix=/usr/local + elif test -f /usr/include/expat.h ; then + expat_prefix=/usr + else + expat_prefix="" + fi + ] + ) + + AC_ARG_WITH([expat-inc], + AS_HELP_STRING([--with-expat-inc=@<:@DIR@:>@], + [path to Expat XML Parser headers] + ), + [expat_include_dir="$withval"], + [expat_include_dir=""] + ) + AC_ARG_WITH([expat-lib], + AS_HELP_STRING([--with-expat-lib=@<:@ARG@:>@], + [link options for Expat XML Parser libraries] + ), + [expat_lib_flags="$withval"], + [expat_lib_flags=""] + ) + + EXPAT_CFLAGS="" + EXPAT_LIBS="" + EXPAT_VERSION="" + + dnl + dnl Collect include/lib paths and flags + dnl + run_expat_test="no" + + if test -n "$expat_prefix"; then + expat_include_dir="$expat_prefix/include" + expat_lib_flags="-L$expat_prefix/lib -lexpat" + run_expat_test="yes" + elif test "$expat_requested" = "yes"; then + if test -n "$expat_include_dir" -a -n "$expat_lib_flags"; then + run_expat_test="yes" + fi + else + run_expat_test="no" + fi + + dnl + dnl Check Expat XML Parser files + dnl + if test "$run_expat_test" = "yes"; then + + saved_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$expat_include_dir" + + saved_LDFLAGS="$LDFLAGS" + LIBS="$LDFLAGS $expat_lib_flags" + + dnl + dnl Check Expat headers + dnl + AC_MSG_CHECKING([for Expat XML Parser headers in $expat_include_dir]) + + AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[ +@%:@include <expat.h> + ]], + [[]] + )], + [ + EXPAT_CFLAGS="-I$expat_include_dir" + expat_header_found="yes" + AC_MSG_RESULT([found]) + ], + [ + expat_header_found="no" + AC_MSG_RESULT([not found]) + ] + ) + AC_LANG_POP([C++]) + + dnl + dnl Check Expat libraries + dnl + if test "$expat_header_found" = "yes"; then + + AC_MSG_CHECKING([for Expat XML Parser libraries]) + + AC_LANG_PUSH([C++]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM( + [[ +@%:@include <expat.h> + ]], + [[ +XML_Parser p = XML_ParserCreate(NULL); +XML_ParserFree(p); +p = NULL; + ]] + )], + [ + EXPAT_LIBS="$expat_lib_flags" + expat_lib_found="yes" + AC_MSG_RESULT([found]) + ], + [ + expat_lib_found="no" + AC_MSG_RESULT([not found]) + ] + ) + AC_LANG_POP([C++]) + fi + + CPPFLAGS="$saved_CPPFLAGS" + LDFLAGS="$saved_LDFLAGS" + fi + + AC_MSG_CHECKING([for Expat XML Parser]) + + if test "$run_expat_test" = "yes"; then + if test "$expat_header_found" = "yes" -a "$expat_lib_found" = "yes"; then + + AC_SUBST([EXPAT_CFLAGS]) + AC_SUBST([EXPAT_LIBS]) + + HAVE_EXPAT="yes" + else + HAVE_EXPAT="no" + fi + + AC_MSG_RESULT([$HAVE_EXPAT]) + + dnl + dnl Check Expat version + dnl + if test "$HAVE_EXPAT" = "yes"; then + + expat_version_req=ifelse([$1], [], [], [$1]) + + if test -n "$expat_version_req"; then + + AC_MSG_CHECKING([if Expat XML Parser version is >= $expat_version_req]) + + if test -f "$expat_include_dir/expat.h"; then + + expat_major=`cat $expat_include_dir/expat.h | \ + grep '^#define.*XML_MAJOR_VERSION.*[0-9]$' | \ + sed -e 's/#define XML_MAJOR_VERSION.//'` + + expat_minor=`cat $expat_include_dir/expat.h | \ + grep '^#define.*XML_MINOR_VERSION.*[0-9]$' | \ + sed -e 's/#define XML_MINOR_VERSION.//'` + + expat_revision=`cat $expat_include_dir/expat.h | \ + grep '^#define.*XML_MICRO_VERSION.*[0-9]$' | \ + sed -e 's/#define XML_MICRO_VERSION.//'` + + EXPAT_VERSION="$expat_major.$expat_minor.$expat_revision" + AC_SUBST([EXPAT_VERSION]) + + dnl Decompose required version string and calculate numerical representation + expat_version_req_major=`expr $expat_version_req : '\([[0-9]]*\)'` + expat_version_req_minor=`expr $expat_version_req : '[[0-9]]*\.\([[0-9]]*\)'` + expat_version_req_revision=`expr $expat_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` + if test "x$expat_version_req_revision" = "x"; then + expat_version_req_revision="0" + fi + + expat_version_req_number=`expr $expat_version_req_major \* 10000 \ + \+ $expat_version_req_minor \* 100 \ + \+ $expat_version_req_revision` + + dnl Calculate numerical representation of detected version + expat_version_number=`expr $expat_major \* 10000 \ + \+ $expat_minor \* 100 \ + \+ $expat_revision` + + expat_version_check=`expr $expat_version_number \>\= $expat_version_req_number` + if test "$expat_version_check" = "1"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_WARN([Found Expat XML Parser $EXPAT_VERSION, which is older than required. Possible compilation failure.]) + fi + else + AC_MSG_RESULT([no]) + AC_MSG_WARN([Missing expat.h header. Unable to determine Expat version.]) + fi + fi + fi + + else + HAVE_EXPAT="no" + AC_MSG_RESULT([$HAVE_EXPAT]) + + if test "$expat_requested" = "yes"; then + AC_MSG_WARN([Expat XML Parser support requested but headers or library not found. Specify valid prefix of Expat using --with-expat=@<:@DIR@:>@ or provide include directory and linker flags using --with-expat-inc and --with-expat-lib]) + fi + fi +]) diff --git a/daemon/m4/ax_path_lib_pcre.m4 b/daemon/m4/ax_path_lib_pcre.m4 new file mode 100644 index 0000000000000000000000000000000000000000..926e69d272d8288761c21163a96121f9e3691b0d --- /dev/null +++ b/daemon/m4/ax_path_lib_pcre.m4 @@ -0,0 +1,90 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_path_lib_pcre.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PATH_LIB_PCRE [(A/NA)] +# +# DESCRIPTION +# +# check for pcre lib and set PCRE_LIBS and PCRE_CFLAGS accordingly. +# +# also provide --with-pcre option that may point to the $prefix of the +# pcre installation - the macro will check $pcre/include and $pcre/lib to +# contain the necessary files. +# +# the usual two ACTION-IF-FOUND / ACTION-IF-NOT-FOUND are supported and +# they can take advantage of the LIBS/CFLAGS additions. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> +# +# 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, see <http://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AC_DEFUN([AX_PATH_LIB_PCRE],[dnl +AC_MSG_CHECKING([lib pcre]) +AC_ARG_WITH(pcre, +[ --with-pcre[[=prefix]] compile xmlpcre part (via libpcre check)],, + with_pcre="yes") +if test ".$with_pcre" = ".no" ; then + AC_MSG_RESULT([disabled]) + m4_ifval($2,$2) +else + AC_MSG_RESULT([(testing)]) + AC_CHECK_LIB(pcre, pcre_study) + if test "$ac_cv_lib_pcre_pcre_study" = "yes" ; then + PCRE_LIBS="-lpcre" + AC_MSG_CHECKING([lib pcre]) + AC_MSG_RESULT([$PCRE_LIBS]) + m4_ifval($1,$1) + else + OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$with_pcre/lib" + OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$with_pcre/include" + AC_CHECK_LIB(pcre, pcre_compile) + CPPFLAGS="$OLDCPPFLAGS" + LDFLAGS="$OLDLDFLAGS" + if test "$ac_cv_lib_pcre_pcre_compile" = "yes" ; then + AC_MSG_RESULT(.setting PCRE_LIBS -L$with_pcre/lib -lpcre) + PCRE_LIBS="-L$with_pcre/lib -lpcre" + test -d "$with_pcre/include" && PCRE_CFLAGS="-I$with_pcre/include" + AC_MSG_CHECKING([lib pcre]) + AC_MSG_RESULT([$PCRE_LIBS]) + m4_ifval($1,$1) + else + AC_MSG_CHECKING([lib pcre]) + AC_MSG_RESULT([no, (WARNING)]) + m4_ifval($2,$2) + fi + fi +fi +AC_SUBST([PCRE_LIBS]) +AC_SUBST([PCRE_CFLAGS]) +]) diff --git a/daemon/m4/ax_pthread.m4 b/daemon/m4/ax_pthread.m4 new file mode 100644 index 0000000000000000000000000000000000000000..e20a388ca869b2bf1be9946ef93c37146a9db387 --- /dev/null +++ b/daemon/m4/ax_pthread.m4 @@ -0,0 +1,309 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. It +# sets the PTHREAD_LIBS output variable to the threads library and linker +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler +# flags that are needed. (The user can also force certain compiler +# flags/libs to be tested by setting these environment variables.) +# +# Also sets PTHREAD_CC to any special C compiler that is needed for +# multi-threaded programs (defaults to the value of CC otherwise). (This +# is necessary on AIX to use the special cc_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these flags, +# but also link it with them as well. e.g. you should link with +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# +# If you are only building threads programs, you may wish to use these +# variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name +# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the +# PTHREAD_PRIO_INHERIT symbol is defined when compiling with +# PTHREAD_CFLAGS. +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or if +# you have any other suggestions or comments. This macro was based on work +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +# Alejandro Forero Cuervo to the autoconf macro repository. We are also +# grateful for the helpful feedback of numerous users. +# +# Updated for Autoconf 2.68 by Daniel Richard G. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> +# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG> +# +# 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, see <http://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 17 + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_PUSH([C]) +ax_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) + AC_MSG_RESULT($ax_pthread_ok) + if test x"$ax_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" + ;; + + *-darwin*) + ax_pthread_flags="-pthread $ax_pthread_flags" + ;; +esac + +if test x"$ax_pthread_ok" = xno; then +for flag in $ax_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) + if test x"$ax_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> + static void routine(void *a) { a = 0; } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($ax_pthread_ok) + if test "x$ax_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$ax_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], + [int attr = $attr; return attr /* ; */])], + [attr_name=$attr; break], + []) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *-osf* | *-hpux*) flag="-D_REENTRANT";; + *solaris*) + if test "$GCC" = "yes"; then + flag="-D_REENTRANT" + else + flag="-mt -D_REENTRANT" + fi + ;; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], + ax_cv_PTHREAD_PRIO_INHERIT, [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])], + [ax_cv_PTHREAD_PRIO_INHERIT=yes], + [ax_cv_PTHREAD_PRIO_INHERIT=no]) + ]) + AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], + AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with xlc_r or cc_r + if test x"$GCC" != xyes; then + AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) + else + PTHREAD_CC=$CC + fi +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + ax_pthread_ok=no + $2 +fi +AC_LANG_POP +])dnl AX_PTHREAD diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am index 271c3902d446362786f1df58e1c45fa4cba10767..158628f70c342cb43fe6eaa4bc0847287ae6f033 100644 --- a/daemon/src/Makefile.am +++ b/daemon/src/Makefile.am @@ -30,7 +30,7 @@ sflphoned_CXXFLAGS = \ # libsflphone -sflphoned_LDADD = ./libsflphone.la $(libssl_LIBS) -lcrypto +sflphoned_LDADD = ./libsflphone.la $(libssl_LIBS) -lcrypto $(YAML_LIBS) noinst_LTLIBRARIES = libsflphone.la noinst_HEADERS = \ @@ -73,8 +73,6 @@ libsflphone_la_LDFLAGS = \ @SAMPLERATE_LIBS@ \ @libssl_LIBS@ \ @UUID_LIBS@ \ - @yaml_LIBS@ \ - @xml_LIBS@ \ @DBUSCPP_LIBS@ libsflphone_la_CFLAGS = \ @@ -87,9 +85,7 @@ libsflphone_la_CFLAGS = \ @PULSEAUDIO_CFLAGS@ \ @SAMPLERATE_CFLAGS@ \ @libssl_CFLAGS@ \ - @UUID_CFLAGS@ \ - @yaml_CFLAGS@ \ - @xml_CFLAGS@ + @UUID_CFLAGS@ libsflphone_la_SOURCES = conference.cpp \ voiplink.cpp \ diff --git a/daemon/src/audio/Makefile.am b/daemon/src/audio/Makefile.am index 3e623cbae44c5621a165fe3b1df3c76046c266ef..f816e45a5b45953a026a8c78b1b9d83ec0d65881 100644 --- a/daemon/src/audio/Makefile.am +++ b/daemon/src/audio/Makefile.am @@ -43,6 +43,3 @@ libaudio_la_LIBADD = \ ./alsa/libalsalayer.la \ ./pulseaudio/libpulselayer.la \ ./sound/libsound.la - - - diff --git a/daemon/src/audio/codecs/Makefile.am b/daemon/src/audio/codecs/Makefile.am index e18478023780cb1044bc6bcf630878d65e1ff476..21a1389a9d20514da8db5d0d042fb2dcc5aebbf9 100644 --- a/daemon/src/audio/codecs/Makefile.am +++ b/daemon/src/audio/codecs/Makefile.am @@ -8,7 +8,6 @@ libcodecdescriptor_la_LIBADD = $(CCRTP_LIBS) if BUILD_GSM GSM_LIB = libcodec_gsm.so libcodec_gsm_so_SOURCES = gsmcodec.cpp -libcodec_gsm_so_CFLAGS = -fPIC -g -Wall libcodec_gsm_so_CXXFLAGS = -fPIC -g -Wall libcodec_gsm_so_LDFLAGS = --shared -lc -lgsm libcodec_gsm_so_LDADD = libcodecdescriptor.la @@ -18,9 +17,8 @@ endif if BUILD_SPEEX SPEEX_NB_LIB = libcodec_speex_nb.so libcodec_speex_nb_so_SOURCES = speexcodec_nb.cpp -libcodec_speex_nb_so_CFLAGS = -fPIC -g -Wall libcodec_speex_nb_so_CXXFLAGS = -fPIC -g -Wall $(SPEEXDSP) -libcodec_speex_nb_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP) +libcodec_speex_nb_so_LDFLAGS = --shared -lc -lspeex libcodec_speex_nb_so_LDADD = libcodecdescriptor.la INSTALL_SPEEX_NB_RULE = install-libcodec_speex_nb_so endif @@ -28,9 +26,8 @@ endif if BUILD_SPEEX SPEEX_WB_LIB = libcodec_speex_wb.so libcodec_speex_wb_so_SOURCES = speexcodec_wb.cpp -libcodec_speex_wb_so_CFLAGS = -fPIC -g -Wall libcodec_speex_wb_so_CXXFLAGS = -fPIC -g -Wall $(SPEEXDSP) -libcodec_speex_wb_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP) +libcodec_speex_wb_so_LDFLAGS = --shared -lc -lspeex libcodec_speex_wb_so_LDADD = libcodecdescriptor.la INSTALL_SPEEX_WB_RULE = install-libcodec_speex_wb_so endif @@ -38,9 +35,8 @@ endif if BUILD_SPEEX SPEEX_UB_LIB = libcodec_speex_ub.so libcodec_speex_ub_so_SOURCES = speexcodec_ub.cpp -libcodec_speex_ub_so_CFLAGS = -fPIC -g -Wall libcodec_speex_ub_so_CXXFLAGS = -fPIC -g -Wall $(SPEEXDSP) -libcodec_speex_ub_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP) +libcodec_speex_ub_so_LDFLAGS = --shared -lc -lspeex libcodec_speex_ub_so_LDADD = libcodecdescriptor.la INSTALL_SPEEX_UB_RULE = install-libcodec_speex_ub_so endif @@ -48,9 +44,8 @@ endif if BUILD_CELT_91 CELT_LIB = libcodec_celt.so libcodec_celt_so_SOURCES = celtcodec.cpp -libcodec_celt_so_CFLAGS = -fPIC -g -Wall -DBUILD_CELT_91 libcodec_celt_so_CXXFLAGS = -fPIC -g -Wall -DBUILD_CELT_91 -libcodec_celt_so_LDFLAGS = --shared -lc -lcelt0 $(CELT_NIMP) +libcodec_celt_so_LDFLAGS = --shared -lc ${CELT_LIBS} libcodec_celt_so_LDADD = libcodecdescriptor.la INSTALL_CELT_RULE = install-libcodec_celt_so endif @@ -58,9 +53,17 @@ endif if BUILD_CELT_71 CELT_LIB = libcodec_celt.so libcodec_celt_so_SOURCES = celtcodec.cpp -libcodec_celt_so_CFLAGS = -fPIC -g -Wall -DBUILD_CELT_71 libcodec_celt_so_CXXFLAGS = -fPIC -g -Wall -DBUILD_CELT_71 -libcodec_celt_so_LDFLAGS = --shared -lc -lcelt0 $(CELT_NIMP) +libcodec_celt_so_LDFLAGS = --shared -lc ${CELT_LIBS} +libcodec_celt_so_LDADD = libcodecdescriptor.la +INSTALL_CELT_RULE = install-libcodec_celt_so +endif + +if BUILD_CELT_071 +CELT_LIB = libcodec_celt.so +libcodec_celt_so_SOURCES = celtcodec.cpp +libcodec_celt_so_CXXFLAGS = -fPIC -g -Wall -DBUILD_CELT_071 -I${top_srcdir}/src +libcodec_celt_so_LDFLAGS = --shared -lc ${CELT_LIBS} libcodec_celt_so_LDADD = libcodecdescriptor.la INSTALL_CELT_RULE = install-libcodec_celt_so endif @@ -70,19 +73,16 @@ noinst_PROGRAMS = libcodec_ulaw.so libcodec_alaw.so libcodec_g722.so $(GSM_LIB) noinst_HEADERS = audiocodec.h audiocodecfactory.h speexcodec.h g722.h libcodec_ulaw_so_SOURCES = ulaw.cpp -libcodec_ulaw_so_CFLAGS = -fPIC -g -Wall libcodec_ulaw_so_CXXFLAGS = -fPIC -g -Wall libcodec_ulaw_so_LDADD = libcodecdescriptor.la libcodec_ulaw_so_LDFLAGS = --shared -lc libcodec_alaw_so_SOURCES = alaw.cpp -libcodec_alaw_so_CFLAGS = -fPIC -g -Wall libcodec_alaw_so_CXXFLAGS = -fPIC -g -Wall libcodec_alaw_so_LDADD = libcodecdescriptor.la libcodec_alaw_so_LDFLAGS = --shared -lc libcodec_g722_so_SOURCES = g722.cpp -libcodec_g722_so_CFLAGS = -fPIC -g -Wall libcodec_g722_so_CXXFLAGS = -fPIC -g -Wall libcodec_g722_so_LDADD = libcodecdescriptor.la libcodec_g722_so_LDFLAGS = --shared -lc diff --git a/daemon/src/audio/codecs/celtcodec.cpp b/daemon/src/audio/codecs/celtcodec.cpp index b87e91aed62ccad861db696214cc146f4f45a1e8..98661f8232fe38ce1913a8ea88715459fda112ca 100644 --- a/daemon/src/audio/codecs/celtcodec.cpp +++ b/daemon/src/audio/codecs/celtcodec.cpp @@ -30,7 +30,12 @@ #include "audiocodec.h" #include <cstdio> +#ifdef BUILD_CELT_071 +// FIXME: Hack to workaround celt's insufficient pkg-config file +#include <celt071/celt.h> +#else #include <celt/celt.h> +#endif #include <stdexcept> #include "noncopyable.h" diff --git a/daemon/src/call.h b/daemon/src/call.h index da702a7e312490d001820a0cf80011255912a1a7..b6d4ce59c63b48fde228cbd226f7200889eba30a 100644 --- a/daemon/src/call.h +++ b/daemon/src/call.h @@ -174,6 +174,8 @@ class Call : public Recordable { isIPToIP_ = IPToIP; } + virtual void answer() = 0; + /** * Set my IP [not protected] * @param ip The local IP address diff --git a/daemon/src/config/Makefile.am b/daemon/src/config/Makefile.am index f64c876291d13ed2c4f69c956136123553d6df9f..559faf36eb0b8ad9a4b462822f0bea7ab6dce65b 100644 --- a/daemon/src/config/Makefile.am +++ b/daemon/src/config/Makefile.am @@ -13,6 +13,4 @@ noinst_HEADERS = \ yamlparser.h \ yamlnode.h -libconfig_la_LDFLAGS = @yaml_LIBS@ - -libconfig_la_CXXFLAGS = @yaml_CFLAGS@ -I $(top_srcdir)/src +libconfig_la_CXXFLAGS = -I $(top_srcdir)/src diff --git a/daemon/src/dbus/configurationmanager.cpp b/daemon/src/dbus/configurationmanager.cpp index f58680578ccad7a134e899e5ff9b63638091a7c6..f1043603cb7ce6d805b6fe82e7fe9728ac3a85e3 100644 --- a/daemon/src/dbus/configurationmanager.cpp +++ b/daemon/src/dbus/configurationmanager.cpp @@ -50,7 +50,7 @@ ConfigurationManager::ConfigurationManager(DBus::Connection& connection) : std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails() { std::map<std::string, std::string> ip2ipAccountDetails; - SIPAccount *sipaccount = static_cast<SIPAccount *>(Manager::instance().getAccount(SIPAccount::IP2IP_PROFILE)); + SIPAccount *sipaccount = Manager::instance().getIP2IPAccount(); if (!sipaccount) { ERROR("ConfigurationManager: could not find account"); @@ -100,7 +100,7 @@ std::map<std::string, std::string> ConfigurationManager::getTlsSettings() { std::map<std::string, std::string> tlsSettings; - SIPAccount *sipaccount = (SIPAccount *) Manager::instance().getAccount(SIPAccount::IP2IP_PROFILE); + SIPAccount *sipaccount = Manager::instance().getIP2IPAccount(); if (!sipaccount) return tlsSettings; @@ -110,7 +110,7 @@ std::map<std::string, std::string> ConfigurationManager::getTlsSettings() void ConfigurationManager::setTlsSettings(const std::map<std::string, std::string>& details) { - SIPAccount * sipaccount = (SIPAccount *) Manager::instance().getAccount(SIPAccount::IP2IP_PROFILE); + SIPAccount * sipaccount = Manager::instance().getIP2IPAccount(); if (!sipaccount) { DEBUG("ConfigurationManager: Error: No valid account in set TLS settings"); @@ -389,13 +389,13 @@ void ConfigurationManager::setAddressbookList( std::map<std::string, std::string> ConfigurationManager::getHookSettings() { - return Manager::instance().getHookSettings(); + return Manager::instance().hookPreference.toMap(); } void ConfigurationManager::setHookSettings(const std::map<std::string, std::string>& settings) { - Manager::instance().setHookSettings(settings); + Manager::instance().hookPreference = HookPreference(settings); } void ConfigurationManager::setAccountsOrder(const std::string& order) diff --git a/daemon/src/iax/iaxcall.cpp b/daemon/src/iax/iaxcall.cpp index a1eb21ec93ac7f467f43094922af9eb1d4301402..2b09b4944fbbeb18685d916e072fb464f4c8b870 100644 --- a/daemon/src/iax/iaxcall.cpp +++ b/daemon/src/iax/iaxcall.cpp @@ -29,6 +29,9 @@ * as that of the covered work. */ +#include <cstring> +#include <sys/socket.h> +#include <iax-client.h> #include "iaxcall.h" #include "iax2/frame.h" #include "account.h" @@ -115,3 +118,8 @@ int IAXCall::getAudioCodec() const return -1; } } + +void IAXCall::answer() +{ + iax_answer(session); +} diff --git a/daemon/src/iax/iaxcall.h b/daemon/src/iax/iaxcall.h index b2822520398726543001c18ad02f581f2462f43e..d97b838d35cabb04b377ae3183b7262c5932303e 100644 --- a/daemon/src/iax/iaxcall.h +++ b/daemon/src/iax/iaxcall.h @@ -74,6 +74,7 @@ class IAXCall : public Call { int format; iax_session* session; private: + virtual void answer(); NON_COPYABLE(IAXCall); }; diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp index 1b4cf25c763e137dadb57c4832c2ad661cff0014..17b11d52a86a28fb03ed7f07cfcbb3e338cb57f3 100644 --- a/daemon/src/iax/iaxvoiplink.cpp +++ b/daemon/src/iax/iaxvoiplink.cpp @@ -255,14 +255,12 @@ IAXVoIPLink::newOutgoingCall(const std::string& id, const std::string& toUrl) void -IAXVoIPLink::answer(Call *c) +IAXVoIPLink::answer(Call *call) { - IAXCall* call = dynamic_cast<IAXCall*>(c); - Manager::instance().addStream(call->getCallId()); mutexIAX_.enter(); - iax_answer(call->session); + call->answer(); mutexIAX_.leave(); call->setState(Call::ACTIVE); diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index cec8d75465eb7c95b17dbc94ac2a86aca04100b9..a9b190d1ad311a14c10e0b6d12b8097d43343a7c 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -191,9 +191,7 @@ bool ManagerImpl::outgoingCall(const std::string& account_id, std::string current_call_id(getCurrentCallId()); - std::string prefix; - if (hookPreference.getNumberEnabled()) - prefix = hookPreference.getNumberAddPrefix(); + std::string prefix(hookPreference.getNumberAddPrefix()); std::string to_cleaned(NumberCleaner::clean(to, prefix)); @@ -292,7 +290,7 @@ bool ManagerImpl::answerCall(const std::string& call_id) try { getAccountLink(account_id)->answer(call); - } catch (const VoipLinkException &e) { + } catch (const std::runtime_error &e) { ERROR("Manager: Error: %s", e.what()); } @@ -1236,7 +1234,7 @@ void ManagerImpl::saveConfig() { DEBUG("Manager: Saving Configuration to XDG directory %s", path_.c_str()); AudioLayer *audiolayer = getAudioDriver(); - if(audiolayer != NULL) { + if (audiolayer != NULL) { audioPreference.setVolumemic(audiolayer->getCaptureGain()); audioPreference.setVolumespkr(audiolayer->getPlaybackGain()); } @@ -1244,13 +1242,8 @@ void ManagerImpl::saveConfig() try { Conf::YamlEmitter emitter(path_.c_str()); - for (AccountMap::iterator iter = accountMap_.begin(); iter != accountMap_.end(); ++iter) { - // Skip the "" account ID (which refer to the IP2IP account) - if (iter->first.empty()) - continue; - else - iter->second->serialize(&emitter); - } + for (AccountMap::iterator iter = accountMap_.begin(); iter != accountMap_.end(); ++iter) + iter->second->serialize(&emitter); preferences.serialize(&emitter); voipPreferences.serialize(&emitter); @@ -2663,14 +2656,20 @@ bool ManagerImpl::accountExists(const std::string &accountID) return accountMap_.find(accountID) != accountMap_.end(); } +SIPAccount* +ManagerImpl::getIP2IPAccount() +{ + return static_cast<SIPAccount*>(accountMap_[SIPAccount::IP2IP_PROFILE]); +} + Account* ManagerImpl::getAccount(const std::string& accountID) { AccountMap::const_iterator iter = accountMap_.find(accountID); if (iter != accountMap_.end()) return iter->second; - - return getAccount(SIPAccount::IP2IP_PROFILE); + else + return accountMap_[SIPAccount::IP2IP_PROFILE]; } std::string ManagerImpl::getAccountIdFromNameAndServer(const std::string& userName, const std::string& server) const @@ -2747,30 +2746,6 @@ std::vector<std::string> ManagerImpl::getAddressbookList() const return unserialize(addressbookPreference.getList()); } -std::map<std::string, std::string> ManagerImpl::getHookSettings() const -{ - std::map<std::string, std::string> settings; - - settings["URLHOOK_IAX2_ENABLED"] = hookPreference.getIax2Enabled() ? "true" : "false"; - settings["PHONE_NUMBER_HOOK_ADD_PREFIX"] = hookPreference.getNumberAddPrefix(); - settings["PHONE_NUMBER_HOOK_ENABLED"] = hookPreference.getNumberEnabled() ? "true" : "false"; - settings["URLHOOK_SIP_ENABLED"] = hookPreference.getSipEnabled() ? "true" : "false"; - settings["URLHOOK_COMMAND"] = hookPreference.getUrlCommand(); - settings["URLHOOK_SIP_FIELD"] = hookPreference.getUrlSipField(); - - return settings; -} - -void ManagerImpl::setHookSettings(const std::map<std::string, std::string>& settings) -{ - hookPreference.setIax2Enabled(settings.find("URLHOOK_IAX2_ENABLED")->second == "true"); - hookPreference.setNumberAddPrefix(settings.find("PHONE_NUMBER_HOOK_ADD_PREFIX")->second); - hookPreference.setNumberEnabled(settings.find("PHONE_NUMBER_HOOK_ENABLED")->second == "true"); - hookPreference.setSipEnabled(settings.find("URLHOOK_SIP_ENABLED")->second == "true"); - hookPreference.setUrlCommand(settings.find("URLHOOK_COMMAND")->second); - hookPreference.setUrlSipField(settings.find("URLHOOK_SIP_FIELD")->second); -} - void ManagerImpl::setIPToIPForCall(const std::string& callID, bool IPToIP) { if (not isIPToIP(callID)) // no IPToIP calls with the same ID diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index c8daee1dcaf392ccf7255e6ec9fd9284d4ba1c61..432f65adb2abcd74733c01632dfb8669529b5571 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -73,6 +73,7 @@ class DNSService; #endif class Account; +class SIPAccount; /** Define a type for a AccountMap container */ typedef std::map<std::string, Account*> AccountMap; @@ -690,17 +691,6 @@ class ManagerImpl { */ std::vector <std::string> getAddressbookList() const; - /** - * Hook configuration - */ - std::map<std::string, std::string> getHookSettings() const; - - /** - * Hook configuration - */ - void setHookSettings(const std::map<std::string, std::string>& settings); - - /** * Get the audio manager * @return int The audio manager @@ -1064,6 +1054,7 @@ class ManagerImpl { * @return Account* The account pointer or 0 */ Account* getAccount(const std::string& accountID); + SIPAccount* getIP2IPAccount(); /** Return the std::string from a CallID * Protected by mutex diff --git a/daemon/src/preferences.cpp b/daemon/src/preferences.cpp index 7b8f93dc97ebfa328719e28e7a72db05ead5e9db..caa7623b7ea86f25f262ec4ebdbc8e689537e511 100644 --- a/daemon/src/preferences.cpp +++ b/daemon/src/preferences.cpp @@ -33,6 +33,7 @@ #include "audio/pulseaudio/pulselayer.h" #include "config/yamlemitter.h" #include "config/yamlnode.h" +#include "hooks/urlhook.h" #include <sstream> #include "global.h" #include <cassert> @@ -216,6 +217,28 @@ HookPreference::HookPreference() : iax2Enabled_(false) , urlSipField_("X-sflphone-url") {} +HookPreference::HookPreference(const std::map<std::string, std::string> &settings) : + iax2Enabled_(settings.find("URLHOOK_IAX2_ENABLED")->second == "true") + , numberAddPrefix_(settings.find("PHONE_NUMBER_HOOK_ADD_PREFIX")->second) + , numberEnabled_(settings.find("PHONE_NUMBER_HOOK_ENABLED")->second == "true") + , sipEnabled_(settings.find("URLHOOK_SIP_ENABLED")->second == "true") + , urlCommand_(settings.find("URLHOOK_COMMAND")->second) + , urlSipField_(settings.find("URLHOOK_SIP_FIELD")->second) +{} + +std::map<std::string, std::string> HookPreference::toMap() const +{ + std::map<std::string, std::string> settings; + settings["URLHOOK_IAX2_ENABLED"] = iax2Enabled_ ? "true" : "false"; + settings["PHONE_NUMBER_HOOK_ADD_PREFIX"] = numberAddPrefix_; + settings["PHONE_NUMBER_HOOK_ENABLED"] = numberEnabled_ ? "true" : "false"; + settings["URLHOOK_SIP_ENABLED"] = sipEnabled_ ? "true" : "false"; + settings["URLHOOK_COMMAND"] = urlCommand_; + settings["URLHOOK_SIP_FIELD"] = urlSipField_; + + return settings; +} + void HookPreference::serialize(Conf::YamlEmitter *emitter) { Conf::MappingNode preferencemap(NULL); @@ -252,6 +275,11 @@ void HookPreference::unserialize(const Conf::MappingNode *map) map->getValue(urlSipFieldKey, &urlSipField_); } +void HookPreference::run(const std::string &header) +{ + UrlHook::runAction(urlCommand_, header); +} + AudioPreference::AudioPreference() : audioApi_(PULSEAUDIO_API_STR) , cardin_(atoi(ALSA_DFT_CARD)) // ALSA_DFT_CARD diff --git a/daemon/src/preferences.h b/daemon/src/preferences.h index 8b176a579f56c1e28b7db4e3df5481e647fc20fa..24d15a524e17a27429f6473a1debbcb6eb8bdd2c 100644 --- a/daemon/src/preferences.h +++ b/daemon/src/preferences.h @@ -335,56 +335,23 @@ class AddressbookPreference : public Serializable { class HookPreference : public Serializable { public: HookPreference(); + HookPreference(const std::map<std::string, std::string> &settings); virtual void serialize(Conf::YamlEmitter *emitter); virtual void unserialize(const Conf::MappingNode *map); - bool getIax2Enabled() const { - return iax2Enabled_; - } - - void setIax2Enabled(bool i) { - iax2Enabled_ = i; - } - std::string getNumberAddPrefix() const { - return numberAddPrefix_; - } - - void setNumberAddPrefix(const std::string &n) { - numberAddPrefix_ = n; - } - - bool getNumberEnabled() const { - return numberEnabled_; - } - - void setNumberEnabled(bool n) { - numberEnabled_ = n; + if (numberEnabled_) + return numberAddPrefix_; + else + return ""; } - bool getSipEnabled() const { - return sipEnabled_; - } - - void setSipEnabled(bool s) { - sipEnabled_ = s; - } - - std::string getUrlCommand() const { - return urlCommand_; - } - void setUrlCommand(const std::string &u) { - urlCommand_ = u; - } - - std::string getUrlSipField() const { - return urlSipField_; - } - void setUrlSipField(const std::string &u) { - urlSipField_ = u; - } + std::map<std::string, std::string> toMap() const; + bool getSipEnabled() const { return sipEnabled_; } + std::string getUrlSipField() const { return urlSipField_; } + void run(const std::string &header); private: bool iax2Enabled_; @@ -393,7 +360,6 @@ class HookPreference : public Serializable { bool sipEnabled_; std::string urlCommand_; std::string urlSipField_; - }; class AudioPreference : public Serializable { diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 9cbb3c8d780b9cdf45cbba6f886c5790f3dec981..01d8427ef1915f2934a9eea669ea0528e2490a68 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -428,7 +428,7 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details) // TLS settings // The TLS listener is unique and globally defined through IP2IP_PROFILE - if (accountID_ == IP2IP_PROFILE) + if (isIP2IP()) tlsListenerPort_ = atoi(details[CONFIG_TLS_LISTENER_PORT].c_str()); tlsEnable_ = details[CONFIG_TLS_ENABLE]; @@ -462,7 +462,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const a[CONFIG_ACCOUNT_ID] = accountID_; // The IP profile does not allow to set an alias - a[CONFIG_ACCOUNT_ALIAS] = (accountID_ == IP2IP_PROFILE) ? IP2IP_PROFILE : alias_; + a[CONFIG_ACCOUNT_ALIAS] = isIP2IP() ? IP2IP_PROFILE : alias_; a[CONFIG_ACCOUNT_ENABLE] = enabled_ ? "true" : "false"; a[CONFIG_ACCOUNT_TYPE] = type_; @@ -477,7 +477,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const std::string registrationStateCode; std::string registrationStateDescription; - if (accountID_ == IP2IP_PROFILE) + if (isIP2IP()) registrationStateDescription = "Direct IP call"; else { state = registrationState_; @@ -488,7 +488,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const registrationStateDescription = registrationStateDetailed_.second; } - a[CONFIG_REGISTRATION_STATUS] = (accountID_ == IP2IP_PROFILE) ? "READY": mapStateNumberToString(state); + a[CONFIG_REGISTRATION_STATUS] = isIP2IP() ? "READY": mapStateNumberToString(state); a[CONFIG_REGISTRATION_STATE_CODE] = registrationStateCode; a[CONFIG_REGISTRATION_STATE_DESCRIPTION] = registrationStateDescription; @@ -565,7 +565,7 @@ void SIPAccount::registerVoIPLink() // In our definition of the ip2ip profile (aka Direct IP Calls), // no registration should be performed - if (accountID_ == IP2IP_PROFILE) + if (isIP2IP()) return; try { @@ -577,7 +577,7 @@ void SIPAccount::registerVoIPLink() void SIPAccount::unregisterVoIPLink() { - if (accountID_ == IP2IP_PROFILE) + if (isIP2IP()) return; try { @@ -802,21 +802,16 @@ void SIPAccount::setContactHeader(std::string address, std::string port) std::string SIPAccount::getContactHeader() const { - std::string scheme; - std::string transport; - pjsip_transport_type_e transportType = transportType_; - - if(transport_ == NULL) { + if (transport_ == NULL) ERROR("Transport not created yet"); - } // The transport type must be specified, in our case START_OTHER refers to stun transport - if(transportType == PJSIP_TRANSPORT_START_OTHER) { + pjsip_transport_type_e transportType = transportType_; + if (transportType == PJSIP_TRANSPORT_START_OTHER) transportType = PJSIP_TRANSPORT_UDP; - } // Use the CONTACT header provided by the registrar if any - if(!contactHeader_.empty()) + if (!contactHeader_.empty()) return contactHeader_; // Else we determine this infor based on transport information @@ -824,6 +819,8 @@ std::string SIPAccount::getContactHeader() const link_->findLocalAddressFromTransport(transport_, transportType, address, port); // UDP does not require the transport specification + std::string scheme; + std::string transport; if (transportType_ == PJSIP_TRANSPORT_TLS) { scheme = "sips:"; transport = ";transport=" + std::string(pjsip_transport_get_type_name(transportType)); @@ -831,28 +828,28 @@ std::string SIPAccount::getContactHeader() const scheme = "sip:"; return displayName_ + (displayName_.empty() ? "" : " ") + "<" + - scheme + username_ + (username_.empty() ? "":"@") + + scheme + username_ + (username_.empty() ? "" : "@") + address + ":" + port + transport + ">"; } void SIPAccount::keepAliveRegistrationCb(UNUSED pj_timer_heap_t *th, pj_timer_entry *te) { - SIPAccount *sipAccount = reinterpret_cast<SIPAccount *>(te->user_data); + SIPAccount *sipAccount = static_cast<SIPAccount *>(te->user_data); - if(sipAccount == NULL) { + if (sipAccount == NULL) { ERROR("Sip account is NULL while registering a new keep alive timer"); + return; } // IP2IP default does not require keep-alive - if(sipAccount->getAccountID() == IP2IP_PROFILE) + if (sipAccount->isIP2IP()) return; // TLS is connection oriented and does not require keep-alive if (sipAccount->isTlsEnabled()) return; - if(sipAccount->isRegistered()) { - + if (sipAccount->isRegistered()) { // send a new register request sipAccount->registerVoIPLink(); @@ -865,9 +862,9 @@ void SIPAccount::keepAliveRegistrationCb(UNUSED pj_timer_heap_t *th, pj_timer_en } namespace { -std::string computeMd5HashFromCredential( - const std::string& username, const std::string& password, - const std::string& realm) +std::string computeMd5HashFromCredential(const std::string& username, + const std::string& password, + const std::string& realm) { #define MD5_APPEND(pms,buf,len) pj_md5_update(pms, (const pj_uint8_t*)buf, len) @@ -891,8 +888,6 @@ std::string computeMd5HashFromCredential( return std::string(hash, 32); } - - } // anon namespace void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::string> >& creds) @@ -980,7 +975,7 @@ std::string SIPAccount::getUserAgentName() const std::map<std::string, std::string> SIPAccount::getIp2IpDetails() const { - assert(accountID_ == IP2IP_PROFILE); + assert(isIP2IP()); std::map<std::string, std::string> ip2ipAccountDetails; ip2ipAccountDetails[CONFIG_ACCOUNT_ID] = IP2IP_PROFILE; ip2ipAccountDetails[CONFIG_SRTP_KEY_EXCHANGE] = srtpKeyExchange_; @@ -1006,7 +1001,7 @@ std::map<std::string, std::string> SIPAccount::getIp2IpDetails() const std::map<std::string, std::string> SIPAccount::getTlsSettings() const { std::map<std::string, std::string> tlsSettings; - assert(accountID_ == IP2IP_PROFILE); + assert(isIP2IP()); std::stringstream portstr; portstr << tlsListenerPort_; @@ -1056,7 +1051,7 @@ void set_opt(const std::map<std::string, std::string> &details, const char *key, void SIPAccount::setTlsSettings(const std::map<std::string, std::string>& details) { - assert(accountID_ == IP2IP_PROFILE); + assert(isIP2IP()); set_opt(details, CONFIG_TLS_LISTENER_PORT, tlsListenerPort_); set_opt(details, CONFIG_TLS_ENABLE, tlsEnable_); set_opt(details, CONFIG_TLS_CA_LIST_FILE, tlsCaListFile_); @@ -1076,3 +1071,8 @@ VoIPLink* SIPAccount::getVoIPLink() { return link_; } + +bool SIPAccount::isIP2IP() const +{ + return accountID_ == IP2IP_PROFILE; +} diff --git a/daemon/src/sip/sipaccount.h b/daemon/src/sip/sipaccount.h index ddf53909957635ee667ea8b9676d37c15b08e398..7f2596db839095015ba3cd0f2ed3b44b90d6e6c2 100644 --- a/daemon/src/sip/sipaccount.h +++ b/daemon/src/sip/sipaccount.h @@ -122,6 +122,11 @@ class SIPAccount : public Account { registrationStateDetailed_ = details; } + /** + * Returns true if this is the IP2IP account + */ + bool isIP2IP() const; + /** * Serialize internal state of this account for configuration * @param YamlEmitter the configuration engine which generate the configuration file diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp index dd31f3bdc387e2db9490d1602a5fc0defc73a56e..9c5c9d584027dbcb22ee0b7f427b5b2426ac23e6 100644 --- a/daemon/src/sip/sipcall.cpp +++ b/daemon/src/sip/sipcall.cpp @@ -53,3 +53,16 @@ SIPCall::~SIPCall() delete local_sdp_; pj_pool_release(pool_); } + +void SIPCall::answer() +{ + pjsip_tx_data *tdata; + if (pjsip_inv_answer(inv, PJSIP_SC_OK, NULL, NULL, &tdata) != PJ_SUCCESS) + throw std::runtime_error("Could not init invite request answer (200 OK)"); + + if (pjsip_inv_send_msg(inv, tdata) != PJ_SUCCESS) + throw std::runtime_error("Could not send invite request answer (200 OK)"); + + setConnectionState(CONNECTED); + setState(ACTIVE); +} diff --git a/daemon/src/sip/sipcall.h b/daemon/src/sip/sipcall.h index dab99795a77a66809277723be08e990e28b25248..249d3b7976bafd949dc465cf5a480c87581b78b9 100644 --- a/daemon/src/sip/sipcall.h +++ b/daemon/src/sip/sipcall.h @@ -89,6 +89,7 @@ class SIPCall : public Call { pjsip_inv_session *inv; private: + virtual void answer(); NON_COPYABLE(SIPCall); diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index b5a7496bd740bf890692f56c56e93f3c9f88f120..b226b5d08f94aa921979cf7cbe7cff30767d9f7a 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -48,7 +48,6 @@ #include "dbus/dbusmanager.h" #include "dbus/callmanager.h" -#include "hooks/urlhook.h" #include "im/instant_messaging.h" #include "audio/audiolayer.h" @@ -309,7 +308,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) if (Manager::instance().hookPreference.getSipEnabled()) { std::string header_value(fetchHeaderValue(rdata->msg_info.msg, Manager::instance().hookPreference.getUrlSipField())); - UrlHook::runAction(Manager::instance().hookPreference.getUrlCommand(), header_value); + Manager::instance().hookPreference.run(header_value); } SIPCall* call = new SIPCall(Manager::instance().getNewCallID(), Call::INCOMING, cp_); @@ -651,29 +650,24 @@ void SIPVoIPLink::sendUnregister(Account *a) account->setRegister(false); } -void SIPVoIPLink::registerKeepAliveTimer(pj_timer_entry& timer, pj_time_val& delay) +void SIPVoIPLink::registerKeepAliveTimer(pj_timer_entry &timer, pj_time_val &delay) { - pj_status_t status; - - DEBUG("UserAgent: Registering keep alive timer"); - - if(timer.id == -1) { + if (timer.id == -1) WARN("UserAgent: Timer already scheduled"); - } - - status = pjsip_endpt_schedule_timer(endpt_, &timer, &delay); - if (status != PJ_SUCCESS) { - ERROR("UserAgent: Could not schedule new timer in pjsip endpoint"); - } - if(status == PJ_EINVAL) { - ERROR("UserAgent: Invalid timer or delay entry"); - } - - if(status == PJ_EINVALIDOP) { - ERROR("Invalid timer entry, maybe already scheduled"); + switch (pjsip_endpt_schedule_timer(endpt_, &timer, &delay)) { + case PJ_SUCCESS: + break; + default: + ERROR("UserAgent: Could not schedule new timer in pjsip endpoint"); + /* fallthrough */ + case PJ_EINVAL: + ERROR("UserAgent: Invalid timer or delay entry"); + break; + case PJ_EINVALIDOP: + ERROR("Invalid timer entry, maybe already scheduled"); + break; } - } void SIPVoIPLink::cancelKeepAliveTimer(pj_timer_entry& timer) @@ -749,23 +743,11 @@ Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toU } void -SIPVoIPLink::answer(Call *c) +SIPVoIPLink::answer(Call *call) { - SIPCall *call = dynamic_cast<SIPCall*>(c); - if (!call) return; - - pjsip_tx_data *tdata; - - if (pjsip_inv_answer(call->inv, PJSIP_SC_OK, NULL, NULL, &tdata) != PJ_SUCCESS) - throw VoipLinkException("Could not init invite request answer (200 OK)"); - - if (pjsip_inv_send_msg(call->inv, tdata) != PJ_SUCCESS) - throw VoipLinkException("Could not send invite request answer (200 OK)"); - - call->setConnectionState(Call::CONNECTED); - call->setState(Call::ACTIVE); + call->answer(); } void @@ -1185,7 +1167,7 @@ SIPVoIPLink::getSIPCall(const std::string& id) bool SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to) { - SIPAccount *account = dynamic_cast<SIPAccount *>(Manager::instance().getAccount(SIPAccount::IP2IP_PROFILE)); + SIPAccount *account = Manager::instance().getIP2IPAccount(); if (!account) return false; @@ -1331,7 +1313,7 @@ void SIPVoIPLink::createDefaultSipUdpTransport() pj_uint16_t port = 0; int counter = 0; - SIPAccount *account = dynamic_cast<SIPAccount *>(Manager::instance().getAccount(SIPAccount::IP2IP_PROFILE)); + SIPAccount *account = Manager::instance().getIP2IPAccount(); pjsip_transport *transport = NULL; static const int DEFAULT_TRANSPORT_ATTEMPTS = 5; @@ -2173,14 +2155,14 @@ std::string fetchHeaderValue(pjsip_msg *msg, const std::string &field) if (!hdr) return ""; - std::string value(std::string(hdr->hvalue.ptr, hdr->hvalue.slen)); + std::string value(hdr->hvalue.ptr, hdr->hvalue.slen); size_t pos = value.find("\n"); - if (pos == std::string::npos) + if (pos != std::string::npos) + return value.substr(0, pos); + else return ""; - - return value.substr(0, pos); } } // end anonymous namespace diff --git a/daemon/test/Makefile.am b/daemon/test/Makefile.am index 28c269d257e34af7e9c53d885d1deba3c7911399..111e599a8b178255158eff256cb51ad4c6c58108 100644 --- a/daemon/test/Makefile.am +++ b/daemon/test/Makefile.am @@ -6,7 +6,7 @@ check_PROGRAMS = test TESTS = run_tests.sh test_CXXFLAGS = -I . -test_LDADD = $(top_builddir)/src/libsflphone.la @ZRTPCPP_LIBS@ @LIBCRYPTO_LIBS@ @CPPUNIT_LIBS@ +test_LDADD = $(top_builddir)/src/libsflphone.la @ZRTPCPP_LIBS@ @LIBCRYPTO_LIBS@ @CPPUNIT_LIBS@ @YAML_LIBS@ EXTRA_DIST = $(test_SOURCES) sflphoned-sample.yml history-sample.tpl run_tests.sh test_SOURCES = \ diff --git a/daemon/test/configurationtest.cpp b/daemon/test/configurationtest.cpp index 09b38f36ac1d398725978d077cf518f018db3dbd..b670351c1e11482378a03316cfab6214a42bc8ab 100644 --- a/daemon/test/configurationtest.cpp +++ b/daemon/test/configurationtest.cpp @@ -62,9 +62,9 @@ void ConfigurationTest::testDefaultValueSignalisation() { DEBUG("-------------------- ConfigurationTest::testDefaultValueSignalisation --------------------\n"); - CPPUNIT_ASSERT(Manager::instance().voipPreferences.getSymmetricRtp() == true); - CPPUNIT_ASSERT(Manager::instance().voipPreferences.getPlayDtmf() == true); - CPPUNIT_ASSERT(Manager::instance().voipPreferences.getPlayTones() == true); + CPPUNIT_ASSERT(Manager::instance().voipPreferences.getSymmetricRtp()); + CPPUNIT_ASSERT(Manager::instance().voipPreferences.getPlayDtmf()); + CPPUNIT_ASSERT(Manager::instance().voipPreferences.getPlayTones()); CPPUNIT_ASSERT(Manager::instance().voipPreferences.getPulseLength() == 250); } @@ -93,13 +93,11 @@ void ConfigurationTest::testInitAudioDriver() void ConfigurationTest::testYamlParser() { try { - Conf::YamlParser *parser = new Conf::YamlParser("ymlParser.yml"); - parser->serializeEvents(); - parser->composeEvents(); - parser->constructNativeData(); - - delete parser; - } catch (Conf::YamlParserException &e) { + Conf::YamlParser parser("ymlParser.yml"); + parser.serializeEvents(); + parser.composeEvents(); + parser.constructNativeData(); + } catch (const Conf::YamlParserException &e) { ERROR("ConfigTree: %s", e.what()); } } @@ -223,13 +221,12 @@ void ConfigurationTest::testYamlEmitter() tlsmap.setKeyValue(verifyServerKey, &verifyserver); try { - YamlEmitter *emitter = new YamlEmitter("/tmp/ymlEmiter.txt"); + YamlEmitter emitter("/tmp/ymlEmiter.txt"); - emitter->serializeAccount(&accountmap); - emitter->serializeAccount(&accountmap); - emitter->serializeData(); + emitter.serializeAccount(&accountmap); + emitter.serializeAccount(&accountmap); + emitter.serializeData(); - delete emitter; } catch (const YamlEmitterException &e) { ERROR("ConfigTree: %s", e.what()); } diff --git a/daemon/test/instantmessagingtest.cpp b/daemon/test/instantmessagingtest.cpp index d88185d01ee29bfc9299c556902fdf6517abfe95..99bfa259a2a80021d76f26dd0dea9a66fa247d0b 100644 --- a/daemon/test/instantmessagingtest.cpp +++ b/daemon/test/instantmessagingtest.cpp @@ -53,12 +53,12 @@ void InstantMessagingTest::testSaveSingleMessage() std::string filename = "im:"; // Open a file stream and try to write in it - CPPUNIT_ASSERT(saveMessage("Bonjour, c'est un test d'archivage de message", "Manu", callID, std::ios::out) == true); + CPPUNIT_ASSERT(saveMessage("Bonjour, c'est un test d'archivage de message", "Manu", callID, std::ios::out)); filename.append(callID); // Read it to check it has been successfully written std::ifstream testfile(filename.c_str(), std::ios::in); - CPPUNIT_ASSERT(testfile.is_open() == true); + CPPUNIT_ASSERT(testfile.is_open()); while (!testfile.eof()) { std::getline(testfile, tmp); @@ -78,13 +78,13 @@ void InstantMessagingTest::testSaveMultipleMessage() std::string filename = "im:"; // Open a file stream and try to write in it - CPPUNIT_ASSERT(saveMessage("Bonjour, c'est un test d'archivage de message", "Manu", callID, std::ios::out) == true); - CPPUNIT_ASSERT(saveMessage("Cool", "Alex", callID, std::ios::out || std::ios::app) == true); + CPPUNIT_ASSERT(saveMessage("Bonjour, c'est un test d'archivage de message", "Manu", callID, std::ios::out)); + CPPUNIT_ASSERT(saveMessage("Cool", "Alex", callID, std::ios::out || std::ios::app)); filename.append(callID); // Read it to check it has been successfully written std::ifstream testfile(filename.c_str(), std::ios::in); - CPPUNIT_ASSERT(testfile.is_open() == true); + CPPUNIT_ASSERT(testfile.is_open()); while (!testfile.eof()) { std::getline(testfile, tmp); @@ -231,7 +231,7 @@ void InstantMessagingTest::testGetTextArea() formatedText.append("</resource-lists>"); formatedText.append("--boundary--"); - std::string message = findTextMessage(formatedText); + std::string message(findTextMessage(formatedText)); std::cout << "message " << message << std::endl; diff --git a/daemon/test/mainbuffertest.cpp b/daemon/test/mainbuffertest.cpp index 94085b0c9ca68a83392e233d28fcae534006798a..2b5e80371cd65d7fe2a00e792518fd501d9a5d42 100644 --- a/daemon/test/mainbuffertest.cpp +++ b/daemon/test/mainbuffertest.cpp @@ -73,7 +73,7 @@ void MainBufferTest::testRingBufferCreation() RingBufferMap::iterator iter; // test mainbuffer ringbuffer map size - CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.size() == 0); + CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.empty()); test_ring_buffer = mainbuffer_.createRingBuffer(test_id); CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.size() == 1); @@ -97,10 +97,10 @@ void MainBufferTest::testRingBufferCreation() CPPUNIT_ASSERT(mainbuffer_.getRingBuffer(test_id) == test_ring_buffer); // test remove ring buffer - CPPUNIT_ASSERT(mainbuffer_.removeRingBuffer(null_id) == true); + CPPUNIT_ASSERT(mainbuffer_.removeRingBuffer(null_id)); CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.size() == 1); - CPPUNIT_ASSERT(mainbuffer_.removeRingBuffer(test_id) == true); - CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.size() == 0); + CPPUNIT_ASSERT(mainbuffer_.removeRingBuffer(test_id)); + CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.empty()); CPPUNIT_ASSERT(mainbuffer_.getRingBuffer(test_id) == NULL); iter = mainbuffer_.ringBufferMap_.find(test_id); @@ -171,8 +171,8 @@ void MainBufferTest::testCallIDSet() std::string call_id_2 = "call id 2"; // test initial settings - CPPUNIT_ASSERT(mainbuffer_.callIDMap_.size() == 0); - CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.size() == 0); + CPPUNIT_ASSERT(mainbuffer_.callIDMap_.empty()); + CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.empty()); iter_map = mainbuffer_.callIDMap_.find(test_id); CPPUNIT_ASSERT(iter_map ==mainbuffer_.callIDMap_.end()); @@ -227,15 +227,13 @@ void MainBufferTest::testCallIDSet() CPPUNIT_ASSERT(iter_set == iter_map->second->end()); // Test removeCallIDSet - CPPUNIT_ASSERT(mainbuffer_.removeCallIDSet(false_id) == false); + CPPUNIT_ASSERT(!mainbuffer_.removeCallIDSet(false_id)); CPPUNIT_ASSERT(mainbuffer_.callIDMap_.size() == 1); - CPPUNIT_ASSERT(mainbuffer_.removeCallIDSet(test_id) == true); - CPPUNIT_ASSERT(mainbuffer_.callIDMap_.size() == 0); + CPPUNIT_ASSERT(mainbuffer_.removeCallIDSet(test_id)); + CPPUNIT_ASSERT(mainbuffer_.callIDMap_.empty()); iter_map = mainbuffer_.callIDMap_.find(test_id); - CPPUNIT_ASSERT(iter_map ==mainbuffer_.callIDMap_.end()); - - + CPPUNIT_ASSERT(iter_map == mainbuffer_.callIDMap_.end()); } @@ -247,14 +245,12 @@ void MainBufferTest::testRingBufferInt() int testint1 = 12; int testint2 = 13; - int init_put_size; - // test with default ring buffer RingBuffer* test_ring_buffer = mainbuffer_.createRingBuffer(default_id); // initial state - init_put_size = test_ring_buffer->AvailForPut(); + int init_put_size = test_ring_buffer->AvailForPut(); CPPUNIT_ASSERT(test_ring_buffer->putLen() == 0); CPPUNIT_ASSERT(test_ring_buffer->getReadPointer() == 0); @@ -1764,6 +1760,6 @@ void MainBufferTest::testConference() CPPUNIT_ASSERT(mainbuffer_.callIDMap_.size() == 2); mainbuffer_.unBindCallID(test_id2); - CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.size() == 0); - CPPUNIT_ASSERT(mainbuffer_.callIDMap_.size() == 0); + CPPUNIT_ASSERT(mainbuffer_.ringBufferMap_.empty()); + CPPUNIT_ASSERT(mainbuffer_.callIDMap_.empty()); } diff --git a/daemon/test/ringtonetest.cpp b/daemon/test/ringtonetest.cpp index eaa0e90833a72162131407a83a58639de6ef60b6..0b82edd1d1698bac9cc54521647423fa0fca5257 100644 --- a/daemon/test/ringtonetest.cpp +++ b/daemon/test/ringtonetest.cpp @@ -32,17 +32,12 @@ void RingtoneTest::testLoadWavefile() { - WavFile *wav = new WavFile(); + WavFile wav; // Test initial values - CPPUNIT_ASSERT(wav->isStarted() == false); - CPPUNIT_ASSERT(wav->getSize() == 0); + CPPUNIT_ASSERT(not wav.isStarted()); + CPPUNIT_ASSERT(wav.getSize() == 0); // Test protection against wrong file name - CPPUNIT_ASSERT(wav->loadFile(std::string("wrongfilename.wav"), NULL, 44100) == false); - - - - delete wav; - wav = NULL; + CPPUNIT_ASSERT(not wav.loadFile(std::string("wrongfilename.wav"), NULL, 44100)); } diff --git a/daemon/test/sdesnegotiatortest.cpp b/daemon/test/sdesnegotiatortest.cpp index 2330412ff1a28b8d928b4bc26582acee8e3a56a6..8bca64625cf18a56f195a6153362579028f2fa1c 100644 --- a/daemon/test/sdesnegotiatortest.cpp +++ b/daemon/test/sdesnegotiatortest.cpp @@ -50,24 +50,17 @@ using std::cout; using std::endl; -SdesNegotiatorTest::SdesNegotiatorTest() : pattern(0), sdesnego(0), - remoteOffer(0), localCapabilities(0) -{} - void SdesNegotiatorTest::testTagPattern() { DEBUG("-------------------- SdesNegotiatorTest::testTagPattern --------------------\n"); std::string subject = "a=crypto:4"; - pattern = new sfl::Pattern("^a=crypto:(?P<tag>[0-9]{1,9})"); - *pattern << subject; - - CPPUNIT_ASSERT(pattern->matches()); - CPPUNIT_ASSERT(pattern->group("tag").compare("4") == 0); + sfl::Pattern pattern("^a=crypto:(?P<tag>[0-9]{1,9})"); + pattern << subject; - delete pattern; - pattern = NULL; + CPPUNIT_ASSERT(pattern.matches()); + CPPUNIT_ASSERT(pattern.group("tag").compare("4") == 0); } @@ -77,17 +70,14 @@ void SdesNegotiatorTest::testCryptoSuitePattern() std::string subject = "AES_CM_128_HMAC_SHA1_80"; - pattern = new sfl::Pattern("(?P<cryptoSuite>AES_CM_128_HMAC_SHA1_80|" \ + sfl::Pattern pattern("(?P<cryptoSuite>AES_CM_128_HMAC_SHA1_80|" \ "AES_CM_128_HMAC_SHA1_32|" \ "F8_128_HMAC_SHA1_80|" \ "[A-Za-z0-9_]+)"); - *pattern << subject; - - CPPUNIT_ASSERT(pattern->matches()); - CPPUNIT_ASSERT(pattern->group("cryptoSuite").compare("AES_CM_128_HMAC_SHA1_80") == 0); + pattern << subject; - delete pattern; - pattern = NULL; + CPPUNIT_ASSERT(pattern.matches()); + CPPUNIT_ASSERT(pattern.group("cryptoSuite").compare("AES_CM_128_HMAC_SHA1_80") == 0); } @@ -97,24 +87,21 @@ void SdesNegotiatorTest::testKeyParamsPattern() std::string subject = "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32"; - pattern = new sfl::Pattern("(?P<srtpKeyMethod>inline|[A-Za-z0-9_]+)\\:" \ + sfl::Pattern pattern("(?P<srtpKeyMethod>inline|[A-Za-z0-9_]+)\\:" \ "(?P<srtpKeyInfo>[A-Za-z0-9\x2B\x2F\x3D]+)\\|" \ "(2\\^(?P<lifetime>[0-9]+)\\|" \ "(?P<mkiValue>[0-9]+)\\:" \ "(?P<mkiLength>[0-9]{1,3})\\;?)?", "g"); - *pattern << subject; + pattern << subject; - pattern->matches(); - CPPUNIT_ASSERT(pattern->group("srtpKeyMethod").compare("inline:")); - CPPUNIT_ASSERT(pattern->group("srtpKeyInfo").compare("d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") + pattern.matches(); + CPPUNIT_ASSERT(pattern.group("srtpKeyMethod").compare("inline:")); + CPPUNIT_ASSERT(pattern.group("srtpKeyInfo").compare("d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") == 0); - CPPUNIT_ASSERT(pattern->group("lifetime").compare("20") == 0); - CPPUNIT_ASSERT(pattern->group("mkiValue").compare("1") == 0); - CPPUNIT_ASSERT(pattern->group("mkiLength").compare("32") == 0); - - delete pattern; - pattern = NULL; + CPPUNIT_ASSERT(pattern.group("lifetime").compare("20") == 0); + CPPUNIT_ASSERT(pattern.group("mkiValue").compare("1") == 0); + CPPUNIT_ASSERT(pattern.group("mkiLength").compare("32") == 0); } @@ -122,22 +109,19 @@ void SdesNegotiatorTest::testKeyParamsPatternWithoutMKI() { DEBUG("-------------------- SdesNegotiatorTest::testKeyParamsPatternWithoutMKI --------------------\n"); - std::string subject = "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj"; + std::string subject("inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj"); - pattern = new sfl::Pattern("(?P<srtpKeyMethod>inline|[A-Za-z0-9_]+)\\:" \ + sfl::Pattern pattern("(?P<srtpKeyMethod>inline|[A-Za-z0-9_]+)\\:" \ "(?P<srtpKeyInfo>[A-Za-z0-9\x2B\x2F\x3D]+)" \ "(\\|2\\^(?P<lifetime>[0-9]+)\\|" \ "(?P<mkiValue>[0-9]+)\\:" \ "(?P<mkiLength>[0-9]{1,3})\\;?)?", "g"); - *pattern << subject; - pattern->matches(); - CPPUNIT_ASSERT(pattern->group("srtpKeyMethod").compare("inline:")); - CPPUNIT_ASSERT(pattern->group("srtpKeyInfo").compare("d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") + pattern << subject; + pattern.matches(); + CPPUNIT_ASSERT(pattern.group("srtpKeyMethod").compare("inline:")); + CPPUNIT_ASSERT(pattern.group("srtpKeyInfo").compare("d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") == 0); - - delete pattern; - pattern = NULL; } @@ -150,30 +134,19 @@ void SdesNegotiatorTest::testNegotiation() DEBUG("-------------------- SdesNegotiatorTest::testNegotiation --------------------\n"); // Add a new SDES crypto line to be processed. - remoteOffer = new std::vector<std::string>(); - remoteOffer->push_back(std::string("a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd|2^20|1:32")); - remoteOffer->push_back(std::string("a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32")); + std::vector<std::string> remoteOffer; + remoteOffer.push_back("a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd|2^20|1:32"); + remoteOffer.push_back("a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32"); // Register the local capabilities. - localCapabilities = new std::vector<sfl::CryptoSuiteDefinition>(); + std::vector<sfl::CryptoSuiteDefinition> localCapabilities; - for (int i = 0; i < 3; i++) { - localCapabilities->push_back(sfl::CryptoSuites[i]); - } + for (int i = 0; i < 3; ++i) + localCapabilities.push_back(sfl::CryptoSuites[i]); - sdesnego = new sfl::SdesNegotiator(*localCapabilities, *remoteOffer); + sfl::SdesNegotiator sdesnego(localCapabilities, remoteOffer); - CPPUNIT_ASSERT(sdesnego->negotiate()); - // CPPUNIT_ASSERT(sdesnego->getKeyInfo().compare("AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd|2^20|1:32")==0); - - delete remoteOffer; - remoteOffer = NULL; - - delete localCapabilities; - localCapabilities = NULL; - - delete sdesnego; - sdesnego = NULL; + CPPUNIT_ASSERT(sdesnego.negotiate()); } /** @@ -184,25 +157,21 @@ void SdesNegotiatorTest::testComponent() DEBUG("-------------------- SdesNegotiatorTest::testComponent --------------------\n"); // Register the local capabilities. - std::vector<sfl::CryptoSuiteDefinition> * capabilities = new std::vector<sfl::CryptoSuiteDefinition>(); + std::vector<sfl::CryptoSuiteDefinition> capabilities; - //Support all the CryptoSuites - for (int i = 0; i < 3; i++) { - capabilities->push_back(sfl::CryptoSuites[i]); - } + // Support all the CryptoSuites + for (int i = 0; i < 3; i++) + capabilities.push_back(sfl::CryptoSuites[i]); // Make sure that if a component is missing, negotiate will fail std::string cryptoLine("a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:|2^20|1:32"); - std::vector<std::string> * cryptoOffer = new std::vector<std::string>(); - cryptoOffer->push_back(cryptoLine); + std::vector<std::string> cryptoOffer; + cryptoOffer.push_back(cryptoLine); - sfl::SdesNegotiator * negotiator = new sfl::SdesNegotiator(*capabilities, *cryptoOffer); - - CPPUNIT_ASSERT(negotiator->negotiate() == false); + sfl::SdesNegotiator negotiator(capabilities, cryptoOffer); + CPPUNIT_ASSERT(!negotiator.negotiate()); } - - /** * Make sure that most simple case does not fail. */ @@ -211,37 +180,28 @@ void SdesNegotiatorTest::testMostSimpleCase() DEBUG("-------------------- SdesNegotiatorTest::testMostSimpleCase --------------------\n"); // Register the local capabilities. - std::vector<sfl::CryptoSuiteDefinition> * capabilities = new std::vector<sfl::CryptoSuiteDefinition>(); + std::vector<sfl::CryptoSuiteDefinition> capabilities; - //Support all the CryptoSuites - for (int i = 0; i < 3; i++) { - capabilities->push_back(sfl::CryptoSuites[i]); - } + // Support all the CryptoSuites + for (int i = 0; i < 3; i++) + capabilities.push_back(sfl::CryptoSuites[i]); // Make sure taht this case works (since it's default for most application) std::string cryptoLine("a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd"); - std::vector<std::string> * cryptoOffer = new std::vector<std::string>(); - cryptoOffer->push_back(cryptoLine); - - sfl::SdesNegotiator * negotiator = new sfl::SdesNegotiator(*capabilities, *cryptoOffer); + std::vector<std::string> cryptoOffer; + cryptoOffer.push_back(cryptoLine); - CPPUNIT_ASSERT(negotiator->negotiate() == true); + sfl::SdesNegotiator negotiator(capabilities, cryptoOffer); - CPPUNIT_ASSERT(negotiator->getCryptoSuite() == "AES_CM_128_HMAC_SHA1_80"); - CPPUNIT_ASSERT(negotiator->getKeyMethod() == "inline"); - CPPUNIT_ASSERT(negotiator->getKeyInfo() == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd"); - CPPUNIT_ASSERT(negotiator->getLifeTime() == ""); - CPPUNIT_ASSERT(negotiator->getMkiValue() == ""); - CPPUNIT_ASSERT(negotiator->getMkiLength() == ""); - CPPUNIT_ASSERT(negotiator->getAuthTagLength() == "80"); + CPPUNIT_ASSERT(negotiator.negotiate()); - - delete capabilities; - capabilities = NULL; - delete cryptoOffer; - cryptoOffer = NULL; - delete negotiator; - negotiator = NULL; + CPPUNIT_ASSERT(negotiator.getCryptoSuite() == "AES_CM_128_HMAC_SHA1_80"); + CPPUNIT_ASSERT(negotiator.getKeyMethod() == "inline"); + CPPUNIT_ASSERT(negotiator.getKeyInfo() == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd"); + CPPUNIT_ASSERT(negotiator.getLifeTime().empty()); + CPPUNIT_ASSERT(negotiator.getMkiValue().empty()); + CPPUNIT_ASSERT(negotiator.getMkiLength().empty()); + CPPUNIT_ASSERT(negotiator.getAuthTagLength() == "80"); } @@ -250,34 +210,26 @@ void SdesNegotiatorTest::test32ByteKeyLength() DEBUG("-------------------- SdesNegotiatorTest::test32ByteKeyLength --------------------\n"); // Register the local capabilities. - std::vector<sfl::CryptoSuiteDefinition> * capabilities = new std::vector<sfl::CryptoSuiteDefinition>(); + std::vector<sfl::CryptoSuiteDefinition> capabilities; //Support all the CryptoSuites - for (int i = 0; i < 3; i++) { - capabilities->push_back(sfl::CryptoSuites[i]); - } + for (int i = 0; i < 3; i++) + capabilities.push_back(sfl::CryptoSuites[i]); std::string cryptoLine("a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd"); - std::vector<std::string> * cryptoOffer = new std::vector<std::string>(); - cryptoOffer->push_back(cryptoLine); - - sfl::SdesNegotiator * negotiator = new sfl::SdesNegotiator(*capabilities, *cryptoOffer); - - CPPUNIT_ASSERT(negotiator->negotiate() == true); - - CPPUNIT_ASSERT(negotiator->getCryptoSuite() == "AES_CM_128_HMAC_SHA1_32"); - CPPUNIT_ASSERT(negotiator->getKeyMethod() == "inline"); - CPPUNIT_ASSERT(negotiator->getKeyInfo() == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd"); - CPPUNIT_ASSERT(negotiator->getLifeTime() == ""); - CPPUNIT_ASSERT(negotiator->getMkiValue() == ""); - CPPUNIT_ASSERT(negotiator->getMkiLength() == ""); - CPPUNIT_ASSERT(negotiator->getAuthTagLength() == "32"); - - delete capabilities; - capabilities = NULL; - delete cryptoOffer; - cryptoOffer = NULL; - delete negotiator; - negotiator = NULL; + std::vector<std::string> cryptoOffer; + cryptoOffer.push_back(cryptoLine); + + sfl::SdesNegotiator negotiator(capabilities, cryptoOffer); + + CPPUNIT_ASSERT(negotiator.negotiate()); + + CPPUNIT_ASSERT(negotiator.getCryptoSuite() == "AES_CM_128_HMAC_SHA1_32"); + CPPUNIT_ASSERT(negotiator.getKeyMethod() == "inline"); + CPPUNIT_ASSERT(negotiator.getKeyInfo() == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwd"); + CPPUNIT_ASSERT(negotiator.getLifeTime().empty()); + CPPUNIT_ASSERT(negotiator.getMkiValue().empty()); + CPPUNIT_ASSERT(negotiator.getMkiLength().empty()); + CPPUNIT_ASSERT(negotiator.getAuthTagLength() == "32"); } diff --git a/daemon/test/sdesnegotiatortest.h b/daemon/test/sdesnegotiatortest.h index eb9bb74cde8fc360dcc456e8d70eaf0114e252c0..a634f5bde066d1c9633a5f7e7f83170fe9f777d2 100644 --- a/daemon/test/sdesnegotiatortest.h +++ b/daemon/test/sdesnegotiatortest.h @@ -80,8 +80,6 @@ class SdesNegotiatorTest : public CppUnit::TestCase { CPPUNIT_TEST_SUITE_END(); public: - - SdesNegotiatorTest(); /* * Code factoring - Common resources can be released here. * This method is called by unitcpp after each test @@ -103,14 +101,6 @@ class SdesNegotiatorTest : public CppUnit::TestCase { void testMostSimpleCase(); void test32ByteKeyLength(); - - private: - NON_COPYABLE(SdesNegotiatorTest); - - sfl::Pattern *pattern; - sfl::SdesNegotiator *sdesnego; - std::vector<std::string> *remoteOffer; - std::vector<sfl::CryptoSuiteDefinition> *localCapabilities; }; /* Register our test module */ diff --git a/gnome/.gitignore b/gnome/.gitignore index 062344668bf4748809802cfae31ff6e42fbc1fc3..f6e3821328b639b709f4b2e0b6c03bd6d72a355b 100644 --- a/gnome/.gitignore +++ b/gnome/.gitignore @@ -1,3 +1,5 @@ +m4 +aclocal.m4 config.* configure depcomp diff --git a/gnome/configure.ac b/gnome/configure.ac index b9965233b9584b24d365198443143430f8ffcc6e..542e7996f0cc9274921bca83962472261a01142d 100644 --- a/gnome/configure.ac +++ b/gnome/configure.ac @@ -36,6 +36,9 @@ PKG_CHECK_MODULES(GTK, gtk+-3.0) PKG_CHECK_MODULES(GCONF, gconf-2.0) PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.24) PKG_CHECK_MODULES(WEBKIT, webkitgtk-3.0) +PKG_CHECK_MODULES(X11, x11) +PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, javascriptcoregtk-3.0, , + AC_MSG_RESULT(javascriptcoregtk not installed)) PKG_CHECK_MODULES([CHECK], [check >= 0.9.4]) diff --git a/gnome/src/Makefile.am b/gnome/src/Makefile.am index 3e673bfde457f4c7e9c3e8d994d6b346abc26040..eb80e713779935911dc2f7755b16a91357824bcd 100644 --- a/gnome/src/Makefile.am +++ b/gnome/src/Makefile.am @@ -5,10 +5,10 @@ bin_PROGRAMS = sflphone-client-gnome SUBDIRS = config contacts dbus widget icons NOFIFY_LIBS = -lnotify -X11_LIBS = -lX11 LD_LIBS = -ldl -SFLPHONEGTK_LIBS=./contacts/libcontacts.la ./config/libconfig.la ./dbus/libdbus.la ./widget/libwidget.la ./icons/libicons.la +SFLPHONEGTK_LIBS=./contacts/libcontacts.la ./config/libconfig.la \ + ./dbus/libdbus.la ./widget/libwidget.la ./icons/libicons.la sflphone_client_gnome_SOURCES = \ main.c \ @@ -27,18 +27,25 @@ sflphone_client_gnome_SOURCES = \ codeclist.c \ reqaccount.c \ eel-gconf-extensions.c \ - shortcuts.c + shortcuts.c \ + str_utils.c noinst_HEADERS = actions.h sflnotify.h mainwindow.h dialpad.h codeclist.h \ - reqaccount.h sflphone_const.h uimanager.h \ - accountlist.h sliders.h statusicon.h callable_obj.h conference_obj.h \ - shortcuts.h eel-gconf-extensions.h logger.h imwindow.h unused.h - -sflphone_client_gnome_LDADD = $(DBUSGLIB_LIBS) $(LIBNOTIFY_LIBS) $(NOTIFY_LIBS) $(SFLPHONEGTK_LIBS) $(X11_LIBS) \ - $(GTK_LIBS) $(GLIB_LIBS) $(WEBKIT_LIBS) $(LD_LIBS) $(GCONF_LIBS) - -sflphone_client_gnome_CFLAGS = $(DBUSGLIB_CFLAGS) $(LIBNOTIFY_CFLAGS) $(NOTIFY_CFLAGS) $(GTK_CFLAGS) $(X11_CFLAGS) \ - $(GLIB_CFLAGS) $(WEBKIT_CFLAGS) $(GCONF_CFLAGS) + reqaccount.h sflphone_const.h uimanager.h accountlist.h \ + sliders.h statusicon.h callable_obj.h conference_obj.h \ + shortcuts.h eel-gconf-extensions.h logger.h imwindow.h \ + unused.h str_utils.h + +sflphone_client_gnome_LDADD = $(DBUSGLIB_LIBS) $(LIBNOTIFY_LIBS) \ + $(NOTIFY_LIBS) $(SFLPHONEGTK_LIBS) $(X11_LIBS) \ + $(GTK_LIBS) $(GLIB_LIBS) $(WEBKIT_LIBS) \ + $(LD_LIBS) $(GCONF_LIBS) \ + $(JAVASCRIPT_CORE_GTK_LIBS) + +sflphone_client_gnome_CFLAGS = $(DBUSGLIB_CFLAGS) $(LIBNOTIFY_CFLAGS) \ + $(NOTIFY_CFLAGS) $(GTK_CFLAGS) $(X11_CFLAGS) \ + $(GLIB_CFLAGS) $(WEBKIT_CFLAGS) \ + $(GCONF_CFLAGS) $(JAVASCRIPT_CORE_GTK_CFLAGS) # add symbolic link install-exec-local: diff --git a/gnome/src/accountlist.c b/gnome/src/accountlist.c index 662c7bc8729bbfb53cf32df66501c91944844eaf..2c639ce0fb962476216cb50c35811cb707ac76c5 100644 --- a/gnome/src/accountlist.c +++ b/gnome/src/accountlist.c @@ -29,6 +29,8 @@ * as that of the covered work. */ +#include <glib/gi18n.h> +#include "str_utils.h" #include "accountlist.h" #include "actions.h" #include "unused.h" @@ -42,7 +44,7 @@ static guint account_list_get_position(account_t *account) for (guint i = 0; i < size; i++) { account_t *tmp = account_list_get_nth(i); - if (g_strcasecmp(tmp->accountID, account->accountID) == 0) + if (utf8_case_cmp(tmp->accountID, account->accountID) == 0) return i; } @@ -265,7 +267,7 @@ gboolean current_account_has_mailbox(void) if (current) { gchar * account_mailbox = g_hash_table_lookup(current->properties, ACCOUNT_MAILBOX); - if (account_mailbox && g_strcasecmp(account_mailbox, "") != 0) + if (account_mailbox && utf8_case_cmp(account_mailbox, "") != 0) return TRUE; } diff --git a/gnome/src/actions.c b/gnome/src/actions.c index b5bccc14235142f36586d8ee8260e6236ce14b41..8ac4fa49d52d18fe1d2588fdafdd4bcd32866393 100644 --- a/gnome/src/actions.c +++ b/gnome/src/actions.c @@ -29,6 +29,7 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include <gtk/gtk.h> /* Backward compatibility for gtk < 2.22.0 */ #if GTK_CHECK_VERSION(2,22,0) @@ -36,7 +37,9 @@ #else #include <gdk/gdkkeysyms.h> #endif -#include <glib/gprintf.h> + +#include "str_utils.h" +#include <glib.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -100,7 +103,7 @@ sflphone_notify_voice_mail(const gchar* accountID , guint count) static gboolean is_direct_call(callable_obj_t * c) { - if (g_strcasecmp(c->_accountID, "empty") == 0) { + if (utf8_case_cmp(c->_accountID, "empty") == 0) { if (!g_str_has_prefix(c->_peer_number, "sip:")) { gchar * new_number = g_strconcat("sip:", c->_peer_number, NULL); g_free(c->_peer_number); @@ -815,7 +818,8 @@ static int place_registered_call(callable_obj_t * c) return -1; } - if (g_strcasecmp(g_hash_table_lookup(current->properties, "Status"), "REGISTERED") ==0) { + gpointer status = g_hash_table_lookup(current->properties, "Status"); + if (status && utf8_case_cmp(status, "REGISTERED") == 0) { /* The call is made with the current account */ // free memory for previous account id and get a new one g_free(c->_accountID); diff --git a/gnome/src/callable_obj.c b/gnome/src/callable_obj.c index 83449c6490f80acef63bfe5b9e11b4534a996f82..562745a9b22681aed2d9c5b8eecbe6fe48d271af 100644 --- a/gnome/src/callable_obj.c +++ b/gnome/src/callable_obj.c @@ -29,9 +29,11 @@ */ #include "callable_obj.h" +#include "str_utils.h" #include "codeclist.h" #include "sflphone_const.h" #include <time.h> +#include <glib/gi18n.h> #include "contacts/calltab.h" #include "contacts/calltree.h" #include "dbus.h" @@ -145,15 +147,15 @@ callable_obj_t *create_new_call_from_details(const gchar *call_id, GHashTable *d const gchar * const display_name = g_hash_table_lookup(details, "DISPLAY_NAME"); const gchar * const state_str = g_hash_table_lookup(details, "CALL_STATE"); - if (g_strcasecmp(state_str, "CURRENT") == 0) + if (utf8_case_cmp(state_str, "CURRENT") == 0) state = CALL_STATE_CURRENT; - else if (g_strcasecmp(state_str, "RINGING") == 0) + else if (utf8_case_cmp(state_str, "RINGING") == 0) state = CALL_STATE_RINGING; - else if (g_strcasecmp(state_str, "INCOMING") == 0) + else if (utf8_case_cmp(state_str, "INCOMING") == 0) state = CALL_STATE_INCOMING; - else if (g_strcasecmp(state_str, "HOLD") == 0) + else if (utf8_case_cmp(state_str, "HOLD") == 0) state = CALL_STATE_HOLD; - else if (g_strcasecmp(state_str, "BUSY") == 0) + else if (utf8_case_cmp(state_str, "BUSY") == 0) state = CALL_STATE_BUSY; else state = CALL_STATE_FAILURE; diff --git a/gnome/src/conference_obj.c b/gnome/src/conference_obj.c index f2bda66b51a3310be1f614408da839091b3e0221..f91617458266d8171cd8e405610f45b15bd4d85b 100644 --- a/gnome/src/conference_obj.c +++ b/gnome/src/conference_obj.c @@ -31,6 +31,7 @@ #include <time.h> #include "callable_obj.h" +#include "str_utils.h" #include "dbus.h" #include "sflphone_const.h" #include "logger.h" @@ -80,17 +81,17 @@ conference_obj_t *create_new_conference_from_details(const gchar *conf_id, GHash gchar *state_str = g_hash_table_lookup(details, "CONF_STATE"); - if (g_strcasecmp(state_str, "ACTIVE_ATTACHED") == 0) + if (utf8_case_cmp(state_str, "ACTIVE_ATTACHED") == 0) new_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED; - else if (g_strcasecmp(state_str, "ACTIVE_ATTACHED_REC") == 0) + else if (utf8_case_cmp(state_str, "ACTIVE_ATTACHED_REC") == 0) new_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD; - else if (g_strcasecmp(state_str, "ACTIVE_DETACHED") == 0) + else if (utf8_case_cmp(state_str, "ACTIVE_DETACHED") == 0) new_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED; - else if (g_strcasecmp(state_str, "ACTIVE_DETACHED_REC") == 0) + else if (utf8_case_cmp(state_str, "ACTIVE_DETACHED_REC") == 0) new_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED_RECORD; - else if (g_strcasecmp(state_str, "HOLD") == 0) + else if (utf8_case_cmp(state_str, "HOLD") == 0) new_conf->_state = CONFERENCE_STATE_HOLD; - else if (g_strcasecmp(state_str, "HOLD_REC") == 0) + else if (utf8_case_cmp(state_str, "HOLD_REC") == 0) new_conf->_state = CONFERENCE_STATE_HOLD_RECORD; return new_conf; diff --git a/gnome/src/conference_obj.h b/gnome/src/conference_obj.h index e7f0e3a57cb6c92257a702c24da0ee3ac68876c4..0e17bada2addb8a6bf1384b71354ffd5fb54b743 100644 --- a/gnome/src/conference_obj.h +++ b/gnome/src/conference_obj.h @@ -32,7 +32,7 @@ #define __CONFERENCE_OBJ_H__ #include <gtk/gtk.h> -#include <glib/gprintf.h> +#include <glib.h> #include <stdlib.h> #include <time.h> diff --git a/gnome/src/config/accountconfigdialog.c b/gnome/src/config/accountconfigdialog.c index c6235957ad83ce9bfa297ecd9d9f292a07744c0a..2a8a12aaa90cf03c0570b9e54ff25fda117fe07d 100644 --- a/gnome/src/config/accountconfigdialog.c +++ b/gnome/src/config/accountconfigdialog.c @@ -31,6 +31,7 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <net/if.h> @@ -39,6 +40,7 @@ #include <gtk/gtk.h> #include "config.h" +#include "str_utils.h" #include "logger.h" #include "actions.h" #include "mainwindow.h" @@ -133,7 +135,7 @@ void change_protocol_cb(account_t *currentAccount UNUSED) // Only if tabs are not NULL if (security_tab && advanced_tab) { - if (g_strcasecmp(protocol, "IAX") == 0) { + if (utf8_case_cmp(protocol, "IAX") == 0) { gtk_widget_hide(security_tab); gtk_widget_hide(advanced_tab); } else { @@ -439,8 +441,8 @@ static void cell_edited_cb(GtkCellRendererText *renderer, gchar *path_desc, gcha gint column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(renderer), "column")); DEBUG("path desc in cell_edited_cb: %s\n", text); - if ((g_strcasecmp(path_desc, "0") == 0) && - g_strcasecmp(text, gtk_entry_get_text(GTK_ENTRY(entryUsername))) != 0) + if ((utf8_case_cmp(path_desc, "0") == 0) && + utf8_case_cmp(text, gtk_entry_get_text(GTK_ENTRY(entryUsername))) != 0) g_signal_handlers_disconnect_by_func(G_OBJECT(entryUsername), G_CALLBACK(update_credential_cb), NULL); GtkTreeIter iter; @@ -455,7 +457,7 @@ static void editing_started_cb(GtkCellRenderer *cell UNUSED, GtkCellEditable * e DEBUG("path desc in editing_started_cb: %s\n", path); // If we are dealing the first row - if (g_strcasecmp(path, "0") == 0) + if (utf8_case_cmp(path, "0") == 0) gtk_entry_set_text(GTK_ENTRY(editable), gtk_entry_get_text(GTK_ENTRY(entryPassword))); } @@ -463,7 +465,7 @@ static void show_advanced_zrtp_options_cb(GtkWidget *widget UNUSED, gpointer dat { gchar *proto = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(keyExchangeCombo)); - if (g_strcasecmp(proto, "ZRTP") == 0) + if (utf8_case_cmp(proto, "ZRTP") == 0) show_advanced_zrtp_options((GHashTable *) data); else show_advanced_sdes_options((GHashTable *) data); @@ -483,8 +485,8 @@ static void key_exchange_changed_cb(GtkWidget *widget UNUSED, gpointer data UNUS DEBUG("Key exchange changed %s", active_text); gboolean set_sensitive = FALSE; - set_sensitive |= g_strcasecmp(active_text, "SDES") == 0; - set_sensitive |= g_strcasecmp(active_text, "ZRTP") == 0; + set_sensitive |= utf8_case_cmp(active_text, "SDES") == 0; + set_sensitive |= utf8_case_cmp(active_text, "ZRTP") == 0; g_free(active_text); if (set_sensitive) @@ -862,7 +864,7 @@ static GtkWidget* create_registration_expire(account_t *a) entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic(_("_Comply with RFC 3263")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce), - g_strcasecmp(resolve_once,"false") == 0 ? TRUE: FALSE); + utf8_case_cmp(resolve_once,"false") == 0 ? TRUE: FALSE); gtk_table_attach_defaults(GTK_TABLE(table), entryResolveNameOnlyOnce, 0, 2, 1, 2); gtk_widget_set_sensitive(entryResolveNameOnlyOnce , TRUE); @@ -951,7 +953,7 @@ GtkWidget* create_published_address(account_t *a) use_tls = g_hash_table_lookup(a->properties, TLS_ENABLE); published_sameas_local = g_hash_table_lookup(a->properties, PUBLISHED_SAMEAS_LOCAL); - if (g_strcasecmp(published_sameas_local, "true") == 0) { + if (utf8_case_cmp(published_sameas_local, "true") == 0) { published_address = dbus_get_address_from_interface_name(g_hash_table_lookup(a->properties, LOCAL_INTERFACE)); published_port = g_hash_table_lookup(a->properties, LOCAL_PORT); } else { @@ -972,9 +974,9 @@ GtkWidget* create_published_address(account_t *a) gtk_table_attach_defaults(GTK_TABLE(table), useStunCheckBox, 0, 1, 0, 1); g_signal_connect(useStunCheckBox, "toggled", G_CALLBACK(use_stun_cb), a); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useStunCheckBox), - g_strcasecmp(stun_enable, "true") == 0 ? TRUE: FALSE); + utf8_case_cmp(stun_enable, "true") == 0 ? TRUE: FALSE); gtk_widget_set_sensitive(useStunCheckBox, - g_strcasecmp(use_tls, "true") == 0 ? FALSE: TRUE); + utf8_case_cmp(use_tls, "true") == 0 ? FALSE: TRUE); stunServerLabel = gtk_label_new_with_mnemonic(_("STUN server URL")); gtk_table_attach_defaults(GTK_TABLE(table), stunServerLabel, 0, 1, 1, 2); @@ -990,7 +992,7 @@ GtkWidget* create_published_address(account_t *a) publishedAddrRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(sameAsLocalRadioButton), _("Set published address and port:")); gtk_table_attach_defaults(GTK_TABLE(table), publishedAddrRadioButton, 0, 2, 4, 5); - if (g_strcasecmp(published_sameas_local, "true") == 0) { + if (utf8_case_cmp(published_sameas_local, "true") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton), TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(publishedAddrRadioButton), FALSE); } else { @@ -1096,7 +1098,7 @@ static GtkWidget* create_audiocodecs_configuration(account_t *currentAccount) gboolean dtmf_are_rtp = TRUE; - if (g_strcasecmp(currentDtmfType, OVERRTP) != 0) + if (utf8_case_cmp(currentDtmfType, OVERRTP) != 0) dtmf_are_rtp = FALSE; overrtp = gtk_radio_button_new_with_label(NULL, _("RTP")); @@ -1203,7 +1205,7 @@ void show_account_window(account_t * currentAccount) gtk_widget_show(notebook); // We do not need the global settings for the IP2IP account - if (g_strcasecmp(currentAccount->accountID, IP2IP) != 0) { + if (utf8_case_cmp(currentAccount->accountID, IP2IP) != 0) { /* General Settings */ GtkWidget *basic_tab = create_basic_tab(currentAccount); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), basic_tab, gtk_label_new(_("Basic"))); @@ -1224,7 +1226,7 @@ void show_account_window(account_t * currentAccount) currentProtocol = g_strdup("SIP"); // Do not need advanced or security one for the IP2IP account - if (g_strcasecmp(currentAccount->accountID, IP2IP) != 0) { + if (utf8_case_cmp(currentAccount->accountID, IP2IP) != 0) { /* Advanced */ advanced_tab = create_advanced_tab(currentAccount); @@ -1270,7 +1272,7 @@ void show_account_window(account_t * currentAccount) } // If accept button is - if (g_strcasecmp(currentAccount->accountID, IP2IP) != 0) { + if (utf8_case_cmp(currentAccount->accountID, IP2IP) != 0) { g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_ALIAS), @@ -1293,7 +1295,7 @@ void show_account_window(account_t * currentAccount) } if (g_strcmp0(proto, "SIP") == 0) { - if (g_strcasecmp(currentAccount->accountID, IP2IP) != 0) { + if (utf8_case_cmp(currentAccount->accountID, IP2IP) != 0) { g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_RESOLVE_ONCE), @@ -1355,10 +1357,10 @@ void show_account_window(account_t * currentAccount) gchar* keyExchange = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(keyExchangeCombo)); - if (g_strcasecmp(keyExchange, "ZRTP") == 0) { + if (utf8_case_cmp(keyExchange, "ZRTP") == 0) { g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true")); g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(ZRTP)); - } else if (g_strcasecmp(keyExchange, "SDES") == 0) { + } else if (utf8_case_cmp(keyExchange, "SDES") == 0) { g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true")); g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(SDES)); } else { @@ -1391,7 +1393,7 @@ void show_account_window(account_t * currentAccount) } /** @todo Verify if it's the best condition to check */ - if (g_strcasecmp(currentAccount->accountID, "new") == 0) + if (utf8_case_cmp(currentAccount->accountID, "new") == 0) dbus_add_account(currentAccount); else dbus_set_account_details(currentAccount); @@ -1400,7 +1402,7 @@ void show_account_window(account_t * currentAccount) /* Set new credentials if any */ DEBUG("Config: Setting credentials"); - if (g_strcasecmp(currentAccount->accountID, IP2IP) != 0) { + if (utf8_case_cmp(currentAccount->accountID, IP2IP) != 0) { DEBUG("Config: Get new credentials"); currentAccount->credential_information = getNewCredential(); diff --git a/gnome/src/config/accountlistconfigdialog.c b/gnome/src/config/accountlistconfigdialog.c index aa8db7a8dbbfae7c7d47a54b409815ec621e454a..aef4d63db98b10f9e01e316e7a49511767c83eb8 100644 --- a/gnome/src/config/accountlistconfigdialog.c +++ b/gnome/src/config/accountlistconfigdialog.c @@ -31,6 +31,7 @@ #include "accountlistconfigdialog.h" +#include "str_utils.h" #include "dbus/dbus.h" #include "accountconfigdialog.h" #include "actions.h" @@ -38,6 +39,7 @@ #include "utils.h" #include "unused.h" #include "logger.h" +#include <glib/gi18n.h> #include <string.h> static const int CONTEXT_ID_REGISTRATION = 0; @@ -128,7 +130,7 @@ void account_list_config_dialog_fill() COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup(a->properties, ACCOUNT_ALIAS), // Name COLUMN_ACCOUNT_TYPE, g_hash_table_lookup(a->properties, ACCOUNT_TYPE), // Protocol COLUMN_ACCOUNT_STATUS, account_state_name(a->state), // Status - COLUMN_ACCOUNT_ACTIVE, (g_strcasecmp(g_hash_table_lookup(a->properties, ACCOUNT_ENABLED),"true") == 0) ? TRUE:FALSE, // Enable/Disable + COLUMN_ACCOUNT_ACTIVE, (utf8_case_cmp(g_hash_table_lookup(a->properties, ACCOUNT_ENABLED),"true") == 0) ? TRUE:FALSE, // Enable/Disable COLUMN_ACCOUNT_DATA, a, // Pointer -1); @@ -150,7 +152,7 @@ void account_list_config_dialog_fill() COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup(a->properties, ACCOUNT_ALIAS), // Name COLUMN_ACCOUNT_TYPE, g_hash_table_lookup(a->properties, ACCOUNT_TYPE), // Protocol COLUMN_ACCOUNT_STATUS, account_state_name(a->state), // Status - COLUMN_ACCOUNT_ACTIVE, (g_strcasecmp(g_hash_table_lookup(a->properties, ACCOUNT_ENABLED),"true") == 0) ? TRUE:FALSE, // Enable/Disable + COLUMN_ACCOUNT_ACTIVE, (utf8_case_cmp(g_hash_table_lookup(a->properties, ACCOUNT_ENABLED),"true") == 0) ? TRUE:FALSE, // Enable/Disable COLUMN_ACCOUNT_DATA, a, // Pointer -1); } @@ -187,7 +189,7 @@ select_account_cb(GtkTreeSelection *selection, GtkTreeModel *model) if (selectedAccount != NULL) { gtk_widget_set_sensitive(GTK_WIDGET(editButton), TRUE); - if (g_strcasecmp(selectedAccount->accountID, IP2IP) != 0) { + if (utf8_case_cmp(selectedAccount->accountID, IP2IP) != 0) { gtk_widget_set_sensitive(GTK_WIDGET(accountMoveUpButton), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(accountMoveDownButton), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(deleteButton), TRUE); @@ -237,7 +239,7 @@ static void enable_account_cb(GtkCellRendererToggle *rend UNUSED, gchar* path, account_t* acc ; // The IP2IP profile can't be disabled - if (g_strcasecmp(path, "0") == 0) + if (utf8_case_cmp(path, "0") == 0) return; // Get pointer on object @@ -299,7 +301,7 @@ static void account_move(gboolean moveUp, gpointer data) // The first real account in the list can't move up because of the IP2IP account // It can still move down though - if (g_strcasecmp(path, "1") == 0 && moveUp) + if (utf8_case_cmp(path, "1") == 0 && moveUp) return; treePath = gtk_tree_path_new_from_string(path); @@ -394,7 +396,7 @@ void highlight_ip_profile(GtkTreeViewColumn *col UNUSED, GtkCellRenderer *rend, if (current != NULL) { // Make the first line appear differently - (g_strcasecmp(current->accountID, IP2IP) == 0) ? g_object_set(G_OBJECT(rend), "weight", PANGO_WEIGHT_THIN, + (utf8_case_cmp(current->accountID, IP2IP) == 0) ? g_object_set(G_OBJECT(rend), "weight", PANGO_WEIGHT_THIN, "style", PANGO_STYLE_ITALIC, "stretch", PANGO_STRETCH_ULTRA_EXPANDED, "scale", 0.95, @@ -420,7 +422,7 @@ void highlight_registration(GtkTreeViewColumn *col UNUSED, GtkCellRenderer *rend g_value_unset(&val); if (current != NULL) { - if (g_strcasecmp(current->accountID, IP2IP) != 0) { + if (utf8_case_cmp(current->accountID, IP2IP) != 0) { // Color the account state: green -> registered, otherwise red (current->state == ACCOUNT_STATE_REGISTERED) ? g_object_set(G_OBJECT(rend), "foreground", "Dark Green", NULL) : g_object_set(G_OBJECT(rend), "foreground", "Dark Red", NULL); @@ -579,6 +581,7 @@ show_account_list_config_dialog(void) accountListDialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Accounts"), GTK_WINDOW(get_main_window()), GTK_DIALOG_DESTROY_WITH_PARENT, + NULL, NULL)); /* Set window properties */ diff --git a/gnome/src/config/addressbook-config.c b/gnome/src/config/addressbook-config.c index 4c56da203677369e5e7f14d7d8c4be75d7b89b60..fd12fc8672196ab13d9fcd1318ae7f60cf3c1e3b 100644 --- a/gnome/src/config/addressbook-config.c +++ b/gnome/src/config/addressbook-config.c @@ -29,11 +29,13 @@ */ #include "addressbook-config.h" +#include "str_utils.h" #include "dbus.h" #include "unused.h" #include "logger.h" #include "searchbar.h" #include "contacts/addrbookfactory.h" +#include <glib/gi18n.h> #include <string.h> #include <stdlib.h> @@ -442,13 +444,13 @@ addressbook_display(AddressBook_Config *settings, const gchar *field) { gboolean display; - if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO) == 0) + if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO) == 0) display = (settings->display_contact_photo == 1) ? TRUE : FALSE; - else if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS) == 0) + else if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS) == 0) display = (settings->search_phone_business == 1) ? TRUE : FALSE; - else if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_PHONE_HOME) == 0) + else if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_PHONE_HOME) == 0) display = (settings->search_phone_home == 1) ? TRUE : FALSE; - else if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_PHONE_MOBILE) == 0) + else if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_PHONE_MOBILE) == 0) display = (settings->search_phone_mobile == 1) ? TRUE : FALSE; else display = FALSE; diff --git a/gnome/src/config/addressbook-config.h b/gnome/src/config/addressbook-config.h index cb102604eeb80fd1b9914e24362ef05f4bcc3ec5..cd7a9ac7bc0b0ca120d20ccc8f2731ce6c177748 100644 --- a/gnome/src/config/addressbook-config.h +++ b/gnome/src/config/addressbook-config.h @@ -32,7 +32,7 @@ #define _ADDRESS_BOOK_CONFIG #include <gtk/gtk.h> -#include <glib/gtypes.h> +#include <glib.h> #include "addressbook.h" #include "actions.h" diff --git a/gnome/src/config/assistant.c b/gnome/src/config/assistant.c index 8ca002115543ba01327688b250497f8344797bff..202767eb2494e390f4ed84f0c633d37945073300 100644 --- a/gnome/src/config/assistant.c +++ b/gnome/src/config/assistant.c @@ -29,7 +29,7 @@ */ #include <string.h> - +#include <glib/gi18n.h> #include "unused.h" #include "assistant.h" #include "logger.h" diff --git a/gnome/src/config/audioconf.c b/gnome/src/config/audioconf.c index c7dfe388ea0d7c616a0f1a0cd116666765380016..3f69218bb19dbfba1fdfea23776869d1f0052b3d 100644 --- a/gnome/src/config/audioconf.c +++ b/gnome/src/config/audioconf.c @@ -28,7 +28,8 @@ * as that of the covered work. */ - +#include <glib/gi18n.h> +#include "str_utils.h" #include "audioconf.h" #include "utils.h" #include "logger.h" @@ -271,7 +272,7 @@ select_active_input_audio_device() void update_device_widget(gchar *pluginName) { - if (g_strcasecmp(pluginName, "default") == 0) { + if (utf8_case_cmp(pluginName, "default") == 0) { gtk_widget_set_sensitive(output, FALSE); gtk_widget_set_sensitive(input, FALSE); gtk_widget_set_sensitive(ringtone, FALSE); @@ -314,7 +315,7 @@ select_active_output_audio_plugin() do { gtk_tree_model_get(model, &iter, 0, &pluginname, -1); - if (g_strcasecmp(tmp, pluginname) == 0) { + if (utf8_case_cmp(tmp, pluginname) == 0) { // Set current iteration the active one gtk_combo_box_set_active_iter(GTK_COMBO_BOX(plugin), &iter); return; @@ -421,11 +422,11 @@ codec_active_toggled(GtkCellRendererToggle *renderer UNUSED, gchar *path, gpoint codec_t* codec; - if ((g_strcasecmp(name,"speex") == 0) && (g_strcasecmp(srate,"8 kHz") == 0)) + if ((utf8_case_cmp(name,"speex") == 0) && (utf8_case_cmp(srate,"8 kHz") == 0)) codec = codec_list_get_by_payload((gconstpointer) 110, acc->codecs); - else if ((g_strcasecmp(name,"speex") ==0) && (g_strcasecmp(srate,"16 kHz") ==0)) + else if ((utf8_case_cmp(name,"speex") ==0) && (utf8_case_cmp(srate,"16 kHz") ==0)) codec = codec_list_get_by_payload((gconstpointer) 111, acc->codecs); - else if ((g_strcasecmp(name,"speex") ==0) && (g_strcasecmp(srate,"32 kHz") ==0)) + else if ((utf8_case_cmp(name,"speex") ==0) && (utf8_case_cmp(srate,"32 kHz") ==0)) codec = codec_list_get_by_payload((gconstpointer) 112, acc->codecs); else codec = codec_list_get_by_name((gconstpointer) name, acc->codecs); diff --git a/gnome/src/config/hooks-config.c b/gnome/src/config/hooks-config.c index 2b3e9e882cb9c9cb7de77567699b5008eb764aa4..5a161344ac29d414e0b4fb593b12ed6600de1b29 100644 --- a/gnome/src/config/hooks-config.c +++ b/gnome/src/config/hooks-config.c @@ -28,6 +28,8 @@ * as that of the covered work. */ +#include <glib/gi18n.h> +#include "str_utils.h" #include "hooks-config.h" #include "dbus.h" @@ -155,7 +157,7 @@ GtkWidget* create_hooks_settings() gtk_table_attach(GTK_TABLE(table), info_bar, 0, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 10, 10); widg = gtk_check_button_new_with_mnemonic(_("Trigger on specific _SIP header")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (g_strcasecmp(_urlhook_config->sip_enabled, "true") ==0) ?TRUE:FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (utf8_case_cmp(_urlhook_config->sip_enabled, "true") ==0) ?TRUE:FALSE); g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(sip_enabled_cb), NULL); gtk_table_attach(GTK_TABLE(table), widg, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -164,7 +166,7 @@ GtkWidget* create_hooks_settings() gtk_table_attach(GTK_TABLE(table), field, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); widg = gtk_check_button_new_with_mnemonic(_("Trigger on _IAX2 URL")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (g_strcasecmp(_urlhook_config->iax2_enabled, "true") ==0) ?TRUE:FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (utf8_case_cmp(_urlhook_config->iax2_enabled, "true") ==0) ?TRUE:FALSE); g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(iax2_enabled_cb), NULL); gtk_table_attach(GTK_TABLE(table), widg, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -176,14 +178,12 @@ GtkWidget* create_hooks_settings() gtk_entry_set_text(GTK_ENTRY(command), _urlhook_config->command); gtk_table_attach(GTK_TABLE(table), command, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 10); - - gnome_main_section_new_with_table(_("Phone number rewriting"), &frame, &table, 4, 2); gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); gtk_widget_show(frame); widg = gtk_check_button_new_with_mnemonic(_("_Prefix dialed numbers with")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (g_strcasecmp(_urlhook_config->phone_number_enabled, "true") ==0) ?TRUE:FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (utf8_case_cmp(_urlhook_config->phone_number_enabled, "true") ==0) ?TRUE:FALSE); g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(phone_number_enabled_cb), NULL); gtk_table_attach(GTK_TABLE(table), widg, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); diff --git a/gnome/src/config/hooks-config.h b/gnome/src/config/hooks-config.h index 6f51be9249afb8b37306ebc315209d419daef85b..e35a5b9f203aa7f5ec2a1e90ea5ee755e2ac136f 100644 --- a/gnome/src/config/hooks-config.h +++ b/gnome/src/config/hooks-config.h @@ -32,7 +32,7 @@ #define _HOOKS_CONFIG #include <gtk/gtk.h> -#include <glib/gtypes.h> +#include <glib.h> #include "actions.h" #include "utils.h" diff --git a/gnome/src/config/preferencesdialog.c b/gnome/src/config/preferencesdialog.c index 3bd50579130952f4b00f007b497ca63b3c44145a..87c114ac4367897b51335326a97d71994fb51197 100644 --- a/gnome/src/config/preferencesdialog.c +++ b/gnome/src/config/preferencesdialog.c @@ -32,6 +32,7 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include <gtk/gtk.h> #include <stdlib.h> #include <stdio.h> @@ -362,7 +363,7 @@ static GtkTreeModel* create_model(GtkWidget *widget) PAGE_NUMBER, browser_entries_full[i].page_number, -1); if (pixbuf) - gdk_pixbuf_unref(pixbuf); + g_object_unref(pixbuf); } return GTK_TREE_MODEL(store); diff --git a/gnome/src/config/shortcuts-config.c b/gnome/src/config/shortcuts-config.c index caa354a22c2030d920c88ed846d61bc9a321ff08..4c8365dff85cd31feecc6d7fb65bcf6a296d8c2f 100644 --- a/gnome/src/config/shortcuts-config.c +++ b/gnome/src/config/shortcuts-config.c @@ -28,7 +28,9 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include <gdk/gdk.h> +#include <X11/XKBlib.h> #include "shortcuts-config.h" #include "shortcuts.h" #include "unused.h" @@ -129,7 +131,7 @@ create_shortcuts_settings() gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, ACTION, _(list[i].action), MASK, (gint) list[i].mask, VALUE, - XKeycodeToKeysym(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), list[i].key, 0), -1); + XkbKeycodeToKeysym(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), list[i].key, 0, 0), -1); } gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store)); diff --git a/gnome/src/config/shortcuts-config.h b/gnome/src/config/shortcuts-config.h index abcb424201bdd7f0a568744508acbe3bf0bfc962..123cb9c743a12693eb2ce1e0a39af7f722c4131e 100644 --- a/gnome/src/config/shortcuts-config.h +++ b/gnome/src/config/shortcuts-config.h @@ -32,7 +32,7 @@ #define _SHORTCUTS_CONFIG #include <gtk/gtk.h> -#include <glib/gtypes.h> +#include <glib.h> #include "actions.h" #include <utils.h> diff --git a/gnome/src/config/tlsadvanceddialog.c b/gnome/src/config/tlsadvanceddialog.c index 3d6c11860099d0647afb3b88f35b97dc07e37d99..232c3a8d8938483cc8080ebb03828d792cb5f1eb 100644 --- a/gnome/src/config/tlsadvanceddialog.c +++ b/gnome/src/config/tlsadvanceddialog.c @@ -28,11 +28,12 @@ * as that of the covered work. */ -#include <tlsadvanceddialog.h> -#include <sflphone_const.h> -#include <utils.h> +#include "tlsadvanceddialog.h" +#include "str_utils.h" +#include "sflphone_const.h" +#include "utils.h" #include <dbus.h> - +#include <glib/gi18n.h> #include <gtk/gtk.h> #include <math.h> @@ -237,7 +238,7 @@ void show_advanced_tls_options(GHashTable * properties) GtkWidget * tlsTimeOutSec; hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 10, 11, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - tlsTimeOutSec = gtk_spin_button_new_with_range(0, pow(2,sizeof(long)), 1); + tlsTimeOutSec = gtk_spin_button_new_with_range(0, pow(2, sizeof(long)), 1); gtk_label_set_mnemonic_widget(GTK_LABEL(label), tlsTimeOutSec); gtk_spin_button_set_value(GTK_SPIN_BUTTON(tlsTimeOutSec), g_ascii_strtod(negotiation_timeout_sec, NULL)); gtk_box_pack_start(GTK_BOX(hbox), tlsTimeOutSec, TRUE, TRUE, 0); @@ -250,19 +251,19 @@ void show_advanced_tls_options(GHashTable * properties) GtkWidget * verifyCertificateServer; verifyCertificateServer = gtk_check_button_new_with_mnemonic(_("Verify incoming certificates, as a server")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(verifyCertificateServer), - g_strcasecmp(verify_server,"true") == 0 ? TRUE: FALSE); + utf8_case_cmp(verify_server,"true") == 0); gtk_table_attach(GTK_TABLE(table), verifyCertificateServer, 0, 1, 11, 12, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * verifyCertificateClient; verifyCertificateClient = gtk_check_button_new_with_mnemonic(_("Verify certificates from answer, as a client")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(verifyCertificateClient), - g_strcasecmp(verify_client,"true") == 0 ? TRUE: FALSE); + utf8_case_cmp(verify_client,"true") == 0); gtk_table_attach(GTK_TABLE(table), verifyCertificateClient, 0, 1, 12, 13, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * requireCertificate; requireCertificate = gtk_check_button_new_with_mnemonic(_("Require certificate for incoming tls connections")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(requireCertificate), - g_strcasecmp(require_client_certificate,"true") == 0 ? TRUE: FALSE); + utf8_case_cmp(require_client_certificate,"true") == 0); gtk_table_attach(GTK_TABLE(table), requireCertificate, 0, 1, 13, 14, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show_all(ret); diff --git a/gnome/src/config/zrtpadvanceddialog.c b/gnome/src/config/zrtpadvanceddialog.c index e50898a7be8b2b3bd5edd21ddfa1d9a866ef1636..efb80d976356707b01d34d83fe143c9a1792b761 100644 --- a/gnome/src/config/zrtpadvanceddialog.c +++ b/gnome/src/config/zrtpadvanceddialog.c @@ -28,11 +28,12 @@ * as that of the covered work. */ -#include <zrtpadvanceddialog.h> -#include <sflphone_const.h> -#include <utils.h> - +#include <glib/gi18n.h> #include <gtk/gtk.h> +#include "str_utils.h" +#include <zrtpadvanceddialog.h> +#include "sflphone_const.h" +#include "utils.h" void show_advanced_zrtp_options(GHashTable * properties) { @@ -42,10 +43,10 @@ void show_advanced_zrtp_options(GHashTable * properties) gboolean curDisplaySasOnce = FALSE; if (properties != NULL) { - curHelloEnabled = !g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_HELLO_HASH), "true"); - curSasConfirm = !g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS), "true"); - curZrtpNotSuppOther = !g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_NOT_SUPP_WARNING), "true"); - curDisplaySasOnce = !g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_DISPLAY_SAS_ONCE), "true"); + curHelloEnabled = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_HELLO_HASH), "true"); + curSasConfirm = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS), "true"); + curZrtpNotSuppOther = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_NOT_SUPP_WARNING), "true"); + curDisplaySasOnce = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_DISPLAY_SAS_ONCE), "true"); } GtkDialog *securityDialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("ZRTP Options"), @@ -118,7 +119,7 @@ void show_advanced_sdes_options(GHashTable * properties) gboolean rtpFallback = FALSE; if (properties != NULL) { - rtpFallback = !g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_SRTP_RTP_FALLBACK), "true"); + rtpFallback = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_SRTP_RTP_FALLBACK), "true"); } GtkDialog *securityDialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("SDES Options"), diff --git a/gnome/src/contacts/calllist.c b/gnome/src/contacts/calllist.c index 4cc64dbf3875e006cacfe56a41f72ab283245150..3c00fa83bdbdff3d05b035a1ae3694718c5f9aee 100644 --- a/gnome/src/contacts/calllist.c +++ b/gnome/src/contacts/calllist.c @@ -29,6 +29,7 @@ */ #include "calllist.h" +#include "str_utils.h" #include <string.h> #include "calltab.h" #include "calltree.h" @@ -44,7 +45,7 @@ gint is_callID_callstruct(gconstpointer a, gconstpointer b) if (c == NULL || c->type != HIST_CALL) return 1; - return g_strcasecmp(c->elem.call->_callID, (const gchar *) b); + return utf8_case_cmp(c->elem.call->_callID, (const gchar *) b); } // TODO : try to do this more generically diff --git a/gnome/src/contacts/calltab.c b/gnome/src/contacts/calltab.c index fcf0d85009f6333cddaeef6884bf57bb991c2def..7ff8c1ccc55d40b487c31cfbadb6c90db0458201 100644 --- a/gnome/src/contacts/calltab.c +++ b/gnome/src/contacts/calltab.c @@ -31,6 +31,7 @@ #include "calltab.h" #include <gtk/gtk.h> #include <stdlib.h> +#include "str_utils.h" #include "calltree.h" #include "contacts/searchbar.h" #include "logger.h" @@ -97,9 +98,9 @@ calltab_create_searchbar(calltab_t* tab) { g_assert(tab); - if (g_strcasecmp(tab->_name, HISTORY) == 0) + if (utf8_case_cmp(tab->_name, HISTORY) == 0) tab->searchbar = history_searchbar_new(); - else if (g_strcasecmp(tab->_name, CONTACTS) == 0) + else if (utf8_case_cmp(tab->_name, CONTACTS) == 0) tab->searchbar = contacts_searchbar_new(); else ERROR("Current calls tab does not need a searchbar\n"); diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c index ce92c7b9de6b76ee8a7c457654774f9e688b3017..87521d6ca73641d0a080c7fb1f96633f67450b69 100644 --- a/gnome/src/contacts/calltree.c +++ b/gnome/src/contacts/calltree.c @@ -32,6 +32,8 @@ #include "calllist.h" #include "calltree.h" +#include "str_utils.h" +#include <string.h> #include <stdlib.h> #include "eel-gconf-extensions.h" @@ -290,7 +292,7 @@ row_single_click(GtkTreeView *tree_view UNUSED, void * data UNUSED) case SRTP_STATE_ZRTP_SAS_UNCONFIRMED: selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_CONFIRMED; - if (g_strcasecmp(displaySasOnce, "true") == 0) + if (utf8_case_cmp(displaySasOnce, "true") == 0) selectedCall->_zrtp_confirmed = TRUE; dbus_confirm_sas(selectedCall); @@ -603,7 +605,7 @@ calltree_update_call_recursive(calltab_t* tab, callable_obj_t * c, GtkTreeIter * if (account_details != NULL) { srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); - if (g_strcasecmp(g_hash_table_lookup(account_details->properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) + if (utf8_case_cmp(g_hash_table_lookup(account_details->properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) display_sas = FALSE; } else { GHashTable * properties = sflphone_get_ip2ip_properties(); @@ -611,7 +613,7 @@ calltree_update_call_recursive(calltab_t* tab, callable_obj_t * c, GtkTreeIter * if (properties != NULL) { srtp_enabled = g_hash_table_lookup(properties, ACCOUNT_SRTP_ENABLED); - if (g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) + if (utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) display_sas = FALSE; } } @@ -697,12 +699,12 @@ calltree_update_call_recursive(calltab_t* tab, callable_obj_t * c, GtkTreeIter * pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_certified.svg", NULL); break; case SRTP_STATE_UNLOCKED: - if (g_strcasecmp(srtp_enabled,"true") == 0) + if (utf8_case_cmp(srtp_enabled,"true") == 0) pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); break; default: WARN("Update calltree srtp state #%d- Should not happen!", c->_srtp_state); - if (g_strcasecmp(srtp_enabled, "true") == 0) + if (utf8_case_cmp(srtp_enabled, "true") == 0) pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); } @@ -810,7 +812,7 @@ void calltree_add_call(calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) WARN("Update calltree add - Should not happen!"); } - if (srtp_enabled && g_strcasecmp(srtp_enabled, "true") == 0) + if (srtp_enabled && utf8_case_cmp(srtp_enabled, "true") == 0) pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/secure_off.svg", NULL); } else if (tab == contacts_tab) @@ -971,7 +973,7 @@ void calltree_add_conference_to_current_calls(conference_obj_t* conf) else srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); - if (g_strcasecmp(srtp_enabled, "true") == 0) { + if (utf8_case_cmp(srtp_enabled, "true") == 0) { DEBUG("Calltree: SRTP enabled for participant %s", call_id); conf->_conf_srtp_enabled = TRUE; break; diff --git a/gnome/src/contacts/conferencelist.c b/gnome/src/contacts/conferencelist.c index 3d4c68f8e1f04fbc347f7653fb0e4422e39dce31..a293b268c1452b97ce8e4f550ce8465c4ddeb8a8 100644 --- a/gnome/src/contacts/conferencelist.c +++ b/gnome/src/contacts/conferencelist.c @@ -29,6 +29,7 @@ */ #include "calltab.h" +#include "str_utils.h" #include "callable_obj.h" #include "calltree.h" #include "conferencelist.h" @@ -37,7 +38,7 @@ static gint is_confID_confstruct(gconstpointer a, gconstpointer b) { conference_obj_t * c = (conference_obj_t*) a; - return g_strcasecmp(c->_confID, (const gchar*) b); + return utf8_case_cmp(c->_confID, (const gchar*) b); } void conferencelist_init(calltab_t *tab) diff --git a/gnome/src/contacts/searchbar.c b/gnome/src/contacts/searchbar.c index e48efafbc3a67d32932bc230df4de868c34de642..1ac515b24649874904f06ebb2582ecbc396d04ff 100644 --- a/gnome/src/contacts/searchbar.c +++ b/gnome/src/contacts/searchbar.c @@ -31,6 +31,7 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include "searchbar.h" #include "calltree.h" #include "calltab.h" diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c index 91241f55d2c2a51a3437c9d122c1d54ec21d7268..7559cd4cf70df2e042e0406dbeddf15d36b615d9 100644 --- a/gnome/src/dbus/dbus.c +++ b/gnome/src/dbus/dbus.c @@ -30,7 +30,8 @@ * as that of the covered work. */ #include "config.h" - +#include <glib/gi18n.h> +#include "str_utils.h" #include "logger.h" #include "calltab.h" #include "callmanager-glue.h" @@ -237,7 +238,7 @@ process_nonexisting_call_state_change(const gchar *callID, const gchar *state) GHashTable *call_details = dbus_get_call_details(callID); callable_obj_t *new_call = create_new_call_from_details(callID, call_details); - if (g_strcasecmp(g_hash_table_lookup(call_details, "CALL_TYPE"), INCOMING_STRING) == 0) + if (utf8_case_cmp(g_hash_table_lookup(call_details, "CALL_TYPE"), INCOMING_STRING) == 0) new_call->_history_state = g_strdup(INCOMING_STRING); else new_call->_history_state = g_strdup(OUTGOING_STRING); diff --git a/gnome/src/eel-gconf-extensions.c b/gnome/src/eel-gconf-extensions.c index c1947f24ae8ad3a10529d974a2dbc19e393dc7f7..99be9287350befeb8d8cf2b89aedcebcb6a04bbd 100644 --- a/gnome/src/eel-gconf-extensions.c +++ b/gnome/src/eel-gconf-extensions.c @@ -22,23 +22,22 @@ Authors: Ramiro Estrugo <ramiro@eazel.com> */ -#include <stdlib.h> #include "config.h" +#include <glib/gi18n.h> +#include <stdlib.h> #include "eel-gconf-extensions.h" #include <gconf/gconf-client.h> #include <gconf/gconf.h> #include <gtk/gtk.h> -#include <glib/gi18n.h> +#include <glib.h> static GConfClient *global_gconf_client = NULL; -static void -global_client_free(void) +void eel_gconf_global_client_free(void) { - if (global_gconf_client == NULL) { + if (global_gconf_client == NULL) return; - } g_object_unref(G_OBJECT(global_gconf_client)); global_gconf_client = NULL; @@ -81,10 +80,8 @@ eel_gconf_client_get_global(void) } - if (global_gconf_client == NULL) { + if (global_gconf_client == NULL) global_gconf_client = gconf_client_get_default(); - g_atexit(global_client_free); - } return global_gconf_client; } diff --git a/gnome/src/eel-gconf-extensions.h b/gnome/src/eel-gconf-extensions.h index 0068b15b2f4bf6b35a5f426685c3b67cba5bf12b..e9139477759e3388c84881688bf62edbca1b0001 100644 --- a/gnome/src/eel-gconf-extensions.h +++ b/gnome/src/eel-gconf-extensions.h @@ -25,7 +25,7 @@ #ifndef EEL_GCONF_EXTENSIONS_H #define EEL_GCONF_EXTENSIONS_H -#include <glib/gerror.h> +#include <glib.h> #include <gconf/gconf.h> #include <gconf/gconf-client.h> @@ -57,54 +57,52 @@ BEGIN_EXTERN_C #define EEL_GCONF_UNDEFINED_CONNECTION 0 -GConfClient *eel_gconf_client_get_global (void); -gboolean eel_gconf_handle_error (GError **error); -void eel_gconf_set_boolean (const char *key, - gboolean boolean_value); -gboolean eel_gconf_get_boolean (const char *key); -int eel_gconf_get_integer (const char *key); -void eel_gconf_set_integer (const char *key, - int int_value); -gfloat eel_gconf_get_float (const char *key); -void eel_gconf_set_float (const char *key, - gfloat float_value); -char * eel_gconf_get_string (const char *key); -void eel_gconf_set_string (const char *key, - const char *string_value); -GSList * eel_gconf_get_string_list (const char *key); -void eel_gconf_set_string_list (const char *key, - const GSList *string_list_value); -gboolean eel_gconf_is_default (const char *key); -gboolean eel_gconf_monitor_add (const char *directory); -gboolean eel_gconf_monitor_remove (const char *directory); -void eel_gconf_suggest_sync (void); -GConfValue* eel_gconf_get_value (const char *key); -gboolean eel_gconf_value_is_equal (const GConfValue *a, - const GConfValue *b); -void eel_gconf_set_value (const char *key, - const GConfValue *value); -gboolean eel_gconf_key_exists (const char *key); - -void eel_gconf_value_free (GConfValue *value); -void eel_gconf_unset (const char *key); +GConfClient *eel_gconf_client_get_global(void); + +void eel_gconf_global_client_free(void); + +gboolean eel_gconf_handle_error(GError **error); + +void eel_gconf_set_boolean(const gchar *key, gboolean boolean_value); + +gboolean eel_gconf_get_boolean(const gchar *key); + +int eel_gconf_get_integer(const gchar *key); + +void eel_gconf_set_integer(const gchar *key, gint value); + +gfloat eel_gconf_get_float(const gchar *key); + +void eel_gconf_set_float(const gchar *key, gfloat value); + +gchar *eel_gconf_get_string(const gchar *key); +void eel_gconf_set_string(const gchar *key, const gchar *value); +GSList *eel_gconf_get_string_list (const gchar *key); +void eel_gconf_set_string_list(const gchar *key, const GSList *value); +gboolean eel_gconf_is_default(const gchar *key); +gboolean eel_gconf_monitor_add(const gchar *directory); +gboolean eel_gconf_monitor_remove(const gchar *directory); +void eel_gconf_suggest_sync(void); +GConfValue *eel_gconf_get_value(const gchar *key); +gboolean eel_gconf_value_is_equal(const GConfValue *a, const GConfValue *b); +void eel_gconf_set_value (const gchar *key, const GConfValue *value); +gboolean eel_gconf_key_exists(const gchar *key); +void eel_gconf_value_free(GConfValue *value); +void eel_gconf_unset(const gchar *key); /* Functions which weren't part of the eel-gconf-extensions.h file from eel */ -GSList *eel_gconf_get_integer_list (const char *key); -void eel_gconf_set_integer_list (const char *key, - const GSList *slist); -void gpdf_notification_add (const char *key, - GConfClientNotifyFunc notification_callback, - gpointer callback_data, - GList **notifiers); -void gpdf_notification_remove (GList **notifiers); -guint eel_gconf_notification_add (const char *key, - GConfClientNotifyFunc notification_callback, - gpointer callback_data); -void eel_gconf_notification_remove (guint notification_id); +GSList *eel_gconf_get_integer_list(const gchar *key); +void eel_gconf_set_integer_list(const gchar *key, const GSList *slist); +void gpdf_notification_add(const gchar *key, GConfClientNotifyFunc notification_callback, + gpointer callback_data, GList **notifiers); +void gpdf_notification_remove(GList **notifiers); +guint eel_gconf_notification_add(const gchar *key, + GConfClientNotifyFunc notification_callback, + gpointer callback_data); +void eel_gconf_notification_remove(guint notification_id); #ifdef __cplusplus END_EXTERN_C #endif #endif /* EEL_GCONF_EXTENSIONS_H */ - diff --git a/gnome/src/main.c b/gnome/src/main.c index 7af50785b836d7f47a8f76828101f664a59b6296..8590e276f6f648721bd0e316c65d7e34fd9c1a84 100644 --- a/gnome/src/main.c +++ b/gnome/src/main.c @@ -36,6 +36,7 @@ #include "mainwindow.h" #include "statusicon.h" #include "eel-gconf-extensions.h" +#include <glib/gi18n.h> #include <gtk/gtk.h> #include <stdlib.h> @@ -64,7 +65,7 @@ main(int argc, char *argv[]) gtk_init(&argc, &argv); g_print("%s %s\n", PACKAGE, VERSION); - g_print("\nCopyright (c) 2005 - 2011 Savoir-faire Linux Inc.\n\n"); + g_print("\nCopyright (c) 2005 - 2012 Savoir-faire Linux Inc.\n\n"); g_print("This is free software. You may redistribute copies of it under the terms of\n" \ "the GNU General Public License Version 3 <http://www.gnu.org/licenses/gpl.html>.\n" \ "There is NO WARRANTY, to the extent permitted by law.\n\n" \ @@ -128,6 +129,7 @@ main(int argc, char *argv[]) shortcuts_destroy_bindings(); + eel_gconf_global_client_free(); OUT: #if !GTK_CHECK_VERSION(2,32,0) gdk_threads_leave(); diff --git a/gnome/src/mainwindow.c b/gnome/src/mainwindow.c index 3b14c6a35538f03c1f04569fd67e6bfd01a1f2c4..ce8d3b8140d6807af5bccca9f8029777eec3279b 100644 --- a/gnome/src/mainwindow.c +++ b/gnome/src/mainwindow.c @@ -31,6 +31,7 @@ */ #include "config.h" +#include "str_utils.h" #include "actions.h" #include "dbus.h" #include "calltree.h" @@ -47,9 +48,11 @@ #include "uimanager.h" #include "unused.h" #include "config/audioconf.h" +#include "str_utils.h" #include "eel-gconf-extensions.h" +#include <glib/gi18n.h> #include <sys/stat.h> #include <gtk/gtk.h> @@ -414,7 +417,7 @@ main_window_zrtp_not_supported(callable_obj_t * c) ACCOUNT_ZRTP_NOT_SUPP_WARNING); } - if (g_strcasecmp(warning_enabled, "true") == 0) { + if (utf8_case_cmp(warning_enabled, "true") == 0) { PidginMiniDialog *mini_dialog; gchar *desc = g_markup_printf_escaped( _("ZRTP is not supported by peer %s\n"), c->_peer_number); diff --git a/gnome/src/sflnotify.c b/gnome/src/sflnotify.c index 8dd5ed0f0fdb58e1d57cb23f02ca5ab41776e1bc..773946eb06d8efb8277905de9b364bacad6cbbc4 100644 --- a/gnome/src/sflnotify.c +++ b/gnome/src/sflnotify.c @@ -29,6 +29,9 @@ */ #include "config.h" +#include <glib.h> +#include <glib/gi18n.h> +#include "str_utils.h" #include "eel-gconf-extensions.h" #include "sflnotify.h" #include "logger.h" @@ -87,7 +90,7 @@ notify_incoming_message(const gchar *callID, const gchar *msg) create_new_gnome_notification(title, (gchar *)msg, NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -110,7 +113,7 @@ notify_incoming_call(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -182,7 +185,7 @@ notify_secure_on(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -195,7 +198,7 @@ notify_zrtp_not_supported(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -208,7 +211,7 @@ notify_zrtp_negotiation_failed(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -221,6 +224,6 @@ notify_secure_off(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } diff --git a/gnome/src/sflphone_const.h b/gnome/src/sflphone_const.h index 3766562a008cfa4fe6d2534ffd97808d42f5d5de..e642e0ae8ee5eb102e6bb803e38cd78a09f3e8b7 100644 --- a/gnome/src/sflphone_const.h +++ b/gnome/src/sflphone_const.h @@ -32,7 +32,7 @@ #define __SFLPHONE_CONST_H #include <libintl.h> -#include <glib/gi18n.h> +#include <glib.h> /* @file sflphone_const.h * @brief Contains the global variables for the client code diff --git a/gnome/src/sliders.c b/gnome/src/sliders.c index 4a2fdd805a435b34a46b6074c9d4d5ed934dd246..ab3e40f02c69fde3f7620717cb13cb770a0e7f4b 100644 --- a/gnome/src/sliders.c +++ b/gnome/src/sliders.c @@ -28,6 +28,7 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include "sliders.h" #include "dbus/dbus.h" #include "actions.h" diff --git a/gnome/src/statusicon.c b/gnome/src/statusicon.c index 2fe79ee9b61e5735d3aaf8f655dede4448c16107..b94864c3f0e73f97bac5d72f7e11ad25b683745e 100644 --- a/gnome/src/statusicon.c +++ b/gnome/src/statusicon.c @@ -29,6 +29,7 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include <gtk/gtk.h> #include "actions.h" #include "mainwindow.h" diff --git a/gnome/src/str_utils.c b/gnome/src/str_utils.c new file mode 100644 index 0000000000000000000000000000000000000000..9e395c1efb74a5e8324059e3424b34ce51a0a456 --- /dev/null +++ b/gnome/src/str_utils.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. + * Author: Tristan Matthews <tristan.matthews@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. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#include "str_utils.h" + +gint utf8_case_cmp(const gchar *a, const gchar *b) +{ + gchar *l = g_utf8_casefold(a, -1); + gchar *r = g_utf8_casefold(b, -1); + gint result = g_utf8_collate(l, r); + g_free(l); + g_free(r); + return result; +} diff --git a/gnome/src/str_utils.h b/gnome/src/str_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..b2b4bddb56655337552f51e17ce454fff7ea2245 --- /dev/null +++ b/gnome/src/str_utils.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. + * Author: Tristan Matthews <tristan.matthews@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. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#ifndef STR_UTILS_H_ +#define STR_UTILS_H_ + +#include <glib.h> + +gint utf8_case_cmp(const gchar *a, const gchar *b); + +#endif /* STR_UTILS_H_ */ diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c index 36eb62343c95d7286bdb517bbd599a2661d06c66..04ee1f5d369b77f8a771135306f4805cad15da72 100644 --- a/gnome/src/uimanager.c +++ b/gnome/src/uimanager.c @@ -29,14 +29,16 @@ */ #include "config.h" +#include "str_utils.h" #include "preferencesdialog.h" #include "logger.h" #include "dbus/dbus.h" #include "mainwindow.h" #include "assistant.h" +#include <glib.h> +#include <glib/gi18n.h> #include <gtk/gtk.h> #include <string.h> -#include <glib/gprintf.h> #include "uimanager.h" #include "statusicon.h" @@ -1235,7 +1237,7 @@ add_registered_accounts_to_menu(GtkWidget *menu) account_t *acc = account_list_get_nth(i); // Display only the registered accounts - if (g_strcasecmp(account_state_name(acc->state), account_state_name( + if (utf8_case_cmp(account_state_name(acc->state), account_state_name( ACCOUNT_STATE_REGISTERED)) == 0) { gchar *alias = g_strconcat(g_hash_table_lookup(acc->properties, ACCOUNT_ALIAS), " - ", @@ -1249,7 +1251,7 @@ add_registered_accounts_to_menu(GtkWidget *menu) if (current) { gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items), - g_strcasecmp(acc->accountID, current->accountID) == 0); + utf8_case_cmp(acc->accountID, current->accountID) == 0); } g_signal_connect(G_OBJECT(menu_items), "activate", diff --git a/gnome/src/widget/imwidget.c b/gnome/src/widget/imwidget.c index ec7a686168c73a77f42542a29dd244477bf253b1..130510e3af2d65c647715a813ac1d5d3086b0b8a 100644 --- a/gnome/src/widget/imwidget.c +++ b/gnome/src/widget/imwidget.c @@ -35,6 +35,7 @@ #include "icons/icon_factory.h" #include "contacts/calltab.h" #include "contacts/conferencelist.h" +#include <string.h> #include <JavaScriptCore/JavaScript.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> diff --git a/gnome/tests/Makefile.am b/gnome/tests/Makefile.am index fe5a5190ce90d15fd481aff0f6a9bc365c6fb8d1..4cd128b8019fdfd7f8f201b933b2f47d0e0cb287 100644 --- a/gnome/tests/Makefile.am +++ b/gnome/tests/Makefile.am @@ -9,7 +9,7 @@ SFLPHONE_LIBS = $(top_builddir)/src/contacts/libcontacts.la \ ########################################################### -check_global_SOURCES = check_global.c $(top_srcdir)/src/accountlist.c $(top_srcdir)/src/logger.c +check_global_SOURCES = check_global.c $(top_srcdir)/src/accountlist.c $(top_srcdir)/src/logger.c $(top_srcdir)/src/str_utils.c check_global_CFLAGS = @CHECK_CFLAGS@ @GTK_CFLAGS@ @GLIB_CFLAGS@ @DBUSGLIB_CFLAGS@ @GCONF_CFLAGS@ check_global_LDADD = $(SFLPHONE_LIBS) @CHECK_LIBS@ @GLIB_LIBS@ @GTK_LIBS@ @DBUSGLIB_LIBS@ @GCONF_LIBS@ @@ -42,9 +42,14 @@ check_dbus_SOURCES = check_dbus.c $(top_srcdir)/src/logger.c \ $(top_srcdir)/src/uimanager.c \ $(top_srcdir)/src/conference_obj.c \ $(top_srcdir)/src/shortcuts.c \ - $(top_srcdir)/src/imwindow.c + $(top_srcdir)/src/imwindow.c \ + $(top_srcdir)/src/str_utils.c + check_dbus_CFLAGS = @CHECK_CFLAGS@ @GTK_CFLAGS@ @DBUSGLIB_CFLAGS@ @GCONF_CFLAGS@ @WEBKIT_CFLAGS@ -check_dbus_LDADD = $(SFLPHONE_LIBS) @CHECK_LIBS@ @GCONF_LIBS@ $(top_builddir)/src/widget/libwidget.la $(top_builddir)/src/icons/libicons.la +check_dbus_LDADD = $(SFLPHONE_LIBS) @CHECK_LIBS@ @GCONF_LIBS@ \ + $(top_builddir)/src/widget/libwidget.la \ + $(top_builddir)/src/icons/libicons.la @X11_LIBS@ \ + @JAVASCRIPT_CORE_GTK_LIBS@ -ldl ########################################################### diff --git a/gnome/tests/check_global.c b/gnome/tests/check_global.c index aa3f1bb1569f92f3a7ab1cec9b8e6c0d7219a7ca..d1e6eb37692073e024b2142459984ef361f179cc 100644 --- a/gnome/tests/check_global.c +++ b/gnome/tests/check_global.c @@ -34,6 +34,7 @@ #include "../src/accountlist.h" #include "../src/sflphone_const.h" +#include "../src/str_utils.h" account_t* create_test_account(gchar *alias) { @@ -78,7 +79,7 @@ START_TEST(test_ordered_list) account_list_init(); account_list_add(test); account_list_add(test); - fail_unless(g_strcasecmp(account_list_get_ordered_list(), list) == 0, "ERROR - BAD ACCOUNT LIST SERIALIZING"); + fail_unless(utf8_case_cmp(account_list_get_ordered_list(), list) == 0, "ERROR - BAD ACCOUNT LIST SERIALIZING"); g_free(list); } END_TEST @@ -91,7 +92,7 @@ START_TEST(test_get_by_id) account_list_init(); account_list_add(test); tmp = account_list_get_by_id(test->accountID); - fail_unless(g_strcasecmp(tmp->accountID, test->accountID) == 0, "ERROR - ACCOUNTLIST_GET_BY_ID"); + fail_unless(utf8_case_cmp(tmp->accountID, test->accountID) == 0, "ERROR - ACCOUNTLIST_GET_BY_ID"); } END_TEST @@ -109,7 +110,7 @@ START_TEST(test_get_current_account) // The current account must be the first we add if (current) { - fail_unless(g_strcasecmp(g_hash_table_lookup(current->properties, ACCOUNT_ALIAS) , + fail_unless(utf8_case_cmp(g_hash_table_lookup(current->properties, ACCOUNT_ALIAS) , g_hash_table_lookup(test->properties, ACCOUNT_ALIAS)) == 0, "ERROR - BAD CURRENT ACCOUNT"); } @@ -121,7 +122,7 @@ START_TEST(test_get_current_account) // The current account must be the first we add if (current) { - fail_unless(g_strcasecmp(g_hash_table_lookup(current->properties, ACCOUNT_ALIAS) , + fail_unless(utf8_case_cmp(g_hash_table_lookup(current->properties, ACCOUNT_ALIAS) , g_hash_table_lookup(test2->properties, ACCOUNT_ALIAS)) == 0, "ERROR - BAD CURRENT ACCOUNT"); } diff --git a/plugins/.gitignore b/plugins/.gitignore index 2e55b18e4baa7ea3d7a1e4ecc8480d49679eefc0..ad90355f8e8c80a17399279d88ae038db1ea8f0e 100644 --- a/plugins/.gitignore +++ b/plugins/.gitignore @@ -1,3 +1,5 @@ +m4 +aclocal.m4 .cproject .project .settings/* diff --git a/plugins/addressbook/evolution/eds.h b/plugins/addressbook/evolution/eds.h index 0ce1783831d585eca4bef8bc2422771fe67d39ce..5bbf71e1af469ff4049cb08d9a6f1c72a681d584 100644 --- a/plugins/addressbook/evolution/eds.h +++ b/plugins/addressbook/evolution/eds.h @@ -38,7 +38,7 @@ #ifndef __EDS_H__ #define __EDS_H__ -#include <glib/gtypes.h> +#include <glib.h> #include <gdk-pixbuf/gdk-pixbuf.h> #include <libebook/e-book.h>