project: rename package to "jami", migrate config files

Change-Id: I5c7d429bd32aa22bd4c7ad0914a7581176c2ccdd
This commit is contained in:
Adrien Béraud
2019-03-21 17:38:30 -04:00
parent 27625f2aaf
commit 3d4724cdc1
7 changed files with 53 additions and 17 deletions

View File

@ -54,7 +54,7 @@ print_title()
{
std::cout
<< "Jami Daemon " << DRing::version()
<< ", by Savoir-faire Linux 2004-2018" << std::endl
<< ", by Savoir-faire Linux 2004-2019" << std::endl
<< "https://jami.net/" << std::endl
#ifdef RING_VIDEO
<< "[Video support enabled]" << std::endl

View File

@ -43,7 +43,7 @@ print_title()
{
std::cout
<< "Jami Daemon " << DRing::version()
<< ", by Savoir-faire Linux 2004-2018" << std::endl
<< ", by Savoir-faire Linux 2004-2019" << std::endl
<< "https://jami.net/" << std::endl
#ifdef RING_VIDEO
<< "[Video support enabled]" << std::endl

View File

@ -47,7 +47,7 @@ print_title()
{
std::cout
<< "Jami Daemon " << DRing::version()
<< ", by Savoir-faire Linux 2004-2018" << std::endl
<< ", by Savoir-faire Linux 2004-2019" << std::endl
<< "https://jami.net/" << std::endl
#ifdef RING_VIDEO
<< "[Video support enabled]" << std::endl

View File

@ -2,9 +2,9 @@ dnl Jami - configure.ac for automake 1.9 and autoconf 2.59
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([Ring Daemon],[7.5.0],[ring@gnu.org],[ring])
AC_INIT([Jami Daemon],[7.5.0],[ring@gnu.org],[jami])
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]])
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2019]])
AC_REVISION([$Revision$])
dnl Where to find configure files

View File

@ -500,7 +500,7 @@ void set_program_dir(char *program_path)
#endif
std::string
get_cache_dir()
get_cache_dir(const char* pkg)
{
#ifdef RING_UWP
std::vector<std::string> paths;
@ -530,16 +530,22 @@ get_cache_dir()
#elif defined(__APPLE__)
return get_home_dir() + DIR_SEPARATOR_STR
+ "Library" + DIR_SEPARATOR_STR + "Caches"
+ DIR_SEPARATOR_STR + PACKAGE;
+ DIR_SEPARATOR_STR + pkg;
#else
return get_home_dir() + DIR_SEPARATOR_STR +
".cache" + DIR_SEPARATOR_STR + PACKAGE;
".cache" + DIR_SEPARATOR_STR + pkg;
#endif
#ifndef RING_UWP
}
#endif
}
std::string
get_cache_dir()
{
return get_cache_dir(PACKAGE);
}
std::string
get_home_dir()
{
@ -585,7 +591,7 @@ get_home_dir()
}
std::string
get_data_dir()
get_data_dir(const char* pkg)
{
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
std::vector<std::string> paths;
@ -596,7 +602,7 @@ get_data_dir()
#elif defined(__APPLE__)
return get_home_dir() + DIR_SEPARATOR_STR
+ "Library" + DIR_SEPARATOR_STR + "Application Support"
+ DIR_SEPARATOR_STR + PACKAGE;
+ DIR_SEPARATOR_STR + pkg;
#elif defined (RING_UWP)
std::vector<std::string> paths;
emitSignal<DRing::ConfigurationSignal::GetAppDataPath>("", &paths);
@ -612,16 +618,22 @@ get_data_dir()
#else
const std::string data_home(XDG_DATA_HOME);
if (not data_home.empty())
return data_home + DIR_SEPARATOR_STR + PACKAGE;
return data_home + DIR_SEPARATOR_STR + pkg;
// "If $XDG_DATA_HOME is either not set or empty, a default equal to
// $HOME/.local/share should be used."
return get_home_dir() + DIR_SEPARATOR_STR ".local" DIR_SEPARATOR_STR
"share" DIR_SEPARATOR_STR + PACKAGE;
"share" DIR_SEPARATOR_STR + pkg;
#endif
}
std::string
get_config_dir()
get_data_dir()
{
return get_data_dir(PACKAGE);
}
std::string
get_config_dir(const char* pkg)
{
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
std::vector<std::string> paths;
@ -646,14 +658,14 @@ get_config_dir()
#if defined(__APPLE__)
std::string configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR
+ "Library" + DIR_SEPARATOR_STR + "Application Support"
+ DIR_SEPARATOR_STR + PACKAGE;
+ DIR_SEPARATOR_STR + pkg;
#else
std::string configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR +
".config" + DIR_SEPARATOR_STR + PACKAGE;
".config" + DIR_SEPARATOR_STR + pkg;
#endif
const std::string xdg_env(XDG_CONFIG_HOME);
if (not xdg_env.empty())
configdir = xdg_env + DIR_SEPARATOR_STR + PACKAGE;
configdir = xdg_env + DIR_SEPARATOR_STR + pkg;
if (fileutils::recursive_mkdir(configdir.data(), 0700) != true) {
// If directory creation failed
@ -664,6 +676,12 @@ get_config_dir()
#endif
}
std::string
get_config_dir()
{
return get_config_dir(PACKAGE);
}
bool
recursive_mkdir(const std::string& path, mode_t mode)
{

View File

@ -56,6 +56,10 @@
namespace ring { namespace fileutils {
std::string get_home_dir();
std::string get_config_dir(const char* pkg);
std::string get_data_dir(const char* pkg);
std::string get_cache_dir(const char* pkg);
std::string get_config_dir();
std::string get_data_dir();
std::string get_cache_dir();

View File

@ -107,6 +107,7 @@ using ConferenceMap = std::map<std::string, std::shared_ptr<Conference>>;
using CallIDSet = std::set<std::string>;
static constexpr int ICE_INIT_TIMEOUT {10};
static constexpr const char* PACKAGE_OLD = "ring";
std::atomic_bool Manager::initialized = {false};
@ -136,6 +137,15 @@ restore_backup(const std::string &path)
copy_over(backup_path, path);
}
void
check_rename(const std::string& old_dir, const std::string& new_dir)
{
if (old_dir != new_dir and fileutils::isDirectory(old_dir) and not fileutils::isDirectory(new_dir)) {
RING_WARN() << "Migrating" << old_dir << " to " << new_dir;
std::rename(old_dir.c_str(), new_dir.c_str());
}
}
/**
* Set OpenDHT's log level based on the DHTLOGLEVEL environment variable.
* DHTLOGLEVEL = 0 minimum logging (=disable)
@ -687,7 +697,7 @@ Manager::init(const std::string &config_file)
throw std::runtime_error(#ret " failed"); \
} while (0)
srand(time(NULL)); // to get random number for RANDOM_PORT
srand(time(nullptr)); // to get random number for RANDOM_PORT
// Initialize PJSIP (SIP and ICE implementation)
PJSIP_TRY(pj_init());
@ -704,6 +714,10 @@ Manager::init(const std::string &config_file)
setDhtLogLevel();
check_rename(fileutils::get_cache_dir(PACKAGE_OLD), fileutils::get_cache_dir());
check_rename(fileutils::get_data_dir(PACKAGE_OLD), fileutils::get_data_dir());
check_rename(fileutils::get_config_dir(PACKAGE_OLD), fileutils::get_config_dir());
pimpl_->ice_tf_.reset(new IceTransportFactory());
pimpl_->path_ = config_file.empty() ? pimpl_->retrieveConfigPath() : config_file;