diff --git a/sflphone-common/src/Makefile.am b/sflphone-common/src/Makefile.am index adc562ece445ab2c00f0bb01dda8436d70fbed03..3b2eef2031840db651aaaff54afbcfa3d571c6fb 100644 --- a/sflphone-common/src/Makefile.am +++ b/sflphone-common/src/Makefile.am @@ -20,7 +20,8 @@ sflphoned_SOURCES = \ call.cpp \ account.cpp \ logger.cpp \ - numbercleaner.cpp + numbercleaner.cpp \ + fileutils.cpp # Redefine the USE_IAX variable here, so that it could be used in managerimpl if USE_IAX @@ -58,7 +59,8 @@ noinst_HEADERS = \ accountcreator.h \ call.h \ logger.h \ - numbercleaner.h + numbercleaner.h \ + fileutils.h libsflphone_la_LIBADD = \ $(src)/libs/utilspp/libutilspp.la \ diff --git a/sflphone-common/src/audio/codecs/audiocodecfactory.cpp b/sflphone-common/src/audio/codecs/audiocodecfactory.cpp index 51d73e2cbc1db880f70df8f4b4d572a35570c550..a38c3535ad52ab4650f636771760cf4324abd003 100644 --- a/sflphone-common/src/audio/codecs/audiocodecfactory.cpp +++ b/sflphone-common/src/audio/codecs/audiocodecfactory.cpp @@ -35,6 +35,7 @@ #include <cstdlib> #include "audiocodecfactory.h" +#include "fileutils.h" AudioCodecFactory::AudioCodecFactory() : _CodecsMap(), _defaultCodecOrder(), _Cache(), _nbCodecs(), _CodecInMemory() @@ -192,11 +193,13 @@ std::vector<sfl::Codec*> AudioCodecFactory::scanCodecDirectory (void) std::string libDir = std::string (CODECS_DIR).append ("/"); std::string homeDir = std::string (HOMEDIR) + DIR_SEPARATOR_STR + "." + PROGDIR + "/"; + std::string srcDir = std::string(get_program_dir()) + DIR_SEPARATOR_STR + "audio/codecs/"; // look for a CODECS_PATH environment variable...used in tests const char *envDir = getenv("CODECS_PATH"); std::vector<std::string> dirToScan; dirToScan.push_back (homeDir); dirToScan.push_back (libDir); + dirToScan.push_back (srcDir); if (envDir) dirToScan.push_back(std::string(envDir) + DIR_SEPARATOR_STR); diff --git a/sflphone-common/src/fileutils.cpp b/sflphone-common/src/fileutils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1aae61bb1301a1d1ccd141a7fb45f2eb7069fad4 --- /dev/null +++ b/sflphone-common/src/fileutils.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 Savoir-Faire Linux Inc. + * Author: Rafaël Carré <rafael.carre@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 <libgen.h> + +static char *program_dir; + +void set_program_dir(char *program_path) +{ + program_dir = dirname(program_path); +} + +const char *get_program_dir(void) +{ + return program_dir; +} diff --git a/sflphone-common/src/fileutils.h b/sflphone-common/src/fileutils.h new file mode 100644 index 0000000000000000000000000000000000000000..364e80a23323f75729edc6ba3ecab90b18fab803 --- /dev/null +++ b/sflphone-common/src/fileutils.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011 Savoir-Faire Linux Inc. + * Author: Rafaël Carré <rafael.carre@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 __FILEUTILS_H__ +#define __FILEUTILS_H__ + +void set_program_dir(char *program_path); +const char *get_program_dir(void); + +#endif // __FILEUTILS_H__ diff --git a/sflphone-common/src/main.cpp b/sflphone-common/src/main.cpp index ff8fa6261c74dbb1082fe03cc2bcd9984bb02cd2..414ca3558642385792be3a45114260429c2f0e77 100644 --- a/sflphone-common/src/main.cpp +++ b/sflphone-common/src/main.cpp @@ -39,6 +39,7 @@ #include <sys/stat.h> #include <cc++/common.h> #include "global.h" +#include "fileutils.h" #include "dbus/dbusmanager.h" #include "manager.h" @@ -66,6 +67,8 @@ CommandOptionNoArg help ( int main (int argc, char **argv) { + set_program_dir(argv[0]); + int exit_code = 0; Logger::setConsoleLog (false); diff --git a/sflphone-common/test/run_daemon.sh b/sflphone-common/test/run_daemon.sh deleted file mode 100755 index bf350c0b163e4a80362f4a28e7c8ae4d64b33daa..0000000000000000000000000000000000000000 --- a/sflphone-common/test/run_daemon.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -CODECS_PATH="../src/audio/codecs" ../src/sflphoned -d -c