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

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

#include <glib-object.h>
#include "shotwell-plugin-dev-1.0.h"
#include <glib.h>
#include <gio/gio.h>
#include "shotwell-authenticator.h"
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include "shotwell-publishing.h"
#include <glib/gi18n-lib.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

#define TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES (shotwell_publishing_core_services_get_type ())
#define SHOTWELL_PUBLISHING_CORE_SERVICES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServices))
#define SHOTWELL_PUBLISHING_CORE_SERVICES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServicesClass))
#define IS_SHOTWELL_PUBLISHING_CORE_SERVICES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES))
#define IS_SHOTWELL_PUBLISHING_CORE_SERVICES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES))
#define SHOTWELL_PUBLISHING_CORE_SERVICES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServicesClass))

typedef struct _ShotwellPublishingCoreServices ShotwellPublishingCoreServices;
typedef struct _ShotwellPublishingCoreServicesClass ShotwellPublishingCoreServicesClass;
typedef struct _ShotwellPublishingCoreServicesPrivate ShotwellPublishingCoreServicesPrivate;
enum  {
	SHOTWELL_PUBLISHING_CORE_SERVICES_0_PROPERTY,
	SHOTWELL_PUBLISHING_CORE_SERVICES_NUM_PROPERTIES
};
static GParamSpec* shotwell_publishing_core_services_properties[SHOTWELL_PUBLISHING_CORE_SERVICES_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ShotwellPublishingCoreServices {
	GObject parent_instance;
	ShotwellPublishingCoreServicesPrivate * priv;
};

struct _ShotwellPublishingCoreServicesClass {
	GObjectClass parent_class;
};

struct _ShotwellPublishingCoreServicesPrivate {
	SpitPluggable** pluggables;
	gint pluggables_length1;
	gint _pluggables_size_;
};

static gint ShotwellPublishingCoreServices_private_offset;
static gpointer shotwell_publishing_core_services_parent_class = NULL;
static SpitModuleIface * shotwell_publishing_core_services_spit_module_parent_iface = NULL;

VALA_EXTERN GType shotwell_publishing_core_services_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ShotwellPublishingCoreServices* shotwell_publishing_core_services_new (GFile* module_file);
VALA_EXTERN ShotwellPublishingCoreServices* shotwell_publishing_core_services_construct (GType object_type,
                                                                             GFile* module_file);
static void _vala_array_add1 (SpitPluggable** * array,
                       gint* length,
                       gint* size,
                       SpitPluggable* value);
static void _vala_array_add2 (SpitPluggable** * array,
                       gint* length,
                       gint* size,
                       SpitPluggable* value);
static void _vala_array_add3 (SpitPluggable** * array,
                       gint* length,
                       gint* size,
                       SpitPluggable* value);
static void _vala_array_add4 (SpitPluggable** * array,
                       gint* length,
                       gint* size,
                       SpitPluggable* value);
static void _vala_array_add5 (SpitPluggable** * array,
                       gint* length,
                       gint* size,
                       SpitPluggable* value);
static const gchar* shotwell_publishing_core_services_real_get_module_name (SpitModule* base);
static const gchar* shotwell_publishing_core_services_real_get_version (SpitModule* base);
static const gchar* shotwell_publishing_core_services_real_get_id (SpitModule* base);
static SpitPluggable** shotwell_publishing_core_services_real_get_pluggables (SpitModule* base,
                                                                       gint* result_length1);
static void shotwell_publishing_core_services_finalize (GObject * obj);
static GType shotwell_publishing_core_services_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
shotwell_publishing_core_services_get_instance_private (ShotwellPublishingCoreServices* self)
{
	return G_STRUCT_MEMBER_P (self, ShotwellPublishingCoreServices_private_offset);
}

static void
_vala_array_add1 (SpitPluggable** * array,
                  gint* length,
                  gint* size,
                  SpitPluggable* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (SpitPluggable*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add2 (SpitPluggable** * array,
                  gint* length,
                  gint* size,
                  SpitPluggable* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (SpitPluggable*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add3 (SpitPluggable** * array,
                  gint* length,
                  gint* size,
                  SpitPluggable* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (SpitPluggable*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add4 (SpitPluggable** * array,
                  gint* length,
                  gint* size,
                  SpitPluggable* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (SpitPluggable*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add5 (SpitPluggable** * array,
                  gint* length,
                  gint* size,
                  SpitPluggable* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (SpitPluggable*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

ShotwellPublishingCoreServices*
shotwell_publishing_core_services_construct (GType object_type,
                                             GFile* module_file)
{
	ShotwellPublishingCoreServices * self = NULL;
	PublishingAuthenticatorFactory* factory = NULL;
	PublishingAuthenticatorFactory* _tmp0_;
	GeeList* authenicators = NULL;
	PublishingAuthenticatorFactory* _tmp1_;
	GeeList* _tmp2_;
	GeeList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GeeList* _tmp6_;
	GeeList* _tmp8_;
	GeeList* _tmp10_;
	PiwigoService* _tmp12_;
	TumblrService* _tmp13_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (module_file, g_file_get_type ()), NULL);
	self = (ShotwellPublishingCoreServices*) g_object_new (object_type, NULL);
	_tmp0_ = publishing_authenticator_factory_get_instance ();
	factory = _tmp0_;
	_tmp1_ = factory;
	_tmp2_ = spit_publishing_authenticator_factory_get_available_authenticators (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, SPIT_PUBLISHING_TYPE_AUTHENTICATOR_FACTORY, SpitPublishingAuthenticatorFactory));
	authenicators = _tmp2_;
	_tmp3_ = authenicators;
	_tmp4_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp5_ = _tmp4_;
	g_debug ("shotwell-publishing.vala:21: Found %d authenicators", _tmp5_);
	_tmp6_ = authenicators;
	if (gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_COLLECTION, GeeCollection), "google-photos")) {
		PublishingGooglePhotosService* _tmp7_;
		_tmp7_ = publishing_google_photos_service_new ();
		_vala_array_add1 (&self->priv->pluggables, &self->priv->pluggables_length1, &self->priv->_pluggables_size_, G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, SPIT_TYPE_PLUGGABLE, SpitPluggable));
	}
	_tmp8_ = authenicators;
	if (gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_COLLECTION, GeeCollection), "flickr")) {
		FlickrService* _tmp9_;
		_tmp9_ = flickr_service_new ();
		_vala_array_add2 (&self->priv->pluggables, &self->priv->pluggables_length1, &self->priv->_pluggables_size_, G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, SPIT_TYPE_PLUGGABLE, SpitPluggable));
	}
	_tmp10_ = authenicators;
	if (gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEE_TYPE_COLLECTION, GeeCollection), "youtube")) {
		YouTubeService* _tmp11_;
		_tmp11_ = you_tube_service_new ();
		_vala_array_add3 (&self->priv->pluggables, &self->priv->pluggables_length1, &self->priv->_pluggables_size_, G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, SPIT_TYPE_PLUGGABLE, SpitPluggable));
	}
	_tmp12_ = piwigo_service_new ();
	_vala_array_add4 (&self->priv->pluggables, &self->priv->pluggables_length1, &self->priv->_pluggables_size_, G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, SPIT_TYPE_PLUGGABLE, SpitPluggable));
	_tmp13_ = tumblr_service_new ();
	_vala_array_add5 (&self->priv->pluggables, &self->priv->pluggables_length1, &self->priv->_pluggables_size_, G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, SPIT_TYPE_PLUGGABLE, SpitPluggable));
	_g_object_unref0 (authenicators);
	_g_object_unref0 (factory);
	return self;
}

ShotwellPublishingCoreServices*
shotwell_publishing_core_services_new (GFile* module_file)
{
	return shotwell_publishing_core_services_construct (TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, module_file);
}

static const gchar*
shotwell_publishing_core_services_real_get_module_name (SpitModule* base)
{
	ShotwellPublishingCoreServices * self;
	const gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServices);
	result = _ ("Core Publishing Services");
	return result;
}

static const gchar*
shotwell_publishing_core_services_real_get_version (SpitModule* base)
{
	ShotwellPublishingCoreServices * self;
	const gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServices);
	result = _VERSION;
	return result;
}

static const gchar*
shotwell_publishing_core_services_real_get_id (SpitModule* base)
{
	ShotwellPublishingCoreServices * self;
	const gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServices);
	result = "org.gnome.shotwell.publishing.core_services";
	return result;
}

static SpitPluggable**
shotwell_publishing_core_services_real_get_pluggables (SpitModule* base,
                                                       gint* result_length1)
{
	ShotwellPublishingCoreServices * self;
	SpitPluggable** _tmp0_;
	gint _tmp0__length1;
	SpitPluggable** _tmp1_;
	gint _tmp1__length1;
	SpitPluggable** result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServices);
	_tmp0_ = self->priv->pluggables;
	_tmp0__length1 = self->priv->pluggables_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

static void
shotwell_publishing_core_services_class_init (ShotwellPublishingCoreServicesClass * klass,
                                              gpointer klass_data)
{
	shotwell_publishing_core_services_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ShotwellPublishingCoreServices_private_offset);
	G_OBJECT_CLASS (klass)->finalize = shotwell_publishing_core_services_finalize;
}

static void
shotwell_publishing_core_services_spit_module_interface_init (SpitModuleIface * iface,
                                                              gpointer iface_data)
{
	shotwell_publishing_core_services_spit_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_module_name = (const gchar* (*) (SpitModule*)) shotwell_publishing_core_services_real_get_module_name;
	iface->get_version = (const gchar* (*) (SpitModule*)) shotwell_publishing_core_services_real_get_version;
	iface->get_id = (const gchar* (*) (SpitModule*)) shotwell_publishing_core_services_real_get_id;
	iface->get_pluggables = (SpitPluggable** (*) (SpitModule*, gint*)) shotwell_publishing_core_services_real_get_pluggables;
}

static void
shotwell_publishing_core_services_instance_init (ShotwellPublishingCoreServices * self,
                                                 gpointer klass)
{
	SpitPluggable** _tmp0_;
	self->priv = shotwell_publishing_core_services_get_instance_private (self);
	_tmp0_ = g_new0 (SpitPluggable*, 0 + 1);
	self->priv->pluggables = _tmp0_;
	self->priv->pluggables_length1 = 0;
	self->priv->_pluggables_size_ = self->priv->pluggables_length1;
}

static void
shotwell_publishing_core_services_finalize (GObject * obj)
{
	ShotwellPublishingCoreServices * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SHOTWELL_PUBLISHING_CORE_SERVICES, ShotwellPublishingCoreServices);
	self->priv->pluggables = (_vala_array_free (self->priv->pluggables, self->priv->pluggables_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (shotwell_publishing_core_services_parent_class)->finalize (obj);
}

static GType
shotwell_publishing_core_services_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ShotwellPublishingCoreServicesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) shotwell_publishing_core_services_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ShotwellPublishingCoreServices), 0, (GInstanceInitFunc) shotwell_publishing_core_services_instance_init, NULL };
	static const GInterfaceInfo spit_module_info = { (GInterfaceInitFunc) shotwell_publishing_core_services_spit_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType shotwell_publishing_core_services_type_id;
	shotwell_publishing_core_services_type_id = g_type_register_static (G_TYPE_OBJECT, "ShotwellPublishingCoreServices", &g_define_type_info, 0);
	g_type_add_interface_static (shotwell_publishing_core_services_type_id, SPIT_TYPE_MODULE, &spit_module_info);
	ShotwellPublishingCoreServices_private_offset = g_type_add_instance_private (shotwell_publishing_core_services_type_id, sizeof (ShotwellPublishingCoreServicesPrivate));
	return shotwell_publishing_core_services_type_id;
}

GType
shotwell_publishing_core_services_get_type (void)
{
	static volatile gsize shotwell_publishing_core_services_type_id__once = 0;
	if (g_once_init_enter (&shotwell_publishing_core_services_type_id__once)) {
		GType shotwell_publishing_core_services_type_id;
		shotwell_publishing_core_services_type_id = shotwell_publishing_core_services_get_type_once ();
		g_once_init_leave (&shotwell_publishing_core_services_type_id__once, shotwell_publishing_core_services_type_id);
	}
	return shotwell_publishing_core_services_type_id__once;
}

SpitModule*
spit_entry_point (SpitEntryPointParams* params)
{
	ShotwellPublishingCoreServices* _tmp0_ = NULL;
	ShotwellPublishingCoreServices* _tmp3_;
	SpitModule* result;
	(*params).module_spit_interface = spit_negotiate_interfaces ((*params).host_min_spit_interface, (*params).host_max_spit_interface, SPIT_CURRENT_INTERFACE);
	if ((*params).module_spit_interface != SPIT_UNSUPPORTED_INTERFACE) {
		GFile* _tmp1_;
		ShotwellPublishingCoreServices* _tmp2_;
		_tmp1_ = (*params).module_file;
		_tmp2_ = shotwell_publishing_core_services_new (_tmp1_);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = _tmp2_;
	} else {
		_g_object_unref0 (_tmp0_);
		_tmp0_ = NULL;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, SPIT_TYPE_MODULE, SpitModule);
	_g_object_unref0 (_tmp0_);
	return result;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

