gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Thu Dec 27 16:56:04 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/692e2266 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d22e1db3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/74ed802e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/aaa71f22 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4b398325 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/06da9e97 (commit)
	from  https://github.com/Gnucash/gnucash/commit/e61d5c47 (commit)



commit 692e22668bac261f4bd9183bdc4e961c358f06df
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Dec 27 22:55:54 2018 +0100

    Silence deprecation warnings in the gui
    
    We only want warnings for our own deprecated functions in libgnucash.

diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt
index 4f1bac7..4d5c668 100644
--- a/gnucash/gnome-utils/CMakeLists.txt
+++ b/gnucash/gnome-utils/CMakeLists.txt
@@ -214,6 +214,7 @@ add_library (gncmod-gnome-utils
 target_link_libraries(gncmod-gnome-utils gncmod-app-utils gncmod-engine gnc-backend-xml-utils
      ${CMAKE_DL_LIBS} ${GTK3_LDFLAGS} ${LIBSECRET_LDFLAGS} ${GTK_MAC_LDFLAGS})
 
+target_compile_options(gncmod-gnome-utils PRIVATE -Wno-deprecated-declarations)
 target_compile_definitions(gncmod-gnome-utils PUBLIC ${GTK_MAC_CFLAGS_OTHER}
   PRIVATE -DG_LOG_DOMAIN=\"gnc.gui\")
 

commit d22e1db340e3107dfd152829b6ab736e24db5e3a
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Dec 27 22:28:29 2018 +0100

    gnc-uri - refer to 'scheme' instead of 'protocol' as that's the more formal term used in uris
    
    This involves renaming 3 functions:
    gnc_uri_get_protocol -> gnc_uri_get_scheme
    gnc_uri_is_known_protocol -> gnc_uri_is_known_scheme
    gnc_uri_is_file_protocol -> gnc_uri_is_file_scheme
    
    The *_protocol variants are marked as deprecated.
    Additionally a number of local variables have been renamed from
    protocol to scheme to support this change.

diff --git a/common/platform.h b/common/platform.h
index b6879b5..ac4eb45 100644
--- a/common/platform.h
+++ b/common/platform.h
@@ -65,5 +65,6 @@
 #endif
 
 /* ENABLE macro defaults */
+#define GNC_DEPRECATED(message) __attribute__ ((__deprecated__ (message)))
 
 #endif /* GNC_PLATFORM_H */
diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c
index 085fd25..a69ee20 100644
--- a/gnucash/gnome-utils/dialog-file-access.c
+++ b/gnucash/gnome-utils/dialog-file-access.c
@@ -81,7 +81,7 @@ geturl( FileAccessWindow* faw )
     gchar* path = NULL;
 
     type = gtk_combo_box_text_get_active_text (faw->cb_uri_type);
-    if (gnc_uri_is_file_protocol (type))
+    if (gnc_uri_is_file_scheme (type))
     {
         path = gtk_file_chooser_get_filename (faw->fileChooser);
         if ( !path ) /* file protocol was chosen but no filename was set */
diff --git a/gnucash/gnome-utils/gnc-file.c b/gnucash/gnome-utils/gnc-file.c
index 6dc0dbd..8a2540b 100644
--- a/gnucash/gnome-utils/gnc-file.c
+++ b/gnucash/gnome-utils/gnc-file.c
@@ -658,7 +658,7 @@ gnc_post_file_open (GtkWindow *parent, const char * filename, gboolean is_readon
     char * newfile;
     QofBackendError io_err = ERR_BACKEND_NO_ERR;
 
-    gchar *protocol = NULL;
+    gchar *scheme   = NULL;
     gchar *hostname = NULL;
     gchar *username = NULL;
     gchar *password = NULL;
@@ -681,7 +681,7 @@ RESTART:
         return FALSE;
     }
 
-    gnc_uri_get_components (newfile, &protocol, &hostname,
+    gnc_uri_get_components (newfile, &scheme, &hostname,
                             &port, &username, &password, &path);
 
     /* If the file to open is a database, and no password was given,
@@ -690,24 +690,24 @@ RESTART:
      * cancel this dialog, in which case the open file action will be
      * abandoned.
      * Note newfile is normalized uri so we can safely call
-     * gnc_uri_is_file_protocol on it.
+     * gnc_uri_is_file_scheme on it.
      */
-    if (!gnc_uri_is_file_protocol (protocol) && !password)
+    if (!gnc_uri_is_file_scheme (scheme) && !password)
     {
         gboolean have_valid_pw = FALSE;
-        have_valid_pw = gnc_keyring_get_password ( NULL, protocol, hostname, port,
+        have_valid_pw = gnc_keyring_get_password ( NULL, scheme, hostname, port,
                         path, &username, &password );
         if (!have_valid_pw)
             return FALSE;
 
         /* Got password. Recreate the uri to use internally. */
         g_free ( newfile );
-        newfile = gnc_uri_create_uri ( protocol, hostname, port,
+        newfile = gnc_uri_create_uri ( scheme, hostname, port,
                                        username, password, path);
     }
 
     /* For file based uri's, remember the directory as the default. */
-    if (gnc_uri_is_file_protocol(protocol))
+    if (gnc_uri_is_file_scheme(scheme))
     {
         gchar *default_dir = g_path_get_dirname(path);
         gnc_set_default_directory (GNC_PREFS_GROUP_OPEN_SAVE, default_dir);
@@ -868,8 +868,8 @@ RESTART:
         /* If the new "file" is a database, attempt to store the password
          * in a keyring. GnuCash itself will not save it.
          */
-        if ( !gnc_uri_is_file_protocol (protocol))
-            gnc_keyring_set_password ( protocol, hostname, port,
+        if ( !gnc_uri_is_file_scheme (scheme))
+            gnc_keyring_set_password ( scheme, hostname, port,
                                        path, username, password );
 
         xaccLogDisable();
@@ -967,7 +967,7 @@ RESTART:
         }
     }
 
-    g_free (protocol);
+    g_free (scheme);
     g_free (hostname);
     g_free (username);
     g_free (password);
@@ -1164,7 +1164,7 @@ gnc_file_do_export(GtkWindow *parent, const char * filename)
     gchar *newfile;
     const gchar *oldfile;
 
-    gchar *protocol = NULL;
+    gchar *scheme   = NULL;
     gchar *hostname = NULL;
     gchar *username = NULL;
     gchar *password = NULL;
@@ -1185,17 +1185,17 @@ gnc_file_do_export(GtkWindow *parent, const char * filename)
 
     newfile = gnc_uri_add_extension (norm_file, GNC_DATAFILE_EXT);
     g_free (norm_file);
-    gnc_uri_get_components (newfile, &protocol, &hostname,
+    gnc_uri_get_components (newfile, &scheme, &hostname,
                             &port, &username, &password, &path);
 
     /* Save As can't use the generic 'file' protocol. If the user didn't set
      * a specific protocol, assume the default 'xml'.
      */
-    if (g_strcmp0 (protocol, "file") == 0)
+    if (g_strcmp0 (scheme, "file") == 0)
     {
-        g_free (protocol);
-        protocol = g_strdup ("xml");
-        norm_file = gnc_uri_create_uri (protocol, hostname, port,
+        g_free (scheme);
+        scheme = g_strdup ("xml");
+        norm_file = gnc_uri_create_uri (scheme, hostname, port,
                                         username, password, path);
         g_free (newfile);
         newfile = norm_file;
@@ -1203,8 +1203,8 @@ gnc_file_do_export(GtkWindow *parent, const char * filename)
 
     /* Some extra steps for file based uri's only
      * Note newfile is normalized uri so we can safely call
-     * gnc_uri_is_file_protocol on it. */
-    if (gnc_uri_is_file_protocol(protocol))
+     * gnc_uri_is_file_scheme on it. */
+    if (gnc_uri_is_file_scheme (scheme))
     {
         if (check_file_path (path))
         {
@@ -1395,7 +1395,7 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
     gchar *newfile;
     const gchar *oldfile;
 
-    gchar *protocol = NULL;
+    gchar *scheme   = NULL;
     gchar *hostname = NULL;
     gchar *username = NULL;
     gchar *password = NULL;
@@ -1419,17 +1419,17 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
 
     newfile = gnc_uri_add_extension (norm_file, GNC_DATAFILE_EXT);
     g_free (norm_file);
-    gnc_uri_get_components (newfile, &protocol, &hostname,
+    gnc_uri_get_components (newfile, &scheme, &hostname,
                             &port, &username, &password, &path);
 
     /* Save As can't use the generic 'file' protocol. If the user didn't set
      * a specific protocol, assume the default 'xml'.
      */
-    if (g_strcmp0 (protocol, "file") == 0)
+    if (g_strcmp0 (scheme, "file") == 0)
     {
-        g_free (protocol);
-        protocol = g_strdup ("xml");
-        norm_file = gnc_uri_create_uri (protocol, hostname, port,
+        g_free (scheme);
+        scheme = g_strdup ("xml");
+        norm_file = gnc_uri_create_uri (scheme, hostname, port,
                                         username, password, path);
         g_free (newfile);
         newfile = norm_file;
@@ -1437,8 +1437,8 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
 
     /* Some extra steps for file based uri's only
      * Note newfile is normalized uri so we can safely call
-     * gnc_uri_is_file_protocol on it. */
-    if (gnc_uri_is_file_protocol(protocol))
+     * gnc_uri_is_file_scheme on it. */
+    if (gnc_uri_is_file_scheme (scheme))
     {
         if (check_file_path (path))
         {
@@ -1538,8 +1538,8 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
     /* If the new "file" is a database, attempt to store the password
      * in a keyring. GnuCash itself will not save it.
      */
-    if ( !gnc_uri_is_file_protocol (protocol))
-        gnc_keyring_set_password ( protocol, hostname, port,
+    if ( !gnc_uri_is_file_scheme (scheme))
+        gnc_keyring_set_password ( scheme, hostname, port,
                                    path, username, password );
 
     /* Prevent race condition between swapping the contents of the two
diff --git a/libgnucash/app-utils/gnc-state.c b/libgnucash/app-utils/gnc-state.c
index c305f08..616aea5 100644
--- a/libgnucash/app-utils/gnc-state.c
+++ b/libgnucash/app-utils/gnc-state.c
@@ -107,17 +107,17 @@ gnc_state_set_base (const QofSession *session)
     else
     {
         /* The book_uri is composed of database connection parameters. */
-        gchar* protocol = NULL;
+        gchar* scheme = NULL;
         gchar* host = NULL;
         gchar* dbname = NULL;
         gchar* username = NULL;
         gchar* password = NULL;
         gint portnum = 0;
-        gnc_uri_get_components (uri, &protocol, &host, &portnum,
+        gnc_uri_get_components (uri, &scheme, &host, &portnum,
                                 &username, &password, &dbname);
 
-        basename = g_strjoin ("_", protocol, host, username, dbname, NULL);
-        g_free (protocol);
+        basename = g_strjoin ("_", scheme, host, username, dbname, NULL);
+        g_free (scheme);
         g_free (host);
         g_free (username);
         g_free (password);
diff --git a/libgnucash/backend/dbi/gnc-backend-dbi.cpp b/libgnucash/backend/dbi/gnc-backend-dbi.cpp
index 0d547e4..e2aaddf 100644
--- a/libgnucash/backend/dbi/gnc-backend-dbi.cpp
+++ b/libgnucash/backend/dbi/gnc-backend-dbi.cpp
@@ -152,11 +152,11 @@ struct UriStrings
 
 UriStrings::UriStrings(const std::string& uri)
 {
-    gchar *protocol, *host, *username, *password, *dbname;
+    gchar *scheme, *host, *username, *password, *dbname;
     int portnum;
-    gnc_uri_get_components(uri.c_str(), &protocol, &host, &portnum, &username,
+    gnc_uri_get_components(uri.c_str(), &scheme, &host, &portnum, &username,
                            &password, &dbname);
-    m_protocol = std::string{protocol};
+    m_protocol = std::string{scheme};
     m_host = std::string{host};
     m_dbname = std::string{dbname};
     if (username)
@@ -164,7 +164,7 @@ UriStrings::UriStrings(const std::string& uri)
     if (password)
         m_password = std::string{password};
     m_portnum = portnum;
-    g_free(protocol);
+    g_free(scheme);
     g_free(host);
     g_free(username);
     g_free(password);
diff --git a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
index c1f635a..055062f 100644
--- a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
+++ b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
@@ -248,7 +248,7 @@ setup_business (Fixture* fixture, gconstpointer pData)
 static void
 destroy_database (gchar* url)
 {
-    gchar* protocol = NULL;
+    gchar* scheme = NULL;
     gchar* host = NULL;
     gchar* dbname = NULL;
     gchar* username = NULL;
@@ -263,9 +263,9 @@ destroy_database (gchar* url)
     dbi_result tables;
     StrVec tblnames;
 
-    gnc_uri_get_components (url, &protocol, &host, &portnum,
+    gnc_uri_get_components (url, &scheme, &host, &portnum,
                             &username, &password, &dbname);
-    if (g_strcmp0 (protocol, "postgres") == 0)
+    if (g_strcmp0 (scheme, "postgres") == 0)
 #if HAVE_LIBDBI_R
         conn = dbi_conn_new_r (pgsql, dbi_instance);
 #else
@@ -273,7 +273,7 @@ destroy_database (gchar* url)
 #endif
     else
 #if HAVE_LIBDBI_R
-        conn = dbi_conn_new_r (protocol, dbi_instance);
+        conn = dbi_conn_new_r (scheme, dbi_instance);
 #else
         conn = dbi_conn_new (protocol);
 #endif
diff --git a/libgnucash/engine/gnc-uri-utils.c b/libgnucash/engine/gnc-uri-utils.c
index bfa0381..7c0b2a0 100644
--- a/libgnucash/engine/gnc-uri-utils.c
+++ b/libgnucash/engine/gnc-uri-utils.c
@@ -32,21 +32,21 @@
 gboolean gnc_uri_is_uri (const gchar *uri)
 {
 
-    gchar *protocol = NULL, *hostname = NULL;
+    gchar *scheme = NULL, *hostname = NULL;
     gchar *username = NULL, *password = NULL;
     gchar *path     = NULL;
     gint   port = 0;
     gboolean is_uri = FALSE;
 
-    gnc_uri_get_components ( uri, &protocol, &hostname, &port,
+    gnc_uri_get_components ( uri, &scheme, &hostname, &port,
                              &username, &password, &path );
 
     /* For gnucash to consider a uri valid the following must be true:
-     * - protocol and path must not be NULL
+     * - scheme and path must not be NULL
      * - for anything but local filesystem uris, hostname must be valid as well */
-    is_uri = (protocol && path && (gnc_uri_is_file_protocol(protocol) || hostname));
+    is_uri = (scheme && path && (gnc_uri_is_file_scheme(scheme) || hostname));
 
-    g_free (protocol);
+    g_free (scheme);
     g_free (hostname);
     g_free (username);
     g_free (password);
@@ -55,44 +55,44 @@ gboolean gnc_uri_is_uri (const gchar *uri)
     return is_uri;
 }
 
-/* Checks if the given protocol is used to refer to a file
+/* Checks if the given scheme is used to refer to a file
  * (as opposed to a network service)
  */
-gboolean gnc_uri_is_known_protocol (const gchar *protocol)
+gboolean gnc_uri_is_known_scheme (const gchar *scheme)
 {
-    gboolean is_known_proto = FALSE;
+    gboolean is_known_scheme = FALSE;
     GList *node;
-    GList *known_proto_list = qof_backend_get_registered_access_method_list();
+    GList *known_scheme_list = qof_backend_get_registered_access_method_list();
 
-    for ( node = known_proto_list; node != NULL; node = node->next )
+    for ( node = known_scheme_list; node != NULL; node = node->next )
     {
-        gchar *known_proto = node->data;
-        if ( !g_ascii_strcasecmp (protocol, known_proto) )
+        gchar *known_scheme = node->data;
+        if ( !g_ascii_strcasecmp (scheme, known_scheme) )
         {
-            is_known_proto = TRUE;
+            is_known_scheme = TRUE;
             break;
         }
     }
 
-    g_list_free (known_proto_list);
-    return is_known_proto;
+    g_list_free (known_scheme_list);
+    return is_known_scheme;
 }
 
-/* Checks if the given protocol is used to refer to a file
+/* Checks if the given scheme is used to refer to a file
  * (as opposed to a network service)
- * Note unknown protocols are always considered network protocols.
+ * Note unknown schemes are always considered network schemes.
  *
  * *Compatibility note:*
  * This used to be the other way around before gnucash 3.4. Before
- * that unknown protocols were always considered local file system
- * uri protocols.
+ * that unknown schemes were always considered local file system
+ * uri schemes.
  */
-gboolean gnc_uri_is_file_protocol (const gchar *protocol)
+gboolean gnc_uri_is_file_scheme (const gchar *scheme)
 {
-    return (protocol &&
-            (!g_ascii_strcasecmp (protocol, "file") ||
-             !g_ascii_strcasecmp (protocol, "xml") ||
-             !g_ascii_strcasecmp (protocol, "sqlite3")));
+    return (scheme &&
+            (!g_ascii_strcasecmp (scheme, "file") ||
+             !g_ascii_strcasecmp (scheme, "xml") ||
+             !g_ascii_strcasecmp (scheme, "sqlite3")));
 }
 
 /* Checks if the given uri defines a file
@@ -100,10 +100,10 @@ gboolean gnc_uri_is_file_protocol (const gchar *protocol)
  */
 gboolean gnc_uri_is_file_uri (const gchar *uri)
 {
-    gchar *protocol = gnc_uri_get_protocol ( uri );
-    gboolean result = gnc_uri_is_file_protocol ( protocol );
+    gchar *scheme = gnc_uri_get_scheme ( uri );
+    gboolean result = gnc_uri_is_file_scheme ( scheme );
 
-    g_free ( protocol );
+    g_free ( scheme );
 
     return result;
 }
@@ -113,24 +113,24 @@ gboolean gnc_uri_is_file_uri (const gchar *uri)
 gboolean gnc_uri_targets_local_fs (const gchar *uri)
 {
 
-    gchar *protocol = NULL, *hostname = NULL;
+    gchar *scheme = NULL, *hostname = NULL;
     gchar *username = NULL, *password = NULL;
     gchar *path     = NULL;
     gint   port = 0;
     gboolean is_local_fs = FALSE;
 
-    gnc_uri_get_components ( uri, &protocol, &hostname, &port,
+    gnc_uri_get_components ( uri, &scheme, &hostname, &port,
                              &username, &password, &path );
 
     /* For gnucash to consider a uri to target the local fs:
      * path must not be NULL
      * AND
-     *   protocol should be NULL
+     *   scheme should be NULL
      *   OR
-     *   protocol must be file type protocol (file, xml, sqlite) */
-    is_local_fs = (path && (!protocol || gnc_uri_is_file_protocol(protocol)));
+     *   scheme must be file type scheme (file, xml, sqlite) */
+    is_local_fs = (path && (!scheme || gnc_uri_is_file_scheme(scheme)));
 
-    g_free (protocol);
+    g_free (scheme);
     g_free (hostname);
     g_free (username);
     g_free (password);
@@ -141,7 +141,7 @@ gboolean gnc_uri_targets_local_fs (const gchar *uri)
 
 /* Splits a uri into its separate components */
 void gnc_uri_get_components (const gchar *uri,
-                             gchar **protocol,
+                             gchar **scheme,
                              gchar **hostname,
                              gint32 *port,
                              gchar **username,
@@ -152,9 +152,9 @@ void gnc_uri_get_components (const gchar *uri,
     gchar *url = NULL, *tmpusername = NULL, *tmphostname = NULL;
     gchar *delimiter = NULL;
 
-    *protocol = NULL;
+    *scheme   = NULL;
     *hostname = NULL;
-    *port      = 0;
+    *port     = 0;
     *username = NULL;
     *password = NULL;
     *path     = NULL;
@@ -164,30 +164,19 @@ void gnc_uri_get_components (const gchar *uri,
     splituri = g_strsplit ( uri, "://", 2 );
     if ( splituri[1] == NULL )
     {
-        /* No protocol means simple file path.
+        /* No scheme means simple file path.
            Set path to copy of the input. */
         *path     = g_strdup ( uri );
         g_strfreev ( splituri );
         return;
     }
 
-    /* At least a protocol was found, set it here */
-    *protocol = g_strdup ( splituri[0] );
+    /* At least a scheme was found, set it here */
+    *scheme = g_strdup ( splituri[0] );
 
-    if ( gnc_uri_is_file_protocol ( *protocol ) )
+    if ( gnc_uri_is_file_scheme ( *scheme ) )
     {
-        /* Protocol indicates file based uri.
-         * Note that unknown protocols are treated as if they are
-         * file-based protocols. This is done to prevent password
-         * lookups on unknown protocols.
-         * On the other hand, since we don't know the specifics of
-         * unknown protocols, we don't attempt to return an absolute
-         * pathname for them, just whatever was there.
-         */
-        if ( gnc_uri_is_known_protocol ( *protocol ) )
-            *path     = gnc_resolve_file_path ( splituri[1] );
-        else
-            *path     = g_strdup ( splituri[1] );
+        *path     = gnc_resolve_file_path ( splituri[1] );
         g_strfreev ( splituri );
         return;
     }
@@ -232,7 +221,7 @@ void gnc_uri_get_components (const gchar *uri,
     if ( delimiter != NULL )
     {
         delimiter[0] = '\0';
-        if ( gnc_uri_is_file_protocol ( *protocol ) ) /* always return absolute file paths */
+        if ( gnc_uri_is_file_scheme ( *scheme ) ) /* always return absolute file paths */
             *path = gnc_resolve_file_path ( (const gchar*)(delimiter + 1) );
         else /* path is no file path, so copy it as is */
             *path = g_strdup ( (const gchar*)(delimiter + 1) );
@@ -254,16 +243,16 @@ void gnc_uri_get_components (const gchar *uri,
 
 }
 
-gchar *gnc_uri_get_protocol (const gchar *uri)
+gchar *gnc_uri_get_scheme (const gchar *uri)
 {
-    gchar *protocol = NULL;
+    gchar *scheme   = NULL;
     gchar *hostname = NULL;
     gint32 port     = 0;
     gchar *username = NULL;
     gchar *password = NULL;
     gchar *path     = NULL;
 
-    gnc_uri_get_components ( uri, &protocol, &hostname, &port,
+    gnc_uri_get_components ( uri, &scheme, &hostname, &port,
                              &username, &password, &path );
 
     g_free (hostname);
@@ -271,22 +260,22 @@ gchar *gnc_uri_get_protocol (const gchar *uri)
     g_free (password);
     g_free (path);
 
-    return protocol;
+    return scheme;
 }
 
 gchar *gnc_uri_get_path (const gchar *uri)
 {
-    gchar *protocol = NULL;
+    gchar *scheme   = NULL;
     gchar *hostname = NULL;
     gint32 port = 0;
     gchar *username = NULL;
     gchar *password = NULL;
     gchar *path     = NULL;
 
-    gnc_uri_get_components ( uri, &protocol, &hostname, &port,
+    gnc_uri_get_components ( uri, &scheme, &hostname, &port,
                              &username, &password, &path );
 
-    g_free (protocol);
+    g_free (scheme);
     g_free (hostname);
     g_free (username);
     g_free (password);
@@ -295,7 +284,7 @@ gchar *gnc_uri_get_path (const gchar *uri)
 }
 
 /* Generates a normalized uri from the separate components */
-gchar *gnc_uri_create_uri (const gchar *protocol,
+gchar *gnc_uri_create_uri (const gchar *scheme,
                            const gchar *hostname,
                            gint32 port,
                            const gchar *username,
@@ -306,23 +295,23 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
 
     g_return_val_if_fail( path != 0, NULL );
 
-    if ( (protocol == NULL) || gnc_uri_is_file_protocol ( protocol ) )
+    if (!scheme || gnc_uri_is_file_scheme (scheme))
     {
         /* Compose a file based uri, which means ignore everything but
-         * the protocol and the path
-         * We return an absolute pathname if the protocol is known or
-         * no protocol was given. For an unknown protocol, we return the
+         * the scheme and the path
+         * We return an absolute pathname if the scheme is known or
+         * no scheme was given. For an unknown scheme, we return the
          * path info as is.
          */
         gchar *abs_path;
-        if ( protocol && (!gnc_uri_is_known_protocol (protocol)) )
+        if (scheme && (!gnc_uri_is_known_scheme (scheme)) )
             abs_path = g_strdup ( path );
         else
             abs_path = gnc_resolve_file_path ( path );
-        if ( protocol == NULL )
+        if ( scheme == NULL )
             uri = g_strdup_printf ( "file://%s", abs_path );
         else
-            uri = g_strdup_printf ( "%s://%s", protocol, abs_path );
+            uri = g_strdup_printf ( "%s://%s", scheme, abs_path );
         g_free (abs_path);
         return uri;
     }
@@ -349,7 +338,7 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
 
     // XXX Do I have to add the slash always or are there situations
     //     it is in the path already ?
-    uri = g_strconcat ( protocol, "://", userpass, hostname, portstr, "/", path, NULL );
+    uri = g_strconcat ( scheme, "://", userpass, hostname, portstr, "/", path, NULL );
 
     g_free ( userpass );
     g_free ( portstr );
@@ -360,7 +349,7 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
 
 gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password)
 {
-    gchar *protocol = NULL;
+    gchar *scheme   = NULL;
     gchar *hostname = NULL;
     gint32 port = 0;
     gchar *username = NULL;
@@ -368,16 +357,16 @@ gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password)
     gchar *path     = NULL;
     gchar *newuri   = NULL;
 
-    gnc_uri_get_components ( uri, &protocol, &hostname, &port,
+    gnc_uri_get_components ( uri, &scheme, &hostname, &port,
                              &username, &password, &path );
     if (allow_password)
-        newuri = gnc_uri_create_uri ( protocol, hostname, port,
+        newuri = gnc_uri_create_uri ( scheme, hostname, port,
                                       username, password, path);
     else
-        newuri = gnc_uri_create_uri ( protocol, hostname, port,
+        newuri = gnc_uri_create_uri ( scheme, hostname, port,
                                       username, /* no password */ NULL, path);
 
-    g_free (protocol);
+    g_free (scheme);
     g_free (hostname);
     g_free (username);
     g_free (password);
@@ -403,3 +392,25 @@ gchar *gnc_uri_add_extension ( const gchar *uri, const gchar *extension )
     /* Ok, all tests passed, let's add the extension */
     return g_strconcat( uri, extension, NULL );
 }
+
+
+/* Deprecated functions
+ * ********************/
+
+/* replaced with gnc_uri_get_scheme */
+gchar *gnc_uri_get_protocol (const gchar *uri)
+{
+    return gnc_uri_get_scheme (uri);
+}
+
+/* replaced with gnc_uri_is_known_scheme */
+gboolean gnc_uri_is_known_protocol (const gchar *protocol)
+{
+    return gnc_uri_is_known_scheme(protocol);
+}
+
+/* replaced with gnc_uri_is_file_scheme */
+gboolean gnc_uri_is_file_protocol (const gchar *protocol)
+{
+    return gnc_uri_is_file_scheme (protocol);
+}
diff --git a/libgnucash/engine/gnc-uri-utils.h b/libgnucash/engine/gnc-uri-utils.h
index f1756b6..1964323 100644
--- a/libgnucash/engine/gnc-uri-utils.h
+++ b/libgnucash/engine/gnc-uri-utils.h
@@ -31,12 +31,12 @@
  *  @author Copyright (C) 2010 Geert Janssens <janssens-geert at telenet.be>
  *
  *  These functions help you convert a uri into its separate components
- *  (being protocol, host name, port, user name, password and path) or
+ *  (being scheme, host name, port, user name, password and path) or
  *  to compose a uri from these separate components.
  *
- *  A full uri can be described as:
+ *  For GnuCash' purposes a full uri can be described as:
  *
- *  @li @c proto://[[username[:password]@]hostname[:port]]/path (universal uri)
+ *  @li @c scheme://[[username[:password]@]hostname[:port]]/path (universal uri)
  *  @li @c file://[localhost]/path (uri refering to a file on the local file system)
  *
  *  Anything in square brackets is optional.
@@ -61,9 +61,11 @@
 #define GNC_DATAFILE_EXT ".gnucash"
 #define GNC_LOGFILE_EXT  ".log"
 
+#include "platform.h"
+
 /** Checks if the given uri is a valid uri
  *
- *  A valid uri is defined by having at least a protocol and a path.
+ *  A valid uri is defined by having at least a scheme and a path.
  *  If the uri is not referring to a file on the local file system
  *  a hostname should be set as well.
  *
@@ -81,8 +83,8 @@ gboolean gnc_uri_is_uri (const gchar *uri);
  *
  *  @param uri The uri to convert
  *
- *  @param protocol The protocol for this uri. If the uri didn't have an
- *  explicit protocol, NULL will be returned.
+ *  @param scheme The scheme for this uri. If the uri doesn't have an
+ *  explicit scheme, NULL will be returned.
  *  @param hostname The host name of the server to connect to. In case of
  *  the local file system path, NULL will be returned
  *  @param port An optional port to connect to or 0 if the default port is to
@@ -94,25 +96,25 @@ gboolean gnc_uri_is_uri (const gchar *uri);
  */
 
 void gnc_uri_get_components (const gchar *uri,
-                             gchar **protocol,
+                             gchar **scheme,
                              gchar **hostname,
                              gint32 *port,
                              gchar **username,
                              gchar **password,
                              gchar **path);
 
-/** Extracts the protocol from a uri
+/** Extracts the scheme from a uri
  *
- *  The function allocates memory for the protocol. The calling function should
+ *  The function allocates memory for the scheme. The calling function should
  *  free this memory with g_free if it no longer needs the string.
  *
- *  @param uri The uri to extract the protocol from
+ *  @param uri The uri to extract the scheme from
  *
- *  @return The protocol for this uri. If the uri didn't have an
- *  explicit protocol, NULL will be returned.
+ *  @return The scheme for this uri. If the uri didn't have an
+ *  explicit scheme, NULL will be returned.
  */
 
-gchar *gnc_uri_get_protocol (const gchar *uri);
+gchar *gnc_uri_get_scheme (const gchar *uri);
 
 /** Extracts the path part from a uri
  *
@@ -121,7 +123,7 @@ gchar *gnc_uri_get_protocol (const gchar *uri);
  *
  *  @param uri The uri to extract the path part from
  *
- *  @return The protocol for this uri, or NULL if no path could be extracted.
+ *  @return The path for this uri, or NULL if no path could be extracted.
  */
 
 gchar *gnc_uri_get_path (const gchar *uri);
@@ -131,31 +133,31 @@ gchar *gnc_uri_get_path (const gchar *uri);
  *  The resulting uri will take either of these forms:
  *  @li @c file:///some/absolute/path (file could also be xml or sqlite)
  *  @li @c file://c:\\some\\windows\\path (file could also be xml or sqlite)
- *  @li @c protocol://[user[:password]@]hostname[:port]/path
+ *  @li @c scheme://[user[:password]@]hostname[:port]/path
  *
  *  Only the components that are provided will be inserted in the uri. However
- *  if no protocol has been provided, 'file' will be used as default protocol.
+ *  if no scheme has been provided, 'file' will be used as default scheme.
  *
  *  The function allocates memory for the uri. The calling function should
  *  free this memory with g_free the uri is no longer needed.
  *
-*  @param protocol The protocol for this uri. If NULL,, 'file' will be used
+*  @param scheme The scheme for this uri. If NULL,, 'file' will be used
 *   in the uri.
  *  @param hostname The host name of the server to connect to. This will be
- *  ignored for the 'file' type protocols ('file', 'xml', 'sqlite').
+ *  ignored for the 'file' type schemes ('file', 'xml', 'sqlite').
  *  @param port An optional port to set o, the uri, or 0 if no port is to be
- *  set. This will be ignored for the 'file' type protocols ('file', 'xml',
+ *  set. This will be ignored for the 'file' type schemes ('file', 'xml',
  *  'sqlite').
  *  @param username Optional user name to set in the uri or NULL otherwise. This will
- *  be ignored for the 'file' type protocols ('file', 'xml', 'sqlite').
+ *  be ignored for the 'file' type schemes ('file', 'xml', 'sqlite').
  *  @param password Optional password to set in the uri or NULL otherwise. This will
- *  be ignored for the 'file' type protocols ('file', 'xml', 'sqlite').
+ *  be ignored for the 'file' type schemes ('file', 'xml', 'sqlite').
  *  @param path The path to set in the uri.
  *
  *  @return The normalized uri.
  */
 
-gchar *gnc_uri_create_uri (const gchar *protocol,
+gchar *gnc_uri_create_uri (const gchar *scheme,
                            const gchar *hostname,
                            gint32 port,
                            const gchar *username,
@@ -167,12 +169,12 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
  *  The resulting uri will take either of these forms:
  *  @li @c file:///some/absolute/path ('file' can also be xml or sqlite)
  *  @li @c file://c:\\some\\windows\\path ('file' can also be xml or sqlite)
- *  @li @c protocol://[user[:password]@]hostname[:port]/path
+ *  @li @c scheme://[user[:password]@]hostname[:port]/path
  *
  *  Only the components that are provided will be inserted in the uri. The
  *  allow_password parameter controls if the password should be added to the
  *  returned uri when available.
- *  If no protocol has been provided, 'file' will be used as default protocol.
+ *  If no scheme has been provided, 'file' will be used as default scheme.
  *
  *  The function allocates memory for the uri. The calling function should
  *  free this memory with g_free the uri is no longer needed.
@@ -189,7 +191,7 @@ gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password);
 
 /** Checks if the given uri is a valid uri
  *
- *  A valid uri is defined by having at least a protocol and a path.
+ *  A valid uri is defined by having at least a scheme and a path.
  *  If the uri is not referring to a file on the local file system
  *  a hostname should be set as well.
  *
@@ -200,40 +202,42 @@ gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password);
 gboolean gnc_uri_is_uri (const gchar *uri);
 
 
-/** Checks if there is a backend that explicitly stated to handle the given protocol.
+/** Checks if there is a backend that explicitly stated to handle the given scheme.
  *
- *  @param protocol The protocol to check
+ *  @param scheme The scheme to check
  *
- *  @return TRUE if at least one backend explicitly handles this protocol, otherwise FALSE
+ *  @return TRUE if at least one backend explicitly handles this scheme, otherwise FALSE
  */
-gboolean gnc_uri_is_known_protocol (const gchar *protocol);
+gboolean gnc_uri_is_known_scheme (const gchar *scheme);
 
 
-/** Checks if the given protocol is used to refer to a file
+/** Checks if the given scheme is used to refer to a file
  *  (as opposed to a network service like a database or web url)
  *
- *  @param protocol The protocol to check
+ *  @param scheme The scheme to check
  *
- *  @return TRUE if the protocol is used with files, FALSE of the protocol
- *  is normally used with network services (database, web url,...)
+ *  @return TRUE if the scheme is used with files, FALSE if the scheme
+ *  is normally used with network services (database, web url,...).
+ *  It will also return FALSE if scheme is NULL.
  */
-gboolean gnc_uri_is_file_protocol (const gchar *protocol);
+gboolean gnc_uri_is_file_scheme (const gchar *scheme);
+
 
 /** Checks if the given uri defines a file
  *  (as opposed to a network service like a database or web url)
  *
  *  @param uri The uri to check
  *
- *  @return TRUE if the uri is a files, FALSE of the protocol
+ *  @return TRUE if the uri is a files, FALSE of the scheme
  *  is normally used with network services (database, web url,...)
  */
 gboolean gnc_uri_is_file_uri (const gchar *uri);
 
+
 /** Checks if the given uri is either a valid file uri or a local filesystem path
  *
- *  A valid uri is defined by having at least a protocol and a path.
- *  If the uri is not referring to a file on the local file system
- *  a hostname should be set as well.
+ *  A valid file uri is defined by having a file targeting scheme
+ *  ('file', 'xml' or 'sqlite3' are accepted) and a non-NULL path.
  *
  *  @param uri The uri to check
  *
@@ -242,6 +246,7 @@ gboolean gnc_uri_is_file_uri (const gchar *uri);
  */
 gboolean gnc_uri_targets_local_fs (const gchar *uri);
 
+
 /** Adds an extension to the uri if:
  *  * the uri is not empty and file based
  *  * doesn't already have the extension
@@ -257,6 +262,54 @@ gboolean gnc_uri_targets_local_fs (const gchar *uri);
  */
 gchar *gnc_uri_add_extension ( const gchar *uri, const gchar *extension );
 
+
+/** @name Deprecated functions
+ * @{
+ */
+
+/** Extracts the protocol from a uri
+ *
+ *  @deprecated This function has been deprecated in gnucash 3.4. Please use gnc_uri_get_scheme instead.
+ *
+ *  The function allocates memory for the protocol. The calling function should
+ *  free this memory with g_free if it no longer needs the string.
+ *
+ *  @param uri The uri to extract the protocol from
+ *
+ *  @return The protocol for this uri. If the uri didn't have an
+ *  explicit protocol, NULL will be returned.
+ */
+
+gchar *gnc_uri_get_protocol (const gchar *uri)
+    GNC_DEPRECATED("Please use gnc_uri_get_scheme instead (since 3.4)");
+
+/** Checks if there is a backend that explicitly stated to handle the given protocol.
+ *
+ *  @deprecated This function has been deprecated in gnucash 3.4. Please use gnc_uri_is_known_scheme instead.
+ *
+ *  @param protocol The protocol to check
+ *
+ *  @return TRUE if at least one backend explicitly handles this protocol, otherwise FALSE
+ */
+gboolean gnc_uri_is_known_protocol (const gchar *protocol)
+    GNC_DEPRECATED("Please use gnc_uri_known_scheme instead (since 3.4)");
+
+
+/** Checks if the given protocol is used to refer to a file
+ *  (as opposed to a network service like a database or web url)
+ *
+ *  @deprecated This function has been deprecated in gnucash 3.4. Please use gnc_uri_is_file_scheme instead.
+ *
+ *  @param protocol The protocol to check
+ *
+ *  @return TRUE if the protocol is used with files, FALSE of the protocol
+ *  is normally used with network services (database, web url,...)
+ */
+gboolean gnc_uri_is_file_protocol (const gchar *protocol)
+    GNC_DEPRECATED("Please use gnc_uri_is_file_scheme instead (since 3.4)");
+
+/** @} */
+
 #endif /* GNCURIUTILS_H_ */
 /** @} */
 /** @} */
diff --git a/libgnucash/engine/test/test-gnc-uri-utils.c b/libgnucash/engine/test/test-gnc-uri-utils.c
index 9bfad16..2f4bbd8 100644
--- a/libgnucash/engine/test/test-gnc-uri-utils.c
+++ b/libgnucash/engine/test/test-gnc-uri-utils.c
@@ -230,14 +230,14 @@ test_gnc_uri_get_components()
 
 /* TEST: gnc_uri_get_protocol */
 static void
-test_gnc_uri_get_protocol()
+test_gnc_uri_get_scheme()
 {
     int i;
     for (i = 0; strs[i].uri != NULL; i++)
     {
         gchar *tprotocol = NULL;
 
-        tprotocol = gnc_uri_get_protocol( strs[i].uri );
+        tprotocol = gnc_uri_get_scheme( strs[i].uri );
         g_assert_cmpstr ( tprotocol, ==, strs[i].protocol );
         g_free(tprotocol);
     }
@@ -293,14 +293,14 @@ test_gnc_uri_normalize_uri()
 
 /* TEST: gnc_uri_is_file_protocol */
 static void
-test_gnc_uri_is_file_protocol()
+test_gnc_uri_is_file_scheme()
 {
     int i;
     for (i = 0; strs[i].uri != NULL; i++)
     {
         gboolean tis_file_protocol;
 
-        tis_file_protocol = gnc_uri_is_file_protocol( strs[i].protocol );
+        tis_file_protocol = gnc_uri_is_file_scheme( strs[i].protocol );
         g_assert_true ( tis_file_protocol == strs[i].is_file_protocol );
     }
 }
@@ -323,11 +323,11 @@ void
 test_suite_gnc_uri_utils(void)
 {
     GNC_TEST_ADD_FUNC(suitename, "gnc_uri_get_components()", test_gnc_uri_get_components);
-    GNC_TEST_ADD_FUNC(suitename, "gnc_uri_get_protocol()", test_gnc_uri_get_protocol);
+    GNC_TEST_ADD_FUNC(suitename, "gnc_uri_get_scheme()", test_gnc_uri_get_scheme);
     GNC_TEST_ADD_FUNC(suitename, "gnc_uri_get_path()", test_gnc_uri_get_path);
     GNC_TEST_ADD_FUNC(suitename, "gnc_uri_create_uri()", test_gnc_uri_create_uri);
     GNC_TEST_ADD_FUNC(suitename, "gnc_uri_normalize_uri()", test_gnc_uri_normalize_uri);
-    GNC_TEST_ADD_FUNC(suitename, "gnc_uri_is_file_protocol()", test_gnc_uri_is_file_protocol);
+    GNC_TEST_ADD_FUNC(suitename, "gnc_uri_is_file_scheme()", test_gnc_uri_is_file_scheme);
     GNC_TEST_ADD_FUNC(suitename, "gnc_uri_is_file_uri()", test_gnc_uri_is_file_uri);
 
 }

commit 74ed802eae9862ac79a24678cdb5d7c3403edd59
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Dec 27 22:25:18 2018 +0100

    Show warnings for deprecated declarations
    
    We're about to announce our own set of deprecated functions in libgnucash.
    That would be pretty pointless if we also would silence all deprecation warnings
    at the same time...

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8609541..d9f359e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -568,9 +568,9 @@ set(CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")  # FIXME: should be -std=
 
 if (UNIX)
   set( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-unused ${CMAKE_C_FLAGS}")
-  set( CMAKE_C_FLAGS "-Wno-deprecated-declarations -std=gnu11 -Wno-error=parentheses ${CMAKE_C_FLAGS}")
+  set( CMAKE_C_FLAGS "-Wno-error=deprecated-declarations -std=gnu11 -Wno-error=parentheses ${CMAKE_C_FLAGS}")
   set( CMAKE_CXX_FLAGS "-Werror -Wall -Wmissing-declarations -Wno-unused -Wno-error=parentheses ${CMAKE_CXX_FLAGS}")
-  set( CMAKE_CXX_FLAGS "-Wno-deprecated-declarations ${REGISTER_CXXFLAG} ${CMAKE_CXX_FLAGS}")
+  set( CMAKE_CXX_FLAGS "-Wno-error=deprecated-declarations ${REGISTER_CXXFLAG} ${CMAKE_CXX_FLAGS}")
   set( CMAKE_C_FLAGS_RELEASE "-O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${CMAKE_C_FLAGS}")
 endif (UNIX)
 if (MINGW)

commit aaa71f2250fca753d6f44c10d1d04081b2be5026
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Dec 27 20:53:15 2018 +0100

    Fix memory leaks in dialog-file-acces.c:geturl

diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c
index 08cb96d..085fd25 100644
--- a/gnucash/gnome-utils/dialog-file-access.c
+++ b/gnucash/gnome-utils/dialog-file-access.c
@@ -71,33 +71,35 @@ static gchar*
 geturl( FileAccessWindow* faw )
 {
     gchar* url = NULL;
-    const gchar* host;
-    const gchar* database;
-    const gchar* username;
-    const gchar* password;
-    const gchar* type;
-    const gchar* file;
-    const gchar* path;
-
-    host = gtk_entry_get_text( faw->tf_host );
-    database = gtk_entry_get_text( faw->tf_database );
-    username = gtk_entry_get_text( faw->tf_username );
-    password = gtk_entry_get_text( faw->tf_password );
-    file = gtk_file_chooser_get_filename( faw->fileChooser );
-
-    type = gtk_combo_box_text_get_active_text(faw->cb_uri_type );
-    if ( gnc_uri_is_file_protocol( type ) )
+    const gchar* host = NULL;
+    const gchar* database = NULL;
+    const gchar* username = NULL;
+    const gchar* password = NULL;
+    /* Not const as return value of gtk_combo_box_text_get_active_text must be freed */
+    gchar* type = NULL;
+    /* Not const as return value of gtk_file_chooser_get_filename must be freed */
+    gchar* path = NULL;
+
+    type = gtk_combo_box_text_get_active_text (faw->cb_uri_type);
+    if (gnc_uri_is_file_protocol (type))
     {
-        if ( file == NULL ) /* file protocol was chosen but no filename was set */
+        path = gtk_file_chooser_get_filename (faw->fileChooser);
+        if ( !path ) /* file protocol was chosen but no filename was set */
             return NULL;
-        else                /* file protocol was chosen with filename set */
-            path = file;
     }
     else                    /* db protocol was chosen */
-        path = database;
+    {
+        host = gtk_entry_get_text( faw->tf_host );
+        path = g_strdup(gtk_entry_get_text(faw->tf_database));
+        username = gtk_entry_get_text( faw->tf_username );
+        password = gtk_entry_get_text( faw->tf_password );
+    }
 
     url = gnc_uri_create_uri (type, host, 0, username, password, path);
 
+    g_free (type);
+    g_free (path);
+
     return url;
 }
 

commit 4b398325eac49bdd16b9de216ebb636245c1fa77
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Dec 27 20:45:43 2018 +0100

    Redesign gnc-uri-utils
    
    - gnc_uri_get_components will now return NULL as protocol if the input is a normal
      file system path instead of a uri (it used to return 'file')
    - gnc_uri_get_protocol will now return NULL if the input is a normal
      file system path instead of a uri (it used to return 'file')
    - gnc_uri_is_file_protocol now returns FALSE if protocol is NULL (it used to return TRUE)
    - gnc_uri_is_file_uri now returns FALSE if input is a normal file
      system path instead of a uri (it used to return TRUE)
    - a new function gnc_uri_targets_local_fs will return TRUE only if its input
      is either a file uri or a normal file system path. This function is now mostly
      used instead of gnc_uri_is_file_uri in the current code base
    - a new function gnc_uri_is_uri is added to check whether its input
      is a valid uri (has protocol, path and hostname for non-file uris)

diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c
index 3126d3b..08cb96d 100644
--- a/gnucash/gnome-utils/dialog-file-access.c
+++ b/gnucash/gnome-utils/dialog-file-access.c
@@ -335,7 +335,7 @@ gnc_ui_file_access (GtkWindow *parent, int type)
     if (type == FILE_ACCESS_OPEN || type == FILE_ACCESS_SAVE_AS)
     {
         last = gnc_history_get_last();
-        if ( last && gnc_uri_is_file_uri ( last ) )
+        if ( last && gnc_uri_targets_local_fs (last))
         {
             gchar *filepath = gnc_uri_get_path ( last );
             faw->starting_dir = g_path_get_dirname( filepath );
diff --git a/gnucash/gnome-utils/gnc-file.c b/gnucash/gnome-utils/gnc-file.c
index 0f8e0e4..6dc0dbd 100644
--- a/gnucash/gnome-utils/gnc-file.c
+++ b/gnucash/gnome-utils/gnc-file.c
@@ -208,11 +208,11 @@ show_session_error (GtkWindow *parent,
     {
         displayname = g_strdup(_("(null)"));
     }
-    else if (! gnc_uri_is_file_uri (newfile)) /* Hide the db password in error messages */
+    else if (!gnc_uri_targets_local_fs (newfile)) /* Hide the db password in error messages */
         displayname = gnc_uri_normalize_uri ( newfile, FALSE);
     else
     {
-        /* Strip the protocol from the file name. */
+        /* Strip the protocol from the file name and ensure absolute filename. */
         char *uri = gnc_uri_normalize_uri(newfile, FALSE);
         displayname = gnc_uri_get_path(uri);
         g_free(uri);
@@ -515,7 +515,7 @@ gnc_add_history (QofSession * session)
     if ( !strlen (url) )
         return;
 
-    if ( gnc_uri_is_file_uri ( url ) )
+    if (gnc_uri_targets_local_fs (url))
         file = gnc_uri_get_path ( url );
     else
         file = gnc_uri_normalize_uri ( url, FALSE ); /* Note that the password is not saved in history ! */
@@ -689,8 +689,10 @@ RESTART:
      * function will ask the user to enter a password. The user can
      * cancel this dialog, in which case the open file action will be
      * abandoned.
+     * Note newfile is normalized uri so we can safely call
+     * gnc_uri_is_file_protocol on it.
      */
-    if ( !gnc_uri_is_file_protocol (protocol) && !password)
+    if (!gnc_uri_is_file_protocol (protocol) && !password)
     {
         gboolean have_valid_pw = FALSE;
         have_valid_pw = gnc_keyring_get_password ( NULL, protocol, hostname, port,
@@ -774,10 +776,11 @@ RESTART:
                      );
         int rc;
 
-        if (! gnc_uri_is_file_uri (newfile)) /* Hide the db password in error messages */
+        /* Hide the db password and local filesystem schemes in error messages */
+        if (!gnc_uri_is_file_uri (newfile))
             displayname = gnc_uri_normalize_uri ( newfile, FALSE);
         else
-            displayname = g_strdup (newfile);
+            displayname = gnc_uri_get_path (newfile);
 
         dialog = gtk_message_dialog_new(parent,
                                         0,
@@ -1050,7 +1053,7 @@ gnc_file_open (GtkWindow *parent)
     if (!gnc_file_query_save (parent, TRUE))
         return FALSE;
 
-    if ( last && gnc_uri_is_file_uri ( last ) )
+    if ( last && gnc_uri_targets_local_fs (last))
     {
         gchar *filepath = gnc_uri_get_path ( last );
         default_dir = g_path_get_dirname( filepath );
@@ -1099,7 +1102,7 @@ gnc_file_export (GtkWindow *parent)
     ENTER(" ");
 
     last = gnc_history_get_last();
-    if ( last && gnc_uri_is_file_uri ( last ) )
+    if ( last && gnc_uri_targets_local_fs (last))
     {
         gchar *filepath = gnc_uri_get_path ( last );
         default_dir = g_path_get_dirname( filepath );
@@ -1198,7 +1201,9 @@ gnc_file_do_export(GtkWindow *parent, const char * filename)
         newfile = norm_file;
     }
 
-    /* Some extra steps for file based uri's only */
+    /* Some extra steps for file based uri's only
+     * Note newfile is normalized uri so we can safely call
+     * gnc_uri_is_file_protocol on it. */
     if (gnc_uri_is_file_protocol(protocol))
     {
         if (check_file_path (path))
@@ -1360,7 +1365,7 @@ gnc_file_save_as (GtkWindow *parent)
     ENTER(" ");
 
     last = gnc_history_get_last();
-    if ( last && gnc_uri_is_file_uri ( last ) )
+    if ( last && gnc_uri_targets_local_fs (last))
     {
         gchar *filepath = gnc_uri_get_path ( last );
         default_dir = g_path_get_dirname( filepath );
@@ -1430,7 +1435,9 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
         newfile = norm_file;
     }
 
-    /* Some extra steps for file based uri's only */
+    /* Some extra steps for file based uri's only
+     * Note newfile is normalized uri so we can safely call
+     * gnc_uri_is_file_protocol on it. */
     if (gnc_uri_is_file_protocol(protocol))
     {
         if (check_file_path (path))
diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index 6e0d277..921e1b6 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -1518,7 +1518,7 @@ gnc_main_window_generate_title (GncMainWindow *window)
         filename = g_strdup(_("Unsaved Book"));
     else
     {
-        if ( gnc_uri_is_file_uri ( book_id ) )
+        if (gnc_uri_targets_local_fs (book_id))
         {
             /* The filename is a true file.
              * The Gnome HIG 2.0 recommends only the file name (no path) be used. (p15) */
@@ -1657,7 +1657,7 @@ static gchar *generate_statusbar_lastmodified_message()
         return NULL;
     else
     {
-        if ( gnc_uri_is_file_uri ( book_id ) )
+        if (gnc_uri_targets_local_fs (book_id))
         {
 #ifdef HAVE_SYS_STAT_H
             /* The filename is a true file. */
diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c
index de91110..fb2e064 100644
--- a/gnucash/gnome-utils/gnc-plugin-file-history.c
+++ b/gnucash/gnome-utils/gnc-plugin-file-history.c
@@ -329,7 +329,7 @@ gnc_history_generate_label (int index, const gchar *filename)
     gchar *label, *result;
     gchar **splitlabel;
 
-    if ( gnc_uri_is_file_uri ( filename ) )
+    if (gnc_uri_targets_local_fs (filename))
     {
         /* for file paths, only display the file name */
         gchar *filepath = gnc_uri_get_path ( filename );
@@ -368,7 +368,7 @@ static gchar *
 gnc_history_generate_tooltip (int index, const gchar *filename)
 {
 
-    if ( gnc_uri_is_file_uri ( filename ) )
+    if (gnc_uri_targets_local_fs (filename))
         /* for file paths, display the full file path */
         return gnc_uri_get_path ( filename );
     else
diff --git a/libgnucash/app-utils/gnc-state.c b/libgnucash/app-utils/gnc-state.c
index 8b2f8d9..c305f08 100644
--- a/libgnucash/app-utils/gnc-state.c
+++ b/libgnucash/app-utils/gnc-state.c
@@ -97,7 +97,7 @@ gnc_state_set_base (const QofSession *session)
     guid = qof_entity_get_guid(QOF_INSTANCE(book));
     guid_to_string_buff(guid, guid_string);
 
-    if (gnc_uri_is_file_uri (uri))
+    if (gnc_uri_targets_local_fs (uri))
     {
         /* The book_uri is a true file, use its basename. */
         gchar *path = gnc_uri_get_path (uri);
diff --git a/libgnucash/engine/gnc-uri-utils.c b/libgnucash/engine/gnc-uri-utils.c
index 0a96978..bfa0381 100644
--- a/libgnucash/engine/gnc-uri-utils.c
+++ b/libgnucash/engine/gnc-uri-utils.c
@@ -27,6 +27,34 @@
 #include "gnc-filepath-utils.h"
 #include "qofsession.h"
 
+/* Checks if the given uri is a valid uri
+ */
+gboolean gnc_uri_is_uri (const gchar *uri)
+{
+
+    gchar *protocol = NULL, *hostname = NULL;
+    gchar *username = NULL, *password = NULL;
+    gchar *path     = NULL;
+    gint   port = 0;
+    gboolean is_uri = FALSE;
+
+    gnc_uri_get_components ( uri, &protocol, &hostname, &port,
+                             &username, &password, &path );
+
+    /* For gnucash to consider a uri valid the following must be true:
+     * - protocol and path must not be NULL
+     * - for anything but local filesystem uris, hostname must be valid as well */
+    is_uri = (protocol && path && (gnc_uri_is_file_protocol(protocol) || hostname));
+
+    g_free (protocol);
+    g_free (hostname);
+    g_free (username);
+    g_free (password);
+    g_free (path);
+
+    return is_uri;
+}
+
 /* Checks if the given protocol is used to refer to a file
  * (as opposed to a network service)
  */
@@ -52,17 +80,19 @@ gboolean gnc_uri_is_known_protocol (const gchar *protocol)
 
 /* Checks if the given protocol is used to refer to a file
  * (as opposed to a network service)
- * For simplicity, handle all unknown protocols as if it were
- * file based protocols. This will avoid password lookups and such.
+ * Note unknown protocols are always considered network protocols.
+ *
+ * *Compatibility note:*
+ * This used to be the other way around before gnucash 3.4. Before
+ * that unknown protocols were always considered local file system
+ * uri protocols.
  */
 gboolean gnc_uri_is_file_protocol (const gchar *protocol)
 {
-    if ( !g_ascii_strcasecmp (protocol, "mysql") ||
-            !g_ascii_strcasecmp (protocol, "postgres")
-       )
-        return FALSE;
-    else
-        return TRUE;
+    return (protocol &&
+            (!g_ascii_strcasecmp (protocol, "file") ||
+             !g_ascii_strcasecmp (protocol, "xml") ||
+             !g_ascii_strcasecmp (protocol, "sqlite3")));
 }
 
 /* Checks if the given uri defines a file
@@ -78,6 +108,37 @@ gboolean gnc_uri_is_file_uri (const gchar *uri)
     return result;
 }
 
+/* Checks if the given uri is a valid uri
+ */
+gboolean gnc_uri_targets_local_fs (const gchar *uri)
+{
+
+    gchar *protocol = NULL, *hostname = NULL;
+    gchar *username = NULL, *password = NULL;
+    gchar *path     = NULL;
+    gint   port = 0;
+    gboolean is_local_fs = FALSE;
+
+    gnc_uri_get_components ( uri, &protocol, &hostname, &port,
+                             &username, &password, &path );
+
+    /* For gnucash to consider a uri to target the local fs:
+     * path must not be NULL
+     * AND
+     *   protocol should be NULL
+     *   OR
+     *   protocol must be file type protocol (file, xml, sqlite) */
+    is_local_fs = (path && (!protocol || gnc_uri_is_file_protocol(protocol)));
+
+    g_free (protocol);
+    g_free (hostname);
+    g_free (username);
+    g_free (password);
+    g_free (path);
+
+    return is_local_fs;
+}
+
 /* Splits a uri into its separate components */
 void gnc_uri_get_components (const gchar *uri,
                              gchar **protocol,
@@ -103,9 +164,9 @@ void gnc_uri_get_components (const gchar *uri,
     splituri = g_strsplit ( uri, "://", 2 );
     if ( splituri[1] == NULL )
     {
-        /* No protocol means simple file uri */
-        *protocol = g_strdup ( "file" );
-        *path     = g_strdup ( splituri[0] );
+        /* No protocol means simple file path.
+           Set path to copy of the input. */
+        *path     = g_strdup ( uri );
         g_strfreev ( splituri );
         return;
     }
diff --git a/libgnucash/engine/gnc-uri-utils.h b/libgnucash/engine/gnc-uri-utils.h
index e2b4517..f1756b6 100644
--- a/libgnucash/engine/gnc-uri-utils.h
+++ b/libgnucash/engine/gnc-uri-utils.h
@@ -34,6 +34,25 @@
  *  (being protocol, host name, port, user name, password and path) or
  *  to compose a uri from these separate components.
  *
+ *  A full uri can be described as:
+ *
+ *  @li @c proto://[[username[:password]@]hostname[:port]]/path (universal uri)
+ *  @li @c file://[localhost]/path (uri refering to a file on the local file system)
+ *
+ *  Anything in square brackets is optional.
+ *
+ *  While not strictly uris this function will also accept input in the form
+ *  of a local file system path for convenience:
+ *
+ *  @li @c some/filesystem/path A simple relative file system path (unix style)
+ *  @li @c /some/filesystem/path A simple absolute file system path (unix style)
+ *  @li @c some\\windows\\path A simple relative file system path (Windows style)
+ *  @li @c c:\\some\\windows\\path A simple file system path (Windows style)
+ *
+ *  The local path will then be considered as the path component of a uri where
+ *  appropriate. In case of conversion from a file system path to a uri the relative
+ *  paths will be converted to absolute paths as uris don't allow relative paths.
+ *
  */
 
 #ifndef GNCURIUTILS_H_
@@ -42,33 +61,35 @@
 #define GNC_DATAFILE_EXT ".gnucash"
 #define GNC_LOGFILE_EXT  ".log"
 
-/** Converts a uri in separate components.
+/** Checks if the given uri is a valid uri
  *
- *  Uri's can take any of the following forms:
+ *  A valid uri is defined by having at least a protocol and a path.
+ *  If the uri is not referring to a file on the local file system
+ *  a hostname should be set as well.
  *
- *  @li @c /some/filesystem/path A simple file system path (unix style)
- *  @li @c c:\\some\\windows\\path A simple file system path (Windows style)
- *  @li @c proto://[[username[:password]@]hostname[:port]]/path (universal uri)
- *
- *  In the last form, anything in square brackets is optional.
+ *  @param uri The uri to check
  *
+ *  @return TRUE if the input is a valid uri, FALSE otherwise
+ */
+gboolean gnc_uri_is_uri (const gchar *uri);
+
+/** Converts a uri in separate components.
+  *
  *  The function allocates memory for each of the components that it finds
  *  in the uri. The calling function should free this memory with g_free
- *  if the items are no longer needed.
+ *  when the items are no longer needed.
  *
  *  @param uri The uri to convert
  *
  *  @param protocol The protocol for this uri. If the uri didn't have an
- *  explicit protocol, 'file' will be the assumed protocol and hence what
- *  will be returned.
+ *  explicit protocol, NULL will be returned.
  *  @param hostname The host name of the server to connect to. In case of
- *  the 'file' protocol, this will be NULL
+ *  the local file system path, NULL will be returned
  *  @param port An optional port to connect to or 0 if the default port is to
- *  be used. For the 'file' protocol this is always 0 as well.
+ *  be used. For local filesystem path this is always 0 as well.
  *  @param username Optional user name found in this uri or NULL if none is found.
  *  @param password Optional password found in this uri or NULL if none is found.
- *  @param path The path found in this uri. Note that if the protocol is a file based
- *  protocol, the path will be converted to an absolute path.
+ *  @param path The path found in this uri.
  *
  */
 
@@ -82,35 +103,19 @@ void gnc_uri_get_components (const gchar *uri,
 
 /** Extracts the protocol from a uri
  *
- *  Uri's can take any of the following forms:
- *
- *  @li @c /some/filesystem/path A simple file system path (unix style)
- *  @li @c c:\\some\\windows\\path A simple file system path (Windows style)
- *  @li @c proto://[[username[:password]@]hostname[:port]]/path (universal uri)
- *
- *  In the last form, anything in square brackets is optional.
- *
  *  The function allocates memory for the protocol. The calling function should
  *  free this memory with g_free if it no longer needs the string.
  *
  *  @param uri The uri to extract the protocol from
  *
  *  @return The protocol for this uri. If the uri didn't have an
- *  explicit protocol, 'file' will be returned as protocol.
+ *  explicit protocol, NULL will be returned.
  */
 
 gchar *gnc_uri_get_protocol (const gchar *uri);
 
 /** Extracts the path part from a uri
  *
- *  Uri's can take any of the following forms:
- *
- *  @li @c /some/filesystem/path A simple file system path (unix style)
- *  @li @c c:\\some\\windows\\path A simple file system path (Windows style)
- *  @li @c proto://[[username[:password]@]hostname[:port]]/path (universal uri)
- *
- *  In the last form, anything in square brackets is optional.
- *
  *  The function allocates memory for the path. The calling function should
  *  free this memory with g_free if it no longer needs the string.
  *
@@ -160,8 +165,8 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
 /** Composes a normalized uri starting from any uri (filename, db spec,...).
  *
  *  The resulting uri will take either of these forms:
- *  @li @c file:///some/absolute/path (file could also be xml or sqlite)
- *  @li @c file://c:\\some\\windows\\path (file could also be xml or sqlite)
+ *  @li @c file:///some/absolute/path ('file' can also be xml or sqlite)
+ *  @li @c file://c:\\some\\windows\\path ('file' can also be xml or sqlite)
  *  @li @c protocol://[user[:password]@]hostname[:port]/path
  *
  *  Only the components that are provided will be inserted in the uri. The
@@ -182,6 +187,19 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
 gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password);
 
 
+/** Checks if the given uri is a valid uri
+ *
+ *  A valid uri is defined by having at least a protocol and a path.
+ *  If the uri is not referring to a file on the local file system
+ *  a hostname should be set as well.
+ *
+ *  @param uri The uri to check
+ *
+ *  @return TRUE if the input is a valid uri, FALSE otherwise
+ */
+gboolean gnc_uri_is_uri (const gchar *uri);
+
+
 /** Checks if there is a backend that explicitly stated to handle the given protocol.
  *
  *  @param protocol The protocol to check
@@ -190,6 +208,7 @@ gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password);
  */
 gboolean gnc_uri_is_known_protocol (const gchar *protocol);
 
+
 /** Checks if the given protocol is used to refer to a file
  *  (as opposed to a network service like a database or web url)
  *
@@ -210,6 +229,19 @@ gboolean gnc_uri_is_file_protocol (const gchar *protocol);
  */
 gboolean gnc_uri_is_file_uri (const gchar *uri);
 
+/** Checks if the given uri is either a valid file uri or a local filesystem path
+ *
+ *  A valid uri is defined by having at least a protocol and a path.
+ *  If the uri is not referring to a file on the local file system
+ *  a hostname should be set as well.
+ *
+ *  @param uri The uri to check
+ *
+ *  @return TRUE if the input is a valid file uri or a local filesystem path.
+ *  FALSE otherwise
+ */
+gboolean gnc_uri_targets_local_fs (const gchar *uri);
+
 /** Adds an extension to the uri if:
  *  * the uri is not empty and file based
  *  * doesn't already have the extension
diff --git a/libgnucash/engine/test/test-gnc-uri-utils.c b/libgnucash/engine/test/test-gnc-uri-utils.c
index 287d942..9bfad16 100644
--- a/libgnucash/engine/test/test-gnc-uri-utils.c
+++ b/libgnucash/engine/test/test-gnc-uri-utils.c
@@ -56,9 +56,9 @@ test_strings strs[] =
     /* basic file tests in posix like environment */
     {
         "/test/path/file.gnucash", FALSE,
-        "file", NULL, NULL, NULL, "/test/path/file.gnucash", 0,
+        NULL, NULL, NULL, NULL, "/test/path/file.gnucash", 0,
         "file:///test/path/file.gnucash",
-        "file:///test/path/file.gnucash", TRUE
+        "file:///test/path/file.gnucash", FALSE
     },
     {
         "file:///test/path/file.gnucash", FALSE,
@@ -82,9 +82,9 @@ test_strings strs[] =
     /* basic file tests in windows environment */
     {
         "c:\\test\\path\\file.gnucash", FALSE,
-        "file", NULL, NULL, NULL, "c:\\test\\path\\file.gnucash", 0,
+        NULL, NULL, NULL, NULL, "c:\\test\\path\\file.gnucash", 0,
         "file://c:\\test\\path\\file.gnucash",
-        "file://c:\\test\\path\\file.gnucash", TRUE
+        "file://c:\\test\\path\\file.gnucash", FALSE
     },
     {
         "file://c:\\test\\path\\file.gnucash", FALSE,

commit 06da9e9712b66d3b1e3deb034f5a7f21329d1e02
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Dec 27 20:52:38 2018 +0100

    Enable gnc-uri test suite
    
    It was there but never run :(

diff --git a/libgnucash/engine/test/test-engine.c b/libgnucash/engine/test/test-engine.c
index 0cbe188..c025d59 100644
--- a/libgnucash/engine/test/test-engine.c
+++ b/libgnucash/engine/test/test-engine.c
@@ -34,6 +34,7 @@ extern void test_suite_transaction();
 extern void test_suite_split();
 extern void test_suite_engine_kvp_properties (void);
 extern void test_suite_gnc_pricedb();
+extern void test_suite_gnc_uri_utils(void);
 
 int
 main (int   argc,
@@ -55,6 +56,7 @@ main (int   argc,
     test_suite_split();
     test_suite_engine_kvp_properties ();
     test_suite_gnc_pricedb();
+    test_suite_gnc_uri_utils();
 
     return g_test_run( );
 }
diff --git a/libgnucash/engine/test/test-gnc-uri-utils.c b/libgnucash/engine/test/test-gnc-uri-utils.c
index 3d162db..287d942 100644
--- a/libgnucash/engine/test/test-gnc-uri-utils.c
+++ b/libgnucash/engine/test/test-gnc-uri-utils.c
@@ -30,7 +30,7 @@
 #include <unittest-support.h>
 #include "gnc-uri-utils.h"
 
-static const gchar *suitename = "engine/uri-utils";
+static const gchar *suitename = "/engine/uri-utils";
 void test_suite_gnc_uri_utils(void);
 
 struct test_strings_struct



Summary of changes:
 CMakeLists.txt                                     |   4 +-
 common/platform.h                                  |   1 +
 gnucash/gnome-utils/CMakeLists.txt                 |   1 +
 gnucash/gnome-utils/dialog-file-access.c           |  44 ++---
 gnucash/gnome-utils/gnc-file.c                     |  77 ++++----
 gnucash/gnome-utils/gnc-main-window.c              |   4 +-
 gnucash/gnome-utils/gnc-plugin-file-history.c      |   4 +-
 libgnucash/app-utils/gnc-state.c                   |  10 +-
 libgnucash/backend/dbi/gnc-backend-dbi.cpp         |   8 +-
 .../backend/dbi/test/test-backend-dbi-basic.cpp    |   8 +-
 libgnucash/engine/gnc-uri-utils.c                  | 204 +++++++++++++-------
 libgnucash/engine/gnc-uri-utils.h                  | 209 +++++++++++++++------
 libgnucash/engine/test/test-engine.c               |   2 +
 libgnucash/engine/test/test-gnc-uri-utils.c        |  22 +--
 14 files changed, 384 insertions(+), 214 deletions(-)



More information about the gnucash-changes mailing list