Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
/*
|
|
|
|
* gnc-uri-utils.c -- utility functions to convert uri in separate
|
|
|
|
* components and back.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Geert Janssens <janssens.geert@telenet.be>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, contact:
|
|
|
|
*
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942
|
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include "gnc-uri-utils.h"
|
|
|
|
#include "gnc-filepath-utils.h"
|
2010-06-08 11:21:14 -05:00
|
|
|
#include "qofsession.h"
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
2018-12-27 13:45:43 -06:00
|
|
|
/* Checks if the given uri is a valid uri
|
|
|
|
*/
|
|
|
|
gboolean gnc_uri_is_uri (const gchar *uri)
|
|
|
|
{
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *scheme = NULL, *hostname = NULL;
|
2018-12-27 13:45:43 -06:00
|
|
|
gchar *username = NULL, *password = NULL;
|
|
|
|
gchar *path = NULL;
|
|
|
|
gint port = 0;
|
|
|
|
gboolean is_uri = FALSE;
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gnc_uri_get_components ( uri, &scheme, &hostname, &port,
|
2018-12-27 13:45:43 -06:00
|
|
|
&username, &password, &path );
|
|
|
|
|
|
|
|
/* For gnucash to consider a uri valid the following must be true:
|
2018-12-27 15:28:29 -06:00
|
|
|
* - scheme and path must not be NULL
|
2018-12-27 13:45:43 -06:00
|
|
|
* - for anything but local filesystem uris, hostname must be valid as well */
|
2018-12-27 15:28:29 -06:00
|
|
|
is_uri = (scheme && path && (gnc_uri_is_file_scheme(scheme) || hostname));
|
2018-12-27 13:45:43 -06:00
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
g_free (scheme);
|
2018-12-27 13:45:43 -06:00
|
|
|
g_free (hostname);
|
|
|
|
g_free (username);
|
|
|
|
g_free (password);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
return is_uri;
|
|
|
|
}
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
/* Checks if the given scheme is used to refer to a file
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
* (as opposed to a network service)
|
|
|
|
*/
|
2018-12-27 15:28:29 -06:00
|
|
|
gboolean gnc_uri_is_known_scheme (const gchar *scheme)
|
2010-06-08 11:21:14 -05:00
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
gboolean is_known_scheme = FALSE;
|
2010-06-08 11:21:14 -05:00
|
|
|
GList *node;
|
2018-12-27 15:28:29 -06:00
|
|
|
GList *known_scheme_list = qof_backend_get_registered_access_method_list();
|
2010-06-08 11:21:14 -05:00
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
for ( node = known_scheme_list; node != NULL; node = node->next )
|
2010-06-08 11:21:14 -05:00
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *known_scheme = node->data;
|
|
|
|
if ( !g_ascii_strcasecmp (scheme, known_scheme) )
|
2010-06-08 11:21:14 -05:00
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
is_known_scheme = TRUE;
|
2010-06-08 11:21:14 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
g_list_free (known_scheme_list);
|
|
|
|
return is_known_scheme;
|
2010-06-08 11:21:14 -05:00
|
|
|
}
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
/* Checks if the given scheme is used to refer to a file
|
2010-06-08 11:21:14 -05:00
|
|
|
* (as opposed to a network service)
|
2018-12-27 15:28:29 -06:00
|
|
|
* Note unknown schemes are always considered network schemes.
|
2018-12-27 13:45:43 -06:00
|
|
|
*
|
|
|
|
* *Compatibility note:*
|
|
|
|
* This used to be the other way around before gnucash 3.4. Before
|
2018-12-27 15:28:29 -06:00
|
|
|
* that unknown schemes were always considered local file system
|
|
|
|
* uri schemes.
|
2010-06-08 11:21:14 -05:00
|
|
|
*/
|
2018-12-27 15:28:29 -06:00
|
|
|
gboolean gnc_uri_is_file_scheme (const gchar *scheme)
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
return (scheme &&
|
|
|
|
(!g_ascii_strcasecmp (scheme, "file") ||
|
|
|
|
!g_ascii_strcasecmp (scheme, "xml") ||
|
|
|
|
!g_ascii_strcasecmp (scheme, "sqlite3")));
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Checks if the given uri defines a file
|
|
|
|
* (as opposed to a network service)
|
|
|
|
*/
|
|
|
|
gboolean gnc_uri_is_file_uri (const gchar *uri)
|
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *scheme = gnc_uri_get_scheme ( uri );
|
|
|
|
gboolean result = gnc_uri_is_file_scheme ( scheme );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
g_free ( scheme );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-12-27 13:45:43 -06:00
|
|
|
/* Checks if the given uri is a valid uri
|
|
|
|
*/
|
|
|
|
gboolean gnc_uri_targets_local_fs (const gchar *uri)
|
|
|
|
{
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *scheme = NULL, *hostname = NULL;
|
2018-12-27 13:45:43 -06:00
|
|
|
gchar *username = NULL, *password = NULL;
|
|
|
|
gchar *path = NULL;
|
|
|
|
gint port = 0;
|
|
|
|
gboolean is_local_fs = FALSE;
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gnc_uri_get_components ( uri, &scheme, &hostname, &port,
|
2018-12-27 13:45:43 -06:00
|
|
|
&username, &password, &path );
|
|
|
|
|
|
|
|
/* For gnucash to consider a uri to target the local fs:
|
|
|
|
* path must not be NULL
|
|
|
|
* AND
|
2018-12-27 15:28:29 -06:00
|
|
|
* scheme should be NULL
|
2018-12-27 13:45:43 -06:00
|
|
|
* OR
|
2018-12-27 15:28:29 -06:00
|
|
|
* scheme must be file type scheme (file, xml, sqlite) */
|
|
|
|
is_local_fs = (path && (!scheme || gnc_uri_is_file_scheme(scheme)));
|
2018-12-27 13:45:43 -06:00
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
g_free (scheme);
|
2018-12-27 13:45:43 -06:00
|
|
|
g_free (hostname);
|
|
|
|
g_free (username);
|
|
|
|
g_free (password);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
return is_local_fs;
|
|
|
|
}
|
|
|
|
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
/* Splits a uri into its separate components */
|
|
|
|
void gnc_uri_get_components (const gchar *uri,
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar **scheme,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar **hostname,
|
2010-03-13 09:48:09 -06:00
|
|
|
gint32 *port,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar **username,
|
|
|
|
gchar **password,
|
|
|
|
gchar **path)
|
|
|
|
{
|
2012-05-26 18:47:34 -05:00
|
|
|
gchar **splituri;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar *url = NULL, *tmpusername = NULL, *tmphostname = NULL;
|
|
|
|
gchar *delimiter = NULL;
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
*scheme = NULL;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
*hostname = NULL;
|
2018-12-27 15:28:29 -06:00
|
|
|
*port = 0;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
*username = NULL;
|
|
|
|
*password = NULL;
|
|
|
|
*path = NULL;
|
|
|
|
|
2013-12-02 17:46:49 -06:00
|
|
|
g_return_if_fail( uri != NULL && strlen (uri) > 0);
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
|
|
|
splituri = g_strsplit ( uri, "://", 2 );
|
|
|
|
if ( splituri[1] == NULL )
|
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
/* No scheme means simple file path.
|
2018-12-27 13:45:43 -06:00
|
|
|
Set path to copy of the input. */
|
|
|
|
*path = g_strdup ( uri );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
g_strfreev ( splituri );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
/* At least a scheme was found, set it here */
|
|
|
|
*scheme = g_strdup ( splituri[0] );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
if ( gnc_uri_is_file_scheme ( *scheme ) )
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
{
|
2019-03-29 12:34:45 -05:00
|
|
|
/* a true file uri on windows can start file:///N:/
|
2019-04-19 09:51:29 -05:00
|
|
|
so we come here with /N:/, it could also be /N:\
|
|
|
|
*/
|
|
|
|
if (g_str_has_prefix (splituri[1], "/") &&
|
|
|
|
((g_strstr_len (splituri[1], -1, ":/") != NULL) || (g_strstr_len (splituri[1], -1, ":\\") != NULL)))
|
2019-03-29 12:34:45 -05:00
|
|
|
{
|
|
|
|
gchar *ptr = splituri[1];
|
|
|
|
*path = gnc_resolve_file_path ( ptr + 1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*path = gnc_resolve_file_path ( splituri[1] );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
g_strfreev ( splituri );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Protocol indicates full network style uri, let's see if it
|
|
|
|
* has a username and/or password
|
|
|
|
*/
|
|
|
|
url = g_strdup (splituri[1]);
|
|
|
|
g_strfreev ( splituri );
|
|
|
|
|
2010-03-12 16:39:48 -06:00
|
|
|
/* Check for "@" sign, but start from the end - the password may contain
|
2010-03-12 16:43:47 -06:00
|
|
|
* this sign as well
|
2010-03-12 16:39:48 -06:00
|
|
|
*/
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
delimiter = g_strrstr ( url, "@" );
|
|
|
|
if ( delimiter != NULL )
|
|
|
|
{
|
|
|
|
/* There is at least a username in the url */
|
|
|
|
delimiter[0] = '\0';
|
|
|
|
tmpusername = url;
|
|
|
|
tmphostname = delimiter + 1;
|
|
|
|
|
2010-03-12 16:39:48 -06:00
|
|
|
/* Check if there's a password too by looking for a :
|
|
|
|
* Start from the beginning this time to avoid possible :
|
|
|
|
* in the password */
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
delimiter = g_strstr_len ( tmpusername, -1, ":" );
|
|
|
|
if ( delimiter != NULL )
|
|
|
|
{
|
|
|
|
/* There is password in the url */
|
|
|
|
delimiter[0] = '\0';
|
2010-03-27 16:01:56 -05:00
|
|
|
*password = g_strdup ( (const gchar*)(delimiter + 1) );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
}
|
2010-03-12 16:39:48 -06:00
|
|
|
*username = g_strdup ( (const gchar*)tmpusername );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No username and password were given */
|
|
|
|
tmphostname = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the path part */
|
|
|
|
delimiter = g_strstr_len ( tmphostname, -1, "/" );
|
|
|
|
if ( delimiter != NULL )
|
|
|
|
{
|
2010-03-13 09:48:09 -06:00
|
|
|
delimiter[0] = '\0';
|
2018-12-27 15:28:29 -06:00
|
|
|
if ( gnc_uri_is_file_scheme ( *scheme ) ) /* always return absolute file paths */
|
2010-03-27 16:01:56 -05:00
|
|
|
*path = gnc_resolve_file_path ( (const gchar*)(delimiter + 1) );
|
2010-03-13 09:48:09 -06:00
|
|
|
else /* path is no file path, so copy it as is */
|
2010-03-27 16:01:56 -05:00
|
|
|
*path = g_strdup ( (const gchar*)(delimiter + 1) );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for a port specifier */
|
|
|
|
delimiter = g_strstr_len ( tmphostname, -1, ":" );
|
|
|
|
if ( delimiter != NULL )
|
|
|
|
{
|
2010-03-13 09:48:09 -06:00
|
|
|
delimiter[0] = '\0';
|
2010-03-27 16:01:56 -05:00
|
|
|
*port = g_ascii_strtoll ( delimiter + 1, NULL, 0 );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
*hostname = g_strdup ( (const gchar*)tmphostname );
|
|
|
|
|
|
|
|
g_free ( url );
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *gnc_uri_get_scheme (const gchar *uri)
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *scheme = NULL;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar *hostname = NULL;
|
2010-03-13 09:48:09 -06:00
|
|
|
gint32 port = 0;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar *username = NULL;
|
|
|
|
gchar *password = NULL;
|
|
|
|
gchar *path = NULL;
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gnc_uri_get_components ( uri, &scheme, &hostname, &port,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
&username, &password, &path );
|
|
|
|
|
|
|
|
g_free (hostname);
|
|
|
|
g_free (username);
|
|
|
|
g_free (password);
|
|
|
|
g_free (path);
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
return scheme;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
gchar *gnc_uri_get_path (const gchar *uri)
|
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *scheme = NULL;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar *hostname = NULL;
|
2010-03-13 09:48:09 -06:00
|
|
|
gint32 port = 0;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar *username = NULL;
|
|
|
|
gchar *password = NULL;
|
|
|
|
gchar *path = NULL;
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gnc_uri_get_components ( uri, &scheme, &hostname, &port,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
&username, &password, &path );
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
g_free (scheme);
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
g_free (hostname);
|
|
|
|
g_free (username);
|
|
|
|
g_free (password);
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generates a normalized uri from the separate components */
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *gnc_uri_create_uri (const gchar *scheme,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
const gchar *hostname,
|
2010-03-13 09:48:09 -06:00
|
|
|
gint32 port,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
const gchar *username,
|
|
|
|
const gchar *password,
|
|
|
|
const gchar *path)
|
|
|
|
{
|
2010-03-27 16:01:56 -05:00
|
|
|
gchar *userpass = NULL, *portstr = NULL, *uri = NULL;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
|
|
|
g_return_val_if_fail( path != 0, NULL );
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
if (!scheme || gnc_uri_is_file_scheme (scheme))
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
{
|
|
|
|
/* Compose a file based uri, which means ignore everything but
|
2018-12-27 15:28:29 -06:00
|
|
|
* 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
|
2010-06-08 11:21:14 -05:00
|
|
|
* path info as is.
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
*/
|
2010-06-08 11:21:14 -05:00
|
|
|
gchar *abs_path;
|
2019-03-29 12:34:45 -05:00
|
|
|
gchar *uri_scheme;
|
2018-12-27 15:28:29 -06:00
|
|
|
if (scheme && (!gnc_uri_is_known_scheme (scheme)) )
|
2010-06-08 11:21:14 -05:00
|
|
|
abs_path = g_strdup ( path );
|
|
|
|
else
|
|
|
|
abs_path = gnc_resolve_file_path ( path );
|
2019-03-29 12:34:45 -05:00
|
|
|
|
|
|
|
if (!scheme)
|
|
|
|
uri_scheme = g_strdup ("file");
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
else
|
2019-03-29 12:34:45 -05:00
|
|
|
uri_scheme = g_strdup (scheme);
|
|
|
|
|
2019-04-12 05:46:59 -05:00
|
|
|
/* Arrive here with...
|
|
|
|
*
|
|
|
|
* /my/path/to/file with space.txt
|
|
|
|
* becomes file:///my/path/to/file with space.txt
|
|
|
|
*
|
|
|
|
* c:\my\path\to\file with space.txt
|
|
|
|
* becomes file:///c:\my\path\to\file with space.txt
|
|
|
|
*
|
|
|
|
* \\myserver\share\path\to\file with space.txt
|
|
|
|
* becomes file://\\myserver\share\path\to\file with space.txt
|
|
|
|
*
|
2021-02-05 13:52:33 -06:00
|
|
|
* probably they should all be forward slashes and spaces escaped
|
2019-04-12 05:46:59 -05:00
|
|
|
* also with UNC it could be file://myserver/share/path/to/file with space.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (g_str_has_prefix (abs_path, "/") || g_str_has_prefix (abs_path, "\\"))
|
2019-03-29 12:34:45 -05:00
|
|
|
uri = g_strdup_printf ( "%s://%s", uri_scheme, abs_path );
|
|
|
|
else // for windows add an extra "/"
|
|
|
|
uri = g_strdup_printf ( "%s:///%s", uri_scheme, abs_path );
|
|
|
|
|
|
|
|
g_free (uri_scheme);
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
g_free (abs_path);
|
2019-03-29 12:34:45 -05:00
|
|
|
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Not a file based uri, we need to setup all components that are not NULL
|
|
|
|
* For this scenario, hostname is mandatory.
|
|
|
|
*/
|
|
|
|
g_return_val_if_fail( hostname != 0, NULL );
|
|
|
|
|
2010-05-19 15:27:12 -05:00
|
|
|
if ( username != NULL && *username )
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
{
|
2010-05-19 15:27:12 -05:00
|
|
|
if ( password != NULL && *password )
|
2010-03-13 09:48:09 -06:00
|
|
|
userpass = g_strdup_printf ( "%s:%s@", username, password );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
else
|
2010-03-13 09:48:09 -06:00
|
|
|
userpass = g_strdup_printf ( "%s@", username );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
}
|
2010-03-13 09:48:09 -06:00
|
|
|
else
|
|
|
|
userpass = g_strdup ( "" );
|
|
|
|
|
|
|
|
if ( port != 0 )
|
|
|
|
portstr = g_strdup_printf ( ":%d", port );
|
|
|
|
else
|
|
|
|
portstr = g_strdup ( "" );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
|
|
|
// XXX Do I have to add the slash always or are there situations
|
|
|
|
// it is in the path already ?
|
2018-12-27 15:28:29 -06:00
|
|
|
uri = g_strconcat ( scheme, "://", userpass, hostname, portstr, "/", path, NULL );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
|
|
|
g_free ( userpass );
|
2010-03-13 09:48:09 -06:00
|
|
|
g_free ( portstr );
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
|
|
|
|
return uri;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password)
|
|
|
|
{
|
2018-12-27 15:28:29 -06:00
|
|
|
gchar *scheme = NULL;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar *hostname = NULL;
|
2010-03-13 09:48:09 -06:00
|
|
|
gint32 port = 0;
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
gchar *username = NULL;
|
|
|
|
gchar *password = NULL;
|
|
|
|
gchar *path = NULL;
|
|
|
|
gchar *newuri = NULL;
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
gnc_uri_get_components ( uri, &scheme, &hostname, &port,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
&username, &password, &path );
|
|
|
|
if (allow_password)
|
2018-12-27 15:28:29 -06:00
|
|
|
newuri = gnc_uri_create_uri ( scheme, hostname, port,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
username, password, path);
|
|
|
|
else
|
2018-12-27 15:28:29 -06:00
|
|
|
newuri = gnc_uri_create_uri ( scheme, hostname, port,
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
username, /* no password */ NULL, path);
|
|
|
|
|
2018-12-27 15:28:29 -06:00
|
|
|
g_free (scheme);
|
Use a normalized uri format internally to refer to data stores.
Data stores for GC can be a file (xml or sqlite3) or a database
one some server (mysql or postgres).
Wherever it makes sense internally, data stores will be referred to
via a normalized uri:
protocol://user:password@host:port/path
Depending on the context and story type some of these parts are optional or unused.
To achieve this, a new utility interface has been setup:
gnc_uri_<xxx>_<yyy>
that can be used to manipulate the uris or convert from non-normalized
formats to normalized and back.
For example, when the user selects a file in the Open or Save As dialog,
gnc_uri_get_normalized_uri will convert the file into a normalized uri.
Or when the actual filename is needed this can be extracted with
gnc_uri_get_path.
You can also test if a uri defines a file or something else with
gnc_uri_is_file_uri.
For the complete documentation, see src/core-utils/gnc-uri-uitls.h
This commit installs gnc-uri-utils and modifies the source where it makes
sense to use its convenience functions. This concerns all functions that
had to deal with file access in some way or another, the history module
and the functions that generate the history menu list and the window titles.
Note that gnc-uri-utils replaces xaccResolveFilePath and xaccResolveUrl in all cases.
xaccResolveUrl has been removed, because gnc-uri-utils fully replaces its functionality.
xaccResolveFilePath is used internally in gnc-uri-utils to ensure an absolute path
is always returned (in case of a file uri, not for db uris). But it has been renamed to
gnc_resolve_file_path to be more consistent with the other functions.
Lastly, this commit also adds a first implementation to work with a keyring to
store and retrieve passwords, althoug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18842 57a11ea4-9604-0410-9ed3-97b8803252fd
2010-03-05 14:15:31 -06:00
|
|
|
g_free (hostname);
|
|
|
|
g_free (username);
|
|
|
|
g_free (password);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
return newuri;
|
|
|
|
}
|
2010-06-12 04:23:51 -05:00
|
|
|
|
|
|
|
gchar *gnc_uri_add_extension ( const gchar *uri, const gchar *extension )
|
|
|
|
{
|
|
|
|
g_return_val_if_fail( uri != 0, NULL );
|
|
|
|
|
|
|
|
/* Only add extension if the user provided the extension and the uri is
|
|
|
|
* file based.
|
|
|
|
*/
|
|
|
|
if ( !extension || !gnc_uri_is_file_uri( uri ) )
|
|
|
|
return g_strdup( uri );
|
|
|
|
|
|
|
|
/* Don't add extension if it's already there */
|
|
|
|
if ( g_str_has_suffix( uri, extension ) )
|
|
|
|
return g_strdup( uri );
|
|
|
|
|
|
|
|
/* Ok, all tests passed, let's add the extension */
|
|
|
|
return g_strconcat( uri, extension, NULL );
|
|
|
|
}
|