From 734f90bd36f520c0d08f37a5cf5e0fb08f96b152 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 24 Oct 2022 21:41:08 +0200 Subject: [PATCH] Replace string literal 'gnucash' with PROJECT_NAME parameter where it makes sense The idea behind this is to not assume the project is always built as "gnucash" exactly. One example where it can be useful to use a different project name would be when building multiple development versions of the project on the same system and don't want these different versions share the same settings in GSettings or the same stored passwords. --- gnucash/gnome-utils/dialog-file-access.c | 2 +- gnucash/gnome-utils/gnc-keyring.c | 12 ++++++------ gnucash/gnucash-cli.cpp | 3 ++- gnucash/gnucash.cpp | 4 ++-- gnucash/import-export/aqb/gnc-ab-utils.c | 2 +- .../backend/dbi/test/test-backend-dbi-basic.cpp | 2 +- libgnucash/core-utils/gnc-path.c | 12 ++++++------ libgnucash/core-utils/test/gtest-path-utilities.cpp | 4 ++-- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c index 50f5b4f135..2082df65e1 100644 --- a/gnucash/gnome-utils/dialog-file-access.c +++ b/gnucash/gnome-utils/dialog-file-access.c @@ -39,7 +39,7 @@ static QofLogModule log_module = GNC_MOD_GUI; #define DEFAULT_HOST "localhost" -#define DEFAULT_DATABASE "gnucash" +#define DEFAULT_DATABASE PROJECT_NAME #define FILE_ACCESS_OPEN 0 #define FILE_ACCESS_SAVE_AS 1 #define FILE_ACCESS_EXPORT 2 diff --git a/gnucash/gnome-utils/gnc-keyring.c b/gnucash/gnome-utils/gnc-keyring.c index 99d5b9c3ca..4bb72d9493 100644 --- a/gnucash/gnome-utils/gnc-keyring.c +++ b/gnucash/gnome-utils/gnc-keyring.c @@ -200,14 +200,14 @@ gboolean gnc_keyring_get_password ( GtkWidget *parent, * referenced above. */ secret_password_store_sync (SECRET_SCHEMA_GNUCASH, SECRET_COLLECTION_DEFAULT, "Dummy password", "dummy", NULL, &error, - "protocol", "gnucash", - "server", "gnucash", - "user", "gnucash", + "protocol", PROJECT_NAME, + "server", PROJECT_NAME, + "user", PROJECT_NAME, NULL); secret_password_clear_sync (SECRET_SCHEMA_GNUCASH, NULL, &error, - "protocol", "gnucash", - "server", "gnucash", - "user", "gnucash", + "protocol", PROJECT_NAME, + "server", PROJECT_NAME, + "user", PROJECT_NAME, NULL); /* Note: only use the port attribute if it was set by the user. */ diff --git a/gnucash/gnucash-cli.cpp b/gnucash/gnucash-cli.cpp index f81cc3cca3..edcf33d6ca 100644 --- a/gnucash/gnucash-cli.cpp +++ b/gnucash/gnucash-cli.cpp @@ -226,7 +226,8 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a int main(int argc, char **argv) { - Gnucash::GnucashCli application (argv[0]); + const char *app_name = PROJECT_NAME "-cli"; + Gnucash::GnucashCli application (app_name); #ifdef __MINGW32__ boost::nowide::args a(argc, argv); // Fix arguments - make them UTF-8 #endif diff --git a/gnucash/gnucash.cpp b/gnucash/gnucash.cpp index ddaa09a479..669f152fcd 100644 --- a/gnucash/gnucash.cpp +++ b/gnucash/gnucash.cpp @@ -287,7 +287,7 @@ Gnucash::Gnucash::configure_program_options (void) // for gtk's options. The options themselves are already parsed out by // gtk_init_check by the time this function is called though. So it really only // serves to be able to display a help message. - g_set_prgname ("gnucash"); + g_set_prgname (PROJECT_NAME); auto context = g_option_context_new (m_tagline.c_str()); auto gtk_options = gtk_get_option_group(FALSE); g_option_context_add_group (context, gtk_options); @@ -357,7 +357,7 @@ Gnucash::Gnucash::start ([[maybe_unused]] int argc, [[maybe_unused]] char **argv int main(int argc, char ** argv) { - Gnucash::Gnucash application (argv[0]); + Gnucash::Gnucash application (PROJECT_NAME); #ifdef __MINGW32__ boost::nowide::args a(argc, argv); // Fix arguments - make them UTF-8 #endif diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c index 861edc0802..e9727ff239 100644 --- a/gnucash/import-export/aqb/gnc-ab-utils.c +++ b/gnucash/import-export/aqb/gnc-ab-utils.c @@ -176,7 +176,7 @@ gnc_AB_BANKING_new (void) } else { - api = AB_Banking_new ("gnucash", NULL, 0); + api = AB_Banking_new (PROJECT_NAME, NULL, 0); g_return_val_if_fail (api, NULL); /* These two values must be set because newest bank regulation requires diff --git a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp index b23e69a33d..75a86ed749 100644 --- a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp +++ b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp @@ -233,7 +233,7 @@ setup_business (Fixture* fixture, gconstpointer pData) emp = gncEmployeeCreate (book); gncEmployeeSetID (emp, "0001"); - gncEmployeeSetUsername (emp, "gnucash"); + gncEmployeeSetUsername (emp, PROJECT_NAME); gncEmployeeSetLanguage (emp, "english"); gncEmployeeSetCurrency (emp, currency); diff --git a/libgnucash/core-utils/gnc-path.c b/libgnucash/core-utils/gnc-path.c index eb362a4c26..99adef2799 100644 --- a/libgnucash/core-utils/gnc-path.c +++ b/libgnucash/core-utils/gnc-path.c @@ -69,7 +69,7 @@ gchar *gnc_path_get_datadir() gchar *gnc_path_get_pkgdatadir() { gchar *datadir = gnc_gbr_find_data_dir (DATADIR); - gchar *result = g_build_filename (datadir, "gnucash", (char*)NULL); + gchar *result = g_build_filename (datadir, PROJECT_NAME, (char*)NULL); g_free (datadir); //printf("Returning pkgdatadir %s\n", result); return result; @@ -82,7 +82,7 @@ gchar *gnc_path_get_pkgdatadir() gchar *gnc_path_get_pkgdocdir() { gchar *docdir = gnc_gbr_find_data_dir (DATADIR); - gchar *result = g_build_filename (docdir, "doc", "gnucash", (char*)NULL); + gchar *result = g_build_filename (docdir, "doc", PROJECT_NAME, (char*)NULL); g_free (docdir); //printf("Returning pkgdocdir %s\n", result); return result; @@ -95,7 +95,7 @@ gchar *gnc_path_get_pkgdocdir() gchar *gnc_path_get_pkgsysconfdir() { gchar *sysconfdir = gnc_gbr_find_etc_dir (SYSCONFDIR); - gchar *result = g_build_filename (sysconfdir, "gnucash", (char*)NULL); + gchar *result = g_build_filename (sysconfdir, PROJECT_NAME, (char*)NULL); g_free (sysconfdir); //printf("Returning pkgsysconfdir %s\n", result); return result; @@ -113,7 +113,7 @@ gchar *gnc_path_get_pkglibdir() /* Workaround for Bug 618646, {pkglibdir} will be bin/ on Windows */ gchar *result = gnc_gbr_find_bin_dir(libdir); #else - gchar *result = g_build_filename (libdir, "gnucash", (char*)NULL); + gchar *result = g_build_filename (libdir, PROJECT_NAME, (char*)NULL); #endif g_free (libdir); //printf("Returning pkglibdir %s\n", result); @@ -192,7 +192,7 @@ gchar *gnc_path_get_scmdir() gchar *gnc_path_get_reportdir() { gchar *scmdir = gnc_path_get_scmdir (); - gchar *result = g_build_filename (scmdir, "gnucash", "report", (char*)NULL); + gchar *result = g_build_filename (scmdir, PROJECT_NAME, "report", (char*)NULL); g_free (scmdir); return result; @@ -205,7 +205,7 @@ gchar *gnc_path_get_reportdir() gchar *gnc_path_get_reportsdir() { gchar *scmdir = gnc_path_get_scmdir (); - gchar *result = g_build_filename (scmdir, "gnucash", "reports", NULL); + gchar *result = g_build_filename (scmdir, PROJECT_NAME, "reports", NULL); g_free (scmdir); //printf("Returning reportsdir %s\n", result); return result; diff --git a/libgnucash/core-utils/test/gtest-path-utilities.cpp b/libgnucash/core-utils/test/gtest-path-utilities.cpp index d7210007bd..90e1240ee6 100644 --- a/libgnucash/core-utils/test/gtest-path-utilities.cpp +++ b/libgnucash/core-utils/test/gtest-path-utilities.cpp @@ -107,7 +107,7 @@ TEST_F(PathTest, gnc_path_get_datadir) TEST_F(PathTest, gnc_path_get_sysconfdir) { gchar *dirname = gnc_file_path_relative_part(PREFIX, SYSCONFDIR); - gchar *sysconfpath = g_build_filename(m_prefix, dirname, "gnucash", NULL); + gchar *sysconfpath = g_build_filename(m_prefix, dirname, PROJECT_NAME, NULL); g_free(dirname); #ifdef ENABLE_BINRELOC EXPECT_STREQ(gnc_path_get_pkgsysconfdir(), sysconfpath); @@ -119,7 +119,7 @@ TEST_F(PathTest, gnc_path_get_sysconfdir) g_free(sysconfpath); g_unsetenv("GNC_UNINSTALLED"); g_unsetenv("GNC_BUILDDIR"); - sysconfpath = g_build_filename(SYSCONFDIR, "gnucash", NULL); + sysconfpath = g_build_filename(SYSCONFDIR, PROJECT_NAME, NULL); EXPECT_STREQ(gnc_path_get_pkgsysconfdir(), sysconfpath); g_free(sysconfpath); #endif