Commit 0978331a authored by Matthew Leeds's avatar Matthew Leeds

config-provider: Add IdeConfigurationProvider

This interface will allow build configurations to come from any plugin,
such as the flatpak one.

https://bugzilla.gnome.org/show_bug.cgi?id=777959
parent bf9b44f1
......@@ -42,6 +42,7 @@ libide_1_0_la_public_headers = \
buildsystem/ide-build-target.h \
buildsystem/ide-configuration-manager.h \
buildsystem/ide-configuration.h \
buildsystem/ide-configuration-provider.h \
buildsystem/ide-environment-variable.h \
buildsystem/ide-environment.h \
devices/ide-device-manager.h \
......@@ -211,6 +212,7 @@ libide_1_0_la_public_sources = \
buildsystem/ide-build-target.c \
buildsystem/ide-configuration-manager.c \
buildsystem/ide-configuration.c \
buildsystem/ide-configuration-provider.c \
buildsystem/ide-environment-variable.c \
buildsystem/ide-environment.c \
devices/ide-device-manager.c \
......
......@@ -32,6 +32,11 @@ file.
An individual configuration that was loaded/persisted to the .buildconfig file.
## ide-configuration-provider.*
This is the interface used for loading and unloading configurations into the
IdeConfigurationManager. The flatpak plugin is one place it's implemented.
## ide-environment.c
Manages a collection of key/value pairs (IdeEnvironmentVariable). This is a
......
/* ide-configuration-provider.c
*
* Copyright (C) 2016 Matthew Leeds <mleeds@redhat.com>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "ide-configuration-manager.h"
#include "ide-configuration-provider.h"
G_DEFINE_INTERFACE (IdeConfigurationProvider, ide_configuration_provider, G_TYPE_OBJECT)
static void
ide_configuration_provider_real_load (IdeConfigurationProvider *self,
IdeConfigurationManager *manager)
{
}
static void
ide_configuration_provider_real_unload (IdeConfigurationProvider *self,
IdeConfigurationManager *manager)
{
}
void
ide_configuration_provider_real_save_async (IdeConfigurationProvider *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
g_return_if_fail (IDE_IS_CONFIGURATION_PROVIDER (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
g_return_if_fail (G_IS_TASK (task));
g_warning ("The current IdeConfigurationProvider doesn't implement save_async");
g_task_return_boolean (task, TRUE);
}
gboolean
ide_configuration_provider_real_save_finish (IdeConfigurationProvider *self,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (IDE_IS_CONFIGURATION_PROVIDER (self), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
return TRUE;
}
static void
ide_configuration_provider_default_init (IdeConfigurationProviderInterface *iface)
{
iface->load = ide_configuration_provider_real_load;
iface->unload = ide_configuration_provider_real_unload;
iface->save_async = ide_configuration_provider_real_save_async;
iface->save_finish = ide_configuration_provider_real_save_finish;
}
void
ide_configuration_provider_load (IdeConfigurationProvider *self,
IdeConfigurationManager *manager)
{
g_return_if_fail (IDE_IS_CONFIGURATION_PROVIDER (self));
g_return_if_fail (IDE_IS_CONFIGURATION_MANAGER (manager));
IDE_CONFIGURATION_PROVIDER_GET_IFACE (self)->load (self, manager);
}
void
ide_configuration_provider_unload (IdeConfigurationProvider *self,
IdeConfigurationManager *manager)
{
g_return_if_fail (IDE_IS_CONFIGURATION_PROVIDER (self));
g_return_if_fail (IDE_IS_CONFIGURATION_MANAGER (manager));
IDE_CONFIGURATION_PROVIDER_GET_IFACE (self)->unload (self, manager);
}
void
ide_configuration_provider_save_async (IdeConfigurationProvider *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (IDE_IS_CONFIGURATION_PROVIDER (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
IDE_CONFIGURATION_PROVIDER_GET_IFACE (self)->save_async (self, cancellable, callback, user_data);
}
gboolean
ide_configuration_provider_save_finish (IdeConfigurationProvider *self,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (IDE_IS_CONFIGURATION_PROVIDER (self), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
return IDE_CONFIGURATION_PROVIDER_GET_IFACE (self)->save_finish (self, result, error);
}
/* ide-configuration-provider.h
*
* Copyright (C) 2016 Matthew Leeds <mleeds@redhat.com>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef IDE_CONFIGURATION_PROVIDER_H
#define IDE_CONFIGURATION_PROVIDER_H
#include <gio/gio.h>
#include "ide-types.h"
G_BEGIN_DECLS
#define IDE_TYPE_CONFIGURATION_PROVIDER (ide_configuration_provider_get_type ())
G_DECLARE_INTERFACE (IdeConfigurationProvider, ide_configuration_provider, IDE, CONFIGURATION_PROVIDER, GObject)
struct _IdeConfigurationProviderInterface
{
GTypeInterface parent;
void (*load) (IdeConfigurationProvider *self,
IdeConfigurationManager *manager);
void (*unload) (IdeConfigurationProvider *self,
IdeConfigurationManager *manager);
void (*save_async) (IdeConfigurationProvider *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*save_finish) (IdeConfigurationProvider *self,
GAsyncResult *result,
GError **error);
};
void ide_configuration_provider_load (IdeConfigurationProvider *self,
IdeConfigurationManager *manager);
void ide_configuration_provider_unload (IdeConfigurationProvider *self,
IdeConfigurationManager *manager);
void ide_configuration_provider_save_async (IdeConfigurationProvider *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean ide_configuration_provider_save_finish (IdeConfigurationProvider *self,
GAsyncResult *result,
GError **error);
G_END_DECLS
#endif /* IDE_CONFIGURATION_PROVIDER_H */
......@@ -46,6 +46,7 @@ G_BEGIN_DECLS
#include "buildsystem/ide-build-target.h"
#include "buildsystem/ide-configuration-manager.h"
#include "buildsystem/ide-configuration.h"
#include "buildsystem/ide-configuration-provider.h"
#include "buildsystem/ide-environment-variable.h"
#include "buildsystem/ide-environment.h"
#include "devices/ide-device-manager.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment