예제 #1
0
static void
photos_source_manager_goa_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  PhotosSourceManager *self;
  PhotosSourceManagerPrivate *priv;
  GError *error;
  GoaClient *client;

  error = NULL;
  client = goa_client_new_finish (res, &error);
  if (error != NULL)
    {
      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        g_warning ("Unable to create GoaClient: %s", error->message);

      g_error_free (error);
      return;
    }

  self = PHOTOS_SOURCE_MANAGER (user_data);
  priv = self->priv;

  priv->client = client;
  g_signal_connect_swapped (priv->client,
                            "account-added",
                            G_CALLBACK (photos_source_manager_refresh_accounts),
                            self);
  g_signal_connect_swapped (priv->client,
                            "account-changed",
                            G_CALLBACK (photos_source_manager_refresh_accounts),
                            self);
  g_signal_connect_swapped (priv->client,
                            "account-removed",
                            G_CALLBACK (photos_source_manager_refresh_accounts),
                            self);

  photos_source_manager_refresh_accounts (self);
}
static void
goa_client_new_cb (GObject      *object,
                   GAsyncResult *result,
                   gpointer      user_data)
{
  AddAccountData *data = user_data;

  data->goa_client = goa_client_new_finish (result, &data->error);
  if (data->goa_client == NULL)
    {
      g_set_error (&data->error,
                   GOA_ERROR,
                   GOA_ERROR_FAILED,
                   _("Failed to initialize a GOA client"));
      g_main_loop_quit (data->loop);
      return;
    }

  if (!check_existing_goa_accounts (data))
    {
      data->goa_account_added_id = g_signal_connect (data->goa_client,
          "account-added", G_CALLBACK (goa_account_added_cb), data);
    }
}