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

/*
* Copyright 2020-2021 elementary, Inc. (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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*/

#include "onlineaccounts.h"
#include <glib.h>
#include <glib-object.h>
#include <libedataserver/libedataserver.h>
#include <stdlib.h>
#include <string.h>
#include <camel/camel.h>
#include <gio/gio.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  {
	ONLINE_ACCOUNTS_CAMEL_SESSION_0_PROPERTY,
	ONLINE_ACCOUNTS_CAMEL_SESSION_NUM_PROPERTIES
};
static GParamSpec* online_accounts_camel_session_properties[ONLINE_ACCOUNTS_CAMEL_SESSION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

static gpointer online_accounts_camel_session_parent_class = NULL;
static OnlineAccountsCamelSession* online_accounts_camel_session_session;
static OnlineAccountsCamelSession* online_accounts_camel_session_session = NULL;

static GObject * online_accounts_camel_session_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties);
static void _online_accounts_camel_session___lambda21_ (OnlineAccountsCamelSession* self,
                                                 CamelService* service,
                                                 CamelSessionAlertType type,
                                                 const gchar* message);
static void __online_accounts_camel_session___lambda21__camel_session_user_alert (CamelSession* _sender,
                                                                           CamelService* service,
                                                                           CamelSessionAlertType type,
                                                                           const gchar* message,
                                                                           gpointer self);
static void online_accounts_camel_session_finalize (GObject * obj);
static GType online_accounts_camel_session_get_type_once (void);

OnlineAccountsCamelSession*
online_accounts_camel_session_get_default (void)
{
	OnlineAccountsCamelSession* _tmp0_;
	OnlineAccountsCamelSession* _tmp2_;
	OnlineAccountsCamelSession* result;
	_tmp0_ = online_accounts_camel_session_session;
	if (_tmp0_ == NULL) {
		OnlineAccountsCamelSession* _tmp1_;
		_tmp1_ = online_accounts_camel_session_new ();
		_g_object_unref0 (online_accounts_camel_session_session);
		online_accounts_camel_session_session = _tmp1_;
	}
	_tmp2_ = online_accounts_camel_session_session;
	result = _tmp2_;
	return result;
}

OnlineAccountsCamelSession*
online_accounts_camel_session_construct (GType object_type)
{
	OnlineAccountsCamelSession * self = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	_tmp0_ = e_get_user_data_dir ();
	_tmp1_ = g_build_filename (_tmp0_, "mail", NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = e_get_user_cache_dir ();
	_tmp4_ = g_build_filename (_tmp3_, "mail", NULL);
	_tmp5_ = _tmp4_;
	self = (OnlineAccountsCamelSession*) g_object_new (object_type, "user-data-dir", _tmp2_, "user-cache-dir", _tmp5_, NULL);
	_g_free0 (_tmp5_);
	_g_free0 (_tmp2_);
	return self;
}

OnlineAccountsCamelSession*
online_accounts_camel_session_new (void)
{
	return online_accounts_camel_session_construct (ONLINE_ACCOUNTS_TYPE_CAMEL_SESSION);
}

static void
_online_accounts_camel_session___lambda21_ (OnlineAccountsCamelSession* self,
                                            CamelService* service,
                                            CamelSessionAlertType type,
                                            const gchar* message)
{
	g_return_if_fail (service != NULL);
	g_return_if_fail (message != NULL);
	g_warning ("CamelSession.vala:43: %s", message);
}

static void
__online_accounts_camel_session___lambda21__camel_session_user_alert (CamelSession* _sender,
                                                                      CamelService* service,
                                                                      CamelSessionAlertType type,
                                                                      const gchar* message,
                                                                      gpointer self)
{
	_online_accounts_camel_session___lambda21_ ((OnlineAccountsCamelSession*) self, service, type, message);
}

static GObject *
online_accounts_camel_session_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	OnlineAccountsCamelSession * self;
	const gchar* _tmp0_;
	GNetworkMonitor* _tmp1_;
	parent_class = G_OBJECT_CLASS (online_accounts_camel_session_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ONLINE_ACCOUNTS_TYPE_CAMEL_SESSION, OnlineAccountsCamelSession);
	_tmp0_ = e_get_user_data_dir ();
	camel_init (_tmp0_, FALSE);
	_tmp1_ = e_network_monitor_get_default ();
	camel_session_set_network_monitor ((CamelSession*) self, _tmp1_);
	camel_session_set_online ((CamelSession*) self, TRUE);
	g_signal_connect_object ((CamelSession*) self, "user-alert", (GCallback) __online_accounts_camel_session___lambda21__camel_session_user_alert, self, 0);
	return obj;
}

static void
online_accounts_camel_session_class_init (OnlineAccountsCamelSessionClass * klass,
                                          gpointer klass_data)
{
	online_accounts_camel_session_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = online_accounts_camel_session_constructor;
	G_OBJECT_CLASS (klass)->finalize = online_accounts_camel_session_finalize;
}

static void
online_accounts_camel_session_instance_init (OnlineAccountsCamelSession * self,
                                             gpointer klass)
{
}

static void
online_accounts_camel_session_finalize (GObject * obj)
{
	OnlineAccountsCamelSession * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ONLINE_ACCOUNTS_TYPE_CAMEL_SESSION, OnlineAccountsCamelSession);
	G_OBJECT_CLASS (online_accounts_camel_session_parent_class)->finalize (obj);
}

static GType
online_accounts_camel_session_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OnlineAccountsCamelSessionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) online_accounts_camel_session_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OnlineAccountsCamelSession), 0, (GInstanceInitFunc) online_accounts_camel_session_instance_init, NULL };
	GType online_accounts_camel_session_type_id;
	online_accounts_camel_session_type_id = g_type_register_static (camel_session_get_type (), "OnlineAccountsCamelSession", &g_define_type_info, 0);
	return online_accounts_camel_session_type_id;
}

GType
online_accounts_camel_session_get_type (void)
{
	static volatile gsize online_accounts_camel_session_type_id__once = 0;
	if (g_once_init_enter (&online_accounts_camel_session_type_id__once)) {
		GType online_accounts_camel_session_type_id;
		online_accounts_camel_session_type_id = online_accounts_camel_session_get_type_once ();
		g_once_init_leave (&online_accounts_camel_session_type_id__once, online_accounts_camel_session_type_id);
	}
	return online_accounts_camel_session_type_id__once;
}

