/* Account.c generated by valac 0.56.19, the Vala compiler
 * generated from Account.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2017 elementary LLC. (https://elementary.io)
 *
 * 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/>.
 *
 * Authored by: Corentin Noël <corentin@elementary.io>
 */

#include <glib-object.h>
#include <camel/camel.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <granite.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <handy.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define MAIL_BACKEND_TYPE_ACCOUNT (mail_backend_account_get_type ())
#define MAIL_BACKEND_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccount))
#define MAIL_BACKEND_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccountClass))
#define MAIL_BACKEND_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_BACKEND_TYPE_ACCOUNT))
#define MAIL_BACKEND_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_BACKEND_TYPE_ACCOUNT))
#define MAIL_BACKEND_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccountClass))

typedef struct _MailBackendAccount MailBackendAccount;
typedef struct _MailBackendAccountClass MailBackendAccountClass;
typedef struct _MailBackendAccountPrivate MailBackendAccountPrivate;
enum  {
	MAIL_BACKEND_ACCOUNT_0_PROPERTY,
	MAIL_BACKEND_ACCOUNT_SERVICE_PROPERTY,
	MAIL_BACKEND_ACCOUNT_NUM_PROPERTIES
};
static GParamSpec* mail_backend_account_properties[MAIL_BACKEND_ACCOUNT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block24Data Block24Data;

#define MAIL_TYPE_MAIN_WINDOW (mail_main_window_get_type ())
#define MAIL_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_MAIN_WINDOW, MailMainWindow))
#define MAIL_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_MAIN_WINDOW, MailMainWindowClass))
#define MAIL_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_MAIN_WINDOW))
#define MAIL_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_MAIN_WINDOW))
#define MAIL_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_MAIN_WINDOW, MailMainWindowClass))

typedef struct _MailMainWindow MailMainWindow;
typedef struct _MailMainWindowClass MailMainWindowClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _MailBackendAccountManageConnectionData MailBackendAccountManageConnectionData;

struct _MailBackendAccount {
	GObject parent_instance;
	MailBackendAccountPrivate * priv;
};

struct _MailBackendAccountClass {
	GObjectClass parent_class;
};

struct _MailBackendAccountPrivate {
	CamelService* _service;
};

struct _Block24Data {
	int _ref_count_;
	MailBackendAccount* self;
	GraniteMessageDialog* error_dialog;
};

struct _MailBackendAccountManageConnectionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	MailBackendAccount* self;
	gboolean online;
	CamelOfflineStore* offlinestore;
	CamelService* _tmp0_;
	CamelOfflineStore* _tmp1_;
	CamelOfflineStore* _tmp2_;
	CamelOfflineStore* _tmp3_;
	CamelService* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	GError* e;
	gboolean _tmp7_;
	GError* _tmp8_;
	GError* _tmp9_;
	GError* _tmp10_;
	const gchar* _tmp11_;
	Block24Data* _data24_;
	GraniteMessageDialog* _tmp12_;
	GraniteMessageDialog* _tmp13_;
	GError* _tmp14_;
	const gchar* _tmp15_;
	GraniteMessageDialog* _tmp16_;
	GtkApplication* application;
	GApplication* _tmp17_;
	GtkApplication* _tmp18_;
	GList* _tmp19_;
	GList* window_collection;
	GList* window_it;
	GtkWindow* window;
	GtkWindow* _tmp20_;
	GraniteMessageDialog* _tmp21_;
	GtkWindow* _tmp22_;
	GraniteMessageDialog* _tmp23_;
	CamelOfflineStore* _tmp24_;
	CamelService* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	GError* _vala1_e;
	gboolean _tmp28_;
	GError* _tmp29_;
	GError* _tmp30_;
	GError* _tmp31_;
	const gchar* _tmp32_;
	GError* _tmp33_;
	const gchar* _tmp34_;
	GError* _inner_error0_;
};

static gint MailBackendAccount_private_offset;
static gpointer mail_backend_account_parent_class = NULL;

VALA_EXTERN GType mail_backend_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailBackendAccount, g_object_unref)
VALA_EXTERN MailBackendAccount* mail_backend_account_new (CamelService* service);
VALA_EXTERN MailBackendAccount* mail_backend_account_construct (GType object_type,
                                                    CamelService* service);
static void mail_backend_account_manage_connection_data_free (gpointer _data);
VALA_EXTERN void mail_backend_account_manage_connection (MailBackendAccount* self,
                                             gboolean online,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN void mail_backend_account_manage_connection_finish (MailBackendAccount* self,
                                                    GAsyncResult* _res_);
static gboolean mail_backend_account_manage_connection_co (MailBackendAccountManageConnectionData* _data_);
VALA_EXTERN CamelService* mail_backend_account_get_service (MailBackendAccount* self);
static void mail_backend_account_manage_connection_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static Block24Data* block24_data_ref (Block24Data* _data24_);
static void block24_data_unref (void * _userdata_);
static void _____lambda6_ (Block24Data* _data24_);
static void ______lambda6__gtk_dialog_response (GtkDialog* _sender,
                                         gint response_id,
                                         gpointer self);
VALA_EXTERN GType mail_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailMainWindow, g_object_unref)
VALA_EXTERN guint mail_backend_account_hash (MailBackendAccount* account);
VALA_EXTERN gboolean mail_backend_account_equal (MailBackendAccount* self,
                                     MailBackendAccount* account2);
static void mail_backend_account_set_service (MailBackendAccount* self,
                                       CamelService* value);
static GObject * mail_backend_account_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void _mail_backend_account_manage_connection_g_network_monitor_network_changed (GNetworkMonitor* _sender,
                                                                                gboolean network_available,
                                                                                gpointer self);
static void mail_backend_account_finalize (GObject * obj);
static GType mail_backend_account_get_type_once (void);
static void _vala_mail_backend_account_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_mail_backend_account_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);

static inline gpointer
mail_backend_account_get_instance_private (MailBackendAccount* self)
{
	return G_STRUCT_MEMBER_P (self, MailBackendAccount_private_offset);
}

MailBackendAccount*
mail_backend_account_construct (GType object_type,
                                CamelService* service)
{
	MailBackendAccount * self = NULL;
	g_return_val_if_fail (service != NULL, NULL);
	self = (MailBackendAccount*) g_object_new (object_type, "service", service, NULL);
	return self;
}

MailBackendAccount*
mail_backend_account_new (CamelService* service)
{
	return mail_backend_account_construct (MAIL_BACKEND_TYPE_ACCOUNT, service);
}

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

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

void
mail_backend_account_manage_connection (MailBackendAccount* self,
                                        gboolean online,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	MailBackendAccountManageConnectionData* _data_;
	MailBackendAccount* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (MailBackendAccountManageConnectionData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, mail_backend_account_manage_connection_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->online = online;
	mail_backend_account_manage_connection_co (_data_);
}

void
mail_backend_account_manage_connection_finish (MailBackendAccount* self,
                                               GAsyncResult* _res_)
{
	MailBackendAccountManageConnectionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
mail_backend_account_manage_connection_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	MailBackendAccountManageConnectionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	mail_backend_account_manage_connection_co (_data_);
}

static Block24Data*
block24_data_ref (Block24Data* _data24_)
{
	g_atomic_int_inc (&_data24_->_ref_count_);
	return _data24_;
}

static void
block24_data_unref (void * _userdata_)
{
	Block24Data* _data24_;
	_data24_ = (Block24Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data24_->_ref_count_)) {
		MailBackendAccount* self;
		self = _data24_->self;
		_g_object_unref0 (_data24_->error_dialog);
		_g_object_unref0 (self);
		g_slice_free (Block24Data, _data24_);
	}
}

static void
_____lambda6_ (Block24Data* _data24_)
{
	MailBackendAccount* self;
	GraniteMessageDialog* _tmp0_;
	self = _data24_->self;
	_tmp0_ = _data24_->error_dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp0_);
}

static void
______lambda6__gtk_dialog_response (GtkDialog* _sender,
                                    gint response_id,
                                    gpointer self)
{
	_____lambda6_ (self);
}

static gboolean
mail_backend_account_manage_connection_co (MailBackendAccountManageConnectionData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_service;
	_data_->_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, camel_offline_store_get_type (), CamelOfflineStore));
	_data_->offlinestore = _data_->_tmp1_;
	if (_data_->online) {
		{
			_data_->_tmp2_ = _data_->offlinestore;
			_data_->_state_ = 1;
			camel_offline_store_set_online (_data_->_tmp2_, TRUE, G_PRIORITY_DEFAULT, NULL, mail_backend_account_manage_connection_ready, _data_);
			return FALSE;
			_state_1:
			camel_offline_store_set_online_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp3_ = _data_->offlinestore;
			_data_->_state_ = 2;
			camel_store_synchronize ((CamelStore*) _data_->_tmp3_, FALSE, G_PRIORITY_DEFAULT, NULL, mail_backend_account_manage_connection_ready, _data_);
			return FALSE;
			_state_2:
			camel_store_synchronize_finish ((CamelStore*) _data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp4_ = _data_->self->priv->_service;
			_data_->_tmp5_ = camel_service_get_display_name (_data_->_tmp4_);
			_data_->_tmp6_ = _data_->_tmp5_;
			g_debug ("Account.vala:40: Account '%s' connected to remote server.", _data_->_tmp6_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->e = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp8_ = _data_->e;
			if (g_error_matches (_data_->_tmp8_, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE)) {
				_data_->_tmp7_ = TRUE;
			} else {
				_data_->_tmp9_ = _data_->e;
				_data_->_tmp7_ = g_error_matches (_data_->_tmp9_, G_IO_ERROR, G_IO_ERROR_CANCELLED);
			}
			if (_data_->_tmp7_) {
				_data_->_tmp10_ = _data_->e;
				_data_->_tmp11_ = _data_->_tmp10_->message;
				g_debug ("Account.vala:45: %s", _data_->_tmp11_);
			} else {
				_data_->_data24_ = g_slice_new0 (Block24Data);
				_data_->_data24_->_ref_count_ = 1;
				_data_->_data24_->self = g_object_ref (_data_->self);
				_data_->_tmp12_ = granite_message_dialog_new_with_image_from_icon_name (_ ("Unable to connect"), _ ("There was an unexpected error while trying to connect to the server."), "network-error", GTK_BUTTONS_CLOSE);
				g_object_ref_sink (_data_->_tmp12_);
				_data_->_data24_->error_dialog = _data_->_tmp12_;
				_data_->_tmp13_ = _data_->_data24_->error_dialog;
				_data_->_tmp14_ = _data_->e;
				_data_->_tmp15_ = _data_->_tmp14_->message;
				granite_message_dialog_show_error_details (_data_->_tmp13_, _data_->_tmp15_);
				_data_->_tmp16_ = _data_->_data24_->error_dialog;
				g_signal_connect_data ((GtkDialog*) _data_->_tmp16_, "response", (GCallback) ______lambda6__gtk_dialog_response, block24_data_ref (_data_->_data24_), (GClosureNotify) block24_data_unref, 0);
				_data_->_tmp17_ = g_application_get_default ();
				_data_->application = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp17_, gtk_application_get_type (), GtkApplication);
				_data_->_tmp18_ = _data_->application;
				_data_->_tmp19_ = gtk_application_get_windows (_data_->_tmp18_);
				{
					_data_->window_collection = _data_->_tmp19_;
					for (_data_->window_it = _data_->window_collection; _data_->window_it != NULL; _data_->window_it = _data_->window_it->next) {
						_data_->window = (GtkWindow*) _data_->window_it->data;
						{
							_data_->_tmp20_ = _data_->window;
							if (MAIL_IS_MAIN_WINDOW (_data_->_tmp20_)) {
								_data_->_tmp21_ = _data_->_data24_->error_dialog;
								_data_->_tmp22_ = _data_->window;
								gtk_window_set_transient_for ((GtkWindow*) _data_->_tmp21_, _data_->_tmp22_);
								break;
							}
						}
					}
				}
				_data_->_tmp23_ = _data_->_data24_->error_dialog;
				gtk_window_present ((GtkWindow*) _data_->_tmp23_);
				block24_data_unref (_data_->_data24_);
				_data_->_data24_ = NULL;
			}
			_g_error_free0 (_data_->e);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->offlinestore);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->offlinestore);
		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;
	}
	{
		_data_->_tmp24_ = _data_->offlinestore;
		_data_->_state_ = 3;
		camel_offline_store_set_online (_data_->_tmp24_, FALSE, G_PRIORITY_DEFAULT, NULL, mail_backend_account_manage_connection_ready, _data_);
		return FALSE;
		_state_3:
		camel_offline_store_set_online_finish (_data_->_tmp24_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_data_->_tmp25_ = _data_->self->priv->_service;
		_data_->_tmp26_ = camel_service_get_display_name (_data_->_tmp25_);
		_data_->_tmp27_ = _data_->_tmp26_;
		g_debug ("Account.vala:69: Account '%s' disconnected from remote server.", _data_->_tmp27_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp29_ = _data_->_vala1_e;
		if (g_error_matches (_data_->_tmp29_, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE)) {
			_data_->_tmp28_ = TRUE;
		} else {
			_data_->_tmp30_ = _data_->_vala1_e;
			_data_->_tmp28_ = g_error_matches (_data_->_tmp30_, G_IO_ERROR, G_IO_ERROR_CANCELLED);
		}
		if (_data_->_tmp28_) {
			_data_->_tmp31_ = _data_->_vala1_e;
			_data_->_tmp32_ = _data_->_tmp31_->message;
			g_debug ("Account.vala:72: %s", _data_->_tmp32_);
		} else {
			_data_->_tmp33_ = _data_->_vala1_e;
			_data_->_tmp34_ = _data_->_tmp33_->message;
			g_critical ("Account.vala:74: %s", _data_->_tmp34_);
		}
		_g_error_free0 (_data_->_vala1_e);
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->offlinestore);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->offlinestore);
	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;
}

guint
mail_backend_account_hash (MailBackendAccount* account)
{
	GHashFunc _tmp0_;
	CamelService* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	guint result;
	g_return_val_if_fail (account != NULL, 0U);
	_tmp0_ = g_str_hash;
	_tmp1_ = account->priv->_service;
	_tmp2_ = camel_service_get_uid (_tmp1_);
	_tmp3_ = _tmp2_;
	result = _tmp0_ (_tmp3_);
	return result;
}

gboolean
mail_backend_account_equal (MailBackendAccount* self,
                            MailBackendAccount* account2)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account2 != NULL, FALSE);
	result = mail_backend_account_hash (self) == mail_backend_account_hash (account2);
	return result;
}

CamelService*
mail_backend_account_get_service (MailBackendAccount* self)
{
	CamelService* result;
	CamelService* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_service;
	result = _tmp0_;
	return result;
}

static void
mail_backend_account_set_service (MailBackendAccount* self,
                                  CamelService* value)
{
	CamelService* old_value;
	g_return_if_fail (self != NULL);
	old_value = mail_backend_account_get_service (self);
	if (old_value != value) {
		CamelService* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_service);
		self->priv->_service = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, mail_backend_account_properties[MAIL_BACKEND_ACCOUNT_SERVICE_PROPERTY]);
	}
}

static void
_mail_backend_account_manage_connection_g_network_monitor_network_changed (GNetworkMonitor* _sender,
                                                                           gboolean network_available,
                                                                           gpointer self)
{
	mail_backend_account_manage_connection ((MailBackendAccount*) self, network_available, NULL, NULL);
}

static GObject *
mail_backend_account_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MailBackendAccount * self;
	GNetworkMonitor* network_monitor = NULL;
	GNetworkMonitor* _tmp0_;
	GNetworkMonitor* _tmp1_;
	parent_class = G_OBJECT_CLASS (mail_backend_account_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccount);
	_tmp0_ = g_network_monitor_get_default ();
	network_monitor = _tmp0_;
	_tmp1_ = network_monitor;
	g_signal_connect_object (_tmp1_, "network-changed", (GCallback) _mail_backend_account_manage_connection_g_network_monitor_network_changed, self, 0);
	return obj;
}

static void
mail_backend_account_class_init (MailBackendAccountClass * klass,
                                 gpointer klass_data)
{
	mail_backend_account_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MailBackendAccount_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_mail_backend_account_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_mail_backend_account_set_property;
	G_OBJECT_CLASS (klass)->constructor = mail_backend_account_constructor;
	G_OBJECT_CLASS (klass)->finalize = mail_backend_account_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIL_BACKEND_ACCOUNT_SERVICE_PROPERTY, mail_backend_account_properties[MAIL_BACKEND_ACCOUNT_SERVICE_PROPERTY] = g_param_spec_object ("service", "service", "service", camel_service_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
mail_backend_account_instance_init (MailBackendAccount * self,
                                    gpointer klass)
{
	self->priv = mail_backend_account_get_instance_private (self);
}

static void
mail_backend_account_finalize (GObject * obj)
{
	MailBackendAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccount);
	_g_object_unref0 (self->priv->_service);
	G_OBJECT_CLASS (mail_backend_account_parent_class)->finalize (obj);
}

static GType
mail_backend_account_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MailBackendAccountClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mail_backend_account_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MailBackendAccount), 0, (GInstanceInitFunc) mail_backend_account_instance_init, NULL };
	GType mail_backend_account_type_id;
	mail_backend_account_type_id = g_type_register_static (G_TYPE_OBJECT, "MailBackendAccount", &g_define_type_info, 0);
	MailBackendAccount_private_offset = g_type_add_instance_private (mail_backend_account_type_id, sizeof (MailBackendAccountPrivate));
	return mail_backend_account_type_id;
}

GType
mail_backend_account_get_type (void)
{
	static volatile gsize mail_backend_account_type_id__once = 0;
	if (g_once_init_enter (&mail_backend_account_type_id__once)) {
		GType mail_backend_account_type_id;
		mail_backend_account_type_id = mail_backend_account_get_type_once ();
		g_once_init_leave (&mail_backend_account_type_id__once, mail_backend_account_type_id);
	}
	return mail_backend_account_type_id__once;
}

static void
_vala_mail_backend_account_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	MailBackendAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccount);
	switch (property_id) {
		case MAIL_BACKEND_ACCOUNT_SERVICE_PROPERTY:
		g_value_set_object (value, mail_backend_account_get_service (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_mail_backend_account_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	MailBackendAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccount);
	switch (property_id) {
		case MAIL_BACKEND_ACCOUNT_SERVICE_PROPERTY:
		mail_backend_account_set_service (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

