gnucash/libgnucash/engine/gnc-uri-utils.h

277 lines
10 KiB
C
Raw Normal View History

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.h -- 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
*/
/** @addtogroup Utils Utility functions
@{ */
/** @addtogroup UtilUri Uri conversion
* @{ */
/** @file gnc-uri-utils.h
* @brief Utility functions for convert uri in separate components and back
* @author Copyright (C) 2010 Geert Janssens <janssens-geert@telenet.be>
*
* These functions help you convert a uri into its separate components
* (being scheme, host name, port, user name, password and path) or
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
* to compose a uri from these separate components.
*
* For GnuCash' purposes a full uri can be described as:
*
* @li @c scheme://[[username[:password]@]hostname[:port]]/path (universal uri)
* @li @c file://[localhost]/path (uri referring to a file on the local file system)
*
* Anything in square brackets is optional.
*
* While not strictly uris this function will also accept input in the form
* of a local file system path for convenience:
*
* @li @c some/filesystem/path A simple relative file system path (unix style)
* @li @c /some/filesystem/path A simple absolute file system path (unix style)
* @li @c some\\windows\\path A simple relative file system path (Windows style)
* @li @c c:\\some\\windows\\path A simple file system path (Windows style)
*
* The local path will then be considered as the path component of a uri where
* appropriate. In case of conversion from a file system path to a uri the relative
* paths will be converted to absolute paths as uris don't allow relative paths.
*
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
*/
#ifndef GNCURIUTILS_H_
#define GNCURIUTILS_H_
#define GNC_DATAFILE_EXT ".gnucash"
#define GNC_LOGFILE_EXT ".log"
#include "platform.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Checks if the given uri is a valid 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
*
* A valid uri is defined by having at least a scheme and a path.
* If the uri is not referring to a file on the local file system
* a hostname should be set as well.
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
*
* @param uri The uri to check
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 TRUE if the input is a valid uri, FALSE otherwise
*/
gboolean gnc_uri_is_uri (const gchar *uri);
/** Converts a uri in separate components.
*
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
* The function allocates memory for each of the components that it finds
* in the uri. The calling function should free this memory with g_free
* when the items are no longer needed.
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
*
* @param uri The uri to convert
*
* @param scheme The scheme for this uri. If the uri doesn't have an
* explicit scheme, NULL will be returned.
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
* @param hostname The host name of the server to connect to. In case of
* the local file system path, NULL will be returned
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
* @param port An optional port to connect to or 0 if the default port is to
* be used. For local filesystem path this is always 0 as well.
* @param username Optional user name found in this uri or NULL if none is found.
* @param password Optional password found in this uri or NULL if none is found.
* @param path The path found in this uri.
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
*
*/
void gnc_uri_get_components (const gchar *uri,
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,
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);
/** Extracts the scheme from a 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
*
* The function allocates memory for the scheme. The calling function should
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
* free this memory with g_free if it no longer needs the string.
*
* @param uri The uri to extract the scheme from
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 The scheme for this uri. If the uri didn't have an
* explicit scheme, NULL will be returned.
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_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
/** Extracts the path part from a uri
*
* The function allocates memory for the path. The calling function should
* free this memory with g_free if it no longer needs the string.
*
* @param uri The uri to extract the path part from
*
* @return The path for this uri, or NULL if no path could be extracted.
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);
/** Composes a normalized uri starting from its separate components.
*
* The resulting uri will take either of these forms:
* @li @c file:///some/absolute/path (file could also be xml or sqlite)
* @li @c file://c:\\some\\windows\\path (file could also be xml or sqlite)
* @li @c scheme://[user[:password]@]hostname[:port]/path
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
*
* Only the components that are provided will be inserted in the uri. However
* if no scheme has been provided, 'file' will be used as default 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
*
* The function allocates memory for the uri. The calling function should
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
* free this memory with g_free the uri is no longer needed.
*
* @param scheme The scheme for this uri. If NULL,, 'file' will be used
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
* in the uri.
* @param hostname The host name of the server to connect to. This will be
* ignored for the 'file' type schemes ('file', 'xml', 'sqlite').
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
* @param port An optional port to set o, the uri, or 0 if no port is to be
* set. This will be ignored for the 'file' type schemes ('file', 'xml',
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
* 'sqlite').
* @param username Optional user name to set in the uri or NULL otherwise. This will
* be ignored for the 'file' type schemes ('file', 'xml', 'sqlite').
* @param password Optional password to set in the uri or NULL otherwise. This will
* be ignored for the 'file' type schemes ('file', 'xml', 'sqlite').
* @param path The path to set in the 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
*
* @return The normalized uri.
*/
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,
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);
/** Composes a normalized uri starting from any uri (filename, db spec,...).
*
* The resulting uri will take either of these forms:
* @li @c file:///some/absolute/path ('file' can also be xml or sqlite)
* @li @c file://c:\\some\\windows\\path ('file' can also be xml or sqlite)
* @li @c scheme://[user[:password]@]hostname[:port]/path
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
*
* Only the components that are provided will be inserted in the uri. The
* allow_password parameter controls if the password should be added to the
* returned uri when available.
* If no scheme has been provided, 'file' will be used as default 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
*
* The function allocates memory for the uri. The calling function should
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
* free this memory with g_free the uri is no longer needed.
*
* @param uri The uri that should be converted into a normalized 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
* @param allow_password If set to TRUE, the normalized uri and the input uri
* has a password, this passworld will also be set in the normalized uri.
* Otherwise no password will be set in the normalized uri.
*
* @return The normalized uri.
*/
gchar *gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password);
/** Checks if the given uri is a valid uri
*
* A valid uri is defined by having at least a scheme and a path.
* If the uri is not referring to a file on the local file system
* a hostname should be set as well.
*
* @param uri The uri to check
*
* @return TRUE if the input is a valid uri, FALSE otherwise
*/
gboolean gnc_uri_is_uri (const gchar *uri);
/** Checks if there is a backend that explicitly stated to handle the given scheme.
*
* @param scheme The scheme to check
*
* @return TRUE if at least one backend explicitly handles this scheme, otherwise FALSE
*/
gboolean gnc_uri_is_known_scheme (const gchar *scheme);
/** 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 like a database or web url)
*
* @param scheme The scheme to check
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 TRUE if the scheme is used with files, FALSE if the scheme
* is normally used with network services (database, web url,...).
* It will also return FALSE if scheme is NULL.
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
*/
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
/** Checks if the given uri defines a file
* (as opposed to a network service like a database or web url)
*
* @param uri The uri to check
*
* @return TRUE if the uri is a files, FALSE of the 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
* is normally used with network services (database, web url,...)
*/
gboolean gnc_uri_is_file_uri (const gchar *uri);
/** Checks if the given uri is either a valid file uri or a local filesystem path
*
* A valid file uri is defined by having a file targeting scheme
* ('file', 'xml' or 'sqlite3' are accepted) and a non-NULL path.
*
* @param uri The uri to check
*
* @return TRUE if the input is a valid file uri or a local filesystem path.
* FALSE otherwise
*/
gboolean gnc_uri_targets_local_fs (const gchar *uri);
/** Adds an extension to the uri if:
* * the uri is not empty and file based
* * doesn't already have the extension
*
* @param uri The uri to process
* @param extension The extension to add if missing. Note that the extension
* is added verbatim, so if a dot should be added, this
* should be part of the extension.
*
* @return The uri, but guaranteed to end with extension if the uri is file
* based. Otherwise the uri is returned unmodified. Note that the
* returned value should be freed with g_free when no longer needed.
*/
gchar *gnc_uri_add_extension ( const gchar *uri, const gchar *extension );
#ifdef __cplusplus
}
#endif
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
#endif /* GNCURIUTILS_H_ */
/** @} */
/** @} */