Merge branch 'single-user' into dev
This commit is contained in:
commit
ef7e09a372
@ -121,11 +121,14 @@ void ProfileStore::_parseProfiles ()
|
|||||||
Glib::ustring p2 = options.getGlobalProfilePath();
|
Glib::ustring p2 = options.getGlobalProfilePath();
|
||||||
bool displayLevel0 = options.useBundledProfiles && !p1.empty() && !p2.empty() && p1 != p2;
|
bool displayLevel0 = options.useBundledProfiles && !p1.empty() && !p2.empty() && p1 != p2;
|
||||||
|
|
||||||
Glib::ustring virtualPath ("${U}");
|
Glib::ustring virtualPath;
|
||||||
Glib::ustring currDir ("${U}");
|
Glib::ustring currDir;
|
||||||
parseDir (p1, virtualPath, currDir, 0, 0, displayLevel0);
|
if (!p1.empty()) {
|
||||||
|
virtualPath = "${U}";
|
||||||
if (displayLevel0) {
|
currDir = "${U}";
|
||||||
|
parseDir (p1, virtualPath, currDir, 0, 0, displayLevel0);
|
||||||
|
}
|
||||||
|
if (p1.empty() || displayLevel0) {
|
||||||
virtualPath = "${G}";
|
virtualPath = "${G}";
|
||||||
currDir = "${G}";
|
currDir = "${G}";
|
||||||
parseDir (p2, virtualPath, currDir, 0, 0, displayLevel0);
|
parseDir (p2, virtualPath, currDir, 0, 0, displayLevel0);
|
||||||
|
@ -628,20 +628,19 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
Glib::ustring fatalError;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Options::load();
|
Options::load();
|
||||||
} catch (Options::Error &e) {
|
} catch (Options::Error &e) {
|
||||||
std::cout << "ERROR: " << e.get_msg() << std::endl;
|
fatalError = e.get_msg();
|
||||||
std::cerr << "Fatal error!" << std::endl;
|
|
||||||
std::cerr << "The RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!" << std::endl;
|
|
||||||
return -2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave)));
|
gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave)));
|
||||||
gdk_threads_init();
|
gdk_threads_init();
|
||||||
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal
|
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal
|
||||||
|
|
||||||
if (remote) {
|
if (fatalError.empty() && remote) {
|
||||||
char *app_argv[2] = { const_cast<char *> (argv0.c_str()) };
|
char *app_argv[2] = { const_cast<char *> (argv0.c_str()) };
|
||||||
int app_argc = 1;
|
int app_argc = 1;
|
||||||
|
|
||||||
@ -653,7 +652,7 @@ int main (int argc, char **argv)
|
|||||||
RTApplication app;
|
RTApplication app;
|
||||||
ret = app.run (app_argc, app_argv);
|
ret = app.run (app_argc, app_argv);
|
||||||
} else {
|
} else {
|
||||||
if (init_rt()) {
|
if (fatalError.empty() && init_rt()) {
|
||||||
Gtk::Main m (&argc, &argv);
|
Gtk::Main m (&argc, &argv);
|
||||||
gdk_threads_enter();
|
gdk_threads_enter();
|
||||||
const std::unique_ptr<RTWindow> rtWindow (create_rt_window());
|
const std::unique_ptr<RTWindow> rtWindow (create_rt_window());
|
||||||
@ -679,7 +678,7 @@ int main (int argc, char **argv)
|
|||||||
cleanup_rt();
|
cleanup_rt();
|
||||||
} else {
|
} else {
|
||||||
Gtk::Main m (&argc, &argv);
|
Gtk::Main m (&argc, &argv);
|
||||||
Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
Gtk::MessageDialog msgd (Glib::ustring::compose("FATAL ERROR!\n\n%1", fatalError), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
msgd.run ();
|
msgd.run ();
|
||||||
ret = -2;
|
ret = -2;
|
||||||
}
|
}
|
||||||
|
@ -102,60 +102,48 @@ void Options::updatePaths()
|
|||||||
g_mkdir_with_parents (profilePath.c_str (), 511);
|
g_mkdir_with_parents (profilePath.c_str (), 511);
|
||||||
|
|
||||||
if (!checkDirPath (profilePath, "")) { // had problems with mkdir_with_parents return value on OS X, just check dir again
|
if (!checkDirPath (profilePath, "")) { // had problems with mkdir_with_parents return value on OS X, just check dir again
|
||||||
printf ("Error: user's profiles' directory \"%s\" creation failed\n", profilePath.c_str());
|
Glib::ustring msg = Glib::ustring::compose ("Creation of the user's processing profile directory \"%1\" failed!\n", profilePath);
|
||||||
|
throw Error (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkDirPath (profilePath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) {
|
if (checkDirPath (profilePath, "Error: the user's processing profile path doesn't point to a directory or doesn't exist!\n")) {
|
||||||
if (multiUser) {
|
userProfilePath = profilePath;
|
||||||
userProfilePath = profilePath;
|
tmpPath = Glib::build_filename (argv0, "profiles");
|
||||||
tmpPath = Glib::build_filename (argv0, "profiles");
|
|
||||||
|
|
||||||
if (checkDirPath (tmpPath, "Error: the global's profiles' path doesn't point to a directory or doesn't exist!\n")) {
|
if (checkDirPath (tmpPath, "Error: the global's processing profile path doesn't point to a directory or doesn't exist!\n")) {
|
||||||
if (userProfilePath != tmpPath) {
|
if (userProfilePath != tmpPath) {
|
||||||
globalProfilePath = tmpPath;
|
globalProfilePath = tmpPath;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
globalProfilePath = profilePath;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmpPath = Glib::build_filename (argv0, "profiles");
|
tmpPath = Glib::build_filename (argv0, "profiles");
|
||||||
|
|
||||||
if (checkDirPath (tmpPath, "Error: the global's profiles' path doesn't point to a directory or doesn't exist!\n")) {
|
if (checkDirPath (tmpPath, "Error: the global's processing profile path doesn't point to a directory or doesn't exist!\n")) {
|
||||||
globalProfilePath = tmpPath;
|
globalProfilePath = tmpPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// relative paths
|
// relative paths
|
||||||
if (multiUser) {
|
tmpPath = Glib::build_filename (rtdir, profilePath);
|
||||||
tmpPath = Glib::build_filename (rtdir, profilePath);
|
|
||||||
|
if (!checkDirPath (tmpPath, "")) {
|
||||||
|
g_mkdir_with_parents (tmpPath.c_str (), 511);
|
||||||
|
|
||||||
if (!checkDirPath (tmpPath, "")) {
|
if (!checkDirPath (tmpPath, "")) {
|
||||||
g_mkdir_with_parents (tmpPath.c_str (), 511);
|
Glib::ustring msg = Glib::ustring::compose ("Creation of the user's processing profile directory \"%1\" failed!\n", tmpPath.c_str());
|
||||||
|
throw Error (msg);
|
||||||
if (!checkDirPath (tmpPath, "")) {
|
|
||||||
printf ("Error: user's profiles' directory \"%s\" creation failed\n", tmpPath.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (checkDirPath (tmpPath, "Error: the specified user's profiles' path doesn't point to a directory!\n")) {
|
if (checkDirPath (tmpPath, "Error: the user's processing profile path doesn't point to a directory!\n")) {
|
||||||
userProfilePath = tmpPath;
|
userProfilePath = tmpPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpPath = Glib::build_filename (argv0, "profiles");
|
tmpPath = Glib::build_filename (argv0, "profiles");
|
||||||
|
|
||||||
if (checkDirPath (tmpPath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) {
|
if (checkDirPath (tmpPath, "Error: the user's processing profile path doesn't point to a directory or doesn't exist!\n")) {
|
||||||
globalProfilePath = tmpPath;
|
globalProfilePath = tmpPath;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// common directory
|
|
||||||
// directory name set in options is ignored, we use the default directory name
|
|
||||||
tmpPath = Glib::build_filename (argv0, "profiles");
|
|
||||||
|
|
||||||
if (checkDirPath (tmpPath, "Error: no global profiles' directory found!\n")) {
|
|
||||||
globalProfilePath = tmpPath;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2133,7 +2121,7 @@ void Options::load (bool lightweight)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the cache folder in RT's base folder
|
// Set the cache folder in RT's base folder
|
||||||
cacheBaseDir = Glib::build_filename (argv0, "cache");
|
cacheBaseDir = Glib::build_filename (argv0, "mycache");
|
||||||
|
|
||||||
// Read the global option file (the one located in the application's base folder)
|
// Read the global option file (the one located in the application's base folder)
|
||||||
try {
|
try {
|
||||||
@ -2142,6 +2130,10 @@ void Options::load (bool lightweight)
|
|||||||
// ignore errors here
|
// ignore errors here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!options.multiUser && path == nullptr) {
|
||||||
|
rtdir = Glib::build_filename (argv0, "mysettings");
|
||||||
|
}
|
||||||
|
|
||||||
// Modify the path of the cache folder to the one provided in RT_CACHE environment variable
|
// Modify the path of the cache folder to the one provided in RT_CACHE environment variable
|
||||||
path = g_getenv ("RT_CACHE");
|
path = g_getenv ("RT_CACHE");
|
||||||
|
|
||||||
@ -2153,7 +2145,7 @@ void Options::load (bool lightweight)
|
|||||||
throw Error (msg);
|
throw Error (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No environment variable provided, so falling back to the multi user mode, is enabled
|
// No environment variable provided, so falling back to the multi user mode, if enabled
|
||||||
else if (options.multiUser) {
|
else if (options.multiUser) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
cacheBaseDir = Glib::build_filename (rtdir, "cache");
|
cacheBaseDir = Glib::build_filename (rtdir, "cache");
|
||||||
@ -2162,25 +2154,24 @@ void Options::load (bool lightweight)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if RT is installed in Multi-User mode
|
// Read the user option file (the one located somewhere in the user's home folder)
|
||||||
if (options.multiUser) {
|
// Those values supersets those of the global option file
|
||||||
// Read the user option file (the one located somewhere in the user's home folder)
|
try {
|
||||||
// Those values supersets those of the global option file
|
options.readFromFile (Glib::build_filename (rtdir, "options"));
|
||||||
try {
|
} catch (Options::Error &) {
|
||||||
options.readFromFile (Glib::build_filename (rtdir, "options"));
|
// If the local option file does not exist or is broken, and the local cache folder does not exist, recreate it
|
||||||
} catch (Options::Error &) {
|
if (!g_mkdir_with_parents (rtdir.c_str (), 511)) {
|
||||||
// If the local option file does not exist or is broken, and the local cache folder does not exist, recreate it
|
// Save the option file
|
||||||
if (!g_mkdir_with_parents (rtdir.c_str (), 511)) {
|
options.saveToFile (Glib::build_filename (rtdir, "options"));
|
||||||
// Save the option file
|
|
||||||
options.saveToFile (Glib::build_filename (rtdir, "options"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
if (options.multiUser) {
|
||||||
// make sure .local/share exists on OS X so we don't get problems with recently-used.xbel
|
// make sure .local/share exists on OS X so we don't get problems with recently-used.xbel
|
||||||
g_mkdir_with_parents (g_get_user_data_dir(), 511);
|
g_mkdir_with_parents (g_get_user_data_dir(), 511);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf ("Cache directory (cacheBaseDir) = %s\n", cacheBaseDir.c_str());
|
printf ("Cache directory (cacheBaseDir) = %s\n", cacheBaseDir.c_str());
|
||||||
@ -2275,11 +2266,7 @@ void Options::load (bool lightweight)
|
|||||||
void Options::save ()
|
void Options::save ()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!options.multiUser) {
|
options.saveToFile (Glib::build_filename (rtdir, "options"));
|
||||||
options.saveToFile (Glib::build_filename (argv0, "options"));
|
|
||||||
} else {
|
|
||||||
options.saveToFile (Glib::build_filename (rtdir, "options"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user