/* OperationWatcher.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from OperationWatcher.vala, do not modify */

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: Michael Terry
 */

#include "deja.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	DEJA_DUP_OPERATION_WATCHER_0_PROPERTY,
	DEJA_DUP_OPERATION_WATCHER_ACTIVE_PROPERTY,
	DEJA_DUP_OPERATION_WATCHER_NUM_PROPERTIES
};
static GParamSpec* deja_dup_operation_watcher_properties[DEJA_DUP_OPERATION_WATCHER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _DejaDupOperationWatcherStartData DejaDupOperationWatcherStartData;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _DejaDupOperationWatcherSetPassphraseData DejaDupOperationWatcherSetPassphraseData;
typedef struct _DejaDupOperationWatcherSetBackendPasswordData DejaDupOperationWatcherSetBackendPasswordData;

struct _DejaDupOperationWatcherPrivate {
	GWeakRef current_op_ref;
};

struct _DejaDupOperationWatcherStartData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DejaDupOperationWatcher* self;
};

struct _DejaDupOperationWatcherSetPassphraseData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DejaDupOperationWatcher* self;
	gchar* passphrase;
	gboolean save;
	DejaDupOperation* op;
	GObject* _tmp0_;
};

struct _DejaDupOperationWatcherSetBackendPasswordData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DejaDupOperationWatcher* self;
	gchar* password;
	gboolean save;
	DejaDupOperation* op;
	GObject* _tmp0_;
};

static gint DejaDupOperationWatcher_private_offset;
static gpointer deja_dup_operation_watcher_parent_class = NULL;
static DejaDupOperationWatcher* deja_dup_operation_watcher_instance;
static DejaDupOperationWatcher* deja_dup_operation_watcher_instance = NULL;

static DejaDupOperationWatcher* deja_dup_operation_watcher_new (void);
static DejaDupOperationWatcher* deja_dup_operation_watcher_construct (GType object_type);
static void deja_dup_operation_watcher_disconnect_from_op (DejaDupOperationWatcher* self);
static void deja_dup_operation_watcher_connect_to_op (DejaDupOperationWatcher* self);
static DejaDupOperationState* deja_dup_operation_watcher_real_get_state (DejaDupOperation* base);
static void deja_dup_operation_watcher_real_set_state (DejaDupOperation* base,
                                                DejaDupOperationState* state);
static void deja_dup_operation_watcher_real_start_data_free (gpointer _data);
static void deja_dup_operation_watcher_real_start (DejaDupOperation* base,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
static gboolean deja_dup_operation_watcher_real_start_co (DejaDupOperationWatcherStartData* _data_);
static gboolean deja_dup_operation_watcher_real_stop_if_dormant (DejaDupOperation* base);
static void deja_dup_operation_watcher_real_stop (DejaDupOperation* base);
static void deja_dup_operation_watcher_real_resume (DejaDupOperation* base);
static void deja_dup_operation_watcher_real_set_mount_op (DejaDupOperation* base,
                                                   GMountOperation* mount_op);
static void deja_dup_operation_watcher_real_set_passphrase_data_free (gpointer _data);
static void deja_dup_operation_watcher_real_set_passphrase (DejaDupOperation* base,
                                                     const gchar* passphrase,
                                                     gboolean save,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean deja_dup_operation_watcher_real_set_passphrase_co (DejaDupOperationWatcherSetPassphraseData* _data_);
static void deja_dup_operation_watcher_set_passphrase_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static void deja_dup_operation_watcher_real_set_backend_password_data_free (gpointer _data);
static void deja_dup_operation_watcher_real_set_backend_password (DejaDupOperation* base,
                                                           const gchar* password,
                                                           gboolean save,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static gboolean deja_dup_operation_watcher_real_set_backend_password_co (DejaDupOperationWatcherSetBackendPasswordData* _data_);
static void deja_dup_operation_watcher_set_backend_password_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static gboolean deja_dup_operation_watcher_real_set_oauth_token (DejaDupOperation* base,
                                                          const gchar* url);
static void __lambda48_ (DejaDupOperationWatcher* self);
static void ___lambda48__deja_dup_operation_started (DejaDupOperation* _sender,
                                              gpointer self);
static void __lambda49_ (DejaDupOperationWatcher* self,
                  gboolean s,
                  gboolean c,
                  const gchar* d);
static void ___lambda49__deja_dup_operation_done (DejaDupOperation* _sender,
                                           gboolean success,
                                           gboolean cancelled,
                                           const gchar* detail,
                                           gpointer self);
static void __lambda50_ (DejaDupOperationWatcher* self,
                  const gchar* e,
                  const gchar* d);
static void ___lambda50__deja_dup_operation_raise_error (DejaDupOperation* _sender,
                                                  const gchar* errstr,
                                                  const gchar* detail,
                                                  gpointer self);
static void __lambda51_ (DejaDupOperationWatcher* self,
                  const gchar* a);
static void ___lambda51__deja_dup_operation_action_desc_changed (DejaDupOperation* _sender,
                                                          const gchar* action,
                                                          gpointer self);
static void __lambda52_ (DejaDupOperationWatcher* self,
                  GFile* f,
                  gboolean a);
static void ___lambda52__deja_dup_operation_action_file_changed (DejaDupOperation* _sender,
                                                          GFile* file,
                                                          gboolean actual,
                                                          gpointer self);
static void __lambda53_ (DejaDupOperationWatcher* self,
                  gboolean f);
static void ___lambda53__deja_dup_operation_is_full (DejaDupOperation* _sender,
                                              gboolean first,
                                              gpointer self);
static void __lambda54_ (DejaDupOperationWatcher* self,
                  gdouble p);
static void ___lambda54__deja_dup_operation_progress (DejaDupOperation* _sender,
                                               gdouble percent,
                                               gpointer self);
static void __lambda55_ (DejaDupOperationWatcher* self,
                  const gchar* u);
static void ___lambda55__deja_dup_operation_open_url (DejaDupOperation* _sender,
                                               const gchar* url,
                                               gpointer self);
static void __lambda56_ (DejaDupOperationWatcher* self);
static void ___lambda56__deja_dup_operation_mount_op_required (DejaDupOperation* _sender,
                                                        gpointer self);
static void __lambda57_ (DejaDupOperationWatcher* self,
                  gboolean r,
                  gboolean f);
static void ___lambda57__deja_dup_operation_passphrase_required (DejaDupOperation* _sender,
                                                          gboolean repeat,
                                                          gboolean first,
                                                          gpointer self);
static void __lambda58_ (DejaDupOperationWatcher* self,
                  const gchar* d,
                  const gchar* l,
                  const gchar* e);
static void ___lambda58__deja_dup_operation_backend_password_required (DejaDupOperation* _sender,
                                                                const gchar* desc,
                                                                const gchar* label,
                                                                const gchar* _error_,
                                                                gpointer self);
static void __lambda59_ (DejaDupOperationWatcher* self,
                  const gchar* s,
                  const gchar* h,
                  const gchar* d,
                  const gchar* a,
                  gboolean safe);
static void ___lambda59__deja_dup_operation_question (DejaDupOperation* _sender,
                                               const gchar* summary,
                                               const gchar* header,
                                               const gchar* description,
                                               const gchar* action,
                                               gboolean safe,
                                               gpointer self);
static GObject * deja_dup_operation_watcher_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void _deja_dup_operation_watcher_disconnect_from_op_deja_dup_operation_done (DejaDupOperation* _sender,
                                                                             gboolean success,
                                                                             gboolean cancelled,
                                                                             const gchar* detail,
                                                                             gpointer self);
static void deja_dup_operation_watcher_finalize (GObject * obj);
static GType deja_dup_operation_watcher_get_type_once (void);
static void _vala_deja_dup_operation_watcher_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
deja_dup_operation_watcher_get_instance_private (DejaDupOperationWatcher* self)
{
	return G_STRUCT_MEMBER_P (self, DejaDupOperationWatcher_private_offset);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

DejaDupOperationWatcher*
deja_dup_operation_watcher_get_instance (void)
{
	DejaDupOperationWatcher* _tmp0_;
	DejaDupOperationWatcher* _tmp2_;
	DejaDupOperationWatcher* _tmp3_;
	DejaDupOperationWatcher* result;
	_tmp0_ = deja_dup_operation_watcher_instance;
	if (_tmp0_ == NULL) {
		DejaDupOperationWatcher* _tmp1_;
		_tmp1_ = deja_dup_operation_watcher_new ();
		_g_object_unref0 (deja_dup_operation_watcher_instance);
		deja_dup_operation_watcher_instance = _tmp1_;
	}
	_tmp2_ = deja_dup_operation_watcher_instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

void
deja_dup_operation_watcher_set_current_op (DejaDupOperationWatcher* self,
                                           DejaDupOperation* op)
{
	GObject* _tmp0_;
	GObject* _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (op != NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	_g_object_unref0 (_tmp1_);
	if (_tmp2_) {
		g_warning ("OperationWatcher.vala:33: Overriding one Operation with another.");
		deja_dup_operation_watcher_disconnect_from_op (self);
	}
	g_weak_ref_set (&self->priv->current_op_ref, (GObject*) op);
	deja_dup_operation_watcher_connect_to_op (self);
	g_object_notify ((GObject*) self, "active");
}

static DejaDupOperationState*
deja_dup_operation_watcher_real_get_state (DejaDupOperation* base)
{
	DejaDupOperationWatcher * self;
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	DejaDupOperationState* _tmp1_;
	DejaDupOperationState* result;
	self = (DejaDupOperationWatcher*) base;
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	_tmp1_ = deja_dup_operation_get_state (op);
	result = _tmp1_;
	_g_object_unref0 (op);
	return result;
}

static void
deja_dup_operation_watcher_real_set_state (DejaDupOperation* base,
                                           DejaDupOperationState* state)
{
	DejaDupOperationWatcher * self;
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	self = (DejaDupOperationWatcher*) base;
	g_return_if_fail (state != NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	deja_dup_operation_set_state (op, state);
	_g_object_unref0 (op);
}

static void
deja_dup_operation_watcher_real_start_data_free (gpointer _data)
{
	DejaDupOperationWatcherStartData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DejaDupOperationWatcherStartData, _data_);
}

static void
deja_dup_operation_watcher_real_start (DejaDupOperation* base,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	DejaDupOperationWatcher * self;
	DejaDupOperationWatcherStartData* _data_;
	DejaDupOperationWatcher* _tmp0_;
	self = (DejaDupOperationWatcher*) base;
	_data_ = g_slice_new0 (DejaDupOperationWatcherStartData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, deja_dup_operation_watcher_real_start_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	deja_dup_operation_watcher_real_start_co (_data_);
}

static void
deja_dup_operation_watcher_start_finish (DejaDupOperation* base,
                                         GAsyncResult* _res_)
{
	DejaDupOperationWatcherStartData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
deja_dup_operation_watcher_real_start_co (DejaDupOperationWatcherStartData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_warning ("OperationWatcher.vala:51: Cannot start OperationWatcher.");
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gboolean
deja_dup_operation_watcher_real_stop_if_dormant (DejaDupOperation* base)
{
	DejaDupOperationWatcher * self;
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	gboolean result;
	self = (DejaDupOperationWatcher*) base;
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	result = deja_dup_operation_stop_if_dormant (op);
	_g_object_unref0 (op);
	return result;
}

static void
deja_dup_operation_watcher_real_stop (DejaDupOperation* base)
{
	DejaDupOperationWatcher * self;
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	self = (DejaDupOperationWatcher*) base;
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	deja_dup_operation_stop (op);
	_g_object_unref0 (op);
}

static void
deja_dup_operation_watcher_real_resume (DejaDupOperation* base)
{
	DejaDupOperationWatcher * self;
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	self = (DejaDupOperationWatcher*) base;
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	deja_dup_operation_resume (op);
	_g_object_unref0 (op);
}

static void
deja_dup_operation_watcher_real_set_mount_op (DejaDupOperation* base,
                                              GMountOperation* mount_op)
{
	DejaDupOperationWatcher * self;
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	self = (DejaDupOperationWatcher*) base;
	g_return_if_fail (mount_op != NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	deja_dup_operation_set_mount_op (op, mount_op);
	_g_object_unref0 (op);
}

static void
deja_dup_operation_watcher_real_set_passphrase_data_free (gpointer _data)
{
	DejaDupOperationWatcherSetPassphraseData* _data_;
	_data_ = _data;
	_g_free0 (_data_->passphrase);
	_g_object_unref0 (_data_->self);
	g_slice_free (DejaDupOperationWatcherSetPassphraseData, _data_);
}

static void
deja_dup_operation_watcher_real_set_passphrase (DejaDupOperation* base,
                                                const gchar* passphrase,
                                                gboolean save,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	DejaDupOperationWatcher * self;
	DejaDupOperationWatcherSetPassphraseData* _data_;
	DejaDupOperationWatcher* _tmp0_;
	gchar* _tmp1_;
	self = (DejaDupOperationWatcher*) base;
	_data_ = g_slice_new0 (DejaDupOperationWatcherSetPassphraseData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, deja_dup_operation_watcher_real_set_passphrase_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (passphrase);
	_g_free0 (_data_->passphrase);
	_data_->passphrase = _tmp1_;
	_data_->save = save;
	deja_dup_operation_watcher_real_set_passphrase_co (_data_);
}

static void
deja_dup_operation_watcher_set_passphrase_finish (DejaDupOperation* base,
                                                  GAsyncResult* _res_)
{
	DejaDupOperationWatcherSetPassphraseData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
deja_dup_operation_watcher_set_passphrase_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	DejaDupOperationWatcherSetPassphraseData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	deja_dup_operation_watcher_real_set_passphrase_co (_data_);
}

static gboolean
deja_dup_operation_watcher_real_set_passphrase_co (DejaDupOperationWatcherSetPassphraseData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_weak_ref_get (&_data_->self->priv->current_op_ref);
	_data_->op = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	_data_->_state_ = 1;
	deja_dup_operation_set_passphrase (_data_->op, _data_->passphrase, _data_->save, deja_dup_operation_watcher_set_passphrase_ready, _data_);
	return FALSE;
	_state_1:
	deja_dup_operation_set_passphrase_finish (_data_->op, _data_->_res_);
	_g_object_unref0 (_data_->op);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
deja_dup_operation_watcher_real_set_backend_password_data_free (gpointer _data)
{
	DejaDupOperationWatcherSetBackendPasswordData* _data_;
	_data_ = _data;
	_g_free0 (_data_->password);
	_g_object_unref0 (_data_->self);
	g_slice_free (DejaDupOperationWatcherSetBackendPasswordData, _data_);
}

static void
deja_dup_operation_watcher_real_set_backend_password (DejaDupOperation* base,
                                                      const gchar* password,
                                                      gboolean save,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	DejaDupOperationWatcher * self;
	DejaDupOperationWatcherSetBackendPasswordData* _data_;
	DejaDupOperationWatcher* _tmp0_;
	gchar* _tmp1_;
	self = (DejaDupOperationWatcher*) base;
	_data_ = g_slice_new0 (DejaDupOperationWatcherSetBackendPasswordData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, deja_dup_operation_watcher_real_set_backend_password_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (password);
	_g_free0 (_data_->password);
	_data_->password = _tmp1_;
	_data_->save = save;
	deja_dup_operation_watcher_real_set_backend_password_co (_data_);
}

static void
deja_dup_operation_watcher_set_backend_password_finish (DejaDupOperation* base,
                                                        GAsyncResult* _res_)
{
	DejaDupOperationWatcherSetBackendPasswordData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
deja_dup_operation_watcher_set_backend_password_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	DejaDupOperationWatcherSetBackendPasswordData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	deja_dup_operation_watcher_real_set_backend_password_co (_data_);
}

static gboolean
deja_dup_operation_watcher_real_set_backend_password_co (DejaDupOperationWatcherSetBackendPasswordData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_weak_ref_get (&_data_->self->priv->current_op_ref);
	_data_->op = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	_data_->_state_ = 1;
	deja_dup_operation_set_backend_password (_data_->op, _data_->password, _data_->save, deja_dup_operation_watcher_set_backend_password_ready, _data_);
	return FALSE;
	_state_1:
	deja_dup_operation_set_backend_password_finish (_data_->op, _data_->_res_);
	_g_object_unref0 (_data_->op);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gboolean
deja_dup_operation_watcher_real_set_oauth_token (DejaDupOperation* base,
                                                 const gchar* url)
{
	DejaDupOperationWatcher * self;
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	gboolean result;
	self = (DejaDupOperationWatcher*) base;
	g_return_val_if_fail (url != NULL, FALSE);
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	result = deja_dup_operation_set_oauth_token (op, url);
	_g_object_unref0 (op);
	return result;
}

static void
__lambda48_ (DejaDupOperationWatcher* self)
{
	g_signal_emit_by_name ((DejaDupOperation*) self, "started");
}

static void
___lambda48__deja_dup_operation_started (DejaDupOperation* _sender,
                                         gpointer self)
{
	__lambda48_ ((DejaDupOperationWatcher*) self);
}

static void
__lambda49_ (DejaDupOperationWatcher* self,
             gboolean s,
             gboolean c,
             const gchar* d)
{
	g_signal_emit_by_name ((DejaDupOperation*) self, "done", s, c, d);
}

static void
___lambda49__deja_dup_operation_done (DejaDupOperation* _sender,
                                      gboolean success,
                                      gboolean cancelled,
                                      const gchar* detail,
                                      gpointer self)
{
	__lambda49_ ((DejaDupOperationWatcher*) self, success, cancelled, detail);
}

static void
__lambda50_ (DejaDupOperationWatcher* self,
             const gchar* e,
             const gchar* d)
{
	g_return_if_fail (e != NULL);
	g_signal_emit_by_name ((DejaDupOperation*) self, "raise-error", e, d);
}

static void
___lambda50__deja_dup_operation_raise_error (DejaDupOperation* _sender,
                                             const gchar* errstr,
                                             const gchar* detail,
                                             gpointer self)
{
	__lambda50_ ((DejaDupOperationWatcher*) self, errstr, detail);
}

static void
__lambda51_ (DejaDupOperationWatcher* self,
             const gchar* a)
{
	g_return_if_fail (a != NULL);
	g_signal_emit_by_name ((DejaDupOperation*) self, "action-desc-changed", a);
}

static void
___lambda51__deja_dup_operation_action_desc_changed (DejaDupOperation* _sender,
                                                     const gchar* action,
                                                     gpointer self)
{
	__lambda51_ ((DejaDupOperationWatcher*) self, action);
}

static void
__lambda52_ (DejaDupOperationWatcher* self,
             GFile* f,
             gboolean a)
{
	g_return_if_fail (f != NULL);
	g_signal_emit_by_name ((DejaDupOperation*) self, "action-file-changed", f, a);
}

static void
___lambda52__deja_dup_operation_action_file_changed (DejaDupOperation* _sender,
                                                     GFile* file,
                                                     gboolean actual,
                                                     gpointer self)
{
	__lambda52_ ((DejaDupOperationWatcher*) self, file, actual);
}

static void
__lambda53_ (DejaDupOperationWatcher* self,
             gboolean f)
{
	g_signal_emit_by_name ((DejaDupOperation*) self, "is-full", f);
}

static void
___lambda53__deja_dup_operation_is_full (DejaDupOperation* _sender,
                                         gboolean first,
                                         gpointer self)
{
	__lambda53_ ((DejaDupOperationWatcher*) self, first);
}

static void
__lambda54_ (DejaDupOperationWatcher* self,
             gdouble p)
{
	g_signal_emit_by_name ((DejaDupOperation*) self, "progress", p);
}

static void
___lambda54__deja_dup_operation_progress (DejaDupOperation* _sender,
                                          gdouble percent,
                                          gpointer self)
{
	__lambda54_ ((DejaDupOperationWatcher*) self, percent);
}

static void
__lambda55_ (DejaDupOperationWatcher* self,
             const gchar* u)
{
	g_return_if_fail (u != NULL);
	g_signal_emit_by_name ((DejaDupOperation*) self, "open-url", u);
}

static void
___lambda55__deja_dup_operation_open_url (DejaDupOperation* _sender,
                                          const gchar* url,
                                          gpointer self)
{
	__lambda55_ ((DejaDupOperationWatcher*) self, url);
}

static void
__lambda56_ (DejaDupOperationWatcher* self)
{
	g_signal_emit_by_name ((DejaDupOperation*) self, "mount-op-required");
}

static void
___lambda56__deja_dup_operation_mount_op_required (DejaDupOperation* _sender,
                                                   gpointer self)
{
	__lambda56_ ((DejaDupOperationWatcher*) self);
}

static void
__lambda57_ (DejaDupOperationWatcher* self,
             gboolean r,
             gboolean f)
{
	g_signal_emit_by_name ((DejaDupOperation*) self, "passphrase-required", r, f);
}

static void
___lambda57__deja_dup_operation_passphrase_required (DejaDupOperation* _sender,
                                                     gboolean repeat,
                                                     gboolean first,
                                                     gpointer self)
{
	__lambda57_ ((DejaDupOperationWatcher*) self, repeat, first);
}

static void
__lambda58_ (DejaDupOperationWatcher* self,
             const gchar* d,
             const gchar* l,
             const gchar* e)
{
	g_return_if_fail (d != NULL);
	g_return_if_fail (l != NULL);
	g_signal_emit_by_name ((DejaDupOperation*) self, "backend-password-required", d, l, e);
}

static void
___lambda58__deja_dup_operation_backend_password_required (DejaDupOperation* _sender,
                                                           const gchar* desc,
                                                           const gchar* label,
                                                           const gchar* _error_,
                                                           gpointer self)
{
	__lambda58_ ((DejaDupOperationWatcher*) self, desc, label, _error_);
}

static void
__lambda59_ (DejaDupOperationWatcher* self,
             const gchar* s,
             const gchar* h,
             const gchar* d,
             const gchar* a,
             gboolean safe)
{
	g_return_if_fail (s != NULL);
	g_signal_emit_by_name ((DejaDupOperation*) self, "question", s, h, d, a, safe);
}

static void
___lambda59__deja_dup_operation_question (DejaDupOperation* _sender,
                                          const gchar* summary,
                                          const gchar* header,
                                          const gchar* description,
                                          const gchar* action,
                                          gboolean safe,
                                          gpointer self)
{
	__lambda59_ ((DejaDupOperationWatcher*) self, summary, header, description, action, safe);
}

static void
deja_dup_operation_watcher_connect_to_op (DejaDupOperationWatcher* self)
{
	DejaDupOperation* op = NULL;
	GObject* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, DEJA_DUP_TYPE_OPERATION, DejaDupOperation);
	g_signal_connect_object (op, "started", (GCallback) ___lambda48__deja_dup_operation_started, self, 0);
	g_signal_connect_object (op, "done", (GCallback) ___lambda49__deja_dup_operation_done, self, 0);
	g_signal_connect_object (op, "raise-error", (GCallback) ___lambda50__deja_dup_operation_raise_error, self, 0);
	g_signal_connect_object (op, "action-desc-changed", (GCallback) ___lambda51__deja_dup_operation_action_desc_changed, self, 0);
	g_signal_connect_object (op, "action-file-changed", (GCallback) ___lambda52__deja_dup_operation_action_file_changed, self, 0);
	g_signal_connect_object (op, "is-full", (GCallback) ___lambda53__deja_dup_operation_is_full, self, 0);
	g_signal_connect_object (op, "progress", (GCallback) ___lambda54__deja_dup_operation_progress, self, 0);
	g_signal_connect_object (op, "open-url", (GCallback) ___lambda55__deja_dup_operation_open_url, self, 0);
	g_signal_connect_object (op, "mount-op-required", (GCallback) ___lambda56__deja_dup_operation_mount_op_required, self, 0);
	g_signal_connect_object (op, "passphrase-required", (GCallback) ___lambda57__deja_dup_operation_passphrase_required, self, 0);
	g_signal_connect_object (op, "backend-password-required", (GCallback) ___lambda58__deja_dup_operation_backend_password_required, self, 0);
	g_signal_connect_object (op, "question", (GCallback) ___lambda59__deja_dup_operation_question, self, 0);
	g_object_bind_property_with_closures ((GObject*) op, "use-cached-password", (GObject*) self, "use-cached-password", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_bind_property_with_closures ((GObject*) op, "needs-password", (GObject*) self, "needs-password", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_bind_property_with_closures ((GObject*) op, "backend", (GObject*) self, "backend", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_bind_property_with_closures ((GObject*) op, "use-progress", (GObject*) self, "use-progress", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_bind_property_with_closures ((GObject*) op, "mode", (GObject*) self, "mode", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (op);
}

static void
deja_dup_operation_watcher_disconnect_from_op (DejaDupOperationWatcher* self)
{
	GObject* op = NULL;
	GObject* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	op = _tmp0_;
	g_signal_handlers_disconnect_matched (op, G_SIGNAL_MATCH_DATA, (guint) 0, (GQuark) 0, NULL, NULL, self);
	g_weak_ref_set (&self->priv->current_op_ref, NULL);
	g_object_notify ((GObject*) self, "active");
	_g_object_unref0 (op);
}

static DejaDupOperationWatcher*
deja_dup_operation_watcher_construct (GType object_type)
{
	DejaDupOperationWatcher * self = NULL;
	self = (DejaDupOperationWatcher*) g_object_new (object_type, NULL);
	return self;
}

static DejaDupOperationWatcher*
deja_dup_operation_watcher_new (void)
{
	return deja_dup_operation_watcher_construct (DEJA_DUP_TYPE_OPERATION_WATCHER);
}

gboolean
deja_dup_operation_watcher_get_active (DejaDupOperationWatcher* self)
{
	gboolean result;
	GObject* _tmp0_;
	GObject* _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = g_weak_ref_get (&self->priv->current_op_ref);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	_g_object_unref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

static void
_deja_dup_operation_watcher_disconnect_from_op_deja_dup_operation_done (DejaDupOperation* _sender,
                                                                        gboolean success,
                                                                        gboolean cancelled,
                                                                        const gchar* detail,
                                                                        gpointer self)
{
	deja_dup_operation_watcher_disconnect_from_op ((DejaDupOperationWatcher*) self);
}

static GObject *
deja_dup_operation_watcher_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupOperationWatcher * self;
	GApplication* _tmp0_;
	parent_class = G_OBJECT_CLASS (deja_dup_operation_watcher_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_OPERATION_WATCHER, DejaDupOperationWatcher);
	_tmp0_ = g_application_get_default ();
	g_application_bind_busy_property (_tmp0_, (GObject*) self, "active");
	g_signal_connect_object ((DejaDupOperation*) self, "done", (GCallback) _deja_dup_operation_watcher_disconnect_from_op_deja_dup_operation_done, self, G_CONNECT_AFTER);
	return obj;
}

static void
deja_dup_operation_watcher_class_init (DejaDupOperationWatcherClass * klass,
                                       gpointer klass_data)
{
	deja_dup_operation_watcher_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DejaDupOperationWatcher_private_offset);
	((DejaDupOperationClass *) klass)->get_state = (DejaDupOperationState* (*) (DejaDupOperation*)) deja_dup_operation_watcher_real_get_state;
	((DejaDupOperationClass *) klass)->set_state = (void (*) (DejaDupOperation*, DejaDupOperationState*)) deja_dup_operation_watcher_real_set_state;
	((DejaDupOperationClass *) klass)->start = (void (*) (DejaDupOperation*, GAsyncReadyCallback, gpointer)) deja_dup_operation_watcher_real_start;
	((DejaDupOperationClass *) klass)->start_finish = (void (*) (DejaDupOperation*, GAsyncResult*)) deja_dup_operation_watcher_start_finish;
	((DejaDupOperationClass *) klass)->stop_if_dormant = (gboolean (*) (DejaDupOperation*)) deja_dup_operation_watcher_real_stop_if_dormant;
	((DejaDupOperationClass *) klass)->stop = (void (*) (DejaDupOperation*)) deja_dup_operation_watcher_real_stop;
	((DejaDupOperationClass *) klass)->resume = (void (*) (DejaDupOperation*)) deja_dup_operation_watcher_real_resume;
	((DejaDupOperationClass *) klass)->set_mount_op = (void (*) (DejaDupOperation*, GMountOperation*)) deja_dup_operation_watcher_real_set_mount_op;
	((DejaDupOperationClass *) klass)->set_passphrase = (void (*) (DejaDupOperation*, const gchar*, gboolean, GAsyncReadyCallback, gpointer)) deja_dup_operation_watcher_real_set_passphrase;
	((DejaDupOperationClass *) klass)->set_passphrase_finish = (void (*) (DejaDupOperation*, GAsyncResult*)) deja_dup_operation_watcher_set_passphrase_finish;
	((DejaDupOperationClass *) klass)->set_backend_password = (void (*) (DejaDupOperation*, const gchar*, gboolean, GAsyncReadyCallback, gpointer)) deja_dup_operation_watcher_real_set_backend_password;
	((DejaDupOperationClass *) klass)->set_backend_password_finish = (void (*) (DejaDupOperation*, GAsyncResult*)) deja_dup_operation_watcher_set_backend_password_finish;
	((DejaDupOperationClass *) klass)->set_oauth_token = (gboolean (*) (DejaDupOperation*, const gchar*)) deja_dup_operation_watcher_real_set_oauth_token;
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_operation_watcher_get_property;
	G_OBJECT_CLASS (klass)->constructor = deja_dup_operation_watcher_constructor;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_operation_watcher_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_OPERATION_WATCHER_ACTIVE_PROPERTY, deja_dup_operation_watcher_properties[DEJA_DUP_OPERATION_WATCHER_ACTIVE_PROPERTY] = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
deja_dup_operation_watcher_instance_init (DejaDupOperationWatcher * self,
                                          gpointer klass)
{
	self->priv = deja_dup_operation_watcher_get_instance_private (self);
}

static void
deja_dup_operation_watcher_finalize (GObject * obj)
{
	DejaDupOperationWatcher * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_OPERATION_WATCHER, DejaDupOperationWatcher);
	g_weak_ref_clear (&self->priv->current_op_ref);
	G_OBJECT_CLASS (deja_dup_operation_watcher_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
deja_dup_operation_watcher_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DejaDupOperationWatcherClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_operation_watcher_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupOperationWatcher), 0, (GInstanceInitFunc) deja_dup_operation_watcher_instance_init, NULL };
	GType deja_dup_operation_watcher_type_id;
	deja_dup_operation_watcher_type_id = g_type_register_static (DEJA_DUP_TYPE_OPERATION, "DejaDupOperationWatcher", &g_define_type_info, 0);
	DejaDupOperationWatcher_private_offset = g_type_add_instance_private (deja_dup_operation_watcher_type_id, sizeof (DejaDupOperationWatcherPrivate));
	return deja_dup_operation_watcher_type_id;
}

GType
deja_dup_operation_watcher_get_type (void)
{
	static gsize deja_dup_operation_watcher_type_id__once = 0;
	if (g_once_init_enter (&deja_dup_operation_watcher_type_id__once)) {
		GType deja_dup_operation_watcher_type_id;
		deja_dup_operation_watcher_type_id = deja_dup_operation_watcher_get_type_once ();
		g_once_init_leave (&deja_dup_operation_watcher_type_id__once, deja_dup_operation_watcher_type_id);
	}
	return deja_dup_operation_watcher_type_id__once;
}

static void
_vala_deja_dup_operation_watcher_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	DejaDupOperationWatcher * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_OPERATION_WATCHER, DejaDupOperationWatcher);
	switch (property_id) {
		case DEJA_DUP_OPERATION_WATCHER_ACTIVE_PROPERTY:
		g_value_set_boolean (value, deja_dup_operation_watcher_get_active (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

