Add new method qof_backend_get_registered_access_method_list() which

returns a GList of the access_method strings from the registered backends.
Modify xaccResolveURL() to get and use this list rather than using hard-wired
"gda" and "postgres" access methods.  "http", "https", "file" and "xml" are
still hard-wired in xaccResolveURL().



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gda-dev2@17321 57a11ea4-9604-0410-9ed3-97b8803252fd
archive
Phil Longstaff 18 years ago
parent d2b01d5d06
commit f9502e04ef

@ -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 */

@ -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 */
/** @} */

@ -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));
}

Loading…
Cancel
Save