r17321 - gnucash/branches/gda-dev2 - Add new method qof_backend_get_registered_access_method_list() which
Phil Longstaff
plongstaff at cvs.gnucash.org
Sun Jul 13 12:01:19 EDT 2008
Author: plongstaff
Date: 2008-07-13 12:01:18 -0400 (Sun, 13 Jul 2008)
New Revision: 17321
Trac: http://svn.gnucash.org/trac/changeset/17321
Modified:
gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.c
gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.h
gnucash/branches/gda-dev2/src/engine/gnc-filepath-utils.c
Log:
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().
Modified: gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.c
===================================================================
--- gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.c 2008-07-13 03:14:24 UTC (rev 17320)
+++ gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.c 2008-07-13 16:01:18 UTC (rev 17321)
@@ -63,6 +63,20 @@
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 */
Modified: gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.h
===================================================================
--- gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.h 2008-07-13 03:14:24 UTC (rev 17320)
+++ gnucash/branches/gda-dev2/lib/libqof/qof/qofsession.h 2008-07-13 16:01:18 UTC (rev 17321)
@@ -436,5 +436,10 @@
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 */
/** @} */
Modified: gnucash/branches/gda-dev2/src/engine/gnc-filepath-utils.c
===================================================================
--- gnucash/branches/gda-dev2/src/engine/gnc-filepath-utils.c 2008-07-13 03:14:24 UTC (rev 17320)
+++ gnucash/branches/gda-dev2/src/engine/gnc-filepath-utils.c 2008-07-13 16:01:18 UTC (rev 17321)
@@ -285,6 +285,9 @@
char *
xaccResolveURL (const char * pathfrag)
{
+ GList* list;
+ GList* node;
+
/* seriously invalid */
if (!pathfrag) return NULL;
@@ -296,13 +299,28 @@
*/
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));
}
More information about the gnucash-changes
mailing list