diff --git a/autogen.sh b/autogen.sh index 06b6a97c95e0c7f4db9c8bd21a358a14784e9187..ac85bd137c9dcf2f99eef6992751d1a92876cdcd 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,6 +4,6 @@ aclocal -I m4 libtoolize --force autoheader -autoconf -f +autoconf -v -f automake -a ./configure $@ diff --git a/build-package.sh b/build-package.sh index a2c775ac077e8d1f9aedf5cc837277e5f99aca2b..78aa9774b07f8bf2ccc14c2cdb902a8f35adf96c 100755 --- a/build-package.sh +++ b/build-package.sh @@ -2,16 +2,48 @@ # # @author: Yun Liu <yun.liu@savoirfairelinux.com> # -# Build sflphone debian packages for Ubuntu 8.04 +# Build sflphone rpm packages for Fedora 10 and openSUSE 11 # 1 - The SFLphone package must be build with a specific GnuPG key. Please contact us to have more information about that (<sflphoneteam@savoirfairelinux.com>) # 2. The source code can be teched through anonymous http access. So no need of special access. -# 3. After having all the prerequisites, you can run "build-package.sh" to build debian packages for sflphone. -# All the source packages and binary packages will be generated in the current directory. +# 3. After having all the prerequisites, you can run "build-rpm-package.sh" to build rpm packages for sflphone. +# # Refer to http://www.sflphone.org for futher information +# Analyze parameters +if [ "$1" == "--help" ] || [ "$1" == "" ];then + echo -e '\E[34mThis script is used to build sflphone rpm packages on ubuntu series(8.04,8,10,9), Fedora 10 and SUSE 11 platform.' + echo -e '\E[34mYou can add --fedora, --suse or --ubuntu to start packaging.' + echo + echo "The SFLphone package must be build with a specific GnuPG key. Please contact us to have more information about that (<sflphoneteam@savoirfairelinux.com>)" + echo + echo "For fedora and SUSE, you also need to add the following lines to $HOME/.rpmmacros:" + echo -e '\E[32m%_gpg_path /home/yun/.gnupg' + echo -e '\E[32m%_gpg_name Savoir-Faire Linux Inc. (Génération des paquets pour SFLphone) <sflphoneteam@savoirfairelinux.com>' + echo -e '\E[32m%_gpgbin /usr/bin/gpg' + echo + echo -e '\E[34mAfter all these preparations done, you can run ./build-package.sh --platform-name' + echo + echo -e '\E[36mHave fun!' + + tput sgr0 # Reset colors to "normal." + echo + exit 1 +elif [ $1 == "--fedora" ];then + BUILDDIR=$HOME/rpmbuild + platform="fedora" +elif [ $1 == "--suse" ];then + BUILDDIR=/usr/src/packages + platform="suse" +elif [ $1 == "--ubuntu" ];then + platform="ubuntu" +else + echo "This script can only be used for Ubuntu series, Fedora 10 and SUSE 11 platform. Use --help to get more information." + exit 1 +fi + if [ -d "sflphone" ]; then echo "Directory sflphone already exists. Please remove it first." - exit 1 + exit 1 fi # Anonymous git http access @@ -22,33 +54,54 @@ git checkout origin/release -b release # Get system parameters arch_flag=`getconf -a|grep LONG_BIT | sed -e 's/LONG_BIT\s*//'` os_version=`lsb_release -d -s -c | sed -e '1d'` +ver=0.9.2 + +if [ $platform == "ubuntu" ];then + # Generate the changelog, according to the distribution and the git commit messages + cp debian/changelog.$os_version debian/changelog + git-dch --debian-branch=release --release +fi -# Generate the changelog, according to the distribution and the git commit messages -cp debian/changelog.$os_version debian/changelog -git-dch --debian-branch=release --release cd .. # Remove useless git directory rm sflphone/.git/ -rf -# Copy the appropriate control file based on different archtecture -cp sflphone/debian/control.$os_version sflphone/debian/control +# Get the public gpg key to sign the packages +wget -q http://www.sflphone.org/downloads/gpg/sflphone.gpg.asc -O- | gpg --import - -echo "Building sflphone package on Ubuntu $os_version $arch_flag bit architecture...." +if [ $platform == "ubuntu" ];then + # Copy the appropriate control file based on different archtecture + cp sflphone/debian/control.$os_version sflphone/debian/control -# Provide prerequisite directories used by debuild -cp sflphone sflphone-0.9.2 -r -cp sflphone sflphone-0.9.2.orig -r + echo "Building sflphone package on Ubuntu $os_version $arch_flag bit architecture...." + # Provide prerequisite directories used by debuild + cp sflphone sflphone-$ver -r + cp sflphone sflphone-$ver.orig -r + + # Build packages + cd sflphone-$ver/debian; debuild -k'Savoir-Faire Linux Inc.' -# Get the public gpg key to sign the packages -wget -q http://www.sflphone.org/downloads/gpg/sflphone.gpg.asc -O- | gpg --import - + # Post clean + cd .. + rm sflphone-$ver sflphone -rf + echo "Done! All the source packages and binary packages are generated in the current directory" -# Build packages -cd sflphone-0.9.2/debian; debuild -k'Savoir-Faire Linux Inc.' +else + # Prepare for packaging + mv sflphone sflphone-$ver -# Clean -cd ../.. -rm sflphone-0.9.2/ -rf -rm sflphone/ -rf + cp sflphone-$ver/platform/$platform.spec $BUILDDIR/SPECS/ + cp sflphone-$ver/libs/pjproject-1.0/libpj-sfl.pc $BUILDDIR/SOURCES + tar zcvf sflphone-$ver.tar.gz sflphone-$ver -echo "Building package finished successullly!" + rm sflphone-$ver -rf + mv sflphone-$ver.tar.gz $BUILDDIR/SOURCES + echo "Building sflphone package on $platform $arch_flag bit architecture...." + + # Build packages + cd $BUILDDIR/SPECS/ + rpmbuild -ba --sign sflphone.spec + + echo "Done! All source rpms and binary rpms are stored in $BUILDDIR/SRPMS and $BUILDDIR/RPMS" +fi diff --git a/configure.ac b/configure.ac index d9b4ed6dd946e89a73809b67d9bf1b53b14214aa..100f5d33d603f38acaefc85422c0899c844034cb 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ dnl SFLPhone - configure.ac for automake 1.9 and autoconf 2.59 dnl dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([SFLPhone],[0.7],[sflphoneteam@savoirfairelinux.com],[sflphone]) -AC_COPYRIGHT([[Copyright (c) Savoir-Faire Linux 2004-2008]]) +AC_INIT([SFLPhone],[0.9.2-7],[sflphoneteam@savoirfairelinux.com],[sflphone]) +AC_COPYRIGHT([[Copyright (c) Savoir-Faire Linux 2004-2009]]) AC_REVISION([$Revision$]) dnl Compute canonical system name @@ -13,7 +13,7 @@ dnl Rewrite name of programs to be installed AC_ARG_PROGRAM dnl Automake options -AM_INIT_AUTOMAKE([-Wall -Wno-portability]) +AM_INIT_AUTOMAKE([-Wno-portability]) dnl Improve make variable MAKE AC_PROG_MAKE_SET @@ -37,7 +37,8 @@ AC_CONFIG_FILES([src/Makefile \ src/audio/codecs/ilbc/Makefile \ src/config/Makefile \ src/dbus/Makefile \ - src/zeroconf/Makefile]) + src/zeroconf/Makefile \ + src/plug-in/Makefile]) dnl Unitary test section AC_CONFIG_FILES([test/Makefile]) @@ -95,7 +96,7 @@ dnl Define C++ as default language AC_LANG(C++) dnl Setup C++ compiler flags -CXXFLAGS="$CXXFLAGS $USE_EXCEPTIONS $USER_INCLUDES -O0 -g -Wall -Wextra" +CXXFLAGS="$CXXFLAGS $USE_EXCEPTIONS $USER_INCLUDES -O0 -g -Wno-return-type" dnl Check for header files AC_FUNC_ALLOCA diff --git a/debian/changelog b/debian/changelog index 645b87bab9f9fcf59117b4c64fee8730ee87b5fb..93faa51b23cf7bd923cc0d115ff12fca96d0a49e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,53 @@ +sflphone (0.9.2-2ubuntu6) intrepid; urgency=low + + [ Emmanuel Milou ] + * Migrate STUN configuration to the main config window + * Update french translation + * Other tiny memory leaks + * Fix memory leak in sampleconverter.cpp + * Generate packages from the release branch + * update the build package script + * modify the control files with architecture=any + * Remove valgring uninitialized value + * IAX and SIP use the same global variables to set account + configuration ; fix broken code + + [ Maxime Chambreuil ] + * Update spanish translation + + [ Hussein Abdallah ] + * Update russian translation + + [ Yun Liu ] + * Update translation files + * Fix the bug when user uncheck the account which fails in the + previous registration + * Add stun error status + * Fix bug ticket #143 + * Script for auto-install dependencies + * Fix bug ticket #140 + * Fix bug ticket 141 + * Fix the reregister process when user change the details of an + account + + -- Emmanuel Milou <manu@sulfur.inside.savoirfairelinux.net> Fri, 16 Jan 2009 18:19:05 -0500 + +sflphone (0.9.2-2ubuntu5) intrepid; urgency=low + + * Fix memory leak in the pulseaudio callback + * Update debian package generation script + * Warnings removal in GTK+ client + * Clean adjust volume method in alsalayer + * Plug the sflphone playback volume control to the pulseaudio volume + manager + * Display the date in history according to the current locale + * Generate the changelog according to the git commit messages + * Complete header in chinese translation file + * Use the right gpg key to sign the packages + * add debian jaunty jackalope support + + -- Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Wed, 14 Jan 2009 21:17:20 -0500 + sflphone (0.9.2-2ubuntu4) intrepid; urgency=low [ Emmanuel Milou ] diff --git a/debian/changelog.hardy b/debian/changelog.hardy index 1eb567db468442e164f2ce7bca174775c1fd8a6a..93faa51b23cf7bd923cc0d115ff12fca96d0a49e 100644 --- a/debian/changelog.hardy +++ b/debian/changelog.hardy @@ -1,32 +1,82 @@ -sflphone (0.9.2-0ubuntu4) hardy; urgency=low +sflphone (0.9.2-2ubuntu6) intrepid; urgency=low [ Emmanuel Milou ] - * add german translation + * Migrate STUN configuration to the main config window + * Update french translation + * Other tiny memory leaks + * Fix memory leak in sampleconverter.cpp + * Generate packages from the release branch + * update the build package script + * modify the control files with architecture=any + * Remove valgring uninitialized value + * IAX and SIP use the same global variables to set account + configuration ; fix broken code + + [ Maxime Chambreuil ] + * Update spanish translation + + [ Hussein Abdallah ] + * Update russian translation [ Yun Liu ] - * Fix GUI crash in Ubuntu8.10 64bit system + * Update translation files + * Fix the bug when user uncheck the account which fails in the + previous registration + * Add stun error status + * Fix bug ticket #143 + * Script for auto-install dependencies + * Fix bug ticket #140 + * Fix bug ticket 141 + * Fix the reregister process when user change the details of an + account + + -- Emmanuel Milou <manu@sulfur.inside.savoirfairelinux.net> Fri, 16 Jan 2009 18:19:05 -0500 + +sflphone (0.9.2-2ubuntu5) intrepid; urgency=low + + * Fix memory leak in the pulseaudio callback + * Update debian package generation script + * Warnings removal in GTK+ client + * Clean adjust volume method in alsalayer + * Plug the sflphone playback volume control to the pulseaudio volume + manager + * Display the date in history according to the current locale + * Generate the changelog according to the git commit messages + * Complete header in chinese translation file + * Use the right gpg key to sign the packages + * add debian jaunty jackalope support + + -- Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Wed, 14 Jan 2009 21:17:20 -0500 + +sflphone (0.9.2-2ubuntu4) intrepid; urgency=low + [ Emmanuel Milou ] + * add german translation + + [ Yun Liu ] + * Fix GUI crash in Ubuntu8.10 64bit system + -- Yun Liu <yun.liu@savoirfairelinux.com> Thu, 08 Jan 2009 13:08:51 -0500 -sflphone (0.9.2-0ubuntu3) hardy; urgency=low +sflphone (0.9.2-2ubuntu3) intrepid; urgency=low [ Emmanuel Milou ] * The main thread synchronizes the ringtone thread * disable custom ringtone for the ALSA layer * Fix the Makefile.am in man directory, add a SEE ALSO section - + [ Yun Liu ] * Fix daemon crash caused by the previous patch ( for bug ticket #129) - + -- Yun Liu <yun.liu@savoirfairelinux.com> Tue, 06 Jan 2009 16:18:38 -0500 -sflphone (0.9.2-0ubuntu2) hardy; urgency=low +sflphone (0.9.2-2ubuntu2) intrepid; urgency=low * Fix bug ticket #129 -- Yun Liu <yun.liu@savoirfairelinux.com> Wed, 5 Jan 2009 15:54:53 -0500 -sflphone (0.9.2-0ubuntu1) hardy; urgency=low +sflphone (0.9.2-2ubuntu1) intrepid; urgency=low * Migrate from eXosip library to pjsip * Add multiple SIP accounts support diff --git a/debian/changelog.intrepid b/debian/changelog.intrepid index 645b87bab9f9fcf59117b4c64fee8730ee87b5fb..93faa51b23cf7bd923cc0d115ff12fca96d0a49e 100644 --- a/debian/changelog.intrepid +++ b/debian/changelog.intrepid @@ -1,3 +1,53 @@ +sflphone (0.9.2-2ubuntu6) intrepid; urgency=low + + [ Emmanuel Milou ] + * Migrate STUN configuration to the main config window + * Update french translation + * Other tiny memory leaks + * Fix memory leak in sampleconverter.cpp + * Generate packages from the release branch + * update the build package script + * modify the control files with architecture=any + * Remove valgring uninitialized value + * IAX and SIP use the same global variables to set account + configuration ; fix broken code + + [ Maxime Chambreuil ] + * Update spanish translation + + [ Hussein Abdallah ] + * Update russian translation + + [ Yun Liu ] + * Update translation files + * Fix the bug when user uncheck the account which fails in the + previous registration + * Add stun error status + * Fix bug ticket #143 + * Script for auto-install dependencies + * Fix bug ticket #140 + * Fix bug ticket 141 + * Fix the reregister process when user change the details of an + account + + -- Emmanuel Milou <manu@sulfur.inside.savoirfairelinux.net> Fri, 16 Jan 2009 18:19:05 -0500 + +sflphone (0.9.2-2ubuntu5) intrepid; urgency=low + + * Fix memory leak in the pulseaudio callback + * Update debian package generation script + * Warnings removal in GTK+ client + * Clean adjust volume method in alsalayer + * Plug the sflphone playback volume control to the pulseaudio volume + manager + * Display the date in history according to the current locale + * Generate the changelog according to the git commit messages + * Complete header in chinese translation file + * Use the right gpg key to sign the packages + * add debian jaunty jackalope support + + -- Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Wed, 14 Jan 2009 21:17:20 -0500 + sflphone (0.9.2-2ubuntu4) intrepid; urgency=low [ Emmanuel Milou ] diff --git a/debian/changelog.jaunty b/debian/changelog.jaunty index 99db3887ffc3de8da7f5c2c9093807d59bba73f1..93faa51b23cf7bd923cc0d115ff12fca96d0a49e 100644 --- a/debian/changelog.jaunty +++ b/debian/changelog.jaunty @@ -1,4 +1,54 @@ -sflphone (0.9.2-2ubuntu4) jaunty; urgency=low +sflphone (0.9.2-2ubuntu6) intrepid; urgency=low + + [ Emmanuel Milou ] + * Migrate STUN configuration to the main config window + * Update french translation + * Other tiny memory leaks + * Fix memory leak in sampleconverter.cpp + * Generate packages from the release branch + * update the build package script + * modify the control files with architecture=any + * Remove valgring uninitialized value + * IAX and SIP use the same global variables to set account + configuration ; fix broken code + + [ Maxime Chambreuil ] + * Update spanish translation + + [ Hussein Abdallah ] + * Update russian translation + + [ Yun Liu ] + * Update translation files + * Fix the bug when user uncheck the account which fails in the + previous registration + * Add stun error status + * Fix bug ticket #143 + * Script for auto-install dependencies + * Fix bug ticket #140 + * Fix bug ticket 141 + * Fix the reregister process when user change the details of an + account + + -- Emmanuel Milou <manu@sulfur.inside.savoirfairelinux.net> Fri, 16 Jan 2009 18:19:05 -0500 + +sflphone (0.9.2-2ubuntu5) intrepid; urgency=low + + * Fix memory leak in the pulseaudio callback + * Update debian package generation script + * Warnings removal in GTK+ client + * Clean adjust volume method in alsalayer + * Plug the sflphone playback volume control to the pulseaudio volume + manager + * Display the date in history according to the current locale + * Generate the changelog according to the git commit messages + * Complete header in chinese translation file + * Use the right gpg key to sign the packages + * add debian jaunty jackalope support + + -- Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Wed, 14 Jan 2009 21:17:20 -0500 + +sflphone (0.9.2-2ubuntu4) intrepid; urgency=low [ Emmanuel Milou ] * add german translation @@ -8,7 +58,7 @@ sflphone (0.9.2-2ubuntu4) jaunty; urgency=low -- Yun Liu <yun.liu@savoirfairelinux.com> Thu, 08 Jan 2009 13:08:51 -0500 -sflphone (0.9.2-2ubuntu3) jaunty; urgency=low +sflphone (0.9.2-2ubuntu3) intrepid; urgency=low [ Emmanuel Milou ] * The main thread synchronizes the ringtone thread @@ -20,13 +70,13 @@ sflphone (0.9.2-2ubuntu3) jaunty; urgency=low -- Yun Liu <yun.liu@savoirfairelinux.com> Tue, 06 Jan 2009 16:18:38 -0500 -sflphone (0.9.2-2ubuntu2) jaunty; urgency=low +sflphone (0.9.2-2ubuntu2) intrepid; urgency=low * Fix bug ticket #129 -- Yun Liu <yun.liu@savoirfairelinux.com> Wed, 5 Jan 2009 15:54:53 -0500 -sflphone (0.9.2-2ubuntu1) jaunty; urgency=low +sflphone (0.9.2-2ubuntu1) intrepid; urgency=low * Migrate from eXosip library to pjsip * Add multiple SIP accounts support diff --git a/globals.mak b/globals.mak index c03985035c4058b00b378f1b0809017241339313..7a0b085b9efbe0f7deefb226deed286cbba7982a 100644 --- a/globals.mak +++ b/globals.mak @@ -1,6 +1,7 @@ # Global variables src=$(top_srcdir) sflcodecdir=$(libdir)/sflphone/codecs +sflplugindir=$(libdir)/sflphone/plugins PJSIP_LIBS = -lpjnath-sfl -lpjsua-sfl -lpjsip-sfl -lpjmedia-sfl -lpjsip-simple-sfl -lpjsip-ua-sfl -lpjmedia-codec-sfl -lpjlib-util-sfl -lpj-sfl @@ -16,5 +17,6 @@ AM_CPPFLAGS = \ @SIP_CFLAGS@ \ @DBUSCPP_CFLAGS@ \ -DCODECS_DIR=\""$(sflcodecdir)"\" \ + -DPLUGINS_DIR=\""$(sflplugindir)"\" \ -DENABLE_TRACE diff --git a/sflphone-gtk/configure.ac b/sflphone-gtk/configure.ac index b90af938de2786df192558b41aa3befd45ee1f23..fc3a5108d538a149843449ba7d88325bb88129fc 100644 --- a/sflphone-gtk/configure.ac +++ b/sflphone-gtk/configure.ac @@ -1,8 +1,8 @@ -AC_INIT([SFLphone],[0.9.2],[sflphoneteam@savoirfairelinux.com],[sflphone]) +AC_INIT([SFLphone],[0.9.2-7],[sflphoneteam@savoirfairelinux.com],[sflphone]) AM_CONFIG_HEADER(config.h) PACKAGE=SFLphone -VERSION=0.9.2 +VERSION=0.9.2-7 AM_INIT_AUTOMAKE($PACKAGE,$VERSION) diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 19b024322b132ca6795e49cc34c007ebb390ce66..6efb5cbcc125d58bc629f2cddcf0b1107a4e7471 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -164,6 +164,8 @@ sflphone_fill_account_list(gboolean toolbarInitialized) { account_t * a = account_list_get_nth (i); GHashTable * details = (GHashTable *) dbus_account_details(a->accountID); + if( details == NULL ) + break; a->properties = details; gchar * status = g_hash_table_lookup(details, "Status"); @@ -215,15 +217,8 @@ sflphone_fill_account_list(gboolean toolbarInitialized) toolbar_update_buttons(); } -gboolean -sflphone_init() +gboolean sflphone_init() { - current_calls = calltab_init(); - history = calltab_init(); - sleep(0.5); - if(SHOW_SEARCHBAR) histfilter = create_filter(GTK_TREE_MODEL(history->store)); - account_list_init (); - codec_list_init(); if(!dbus_connect ()){ main_window_error_message(_("Unable to connect to the SFLphone server.\nMake sure the daemon is running.")); @@ -232,6 +227,11 @@ sflphone_init() else { dbus_register(getpid(), "Gtk+ Client"); + current_calls = calltab_init(); + history = calltab_init(); + if(SHOW_SEARCHBAR) histfilter = create_filter(GTK_TREE_MODEL(history->store)); + account_list_init (); + codec_list_init(); sflphone_fill_account_list(FALSE); sflphone_fill_codec_list(); sflphone_set_current_account(); @@ -643,60 +643,63 @@ sflphone_keypad( guint keyval, gchar * key) void sflphone_place_call ( call_t * c ) { - if(c->state == CALL_STATE_DIALING) - { - if( account_list_get_size() == 0 ) - { - notify_no_accounts(); - sflphone_fail(c); - } - else if( account_list_get_by_state( ACCOUNT_STATE_REGISTERED ) == NULL ) - { - notify_no_registered_accounts(); - sflphone_fail(c); - } - else + + if(c->state == CALL_STATE_DIALING && strcmp(c->to, "") != 0) { - account_t * current = account_list_get_current(); - if( current ) - { - if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) - { - // OK, everything alright - the call is made with the current account - c -> accountID = current -> accountID; - status_bar_display_account(c); - dbus_place_call(c); - } - else - { - // Current account is not registered - // So we place a call with the first registered account - // And we switch the current account - current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); - c -> accountID = current -> accountID; - dbus_place_call(c); - notify_current_account( current ); - status_bar_display_account(c); - account_list_set_current_id( c-> accountID ); - } - } - else - { - // No current accounts have been setup. - // So we place a call with the first registered account - // and we change the current account - current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); - c -> accountID = current -> accountID; - dbus_place_call(c); - notify_current_account( current ); - status_bar_display_account(c); - account_list_set_current_id( c-> accountID ); - } + if( account_list_get_size() == 0 ) + { + notify_no_accounts(); + sflphone_fail(c); + } + + else if( account_list_get_by_state( ACCOUNT_STATE_REGISTERED ) == NULL ) + { + notify_no_registered_accounts(); + sflphone_fail(c); + } + + else + { + account_t * current = account_list_get_current(); + if( current ) + { + if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) + { + // OK, everything alright - the call is made with the current account + c -> accountID = current -> accountID; + status_bar_display_account(c); + dbus_place_call(c); + } + else + { + // Current account is not registered + // So we place a call with the first registered account + // And we switch the current account + current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); + c -> accountID = current -> accountID; + dbus_place_call(c); + notify_current_account( current ); + status_bar_display_account(c); + account_list_set_current_id( c-> accountID ); + } + } + else + { + // No current accounts have been setup. + // So we place a call with the first registered account + // and we change the current account + current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); + c -> accountID = current -> accountID; + dbus_place_call(c); + notify_current_account( current ); + status_bar_display_account(c); + account_list_set_current_id( c-> accountID ); + } + } + // Update history + c->history_state = OUTGOING; + call_list_add(history, c); } - // Update history - c->history_state = OUTGOING; - call_list_add(history, c); - } } /* Internal to action - set the __CURRENT_ACCOUNT variable */ diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index f67dd87b750a81dd9323fdd81406801a1cba54f1..be137c73cf4bc7c7e1f9257351c5e5c3eacc656e 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -184,7 +184,7 @@ clean_history( void ) select_account(GtkTreeSelection *selection, GtkTreeModel *model) { GtkTreeIter iter; - GValue val; + GValue val = {0}; if (!gtk_tree_selection_get_selected(selection, &model, &iter)) { @@ -194,7 +194,7 @@ select_account(GtkTreeSelection *selection, GtkTreeModel *model) return; } - val.g_type = G_TYPE_POINTER; + // The Gvalue will be initialized in the following function gtk_tree_model_get_value(model, &iter, COLUMN_ACCOUNT_DATA, &val); selectedAccount = (account_t*)g_value_get_pointer(&val); diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 8795c1ef8baededd09bc6c910dc1215262c45923..68e0e2d423367cc834a682c13e40b233726aea64 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -39,6 +39,7 @@ DBusGConnection * connection; DBusGProxy * callManagerProxy; DBusGProxy * configurationManagerProxy; DBusGProxy * instanceProxy; +DBusGProxy * nameOwnerProxy; static void incoming_call_cb (DBusGProxy *proxy UNUSED, @@ -172,17 +173,32 @@ error_alert(DBusGProxy *proxy UNUSED, sflphone_throw_exception( errCode ); } + +static void nameOwnerChanged(DBusGProxy *proxy, char *name, char *old_owner, char *new_owner, gpointer data ) +{ + + g_print("******************************************************************\n"); + g_print("Owner name of the service %s changed from %s to %s\n", name, old_owner, new_owner); + g_print("******************************************************************\n"); + + if (strcmp(name, "org.sflphone.SFLphone")!=0) return; + +} + gboolean dbus_connect () { + GError *error = NULL; + connection = NULL; + instanceProxy = NULL; + nameOwnerProxy = NULL; g_type_init (); - error = NULL; - connection = dbus_g_bus_get (DBUS_BUS_SESSION, - &error); - if (connection == NULL) + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + + if (error) { g_printerr ("Failed to open connection to bus: %s\n", error->message); @@ -190,13 +206,33 @@ dbus_connect () return FALSE; } + + nameOwnerProxy = dbus_g_proxy_new_for_name_owner( connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + &error); + + if( nameOwnerProxy==NULL) + { + g_printerr ("Failed to get proxy to NameOwner\n"); + return FALSE; + } + + dbus_g_proxy_add_signal( nameOwnerProxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (nameOwnerProxy, "NameOwnerChanged", + G_CALLBACK (nameOwnerChanged), NULL, NULL); + + /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */ - instanceProxy = dbus_g_proxy_new_for_name (connection, + instanceProxy = dbus_g_proxy_new_for_name_owner (connection, "org.sflphone.SFLphone", "/org/sflphone/SFLphone/Instance", - "org.sflphone.SFLphone.Instance"); - if (!instanceProxy) + "org.sflphone.SFLphone.Instance", + &error); + if (instanceProxy==NULL) { g_printerr ("Failed to get proxy to Instance\n"); return FALSE; @@ -205,11 +241,12 @@ dbus_connect () g_print ("DBus connected to Instance\n"); - callManagerProxy = dbus_g_proxy_new_for_name (connection, + callManagerProxy = dbus_g_proxy_new_for_name_owner (connection, "org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", - "org.sflphone.SFLphone.CallManager"); - if (!callManagerProxy) + "org.sflphone.SFLphone.CallManager", + &error); + if (callManagerProxy==NULL) { g_printerr ("Failed to get proxy to CallManagers\n"); return FALSE; @@ -251,10 +288,11 @@ dbus_connect () dbus_g_proxy_connect_signal (callManagerProxy, "volumeChanged", G_CALLBACK(volume_changed_cb), NULL, NULL); - configurationManagerProxy = dbus_g_proxy_new_for_name (connection, + configurationManagerProxy = dbus_g_proxy_new_for_name_owner (connection, "org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", - "org.sflphone.SFLphone.ConfigurationManager"); + "org.sflphone.SFLphone.ConfigurationManager", + &error); if (!configurationManagerProxy) { g_printerr ("Failed to get proxy to ConfigurationManager\n"); @@ -280,6 +318,7 @@ dbus_clean () { g_object_unref (callManagerProxy); g_object_unref (configurationManagerProxy); + g_object_unref (instanceProxy); } @@ -1026,7 +1065,7 @@ gchar* dbus_get_current_audio_output_plugin() { g_print("Before get audio plugin"); - gchar* plugin; + gchar* plugin=""; GError* error = NULL; org_sflphone_SFLphone_ConfigurationManager_get_current_audio_output_plugin( configurationManagerProxy, @@ -1174,18 +1213,20 @@ dbus_get_searchbar() { int state; GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_searchbar( - configurationManagerProxy, - &state, - &error); - g_print("After"); - if(error) - { - g_error_free(error); - } + if(!org_sflphone_SFLphone_ConfigurationManager_get_searchbar( configurationManagerProxy, &state, &error)) + { + if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) + g_printerr ("Caught remote method (get_searchbar) exception %s: %s\n", dbus_g_error_get_name(error), error->message); + else + g_printerr("Error while calling get_searchbar: %s\n", error->message); + g_error_free (error); + return -1; + } else + { g_print("DBus called get_searchbar on ConfigurationManager\n"); - return state; + return state; + } } void @@ -1354,24 +1395,24 @@ dbus_set_notify( void ) guint dbus_get_notify( void ) { - g_print("Before dbus_get_notif_level()\n"); gint level; GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_notify( - configurationManagerProxy, - &level, - &error); - if(error) - { - g_print("Error calling dbus_get_notif_level\n"); - g_error_free(error); - } - else - g_print("Called dbus_get_notif_level\n"); - - return (guint)level; + if( !org_sflphone_SFLphone_ConfigurationManager_get_notify( configurationManagerProxy,&level, &error) ) + { + if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) + g_printerr ("Caught remote method (get_notify) exception %s: %s\n", dbus_g_error_get_name(error), error->message); + else + g_printerr("Error while calling get_notify: %s\n", error->message); + g_error_free (error); + return 0; + } + else{ + g_print ("DBus called get_notify() on ConfigurationManager\n"); + return (guint)level; + } } + void dbus_set_mail_notify( void ) { @@ -1390,7 +1431,7 @@ dbus_set_mail_notify( void ) guint dbus_get_mail_notify( void ) { - g_print("Before dbus_get_mail_notif_level()\n"); + g_print("Before dbus_get_mail_notif_level()\n"); gint level; GError* error = NULL; org_sflphone_SFLphone_ConfigurationManager_get_mail_notify( diff --git a/sflphone-gtk/src/menus.c b/sflphone-gtk/src/menus.c index bf9fbe93d0e6941edffa4ec8c9f19d14502502df..2f7a36f156e6520a97137cae06b0b1c7f952df82 100644 --- a/sflphone-gtk/src/menus.c +++ b/sflphone-gtk/src/menus.c @@ -128,7 +128,7 @@ help_about ( void * foo UNUSED) "artists", artists, "authors", authors, "comments", _("SFLphone is a VoIP client compatible with SIP and IAX2 protocols."), - "copyright", "Copyright © 2004-2008 Savoir-faire Linux Inc.", + "copyright", "Copyright © 2004-2009 Savoir-faire Linux Inc.", "name", PACKAGE, "title", _("About SFLphone"), "version", VERSION, diff --git a/src/Makefile.am b/src/Makefile.am index 632a388a91672784901a393daa6d5d102a33c3ba..16725b63fb2d28f416c88bb7fd4f6453d0cb56d0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,7 @@ IAXSOURCES = IAXHEADERS = endif -SUBDIRS = audio config dbus $(ZEROCONFDIR) +SUBDIRS = audio config dbus $(ZEROCONFDIR) plug-in # Add here the cpp files to be build with sflphone sflphoned_SOURCES = \ @@ -63,6 +63,8 @@ sflphoned_LDADD = \ -luuid \ @SAMPLERATE_LIBS@ +#sflphoned_LDFLAGS=-pg + noinst_LTLIBRARIES = libsflphone.la noinst_HEADERS = \ @@ -88,6 +90,7 @@ libsflphone_la_LIBADD = \ ./audio/libaudio.la \ ./dbus/libdbus.la \ ./config/libconfig.la \ + ./plug-in/libplugin.la \ $(IAX_LIBS) libsflphone_la_SOURCES = diff --git a/src/audio/alsalayer.cpp b/src/audio/alsalayer.cpp index acd933c9d071b4d82e1a02c7206f07ab069a279d..c72378229e9a7b69f83a5560312ffa7724326414 100644 --- a/src/audio/alsalayer.cpp +++ b/src/audio/alsalayer.cpp @@ -54,7 +54,7 @@ AlsaLayer::~AlsaLayer (void) deviceClosed = true; ringtone_thread_is_running = false; - pthread_join(ringtone_thread, NULL); + //pthread_join(ringtone_thread, NULL); } void @@ -104,7 +104,7 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize, _debugAlsa(" : nb channel in=%2d, out=%2d\n", _inChannel, _outChannel); _debugAlsa(" : sample rate=%5d, format=%s\n", _sampleRate, SFLDataFormatString); - ost::MutexLock lock( _mutex ); + //ost::MutexLock lock( _mutex ); /*void **hint; @@ -163,6 +163,7 @@ void* ringtoneThreadEntry( void *ptr ) ( ( AlsaLayer *) ptr) -> playTones(); //sleep(0.1); } + /* pthread_mutex_lock(&mut); while( ((AlsaLayer*)ptr)->_manager->getTelephoneTone() == NULL ) @@ -171,6 +172,7 @@ void* ringtoneThreadEntry( void *ptr ) } ( AlsaLayer *) ptr -> playTones(); pthread_mutex_unlock(&mut);*/ + return 0; } @@ -206,7 +208,7 @@ AlsaLayer::fillHWBuffer( void) bool AlsaLayer::isStreamActive (void) { - ost::MutexLock lock( _mutex ); + //ost::MutexLock lock( _mutex ); return (isPlaybackActive() && isCaptureActive()); } @@ -279,7 +281,7 @@ AlsaLayer::getMic(void *buffer, int toCopy) bool AlsaLayer::isStreamStopped (void) { - ost::MutexLock lock( _mutex ); + //ost::MutexLock lock( _mutex ); return !(isStreamActive()); } @@ -291,20 +293,18 @@ void AlsaLayer::restorePulseAppsVolume( void ){} ///////////////// ALSA PRIVATE FUNCTIONS //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// - - void AlsaLayer::playTones( void ) { int frames; int maxBytes; - pthread_mutex_lock(&mut); - while(!_manager-> getTelephoneTone() && !_manager->getTelephoneFile()) - { + //pthread_mutex_lock(&mut); + //while(!_manager-> getTelephoneTone() && !_manager->getTelephoneFile()) + //{ _debug("Make the ringtone thread wait\n"); pthread_cond_wait(&cond, &mut); - } + //} //frames = _periodSize ; frames = 940 ; @@ -324,13 +324,13 @@ AlsaLayer::playTones( void ) } // free the temporary data buffer free( out ); out = 0; - pthread_mutex_unlock(&mut); + //pthread_mutex_unlock(&mut); } bool AlsaLayer::isPlaybackActive(void) { - ost::MutexLock guard( _mutex ); + //ost::MutexLock guard( _mutex ); if( _PlaybackHandle ) return (snd_pcm_state(_PlaybackHandle) == SND_PCM_STATE_RUNNING ? true : false); else @@ -339,7 +339,7 @@ AlsaLayer::isPlaybackActive(void) { bool AlsaLayer::isCaptureActive(void) { - ost::MutexLock guard( _mutex ); + //ost::MutexLock guard( _mutex ); if( _CaptureHandle ) return (snd_pcm_state( _CaptureHandle) == SND_PCM_STATE_RUNNING ? true : false); else @@ -452,11 +452,11 @@ bool AlsaLayer::alsa_set_params( snd_pcm_t *pcm_handle, int type, int rate ){ // So the loop could start when the ringtone thread entry function is reached ringtone_thread_is_running = true; - if( pthread_create(&ringtone_thread, NULL, ringtoneThreadEntry, this) != 0 ) + /*if( pthread_create(&ringtone_thread, NULL, ringtoneThreadEntry, this) != 0 ) { _debug("Unable to start the ringtone posix thread\n"); return false; - } + }*/ } snd_pcm_sw_params_free( swparams ); diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index c2f3ec87673b1d73b58029c8215bd0cfc3a24b43..85ec5fea464f198be3e410b68d8cd130dc562bb9 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -52,7 +52,7 @@ AudioRtp::~AudioRtp (void) { int AudioRtp::createNewSession (SIPCall *ca) { - ost::MutexLock m(_threadMutex); + //ost::MutexLock m(_threadMutex); // something should stop the thread before... if ( _RTXThread != 0 ) { @@ -66,7 +66,7 @@ AudioRtp::createNewSession (SIPCall *ca) { _RTXThread = new AudioRtpRTX (ca, _symmetric); try { if (_RTXThread->start() != 0) { - _debug("! ARTP Failure: unable to start RTX Thread\n"); + _debug("! ARTP Failure: unable to start RTX Thread\n"); return -1; } } catch(...) { @@ -79,7 +79,7 @@ AudioRtp::createNewSession (SIPCall *ca) { void AudioRtp::closeRtpSession () { - ost::MutexLock m(_threadMutex); + //ost::MutexLock m(_threadMutex); // This will make RTP threads finish. // _debug("Stopping AudioRTP\n"); try { diff --git a/src/audio/audiostream.cpp b/src/audio/audiostream.cpp index 63654ce0768347134a292e829eddf722e5379e1a..5e4d295871dc2f614f2bf0b1266aac706f3e044b 100644 --- a/src/audio/audiostream.cpp +++ b/src/audio/audiostream.cpp @@ -30,7 +30,7 @@ AudioStream::AudioStream( pa_context* context, int type, std::string desc, doubl sample_spec.rate = 44100; sample_spec.channels = 1; channel_map.channels = 1; - pa_cvolume_set( &_volume , 1 , PA_VOLUME_MUTED ) ; // * vol / 100 ; + pa_cvolume_set( &_volume , 1 , PA_VOLUME_NORM ) ; // * vol / 100 ; _audiostream = createStream( context ); } diff --git a/src/audio/pulselayer.cpp b/src/audio/pulselayer.cpp index 98a6cd6aa54fcf9e3a25a0ae50eb1e263a9f53c5..b1e6f6f725ea9c061cbbbcf8c04d811ff181643f 100644 --- a/src/audio/pulselayer.cpp +++ b/src/audio/pulselayer.cpp @@ -89,7 +89,7 @@ PulseLayer::connectPulseAudioServer( void ) } pa_threaded_mainloop_unlock( m ); - serverinfo(); + //serverinfo(); //muteAudioApps(99); _debug("Context creation done\n"); } diff --git a/src/dbus/callmanager.cpp b/src/dbus/callmanager.cpp index 31929f2983df4d2e8af68239fd678c0e4f63e143..2fa7a779edcfad17266412642454f1eb177a218a 100644 --- a/src/dbus/callmanager.cpp +++ b/src/dbus/callmanager.cpp @@ -34,7 +34,9 @@ CallManager::placeCall( const std::string& accountID, const std::string& to ) { _debug("CallManager::placeCall received\n"); - Manager::instance().outgoingCall(accountID, callID, to); + // Check if a destination number is available + if( to == "") _debug("No number entered - Call stopped\n"); + else Manager::instance().outgoingCall(accountID, callID, to); } void diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index c6177f35fc920738250824a767cd0f07635b32f2..626aca506c6114558d6a1db42fae6259e55a019b 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -64,20 +64,20 @@ ManagerImpl::ManagerImpl (void) : _hasTriedToRegister(false) , _config() , _currentCallId2() - , _currentCallMutex() + //, _currentCallMutex() , _codecBuilder(NULL) , _audiodriver(NULL) , _dtmfKey(NULL) , _codecDescriptorMap() - , _toneMutex() + //, _toneMutex() , _telephoneTone(NULL) , _audiofile() , _spkr_volume(0) , _mic_volume(0) - , _mutex() + //, _mutex() , _dbus(NULL) , _waitingCall() - , _waitingCallMutex() + //, _waitingCallMutex() , _nbIncomingWaitingCall(0) , _path("") , _exist(0) @@ -86,7 +86,7 @@ ManagerImpl::ManagerImpl (void) , _firewallAddr("") , _hasZeroconf(false) , _callAccountMap() - , _callAccountMapMutex() + //, _callAccountMapMutex() , _accountMap() , _userAgent(NULL) , _userAgentInitlized(false) @@ -203,13 +203,13 @@ void ManagerImpl::terminate() bool ManagerImpl::isCurrentCall(const CallID& callId) { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); return (_currentCallId2 == callId ? true : false); } bool ManagerImpl::hasCurrentCall() { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); _debug("Current call ID = %s\n", _currentCallId2.c_str()); if ( _currentCallId2 != "") { return true; @@ -219,13 +219,13 @@ ManagerImpl::hasCurrentCall() { const CallID& ManagerImpl::getCurrentCallId() { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); return _currentCallId2; } void ManagerImpl::switchCall(const CallID& id ) { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); _currentCallId2 = id; } @@ -295,7 +295,9 @@ ManagerImpl::answerCall(const CallID& id) ManagerImpl::hangupCall(const CallID& id) { stopTone(true); + if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP"); + AccountID accountid = getAccountFromCall( id ); if (accountid == AccountNULL) { /** @todo We should tell the GUI that the call doesn't exist, so @@ -305,6 +307,7 @@ ManagerImpl::hangupCall(const CallID& id) } bool returnValue = getAccountLink(accountid)->hangup(id); + _debug("After voip link hungup!\n"); removeCallAccount(id); switchCall(""); @@ -561,20 +564,20 @@ ManagerImpl::playDtmf(char code, bool isTalking) // Multi-thread bool ManagerImpl::incomingCallWaiting() { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); return (_nbIncomingWaitingCall > 0) ? true : false; } void ManagerImpl::addWaitingCall(const CallID& id) { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); _waitingCall.insert(id); _nbIncomingWaitingCall++; } void ManagerImpl::removeWaitingCall(const CallID& id) { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); // should return more than 1 if it erase a call if (_waitingCall.erase(id)) { _nbIncomingWaitingCall--; @@ -583,7 +586,7 @@ ManagerImpl::removeWaitingCall(const CallID& id) { bool ManagerImpl::isWaitingCall(const CallID& id) { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); CallIDSet::iterator iter = _waitingCall.find(id); if (iter != _waitingCall.end()) { return false; @@ -735,9 +738,9 @@ ManagerImpl::playATone(Tone::TONEID toneId) { if (!hasToPlayTone) return false; if (_telephoneTone != 0) { - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); _telephoneTone->setCurrentTone(toneId); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); AudioLoop* audioloop = getTelephoneTone(); unsigned int nbSampling = audioloop->getSize(); @@ -774,16 +777,16 @@ ManagerImpl::stopTone(bool stopAudio=true) { } - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); if (_telephoneTone != 0) { _telephoneTone->setCurrentTone(Tone::TONE_NULL); } - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); // for ringing tone.. - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); _audiofile.stop(); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); } /** @@ -847,13 +850,13 @@ ManagerImpl::ringtone() int sampleRate = audiolayer->getSampleRate(); AudioCodec* codecForTone = _codecDescriptorMap.getFirstCodecAvailable(); - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); bool loadFile = _audiofile.loadFile(ringchoice, codecForTone , sampleRate); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); if (loadFile) { - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); _audiofile.start(); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); if(CHECK_INTERFACE( layer, ALSA )){ /*int size = _audiofile.getSize(); SFLDataFormat output[ size ]; @@ -880,7 +883,7 @@ ManagerImpl::ringtone() ManagerImpl::getTelephoneTone() { if(_telephoneTone != 0) { - ost::MutexLock m(_toneMutex); + //ost::MutexLock m(_toneMutex); return _telephoneTone->getCurrentTone(); } else { @@ -891,7 +894,7 @@ ManagerImpl::getTelephoneTone() AudioLoop* ManagerImpl::getTelephoneFile() { - ost::MutexLock m(_toneMutex); + //ost::MutexLock m(_toneMutex); if(_audiofile.isStarted()) { return &_audiofile; } else { @@ -1837,7 +1840,7 @@ ManagerImpl::detachZeroconfEvents(Pattern::Observer& observer) ManagerImpl::getCallStatus(const std::string& sequenceId UNUSED) { if (!_dbus) { return false; } - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); CallAccountMap::iterator iter = _callAccountMap.begin(); TokenList tk; std::string code; @@ -2139,7 +2142,7 @@ ManagerImpl::associateCallToAccount(const CallID& callID, const AccountID& accou { if (getAccountFromCall(callID) == AccountNULL) { // nothing with the same ID if ( accountExists(accountID) ) { // account id exist in AccountMap - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); _callAccountMap[callID] = accountID; _debug("Associate Call %s with Account %s\n", callID.data(), accountID.data()); return true; @@ -2154,7 +2157,7 @@ ManagerImpl::associateCallToAccount(const CallID& callID, const AccountID& accou AccountID ManagerImpl::getAccountFromCall(const CallID& callID) { - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); CallAccountMap::iterator iter = _callAccountMap.find(callID); if ( iter == _callAccountMap.end()) { return AccountNULL; @@ -2166,7 +2169,7 @@ ManagerImpl::getAccountFromCall(const CallID& callID) bool ManagerImpl::removeCallAccount(const CallID& callID) { - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); if ( _callAccountMap.erase(callID) ) { return true; } diff --git a/src/managerimpl.h b/src/managerimpl.h index a76987d758b48188f60e853759be06a51d5b75de..b13fc911a88d79580e739ac8ea8b5439d5ad7424 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -868,7 +868,7 @@ class ManagerImpl { CallID _currentCallId2; /** Protected current call access */ - ost::Mutex _currentCallMutex; + //ost::Mutex _currentCallMutex; /** Vector of CodecDescriptor */ CodecDescriptor* _codecBuilder; @@ -886,7 +886,7 @@ class ManagerImpl { ///////////////////// // Protected by Mutex ///////////////////// - ost::Mutex _toneMutex; + //ost::Mutex _toneMutex; TelephoneTone* _telephoneTone; AudioFile _audiofile; @@ -899,7 +899,7 @@ class ManagerImpl { // Multithread variable (protected by _mutex) // /** Mutex to protect access to code section */ - ost::Mutex _mutex; + //ost::Mutex _mutex; // Multithread variable (non protected) DBusManagerImpl * _dbus; @@ -908,7 +908,7 @@ class ManagerImpl { CallIDSet _waitingCall; /** Protect waiting call list, access by many voip/audio threads */ - ost::Mutex _waitingCallMutex; + //ost::Mutex _waitingCallMutex; /** Number of waiting call, synchronize with waitingcall callidvector */ unsigned int _nbIncomingWaitingCall; @@ -956,7 +956,7 @@ class ManagerImpl { CallAccountMap _callAccountMap; /** Mutex to lock the call account map (main thread + voiplink thread) */ - ost::Mutex _callAccountMapMutex; + //ost::Mutex _callAccountMapMutex; /** Associate a new CallID to a AccountID * Protected by mutex diff --git a/src/plug-in/Makefile.am b/src/plug-in/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..53bf6b050cba69da07a0f8fd60b2f4b52c8f41d6 --- /dev/null +++ b/src/plug-in/Makefile.am @@ -0,0 +1,8 @@ +include ../../globals.mak + +noinst_LTLIBRARIES = libplugin.la + +libplugin_la_SOURCES = \ + pluginmanager.cpp \ + plugin.h + diff --git a/src/plug-in/plugin.cpp b/src/plug-in/plugin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..495437076549dee7c9bafbdc5ca6782076400d97 --- /dev/null +++ b/src/plug-in/plugin.cpp @@ -0,0 +1,27 @@ +#include "plugin.h" + +::sflphone::Plugin::Plugin( const std::string &filename UNUSED ) +{ + //TODO IMPLEMENT +} + +::sflphone::Plugin::Plugin( const Plugin &plugin UNUSED ) +{ + //TODO IMPLEMENT +} + +::sflphone::Plugin::~Plugin() +{ + //TODO IMPLEMENT +} + +int ::sflphone::Plugin::getCoreVersion( void ) const +{ + //TODO IMPLEMENT + return 1; +} + +void ::sflphone::Plugin::registerPlugin( PluginManager & ) +{ + //TODO IMPLEMENT +} diff --git a/src/plug-in/plugin.h b/src/plug-in/plugin.h new file mode 100644 index 0000000000000000000000000000000000000000..100d6ea5b40bc618e3e6cae9c4435b9b192af676 --- /dev/null +++ b/src/plug-in/plugin.h @@ -0,0 +1,43 @@ +#ifndef PLUGIN_H +#define PLUGIN_H + +#include <string> + +#include "global.h" + +/* + * @file plugin.h + * @brief Define a plugin object + */ + +namespace sflphone { + +class PluginManager; + + class Plugin { + + public: + Plugin( const std::string &name ); + //Plugin( const Plugin &plugin ); + virtual ~Plugin() {} + + public: + /** + * Return the minimal core version required so that the plugin could work + * @return int The version required + */ + virtual int getCoreVersion() const = 0; + + /** + * Register the plugin to the plugin manager + */ + virtual void registerPlugin( PluginManager & ) = 0; + + private: + Plugin &operator =(const Plugin &plugin); + + }; +} + +#endif //PLUGIN_H + diff --git a/src/plug-in/pluginmanager.cpp b/src/plug-in/pluginmanager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6012a59bde292396b2f70fdce8d0a1d458ef8aa7 --- /dev/null +++ b/src/plug-in/pluginmanager.cpp @@ -0,0 +1,98 @@ +#include <dirent.h> +#include <dlfcn.h> + +#include "pluginmanager.h" + +::sflphone::PluginManager::PluginManager():_loadedPlugins() +{ + _instance = this; +} + +::sflphone::PluginManager::~PluginManager() +{ + _instance = 0; +} + +int ::sflphone::PluginManager::loadPlugins( const std::string &path ) +{ + std::string pluginDir, current; + ::sflphone::Plugin *plugin; + DIR *dir; + dirent *dirStruct; + int result=0; + + const std::string pDir = ".."; + const std::string cDir = "."; + + /* The directory in which plugins are dropped. Default: /usr/lib/sflphone/plugins/ */ + ( path == "" )? pluginDir = std::string(PLUGINS_DIR).append("/"):pluginDir = path; + _debug("Loading plugins from %s...\n", pluginDir.c_str()); + + dir = opendir( pluginDir.c_str() ); + /* Test if the directory exists or is readable */ + if( dir ){ + /* Read the directory */ + while( (dirStruct=readdir(dir)) ){ + /* Get the name of the current item in the directory */ + current = dirStruct->d_name; + /* Test if the current item is not the parent or the current directory */ + if( current != pDir && current != cDir ){ + loadDynamicLibrary( current ); + result++; + } + } + } + /* Close the directory */ + closedir( dir ); + + return result; +} + +::sflphone::Plugin* ::sflphone::PluginManager::isPluginLoaded( const std::string &name ) +{ + if(_loadedPlugins.empty()) return NULL; + + /* Use an iterator on the loaded plugins map */ + pluginMap::iterator iter; + + iter = _loadedPlugins.begin(); + while( iter != _loadedPlugins.end() ) { + if ( iter->first == name ) { + /* Return the associated plugin */ + return iter->second; + } + iter++; + } + + /* If we are here, it means that the plugin we were looking for has not been loaded */ + return NULL; +} + +void* ::sflphone::PluginManager::loadDynamicLibrary( const std::string& filename ) { + + void *pluginHandlePtr = NULL; + const char *error; + + _debug("Loading dynamic library %s\n", filename.c_str()); + +#if defined(Q_OS_UNIX) + /* Load the library */ + pluginHandlePtr = dlopen( filename.c_str(), RTLD_LAZY ); + if( !pluginHandlePtr ) { + error = dlerror(); + _debug("Error while opening plug-in: %s\n", error); + } + dlerror(); +#endif + + return pluginHandlePtr; +} + +void ::sflphone::PluginManager::unloadDynamicLibrary( void * pluginHandlePtr ) { + + dlclose( pluginHandlePtr ); + dlerror(); +} + +::sflphone::PluginManager* ::sflphone::PluginManager::_instance = 0; + diff --git a/src/plug-in/pluginmanager.h b/src/plug-in/pluginmanager.h new file mode 100644 index 0000000000000000000000000000000000000000..651a0902f8e0db872052a2b0c234c66866ee92f1 --- /dev/null +++ b/src/plug-in/pluginmanager.h @@ -0,0 +1,72 @@ +#ifndef PLUGIN_MANAGER_H +#define PLUGIN_MANAGER_H + +/* + * @file pluginmanager.h + * @brief Base class of the plugin manager + */ + +#include "plugin.h" +#include "global.h" + +#include <map> +#include <string> + +namespace sflphone { + + class PluginManager { + + public: + /** + * Default constructor + */ + PluginManager(); + + /** + * Destructor + */ + ~PluginManager(); + + /** + * Returns the unique instance of the plugin manager + */ + static PluginManager* instance(); + + /** + * Load all the plugins found in a specific directory + * @param path The absolute path to the directory + * @return int The number of items loaded + */ + int loadPlugins( const std::string &path = "" ); + + /** + * Check if a plugin has been already loaded + * @param name The name of the plugin looked for + * @return Plugin* The pointer on the plugin or NULL if not found + */ + Plugin* isPluginLoaded( const std::string &name ); + + private: + /** + * Load a unix dynamic/shared library + * @param filename The path to the dynamic/shared library + * @return void* A pointer on it + */ + void * loadDynamicLibrary( const std::string &filename ); + + /** + * Unload a unix dynamic/shared library + * @param pluginHandleptr The pointer on the loaded plugin + */ + void unloadDynamicLibrary( void * pluginHandlePtr ); + + /* Map of plugins associated by their string name */ + typedef std::map<std::string, ::sflphone::Plugin*> pluginMap; + pluginMap _loadedPlugins; + + /* The unique static instance */ + static PluginManager* _instance; + }; +} + +#endif //PLUGIN_MANAGER_H diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index cc7e147a8b12f7549173727a6fa01d02d1f934ea..c71fd1da9eb1392f4074c80f29d88a3c6ea40327 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -81,7 +81,7 @@ void SIPVoIPLink::terminateSIPCall() { - ost::MutexLock m(_callMapMutex); + //ost::MutexLock m(_callMapMutex); CallMap::iterator iter = _callMap.begin(); SIPCall *call; while( iter != _callMap.end() ) { @@ -219,18 +219,21 @@ SIPVoIPLink::answer(const CallID& id) bool SIPVoIPLink::hangup(const CallID& id) { - SIPCall* call = getSIPCall(id); - if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } + SIPCall* call = getSIPCall(id); + if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } - Manager::instance().getUserAgent()->hangup(call); + if(!Manager::instance().getUserAgent()->hangup(call)) + return false; - // Release RTP thread - if (Manager::instance().isCurrentCall(id)) { - _debug("* SIP Info: Stopping AudioRTP for hangup\n"); - _audiortp->closeRtpSession(); - } - removeCall(id); - return true; + // Release RTP thread + if (Manager::instance().isCurrentCall(id)) { + _debug("* SIP Info: Stopping AudioRTP for hangup\n"); + _audiortp->closeRtpSession(); + } + + removeCall(id); + + return true; } bool @@ -259,49 +262,59 @@ SIPVoIPLink::onhold(const CallID& id) _debug("* SIP Info: Stopping AudioRTP for onhold action\n"); _audiortp->closeRtpSession(); - Manager::instance().getUserAgent()->onhold(call); - - return true; + return Manager::instance().getUserAgent()->onhold(call); } bool SIPVoIPLink::offhold(const CallID& id) { - SIPCall* call = getSIPCall(id); - if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } + SIPCall *call; - Manager::instance().getUserAgent()->offhold(call); + call = getSIPCall(id); + if (call==0) { + _debug("! SIP Error: Call doesn't exist\n"); + return false; + } - // Enable audio - _debug("* SIP Info: Starting AudioRTP when offhold\n"); - call->setState(Call::Active); - // it's sure that this is the current call id... - if (_audiortp->createNewSession(call) < 0) { - _debug("! SIP Failure: Unable to start sound (%s:%d)\n", __FILE__, __LINE__); - return false; - } - return true; + if(!Manager::instance().getUserAgent()->offhold(call)) + return false; + + // Enable audio + _debug("* SIP Info: Starting AudioRTP when offhold\n"); + call->setState(Call::Active); + // it's sure that this is the current call id... + if (_audiortp->createNewSession(call) < 0) { + _debug("! SIP Failure: Unable to start sound (%s:%d)\n", __FILE__, __LINE__); + return false; + } + + return true; } bool SIPVoIPLink::transfer(const CallID& id, const std::string& to) { - SIPCall* call = getSIPCall(id); - if (call==0) { _debug("! SIP Failure: Call doesn't exist\n"); return false; } + SIPCall *call; + std::string tmp_to; - std::string tmp_to = SIPToHeader(to); - if (tmp_to.find("@") == std::string::npos) { - tmp_to = tmp_to + "@" + getHostname(); - } + call = getSIPCall(id); + if (call==0) { + _debug("! SIP Failure: Call doesn't exist\n"); + return false; + } + + tmp_to = SIPToHeader(to); + if (tmp_to.find("@") == std::string::npos) { + tmp_to = tmp_to + "@" + getHostname(); + } - _debug("In transfer, tmp_to is %s\n", tmp_to.data()); + _debug("In transfer, tmp_to is %s\n", tmp_to.data()); - Manager::instance().getUserAgent()->transfer(call, tmp_to); + return Manager::instance().getUserAgent()->transfer(call, tmp_to); //_audiortp->closeRtpSession(); // shall we delete the call? //removeCall(id); - return true; } bool SIPVoIPLink::transferStep2() @@ -313,34 +326,45 @@ bool SIPVoIPLink::transferStep2() bool SIPVoIPLink::refuse (const CallID& id) { - SIPCall* call = getSIPCall(id); + SIPCall *call; - if (call==0) { _debug("Call doesn't exist\n"); return false; } + call = getSIPCall(id); - // can't refuse outgoing call or connected - if (!call->isIncoming() || call->getConnectionState() == Call::Connected) { - _debug("It's not an incoming call, or it's already answered\n"); - return false; - } + if (call==0) { + _debug("Call doesn't exist\n"); + return false; + } - Manager::instance().getUserAgent()->refuse(call); - - return true; + // can't refuse outgoing call or connected + if (!call->isIncoming() || call->getConnectionState() == Call::Connected) { + _debug("It's not an incoming call, or it's already answered\n"); + return false; + } + + return Manager::instance().getUserAgent()->refuse(call); } bool -SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code UNUSED) +SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code) { - SIPCall* call = getSIPCall(id); - if (call==0) { _debug("Call doesn't exist\n"); return false; } - int duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH); - const int body_len = 1000; - char *dtmf_body = new char[body_len]; + SIPCall *call; + int duration; + const int body_len = 1000; + char *dtmf_body; + + call = getSIPCall(id); + if (call==0) { + _debug("Call doesn't exist\n"); + return false; + } + + duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH); + dtmf_body = new char[body_len]; - snprintf(dtmf_body, body_len - 1, "Signal=%c\r\nDuration=%d\r\n", code, duration); + snprintf(dtmf_body, body_len - 1, "Signal=%c\r\nDuration=%d\r\n", code, duration); - return Manager::instance().getUserAgent()->carryingDTMFdigits(call, dtmf_body); + return Manager::instance().getUserAgent()->carryingDTMFdigits(call, dtmf_body); } bool @@ -447,9 +471,9 @@ SIPVoIPLink::SIPCallServerFailure(SIPCall *call) //SIPCall* call = findSIPCallWithCid(event->cid); if (call != 0) { _debug("Server error!\n"); - CallID id = call->getCallId(); - Manager::instance().callFailure(id); - removeCall(id); + CallID id = call->getCallId(); + Manager::instance().callFailure(id); + removeCall(id); } //break; //} @@ -522,45 +546,6 @@ SIPVoIPLink::SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata) } } -SIPCall* -SIPVoIPLink::findSIPCallWithCid(int cid) -{ - if (cid < 1) { - _debug("! SIP Error: Not enough information for this event\n"); - return NULL; - } - ost::MutexLock m(_callMapMutex); - SIPCall* call = 0; - CallMap::iterator iter = _callMap.begin(); - while(iter != _callMap.end()) { - call = dynamic_cast<SIPCall*>(iter->second); - if (call && call->getCid() == cid) { - return call; - } - iter++; - } - return NULL; -} - -SIPCall* -SIPVoIPLink::findSIPCallWithCidDid(int cid, int did) -{ - if (cid < 1 && did < -1) { - _debug("! SIP Error: Not enough information for this event\n"); - return NULL; - } - ost::MutexLock m(_callMapMutex); - SIPCall* call = 0; - CallMap::iterator iter = _callMap.begin(); - while(iter != _callMap.end()) { - call = dynamic_cast<SIPCall*>(iter->second); - if (call && call->getCid() == cid && call->getDid() == did) { - return call; - } - iter++; - } - return NULL; -} SIPCall* SIPVoIPLink::getSIPCall(const CallID& id) @@ -571,61 +556,7 @@ SIPVoIPLink::getSIPCall(const CallID& id) } return NULL; } -/* -bool -SIPVoIPLink::handleDtmfRelay(eXosip_event_t* event) { - - SIPCall* call = findSIPCallWithCidDid(event->cid, event->did); - if (call==0) { return false; } - - - bool returnValue = false; - osip_body_t *body = NULL; - // Get the message body - if (0 == osip_message_get_body(event->request, 0, &body) && body->body != 0 ) { - _debug("* SIP Info: Text body: %s\n", body->body); - std::string dtmfBody(body->body); - std::string::size_type posStart = 0; - std::string::size_type posEnd = 0; - std::string signal; - std::string duration; - // search for signal=and duration= - posStart = dtmfBody.find("Signal="); - if (posStart != std::string::npos) { - posStart += strlen("Signal="); - posEnd = dtmfBody.find("\n", posStart); - if (posEnd == std::string::npos) { - posEnd = dtmfBody.length(); - } - signal = dtmfBody.substr(posStart, posEnd-posStart+1); - _debug("* SIP Info: Signal value: %s\n", signal.c_str()); - - if (!signal.empty()) { - if (Manager::instance().isCurrentCall(call->getCallId())) { - Manager::instance().playDtmf(signal[0], true); - returnValue = true; - } - } - - // we receive the duration, but we use our configuration... - - posStart = dtmfBody.find("Duration="); - if (posStart != std::string::npos) { - posStart += strlen("Duration="); - posEnd = dtmfBody.find("\n", posStart); - if (posEnd == std::string::npos) { - posEnd = dtmfBody.length(); - } - duration = dtmfBody.substr(posStart, posEnd-posStart+1); - _debug("Duration value: %s\n", duration.c_str()); - returnValue = true; - } - } - } - return returnValue; -} -*/ /////////////////////////////////////////////////////////////////////////////// // Private functions /////////////////////////////////////////////////////////////////////////////// diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h index fb863c491ab20b61e5034cff70460240a1835503..865703e2151eb4345c40e178b5fa2187aa06230a 100644 --- a/src/sipvoiplink.h +++ b/src/sipvoiplink.h @@ -268,22 +268,6 @@ class SIPVoIPLink : public VoIPLink */ void SIPCallReleased(SIPCall *call); - /** - * Find a SIPCall with cid - * Explication there is no DID when the dialog is not establish... - * @param cid call ID - * @return SIPCall* SIPCall pointer or 0 - */ - SIPCall* findSIPCallWithCid(int cid); - - /** - * Find a SIPCall with cid and did - * @param cid call ID - * @param did domain ID - * @return SIPCall* SIPCall pointer or 0 - */ - SIPCall* findSIPCallWithCidDid(int cid, int did); - /** * SIPCall accessor * @param id The call identifier diff --git a/src/useragent.cpp b/src/useragent.cpp index cb39635f05d2593c5090cd43e6c501a683aa9db1..6e0e104cec4ada90606d980fbf15212e2870e450 100644 --- a/src/useragent.cpp +++ b/src/useragent.cpp @@ -1126,42 +1126,65 @@ void UserAgent::call_on_state_changed(pjsip_inv_session *inv, pjsip_event *e) { } bool UserAgent::onhold(SIPCall *call) { - _debug("UserAgent: Before onhold pjsip_inv_reinite begins!\n"); + pj_status_t status; pjsip_tx_data *tdata; pjmedia_sdp_attr *attr; + pjmedia_sdp_session* local_sdp; + local_sdp = call->getLocalSDPSession(); + if( local_sdp == NULL ){ + _debug("! SIP Failure: unable to find local_sdp\n"); + return false; + } /* Create re-INVITE with new offer */ - pjmedia_sdp_media_remove_all_attr(call->getLocalSDPSession()->media[0], "sendrecv"); + // Remove all the attributes with the specified name + pjmedia_sdp_media_remove_all_attr(local_sdp->media[0], "sendrecv"); attr = pjmedia_sdp_attr_create(_pool, "sendonly", NULL); - pjmedia_sdp_media_add_attr(call->getLocalSDPSession()->media[0], attr); + pjmedia_sdp_media_add_attr(local_sdp->media[0], attr); - status = pjsip_inv_reinvite( call->getInvSession(), NULL, call->getLocalSDPSession(), &tdata); + status = pjsip_inv_reinvite( call->getInvSession(), NULL, local_sdp, &tdata); + if( status != PJ_SUCCESS ) + { + _debug("On hold: creation of the Re-invite request failed\n"); + return false; + } /* Send the request */ status = pjsip_inv_send_msg( call->getInvSession(), tdata); - _debug("UserAgent: After pjsip_inv_reinite begins!\n"); return (status == PJ_SUCCESS); } bool UserAgent::offhold(SIPCall *call) { - _debug("UserAgent: Before offhold pjsip_inv_reinite begins!\n"); + pj_status_t status; pjsip_tx_data *tdata; pjmedia_sdp_attr *attr; + pjmedia_sdp_session* local_sdp; + local_sdp = call->getLocalSDPSession(); + if( local_sdp == NULL ){ + _debug("! SIP Failure: unable to find local_sdp\n"); + return false; + } /* Create re-INVITE with new offer */ - pjmedia_sdp_media_remove_all_attr(call->getLocalSDPSession()->media[0], "sendonly"); + // Remove all the attributes with the specified name + pjmedia_sdp_media_remove_all_attr(local_sdp->media[0], "sendonly"); attr = pjmedia_sdp_attr_create(_pool, "sendrecv", NULL); - pjmedia_sdp_media_add_attr(call->getLocalSDPSession()->media[0], attr); + pjmedia_sdp_media_add_attr(local_sdp->media[0], attr); + + status = pjsip_inv_reinvite( call->getInvSession(), NULL, local_sdp , &tdata); + if( status != PJ_SUCCESS ) + { + _debug("Off hold: creation of the Re-invite request failed\n"); + return false; + } - status = pjsip_inv_reinvite( call->getInvSession(), NULL, call->getLocalSDPSession(), &tdata); /* Send the request */ status = pjsip_inv_send_msg( call->getInvSession(), tdata); - _debug("UserAgent: After pjsip_inv_reinite begins!\n"); return (status == PJ_SUCCESS); } @@ -1172,16 +1195,16 @@ bool UserAgent::hangup(SIPCall* call) { // User hangup current call. Notify peer status = pjsip_inv_end_session(call->getInvSession(), 404, NULL, &tdata); if(status != PJ_SUCCESS) - return false; + return false; _debug("UserAgent: Before send msg!\n"); if(tdata == NULL) - return true; + return true; status = pjsip_inv_send_msg(call->getInvSession(), tdata); if(status != PJ_SUCCESS) - return false; + return false; call->getInvSession()->mod_data[getInstance()->getModId()] = NULL; return true; @@ -1194,10 +1217,12 @@ bool UserAgent::refuse(SIPCall* call) // User refuse current call. Notify peer status = pjsip_inv_end_session(call->getInvSession(), PJSIP_SC_DECLINE, NULL, &tdata); //603 - PJ_ASSERT_RETURN(status == PJ_SUCCESS, false); + if(status != PJ_SUCCESS) + return false; status = pjsip_inv_send_msg(call->getInvSession(), tdata); - PJ_ASSERT_RETURN(status == PJ_SUCCESS, false); + if(status != PJ_SUCCESS) + return false; call->getInvSession()->mod_data[getInstance()->getModId()] = NULL; return true; @@ -1253,9 +1278,6 @@ bool UserAgent::transfer(SIPCall *call, const std::string& to) { pjsip_evsub *sub; pjsip_tx_data *tdata; - //pjsip_dialog *dlg; - //pjsip_generic_string_hdr *gs_hdr; - //const pj_str_t str_ref_by = { (char*)"Referred-By", 11 }; struct pjsip_evsub_user xfer_cb; pj_status_t status; pj_str_t dest; diff --git a/test/Makefile.am b/test/Makefile.am index 14411aa140bbc3264308b27f0cd418287544821c..86e70dbc38e76a6fda92b43be969afd51e260781 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ include ../globals.mak -bin_PROGRAMS = configurationTester +bin_PROGRAMS = configurationTester pluginmanagerTester OBJECT_FILES= \ ../src/sflphoned-managerimpl.o \ @@ -16,6 +16,7 @@ OBJECT_FILES= \ ../src/sflphoned-iaxaccount.o \ ../src/sflphoned-eventthread.o \ ../src/sflphoned-useragent.o \ + ../src/plug-in/pluginmanager.o \ ../src/sflphoned-samplerateconverter.o configurationTester_SOURCES = \ @@ -23,6 +24,11 @@ configurationTester_SOURCES = \ configurationTest.h \ TestMain.cpp +pluginmanagerTester_SOURCES = \ + pluginmanagerTest.h \ + pluginmanagerTest.cpp \ + TestMain.cpp + configurationTester_LDADD = \ ../src/libsflphone.la \ $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) \ @@ -36,4 +42,18 @@ configurationTester_LDADD = \ @SAMPLERATE_LIBS@ \ $(PJSIP_LIBS) \ $(OBJECT_FILES) - + +pluginmanagerTester_LDADD = \ + ../src/libsflphone.la \ + $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) \ + @ALSA_LIBS@ \ + @PULSEAUDIO_LIBS@ \ + @CPPUNIT_LIBS@ \ + @CCEXT2_LIBS@ \ + @CCGNU2_LIBS@ \ + @CCRTP_LIBS@ \ + @DBUSCPP_LIBS@ \ + @SAMPLERATE_LIBS@ \ + $(PJSIP_LIBS) \ + $(OBJECT_FILES) + diff --git a/test/pluginmanagerTest.cpp b/test/pluginmanagerTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b9a3d413a400d422a7510963d36124ba1d026e14 --- /dev/null +++ b/test/pluginmanagerTest.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Savoir-Faire Linux inc. + * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <sstream> + +#include "pluginmanagerTest.h" + +using std::cout; +using std::endl; + +void PluginManagerTest::setUp(){ + // Instanciate the plugin manager object + _pm = new ::sflphone::PluginManager(); +} + +void PluginManagerTest::testLoadPluginDirectory(){ + _pm->loadPlugins(); +} + +void PluginManagerTest::testNonloadedPlugin(){ + CPPUNIT_ASSERT( _pm->isPluginLoaded("test") == NULL ); +} + +void PluginManagerTest::tearDown(){ + // Delete the plugin manager object + delete _pm; _pm=NULL; +} diff --git a/test/pluginmanagerTest.h b/test/pluginmanagerTest.h new file mode 100644 index 0000000000000000000000000000000000000000..e43ba8f7ab09262243fddd3edc21130ddca5dd80 --- /dev/null +++ b/test/pluginmanagerTest.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Savoir-Faire Linux inc. + * Author: Emmanuel Milou <emmanuel.milou@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. + */ + +// Cppunit import +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCaller.h> +#include <cppunit/TestCase.h> +#include <cppunit/TestSuite.h> + +#include <assert.h> + +// Application import +#include "plug-in/pluginmanager.h" + +/* + * @file pluginManagerTest.cpp + * @brief Regroups unitary tests related to the plugin manager. + */ + +#ifndef _PLUGINMANAGER_TEST_ +#define _PLUGINMANAGER_TEST_ + +class PluginManagerTest : public CppUnit::TestCase { + + /* + * Use cppunit library macros to add unit test the factory + */ + CPPUNIT_TEST_SUITE( PluginManagerTest ); + CPPUNIT_TEST( testLoadPluginDirectory ); + CPPUNIT_TEST( testNonloadedPlugin ); + CPPUNIT_TEST_SUITE_END(); + + public: + PluginManagerTest() : CppUnit::TestCase("Plugin Manager Tests") {} + + /* + * Code factoring - Common resources can be initialized here. + * This method is called by unitcpp before each test + */ + void setUp(); + + /* + * Code factoring - Common resources can be released here. + * This method is called by unitcpp after each test + */ + inline void tearDown(); + + void testLoadPluginDirectory(); + + void testNonloadedPlugin(); + + private: + ::sflphone::PluginManager *_pm; +}; + +/* Register our test module */ +CPPUNIT_TEST_SUITE_REGISTRATION( PluginManagerTest ); + +#endif