[gnome-builder] deploy: add IdeDeployStrategy stubs



commit eae0cc8e5cfe5ddfe7fa4ac00deced8f03f020ce
Author: Christian Hergert <chergert redhat com>
Date:   Mon Mar 5 15:58:43 2018 -0800

    deploy: add IdeDeployStrategy stubs

 src/libide/devices/ide-deploy-strategy.c | 246 +++++++++++++++++++++++++++++++
 src/libide/devices/ide-deploy-strategy.h |  78 ++++++++++
 src/libide/devices/meson.build           |   2 +
 src/libide/ide-types.h                   |   2 +
 src/libide/ide.h                         |   1 +
 5 files changed, 329 insertions(+)
---
diff --git a/src/libide/devices/ide-deploy-strategy.c b/src/libide/devices/ide-deploy-strategy.c
new file mode 100644
index 000000000..8e024113d
--- /dev/null
+++ b/src/libide/devices/ide-deploy-strategy.c
@@ -0,0 +1,246 @@
+/* ide-deploy-strategy.c
+ *
+ * Copyright 2018 Christian Hergert <chergert 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/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "ide-deploy-strategy"
+
+#include "ide-debug.h"
+
+#include "buildsystem/ide-build-pipeline.h"
+#include "devices/ide-deploy-strategy.h"
+
+G_DEFINE_ABSTRACT_TYPE (IdeDeployStrategy, ide_deploy_strategy, G_TYPE_OBJECT)
+
+static void
+ide_deploy_strategy_real_load_async (IdeDeployStrategy   *self,
+                                     IdeBuildPipeline    *pipeline,
+                                     GCancellable        *cancellable,
+                                     GAsyncReadyCallback  callback,
+                                     gpointer             user_data)
+{
+  g_task_report_new_error (self, callback, user_data,
+                           ide_deploy_strategy_real_load_async,
+                           G_IO_ERROR,
+                           G_IO_ERROR_NOT_SUPPORTED,
+                           "%s does not support the current pipeline",
+                           G_OBJECT_TYPE_NAME (self));
+}
+
+static gboolean
+ide_deploy_strategy_real_load_finish (IdeDeployStrategy  *self,
+                                      GAsyncResult       *result,
+                                      GError            **error)
+{
+  g_assert (IDE_IS_DEPLOY_STRATEGY (self));
+  g_assert (G_IS_TASK (result));
+  g_assert (g_task_is_valid (G_TASK (result), self));
+
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+static void
+ide_deploy_strategy_real_deploy_async (IdeDeployStrategy     *self,
+                                       IdeBuildPipeline      *pipeline,
+                                       GFileProgressCallback  progress,
+                                       gpointer               progress_data,
+                                       GDestroyNotify         progress_data_destroy,
+                                       GCancellable          *cancellable,
+                                       GAsyncReadyCallback    callback,
+                                       gpointer               user_data)
+{
+  g_task_report_new_error (self, callback, user_data,
+                           ide_deploy_strategy_real_deploy_async,
+                           G_IO_ERROR,
+                           G_IO_ERROR_NOT_SUPPORTED,
+                           "%s does not support the current pipeline",
+                           G_OBJECT_TYPE_NAME (self));
+}
+
+static gboolean
+ide_deploy_strategy_real_deploy_finish (IdeDeployStrategy  *self,
+                                        GAsyncResult       *result,
+                                        GError            **error)
+{
+  g_assert (IDE_IS_DEPLOY_STRATEGY (self));
+  g_assert (G_IS_TASK (result));
+  g_assert (g_task_is_valid (G_TASK (result), self));
+
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+static void
+ide_deploy_strategy_class_init (IdeDeployStrategyClass *klass)
+{
+  klass->load_async = ide_deploy_strategy_real_load_async;
+  klass->load_finish = ide_deploy_strategy_real_load_finish;
+  klass->deploy_async = ide_deploy_strategy_real_deploy_async;
+  klass->deploy_finish = ide_deploy_strategy_real_deploy_finish;
+}
+
+static void
+ide_deploy_strategy_init (IdeDeployStrategy *self)
+{
+}
+
+/**
+ * ide_deploy_strategy_load_async:
+ * @self: an #IdeDeployStrategy
+ * @pipeline: an #IdeBuildPipeline
+ * @cancellable: (nullable): a #GCancellable, or %NULL
+ * @callback: a callback to execute upon completion
+ * @user_data: closure data for @callback
+ *
+ * Asynchronously requests that the #IdeDeployStrategy load anything
+ * necessary to support deployment for @pipeline. If the strategy cannot
+ * support the pipeline, it should fail with %G_IO_ERROR error domain
+ * and %G_IO_ERROR_NOT_SUPPORTED error code.
+ *
+ * Generally, the deployment strategy is responsible for checking if
+ * it can support deployment to the given device, and determine how to
+ * get the install data out of the pipeline. Given so many moving parts
+ * in build systems, how to determine that is an implementation detail of
+ * the specific #IdeDeployStrategy.
+ *
+ * Since: 3.28
+ */
+void
+ide_deploy_strategy_load_async (IdeDeployStrategy   *self,
+                                IdeBuildPipeline    *pipeline,
+                                GCancellable        *cancellable,
+                                GAsyncReadyCallback  callback,
+                                gpointer             user_data)
+{
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_DEPLOY_STRATEGY (self));
+  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  IDE_DEPLOY_STRATEGY_GET_CLASS (self)->load_async (self, pipeline, cancellable, callback, user_data);
+
+  IDE_EXIT;
+}
+
+/**
+ * ide_deploy_strategy_load_finish:
+ * @self: an #IdeDeployStrategy
+ * @result: a #GAsyncResult provided to callback
+ * @error: a location for a #GError, or %NULL
+ *
+ * Completes an asynchronous request to load the #IdeDeployStrategy.
+ *
+ * Returns: %TRUE if successful and the pipeline was supported; otherwise
+ *   %FALSE and @error is set.
+ *
+ * Since: 3.28
+ */
+gboolean
+ide_deploy_strategy_load_finish (IdeDeployStrategy  *self,
+                                 GAsyncResult       *result,
+                                 GError            **error)
+{
+  gboolean ret;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_DEPLOY_STRATEGY (self));
+  g_assert (G_IS_ASYNC_RESULT (result));
+
+  ret = IDE_DEPLOY_STRATEGY_GET_CLASS (self)->load_finish (self, result, error);
+
+  IDE_RETURN (ret);
+}
+
+/**
+ * ide_deploy_strategy_deploy_async:
+ * @self: a #IdeDeployStrategy
+ * @pipeline: an #IdeBuildPipeline
+ * @progress: (nullable) (closure progress_data) (scope notified):
+ *   a #GFileProgressCallback or %NULL
+ * @progress_data: (nullable): closure data for @progress or %NULL
+ * @progress_data_destroy: (nullable): destroy callback for @progress_data
+ * @cancellable: (nullable): a #GCancellable or %NULL
+ * @callback: (closure user_data): a callback to execute upon completion
+ * @user_data: closure data for @callback
+ *
+ * Requests that the #IdeDeployStrategy deploy the application to the
+ * configured device in the build pipeline.
+ *
+ * If supported, the strategy will call @progress with periodic updates as
+ * the application is deployed.
+ *
+ * Since: 3.28
+ */
+void
+ide_deploy_strategy_deploy_async (IdeDeployStrategy     *self,
+                                  IdeBuildPipeline      *pipeline,
+                                  GFileProgressCallback  progress,
+                                  gpointer               progress_data,
+                                  GDestroyNotify         progress_data_destroy,
+                                  GCancellable          *cancellable,
+                                  GAsyncReadyCallback    callback,
+                                  gpointer               user_data)
+{
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_DEPLOY_STRATEGY (self));
+  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  IDE_DEPLOY_STRATEGY_GET_CLASS (self)->deploy_async (self,
+                                                      pipeline,
+                                                      progress,
+                                                      progress_data,
+                                                      progress_data_destroy,
+                                                      cancellable,
+                                                      callback,
+                                                      user_data);
+
+  IDE_EXIT;
+}
+
+/**
+ * ide_deploy_strategy_deploy_finish:
+ * @self: an #IdeDeployStrategy
+ * @result: a #GAsyncResult provided to callback
+ * @error: a location for a #GError or %NULL
+ *
+ * Completes an asynchronous request to deploy the application to the
+ * build pipeline's device.
+ *
+ * Returns: %TRUE if successful; otherwise %FALSE and @error is set
+ *
+ * Since: 3.28
+ */
+gboolean
+ide_deploy_strategy_deploy_finish (IdeDeployStrategy  *self,
+                                   GAsyncResult       *result,
+                                   GError            **error)
+{
+  gboolean ret;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_DEPLOY_STRATEGY (self));
+  g_assert (G_IS_ASYNC_RESULT (result));
+
+  ret = IDE_DEPLOY_STRATEGY_GET_CLASS (self)->deploy_finish (self, result, error);
+
+  IDE_RETURN (ret);
+}
diff --git a/src/libide/devices/ide-deploy-strategy.h b/src/libide/devices/ide-deploy-strategy.h
new file mode 100644
index 000000000..cdff27f97
--- /dev/null
+++ b/src/libide/devices/ide-deploy-strategy.h
@@ -0,0 +1,78 @@
+/* ide-deploy-strategy.h
+ *
+ * Copyright 2018 Christian Hergert <chergert 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/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "ide-object.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_DEPLOY_STRATEGY (ide_deploy_strategy_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdeDeployStrategy, ide_deploy_strategy, IDE, DEPLOY_STRATEGY, IdeObject)
+
+struct _IdeDeployStrategyClass
+{
+  IdeObjectClass parent;
+
+  void     (*load_async)    (IdeDeployStrategy     *self,
+                             IdeBuildPipeline      *pipeline,
+                             GCancellable          *cancellable,
+                             GAsyncReadyCallback    callback,
+                             gpointer               user_data);
+  gboolean (*load_finish)   (IdeDeployStrategy     *self,
+                             GAsyncResult          *result,
+                             GError               **error);
+  void     (*deploy_async)  (IdeDeployStrategy     *self,
+                             IdeBuildPipeline      *pipeline,
+                             GFileProgressCallback  progress,
+                             gpointer               progress_data,
+                             GDestroyNotify         progress_data_destroy,
+                             GCancellable          *cancellable,
+                             GAsyncReadyCallback    callback,
+                             gpointer               user_data);
+  gboolean (*deploy_finish) (IdeDeployStrategy     *self,
+                             GAsyncResult          *result,
+                             GError               **error);
+
+  gpointer _reserved[16];
+};
+
+void     ide_deploy_strategy_load_async    (IdeDeployStrategy      *self,
+                                            IdeBuildPipeline       *pipeline,
+                                            GCancellable           *cancellable,
+                                            GAsyncReadyCallback     callback,
+                                            gpointer                user_data);
+gboolean ide_deploy_strategy_load_finish   (IdeDeployStrategy      *self,
+                                            GAsyncResult           *result,
+                                            GError                **error);
+void     ide_deploy_strategy_deploy_async  (IdeDeployStrategy      *self,
+                                            IdeBuildPipeline       *pipeline,
+                                            GFileProgressCallback   progress,
+                                            gpointer                progress_data,
+                                            GDestroyNotify          progress_data_destroy,
+                                            GCancellable           *cancellable,
+                                            GAsyncReadyCallback     callback,
+                                            gpointer                user_data);
+gboolean ide_deploy_strategy_deploy_finish (IdeDeployStrategy      *self,
+                                            GAsyncResult           *result,
+                                            GError                **error);
+
+G_END_DECLS
diff --git a/src/libide/devices/meson.build b/src/libide/devices/meson.build
index 919e7116b..afafe0f21 100644
--- a/src/libide/devices/meson.build
+++ b/src/libide/devices/meson.build
@@ -1,4 +1,5 @@
 devices_headers = [
+  'ide-deploy-strategy.h',
   'ide-device-info.h',
   'ide-device-manager.h',
   'ide-device-provider.h',
@@ -6,6 +7,7 @@ devices_headers = [
 ]
 
 devices_sources = [
+  'ide-deploy-strategy.c',
   'ide-device-info.c',
   'ide-device-manager.c',
   'ide-device-provider.c',
diff --git a/src/libide/ide-types.h b/src/libide/ide-types.h
index 92e413984..0a72eed0d 100644
--- a/src/libide/ide-types.h
+++ b/src/libide/ide-types.h
@@ -45,6 +45,8 @@ typedef struct _IdeDebuggerInstruction         IdeDebuggerInstruction;
 typedef struct _IdeDebuggerRegister            IdeDebuggerRegister;
 typedef struct _IdeDebuggerVariable            IdeDebuggerVariable;
 
+typedef struct _IdeDeployStrategy              IdeDeployStrategy;
+
 typedef struct _IdeDevice                      IdeDevice;
 typedef struct _IdeDeviceInfo                  IdeDeviceInfo;
 typedef struct _IdeDeviceManager               IdeDeviceManager;
diff --git a/src/libide/ide.h b/src/libide/ide.h
index e6935d21d..6f60b9ebf 100644
--- a/src/libide/ide.h
+++ b/src/libide/ide.h
@@ -77,6 +77,7 @@ G_BEGIN_DECLS
 #include "debugger/ide-debugger-types.h"
 #include "debugger/ide-debugger-variable.h"
 #include "debugger/ide-debugger.h"
+#include "devices/ide-deploy-strategy.h"
 #include "devices/ide-device-info.h"
 #include "devices/ide-device-manager.h"
 #include "devices/ide-device-provider.h"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]