ide-buildconfig-configuration-provider.c 22.7 KB
Newer Older
1 2
/* ide-buildconfig-configuration-provider.c
 *
3
 * Copyright © 2016 Matthew Leeds <mleeds@redhat.com>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * 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/>.
 */

#define G_LOG_DOMAIN "ide-buildconfig-configuration-provider"

21
#include <dazzle.h>
22 23 24 25 26
#include <gio/gio.h>

#include "ide-context.h"
#include "ide-debug.h"

27 28
#include "buildconfig/ide-buildconfig-configuration.h"
#include "buildconfig/ide-buildconfig-configuration-provider.h"
29 30 31 32 33 34
#include "buildsystem/ide-configuration-manager.h"
#include "buildsystem/ide-configuration-provider.h"
#include "buildsystem/ide-configuration.h"
#include "buildsystem/ide-environment.h"
#include "vcs/ide-vcs.h"

35
#define DOT_BUILDCONFIG ".buildconfig"
36 37 38 39
#define WRITEBACK_TIMEOUT_SECS 2

struct _IdeBuildconfigConfigurationProvider
{
40
  IdeObject                parent_instance;
41 42 43 44 45

  IdeConfigurationManager *manager;
  GPtrArray               *configurations;
  GKeyFile                *key_file;

46
  guint                    writeback_handler;
47 48 49 50 51
  guint                    change_count;
};

static void configuration_provider_iface_init (IdeConfigurationProviderInterface *);

52 53 54 55 56
G_DEFINE_TYPE_WITH_CODE (IdeBuildconfigConfigurationProvider,
                         ide_buildconfig_configuration_provider,
                         IDE_TYPE_OBJECT,
                         G_IMPLEMENT_INTERFACE (IDE_TYPE_CONFIGURATION_PROVIDER,
                                                configuration_provider_iface_init))
57 58 59 60 61 62 63

static void
ide_buildconfig_configuration_provider_save_cb (GObject      *object,
                                                GAsyncResult *result,
                                                gpointer      user_data)
{
  g_autoptr(GTask) task = user_data;
64
  g_autoptr(GError) error = NULL;
65 66 67 68 69 70
  GFile *file = (GFile *)object;

  g_assert (G_IS_FILE (file));
  g_assert (G_IS_ASYNC_RESULT (result));

  if (!g_file_replace_contents_finish (file, result, NULL, &error))
71
    g_task_return_error (task, g_steal_pointer (&error));
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
  else
    g_task_return_boolean (task, TRUE);
}

void
ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *provider,
                                                   GCancellable             *cancellable,
                                                   GAsyncReadyCallback       callback,
                                                   gpointer                  user_data)
{
  IdeBuildconfigConfigurationProvider *self = (IdeBuildconfigConfigurationProvider *)provider;
  g_autoptr(GHashTable) group_names = NULL;
  g_autoptr(GTask) task = NULL;
  g_auto(GStrv) groups = NULL;
  g_autoptr(GFile) file = NULL;
  g_autoptr(GBytes) bytes = NULL;
88
  g_autoptr(GError) error = NULL;
89
  gchar *data;
90
  gsize length = 0;
91 92 93 94 95 96 97 98 99 100
  IdeContext *context;
  IdeVcs *vcs;
  GFile *workdir;

  IDE_ENTRY;

  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));

  task = g_task_new (self, cancellable, callback, user_data);
101
  g_task_set_source_tag (task, ide_buildconfig_configuration_provider_save_async);
102

103
  if (self->configurations == NULL || self->change_count == 0)
104 105 106 107 108 109 110 111 112 113
    {
      g_task_return_boolean (task, TRUE);
      return;
    }

  self->change_count = 0;

  context = ide_object_get_context (IDE_OBJECT (self->manager));
  vcs = ide_context_get_vcs (context);
  workdir = ide_vcs_get_working_directory (vcs);
114
  file = g_file_get_child (workdir, DOT_BUILDCONFIG);
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131

  /*
   * NOTE:
   *
   * We keep the GKeyFile around from when we parsed .buildconfig, so that
   * we can try to preserve comments and such when writing back.
   *
   * This means that we need to fill in all our known configuration
   * sections, and then remove any that were removed since we were
   * parsed it last.
   */

  if (self->key_file == NULL)
    self->key_file = g_key_file_new ();

  group_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

132
  for (guint i = 0; i < self->configurations->len; i++)
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    {
      IdeConfiguration *configuration = g_ptr_array_index (self->configurations, i);
      IdeEnvironment *environment;
      guint n_items;
      guint j;
      gchar *group;
      gchar *group_environ;

      group = g_strdup (ide_configuration_get_id (configuration));
      group_environ = g_strdup_printf ("%s.environment", group);

      /*
       * Track our known group names, so we can remove missing names after
       * we've updated the GKeyFile.
       */
      g_hash_table_insert (group_names, group, NULL);
      g_hash_table_insert (group_names, group_environ, NULL);

#define PERSIST_STRING_KEY(key, getter) \
      g_key_file_set_string (self->key_file, group, key, \
                             ide_configuration_##getter (configuration) ?: "")
      PERSIST_STRING_KEY ("name", get_display_name);
      PERSIST_STRING_KEY ("device", get_device_id);
      PERSIST_STRING_KEY ("runtime", get_runtime_id);
      PERSIST_STRING_KEY ("config-opts", get_config_opts);
158
      PERSIST_STRING_KEY ("run-opts", get_run_opts);
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
      PERSIST_STRING_KEY ("prefix", get_prefix);
      PERSIST_STRING_KEY ("app-id", get_app_id);
#undef PERSIST_STRING_KEY

      if (configuration == ide_configuration_manager_get_current (self->manager))
        g_key_file_set_boolean (self->key_file, group, "default", TRUE);
      else
        g_key_file_remove_key (self->key_file, group, "default", NULL);

      environment = ide_configuration_get_environment (configuration);

      /*
       * Remove all environment keys that are no longer specified in the
       * environment. This allows us to just do a single pass of additions
       * from the environment below.
       */
      if (g_key_file_has_group (self->key_file, group_environ))
        {
          g_auto(GStrv) keys = NULL;

          if (NULL != (keys = g_key_file_get_keys (self->key_file, group_environ, NULL, NULL)))
            {
              for (j = 0; keys [j]; j++)
                {
                  if (!ide_environment_getenv (environment, keys [j]))
                    g_key_file_remove_key (self->key_file, group_environ, keys [j], NULL);
                }
            }
        }

      n_items = g_list_model_get_n_items (G_LIST_MODEL (environment));

      for (j = 0; j < n_items; j++)
        {
          g_autoptr(IdeEnvironmentVariable) var = NULL;
          const gchar *key;
          const gchar *value;

          var = g_list_model_get_item (G_LIST_MODEL (environment), j);
          key = ide_environment_variable_get_key (var);
          value = ide_environment_variable_get_value (var);

201
          if (!dzl_str_empty0 (key))
202 203 204 205 206 207 208 209 210
            g_key_file_set_string (self->key_file, group_environ, key, value ?: "");
        }
    }

  /*
   * Now truncate any old groups in the keyfile.
   */
  if (NULL != (groups = g_key_file_get_groups (self->key_file, NULL)))
    {
211
      for (guint i = 0; groups [i]; i++)
212 213 214 215 216 217 218 219
        {
          if (!g_hash_table_contains (group_names, groups [i]))
            g_key_file_remove_group (self->key_file, groups [i], NULL);
        }
    }

  if (NULL == (data = g_key_file_to_data (self->key_file, &length, &error)))
    {
220
      g_task_return_error (task, g_steal_pointer (&error));
221 222 223 224 225 226 227 228 229 230 231 232
      IDE_EXIT;
    }

  bytes = g_bytes_new_take (data, length);

  g_file_replace_contents_bytes_async (file,
                                       bytes,
                                       NULL,
                                       FALSE,
                                       G_FILE_CREATE_NONE,
                                       cancellable,
                                       ide_buildconfig_configuration_provider_save_cb,
233
                                       g_steal_pointer (&task));
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350

  IDE_EXIT;
}

gboolean
ide_buildconfig_configuration_provider_save_finish (IdeConfigurationProvider  *provider,
                                                    GAsyncResult              *result,
                                                    GError                   **error)
{
  IdeBuildconfigConfigurationProvider *self = (IdeBuildconfigConfigurationProvider *)provider;

  g_return_val_if_fail (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self), FALSE);
  g_return_val_if_fail (G_IS_TASK (result), FALSE);

  return g_task_propagate_boolean (G_TASK (result), error);
}

static gboolean
ide_buildconfig_configuration_provider_do_writeback (gpointer data)
{
  IdeBuildconfigConfigurationProvider *self = data;

  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));

  self->writeback_handler = 0;

  ide_buildconfig_configuration_provider_save_async (IDE_CONFIGURATION_PROVIDER (self), NULL, NULL, NULL);

  return G_SOURCE_REMOVE;
}

static void
ide_buildconfig_configuration_provider_queue_writeback (IdeBuildconfigConfigurationProvider *self)
{
  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));

  IDE_ENTRY;

  if (self->writeback_handler != 0)
    g_source_remove (self->writeback_handler);

  self->writeback_handler = g_timeout_add_seconds (WRITEBACK_TIMEOUT_SECS,
                                                   ide_buildconfig_configuration_provider_do_writeback,
                                                   self);

  IDE_EXIT;
}

static void
ide_buildconfig_configuration_provider_changed (IdeBuildconfigConfigurationProvider *self,
                                                IdeConfiguration *configuration)
{
  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
  g_assert (IDE_IS_CONFIGURATION (configuration));

  self->change_count++;

  ide_buildconfig_configuration_provider_queue_writeback (self);
}

static void
load_string (IdeConfiguration *configuration,
             GKeyFile         *key_file,
             const gchar      *group,
             const gchar      *key,
             const gchar      *property)
{
  g_assert (IDE_IS_CONFIGURATION (configuration));
  g_assert (key_file != NULL);
  g_assert (group != NULL);
  g_assert (key != NULL);

  if (g_key_file_has_key (key_file, group, key, NULL))
    {
      g_auto(GValue) value = G_VALUE_INIT;

      g_value_init (&value, G_TYPE_STRING);
      g_value_take_string (&value, g_key_file_get_string (key_file, group, key, NULL));
      g_object_set_property (G_OBJECT (configuration), property, &value);
    }
}

static void
load_environ (IdeConfiguration *configuration,
              GKeyFile         *key_file,
              const gchar      *group)
{
  IdeEnvironment *environment;
  g_auto(GStrv) keys = NULL;

  g_assert (IDE_IS_CONFIGURATION (configuration));
  g_assert (key_file != NULL);
  g_assert (group != NULL);

  environment = ide_configuration_get_environment (configuration);
  keys = g_key_file_get_keys (key_file, group, NULL, NULL);

  if (keys != NULL)
    {
      guint i;

      for (i = 0; keys [i]; i++)
        {
          g_autofree gchar *value = NULL;

          value = g_key_file_get_string (key_file, group, keys [i], NULL);

          if (value != NULL)
            ide_environment_setenv (environment, keys [i], value);
        }
    }
}

static gboolean
ide_buildconfig_configuration_provider_load_group (IdeBuildconfigConfigurationProvider  *self,
                                                   GKeyFile                             *key_file,
                                                   const gchar                          *group,
351
                                                   GPtrArray                            *configs,
352 353 354 355 356 357 358 359 360 361 362 363
                                                   GError                              **error)
{
  g_autoptr(IdeConfiguration) configuration = NULL;
  g_autofree gchar *env_group = NULL;
  IdeContext *context;

  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
  g_assert (key_file != NULL);
  g_assert (group != NULL);

  context = ide_object_get_context (IDE_OBJECT (self->manager));

364
  configuration = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
365 366 367 368 369 370 371
                                "id", group,
                                "context", context,
                                NULL);

  load_string (configuration, key_file, group, "config-opts", "config-opts");
  load_string (configuration, key_file, group, "device", "device-id");
  load_string (configuration, key_file, group, "name", "display-name");
372
  load_string (configuration, key_file, group, "run-opts", "run-opts");
373 374 375 376 377 378
  load_string (configuration, key_file, group, "runtime", "runtime-id");
  load_string (configuration, key_file, group, "prefix", "prefix");
  load_string (configuration, key_file, group, "app-id", "app-id");

  if (g_key_file_has_key (key_file, group, "prebuild", NULL))
    {
379
      g_auto(GStrv) commands = NULL;
380

381 382 383
      commands = g_key_file_get_string_list (key_file, group, "prebuild", NULL, NULL);
      ide_buildconfig_configuration_set_prebuild (IDE_BUILDCONFIG_CONFIGURATION (configuration),
                                                  (const gchar * const *)commands);
384 385 386 387
    }

  if (g_key_file_has_key (key_file, group, "postbuild", NULL))
    {
388
      g_auto(GStrv) commands = NULL;
389

390 391 392
      commands = g_key_file_get_string_list (key_file, group, "postbuild", NULL, NULL);
      ide_buildconfig_configuration_set_postbuild (IDE_BUILDCONFIG_CONFIGURATION (configuration),
                                                   (const gchar * const *)commands);
393 394 395 396 397 398 399 400 401 402
    }

  env_group = g_strdup_printf ("%s.environment", group);

  if (g_key_file_has_group (key_file, env_group))
    load_environ (configuration, key_file, env_group);

  ide_configuration_set_dirty (configuration, FALSE);

  if (g_key_file_get_boolean (key_file, group, "default", NULL))
403
    g_object_set_data (G_OBJECT (configuration), "WAS_DEFAULT", GINT_TO_POINTER (TRUE));
404 405 406 407 408 409 410

  g_signal_connect_object (configuration,
                           "changed",
                           G_CALLBACK (ide_buildconfig_configuration_provider_changed),
                           self,
                           G_CONNECT_SWAPPED);

411 412
  g_ptr_array_add (configs, g_steal_pointer (&configuration));

413 414 415 416 417 418
  return TRUE;
}

static gboolean
ide_buildconfig_configuration_provider_restore (IdeBuildconfigConfigurationProvider  *self,
                                                GFile                                *file,
419
                                                GPtrArray                            *configs,
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
                                                GCancellable                         *cancellable,
                                                GError                              **error)
{
  g_autofree gchar *contents = NULL;
  g_auto(GStrv) groups = NULL;
  gsize length = 0;
  guint i;

  IDE_ENTRY;

  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
  g_assert (self->key_file == NULL);
  g_assert (G_IS_FILE (file));
  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));

  self->key_file = g_key_file_new ();

  if (!g_file_load_contents (file, cancellable, &contents, &length, NULL, error))
    IDE_RETURN (FALSE);

  if (!g_key_file_load_from_data (self->key_file,
                                  contents,
                                  length,
                                  G_KEY_FILE_KEEP_COMMENTS,
                                  error))
    IDE_RETURN (FALSE);

  groups = g_key_file_get_groups (self->key_file, NULL);

  for (i = 0; groups [i]; i++)
    {
      if (g_str_has_suffix (groups [i], ".environment"))
        continue;

454
      if (!ide_buildconfig_configuration_provider_load_group (self, self->key_file, groups [i], configs, error))
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
        IDE_RETURN (FALSE);
    }

  IDE_RETURN (TRUE);
}

static void
ide_buildconfig_configuration_provider_load_worker (GTask        *task,
                                                    gpointer      source_object,
                                                    gpointer      task_data,
                                                    GCancellable *cancellable)
{
  IdeBuildconfigConfigurationProvider *self = source_object;
  g_autoptr(GFile) settings_file = NULL;
  g_autoptr(GError) error = NULL;
470 471
  g_autoptr(GPtrArray) configs = NULL;
  IdeConfigurationManager *manager = task_data;
472 473 474 475 476 477 478 479
  IdeContext *context;
  IdeVcs *vcs;
  GFile *workdir;

  IDE_ENTRY;

  g_assert (G_IS_TASK (task));
  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
480
  g_assert (IDE_IS_CONFIGURATION_MANAGER (manager));
481 482
  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));

483 484 485
  configs = g_ptr_array_new_with_free_func (g_object_unref);

  context = ide_object_get_context (IDE_OBJECT (manager));
486 487
  vcs = ide_context_get_vcs (context);
  workdir = ide_vcs_get_working_directory (vcs);
488
  settings_file = g_file_get_child (workdir, DOT_BUILDCONFIG);
489

490
  if (g_file_query_exists (settings_file, cancellable))
491
    {
492 493 494 495 496
      if (!ide_buildconfig_configuration_provider_restore (self, settings_file, configs, cancellable, &error))
        {
          g_task_return_error (task, g_steal_pointer (&error));
          IDE_EXIT;
        }
497 498
    }

499
  g_task_return_pointer (task, g_steal_pointer (&configs), (GDestroyNotify)g_ptr_array_unref);
500 501 502 503 504 505 506 507 508

  IDE_EXIT;
}

static void
ide_buildconfig_configuration_provider_load_cb (GObject      *object,
                                                GAsyncResult *result,
                                                gpointer      user_data)
{
509 510 511
  IdeBuildconfigConfigurationProvider *self;
  g_autoptr(GPtrArray) ar = NULL;
  g_autoptr(GError) error = NULL;
512
  g_autoptr(GTask) task = user_data;
513 514 515

  IDE_ENTRY;

516
  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (object));
517
  g_assert (G_IS_TASK (result));
518
  g_assert (G_IS_TASK (task));
519

520 521 522 523 524 525 526
  ar = g_task_propagate_pointer (G_TASK (result), &error);
  self = g_task_get_source_object (G_TASK (result));

  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
  g_assert (self->configurations == NULL);

  if (ar != NULL && self->manager != NULL)
527
    {
528 529 530 531 532 533 534 535 536 537 538 539 540 541
      for (guint i = 0; i < ar->len; i++)
        {
          IdeConfiguration *config = g_ptr_array_index (ar, i);

          g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION (config));

          ide_configuration_manager_add (self->manager, config);

          if (g_object_get_data (G_OBJECT (config), "WAS_DEFAULT"))
            {
              ide_configuration_manager_set_current (self->manager, config);
              g_object_set_data (G_OBJECT (config), "WAS_DEFAULT", NULL);
            }
        }
542 543
    }

544 545 546
  self->configurations = g_steal_pointer (&ar);

  if (error != NULL)
547 548 549
    g_task_return_error (task, g_steal_pointer (&error));
  else
    g_task_return_boolean (task, TRUE);
550

551 552 553 554
  IDE_EXIT;
}

static void
555 556 557 558 559
ide_buildconfig_configuration_provider_load_async (IdeConfigurationProvider *provider,
                                                   IdeConfigurationManager  *manager,
                                                   GCancellable             *cancellable,
                                                   GAsyncReadyCallback       callback,
                                                   gpointer                  user_data)
560 561
{
  IdeBuildconfigConfigurationProvider *self = (IdeBuildconfigConfigurationProvider *)provider;
562
  g_autoptr(GTask) parent_task = NULL;
563 564 565 566 567 568
  g_autoptr(GTask) task = NULL;

  IDE_ENTRY;

  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
  g_assert (IDE_IS_CONFIGURATION_MANAGER (manager));
569
  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
570

571
  dzl_set_weak_pointer (&self->manager, manager);
572

573 574
  /* This task is needed so the caller knows when the load finishes */
  parent_task = g_task_new (self, cancellable, callback, user_data);
575

576 577 578
  /* This task is used to run the load_worker in its own thread */
  task = g_task_new (self, cancellable, ide_buildconfig_configuration_provider_load_cb, g_steal_pointer (&parent_task));
  g_task_set_source_tag (task, ide_buildconfig_configuration_provider_load_async);
579
  g_task_set_task_data (task, g_object_ref (manager), g_object_unref);
580 581 582 583 584
  g_task_run_in_thread (task, ide_buildconfig_configuration_provider_load_worker);

  IDE_EXIT;
}

585 586 587 588 589 590 591 592 593 594 595 596 597
gboolean
ide_buildconfig_configuration_provider_load_finish (IdeConfigurationProvider  *provider,
                                                    GAsyncResult              *result,
                                                    GError                   **error)
{
  IdeBuildconfigConfigurationProvider *self = (IdeBuildconfigConfigurationProvider *)provider;

  g_return_val_if_fail (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self), FALSE);
  g_return_val_if_fail (G_IS_TASK (result), FALSE);

  return g_task_propagate_boolean (G_TASK (result), error);
}

598 599 600 601 602 603 604 605 606 607 608
static void
ide_buildconfig_configuration_provider_unload (IdeConfigurationProvider *provider,
                                               IdeConfigurationManager  *manager)
{
  IdeBuildconfigConfigurationProvider *self = (IdeBuildconfigConfigurationProvider *)provider;

  IDE_ENTRY;

  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
  g_assert (IDE_IS_CONFIGURATION_MANAGER (manager));

609
  dzl_clear_source (&self->writeback_handler);
610 611 612 613 614 615 616 617 618 619 620 621 622

  if (self->configurations != NULL)
    {
      for (guint i= 0; i < self->configurations->len; i++)
        {
          IdeConfiguration *configuration = g_ptr_array_index (self->configurations, i);

          ide_configuration_manager_remove (manager, configuration);
        }
    }

  g_clear_pointer (&self->configurations, g_ptr_array_unref);

623
  dzl_clear_weak_pointer (&self->manager);
624 625 626 627

  IDE_EXIT;
}

628 629 630 631 632
void
ide_buildconfig_configuration_provider_track_config (IdeBuildconfigConfigurationProvider *self,
                                                     IdeBuildconfigConfiguration         *config)
{
  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
633
  g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION (config));
634 635 636 637 638 639 640

  g_signal_connect_object (config,
                           "changed",
                           G_CALLBACK (ide_buildconfig_configuration_provider_changed),
                           self,
                           G_CONNECT_SWAPPED);

641
  g_ptr_array_add (self->configurations, g_object_ref (config));
642 643
}

644 645 646 647 648 649 650 651 652 653 654 655 656
static void
ide_buildconfig_configuration_provider_class_init (IdeBuildconfigConfigurationProviderClass *klass)
{
}

static void
ide_buildconfig_configuration_provider_init (IdeBuildconfigConfigurationProvider *self)
{
}

static void
configuration_provider_iface_init (IdeConfigurationProviderInterface *iface)
{
657 658
  iface->load_async = ide_buildconfig_configuration_provider_load_async;
  iface->load_finish = ide_buildconfig_configuration_provider_load_finish;
659 660 661 662
  iface->unload = ide_buildconfig_configuration_provider_unload;
  iface->save_async = ide_buildconfig_configuration_provider_save_async;
  iface->save_finish = ide_buildconfig_configuration_provider_save_finish;
}