diff --git a/lib/libqof/qof/qofsession.c b/lib/libqof/qof/qofsession.c index f19af9240a..0992503b7b 100644 --- a/lib/libqof/qof/qofsession.c +++ b/lib/libqof/qof/qofsession.c @@ -63,6 +63,20 @@ qof_backend_register_provider (QofBackendProvider *prov) provider_list = g_slist_append (provider_list, prov); } +GList* +qof_backend_get_registered_access_method_list(void) +{ + GList* list = NULL; + GSList* node; + + for( node = provider_list; node != NULL; node = node->next ) { + QofBackendProvider *prov = node->data; + list = g_list_append( list, (gchar*)prov->access_method ); + } + + return list; +} + /* ====================================================================== */ /* hook routines */ diff --git a/lib/libqof/qof/qofsession.h b/lib/libqof/qof/qofsession.h index 8f1f72af34..32f4e1b267 100644 --- a/lib/libqof/qof/qofsession.h +++ b/lib/libqof/qof/qofsession.h @@ -436,5 +436,10 @@ gboolean qof_session_export (QofSession *tmp_session, QofSession *real_session, QofPercentageFunc percentage_func); +/** Return a list of strings for the registered access methods. The owner is + * responsible for freeing the list but not the strings. + */ +GList* qof_backend_get_registered_access_method_list(void); + #endif /* QOF_SESSION_H */ /** @} */ diff --git a/src/engine/gnc-filepath-utils.c b/src/engine/gnc-filepath-utils.c index 2b8df8b766..3ad100addc 100644 --- a/src/engine/gnc-filepath-utils.c +++ b/src/engine/gnc-filepath-utils.c @@ -285,6 +285,9 @@ xaccResolveFilePath (const char * filefrag) char * xaccResolveURL (const char * pathfrag) { + GList* list; + GList* node; + /* seriously invalid */ if (!pathfrag) return NULL; @@ -296,13 +299,28 @@ xaccResolveURL (const char * pathfrag) */ if (!g_ascii_strncasecmp (pathfrag, "http://", 7) || - !g_ascii_strncasecmp (pathfrag, "https://", 8) || - !g_ascii_strncasecmp (pathfrag, "gda://", 6) || - !g_ascii_strncasecmp (pathfrag, "postgres://", 11)) + !g_ascii_strncasecmp (pathfrag, "https://", 8)) { return g_strdup(pathfrag); } + /* Check the URL against the list of registered access methods */ + list = qof_backend_get_registered_access_method_list(); + for( node = list; node != NULL; node = node->next ) { + const gchar* access_method = node->data; + if( strcmp( access_method, "file" ) != 0 && + strcmp( access_method, "xml" ) != 0 ) { + gchar s[30]; + sprintf( s, "%s://", access_method ); + if( !g_ascii_strncasecmp( pathfrag, s, strlen(s) ) ) { + g_list_free(list); + return g_strdup(pathfrag); + } + } + } + g_list_free(list); + + /* "file:" and "xml:" are handled specially */ if (!g_ascii_strncasecmp (pathfrag, "file:", 5)) { return (xaccResolveFilePath (pathfrag)); }