repo: Add private functions to access remote options

ostree_repo_pull_with_options() needs this, and I'd rather keep the
OstreeRemote struct definition tucked away in ostree-repo.c with its
own internal API.
This commit is contained in:
Matthew Barnes committed 2014-12-08 12:49:25 -05:00
1 parent f79896693e
commit ac882f2128
3 files changed
+162 -57

No files matched your search

+88
View File
@@ -231,6 +231,94 @@ ost_repo_remove_remote (OstreeRepo *self,
return removed;
}
gboolean
_ostree_repo_get_remote_option (OstreeRepo *self,
const char *remote_name,
const char *option_name,
const char *default_value,
char **out_value,
GError **error)
{
local_cleanup_remote OstreeRemote *remote = NULL;
gboolean ret = FALSE;
remote = ost_repo_get_remote (self, remote_name, error);
if (remote != NULL)
{
ret = ot_keyfile_get_value_with_default (remote->options,
remote->group,
option_name,
default_value,
out_value,
error);
}
return ret;
}
gboolean
_ostree_repo_get_remote_list_option (OstreeRepo *self,
const char *remote_name,
const char *option_name,
char ***out_value,
GError **error)
{
local_cleanup_remote OstreeRemote *remote = NULL;
gboolean ret = FALSE;
remote = ost_repo_get_remote (self, remote_name, error);
if (remote != NULL)
{
gs_strfreev char **value = NULL;
GError *local_error = NULL;
value = g_key_file_get_string_list (remote->options,
remote->group,
option_name,
NULL, &local_error);
/* Default value if key not found is always NULL. */
if (g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
g_clear_error (&local_error);
if (local_error == NULL)
{
ot_transfer_out_value (out_value, &value);
ret = TRUE;
}
}
return ret;
}
gboolean
_ostree_repo_get_remote_boolean_option (OstreeRepo *self,
const char *remote_name,
const char *option_name,
gboolean default_value,
gboolean *out_value,
GError **error)
{
local_cleanup_remote OstreeRemote *remote = NULL;
gboolean ret = FALSE;
remote = ost_repo_get_remote (self, remote_name, error);
if (remote != NULL)
{
ret = ot_keyfile_get_boolean_with_default (remote->options,
remote->group,
option_name,
default_value,
out_value,
error);
}
return ret;
}
static void
ostree_repo_finalize (GObject *object)
{