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

/*
 * Copyright © 2026 Alain M. (https://github.com/alainm23/planify)
 *
 * 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
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include <gio/gio.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#define BUILD_APPLICATION_ID "io.github.alainm23.planify"
#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 PLANIFY_TYPE_SEARCH_PROVIDER (planify_search_provider_get_type ())
#define PLANIFY_SEARCH_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANIFY_TYPE_SEARCH_PROVIDER, PlanifySearchProvider))
#define PLANIFY_SEARCH_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLANIFY_TYPE_SEARCH_PROVIDER, PlanifySearchProviderClass))
#define PLANIFY_IS_SEARCH_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLANIFY_TYPE_SEARCH_PROVIDER))
#define PLANIFY_IS_SEARCH_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLANIFY_TYPE_SEARCH_PROVIDER))
#define PLANIFY_SEARCH_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLANIFY_TYPE_SEARCH_PROVIDER, PlanifySearchProviderClass))

typedef struct _PlanifySearchProvider PlanifySearchProvider;
typedef struct _PlanifySearchProviderClass PlanifySearchProviderClass;
typedef struct _PlanifySearchProviderPrivate PlanifySearchProviderPrivate;

#define PLANIFY_TYPE_SEARCH_REPOSITORY (planify_search_repository_get_type ())
#define PLANIFY_SEARCH_REPOSITORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANIFY_TYPE_SEARCH_REPOSITORY, PlanifySearchRepository))
#define PLANIFY_SEARCH_REPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLANIFY_TYPE_SEARCH_REPOSITORY, PlanifySearchRepositoryClass))
#define PLANIFY_IS_SEARCH_REPOSITORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLANIFY_TYPE_SEARCH_REPOSITORY))
#define PLANIFY_IS_SEARCH_REPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLANIFY_TYPE_SEARCH_REPOSITORY))
#define PLANIFY_SEARCH_REPOSITORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLANIFY_TYPE_SEARCH_REPOSITORY, PlanifySearchRepositoryClass))

typedef struct _PlanifySearchRepository PlanifySearchRepository;
typedef struct _PlanifySearchRepositoryClass PlanifySearchRepositoryClass;
enum  {
	PLANIFY_SEARCH_PROVIDER_0_PROPERTY,
	PLANIFY_SEARCH_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* planify_search_provider_properties[PLANIFY_SEARCH_PROVIDER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define PLANIFY_SEARCH_REPOSITORY_TYPE_RESULT_META (planify_search_repository_result_meta_get_type ())
typedef struct _PlanifySearchRepositoryResultMeta PlanifySearchRepositoryResultMeta;
#define _planify_search_repository_result_meta_free0(var) ((var == NULL) ? NULL : (var = (planify_search_repository_result_meta_free (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))

struct _PlanifySearchProvider {
	GApplication parent_instance;
	PlanifySearchProviderPrivate * priv;
};

struct _PlanifySearchProviderClass {
	GApplicationClass parent_class;
};

struct _PlanifySearchProviderPrivate {
	PlanifySearchRepository* repository;
};

struct _PlanifySearchRepositoryResultMeta {
	gchar* name;
	gchar* description;
};

static gint PlanifySearchProvider_private_offset;
static gpointer planify_search_provider_parent_class = NULL;

VALA_EXTERN GType planify_search_provider_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PlanifySearchProvider, g_object_unref)
VALA_EXTERN guint planify_search_provider_register_object (void* object,
                                               GDBusConnection* connection,
                                               const gchar* path,
                                               GError** error);
VALA_EXTERN GType planify_search_repository_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PlanifySearchRepository, g_object_unref)
VALA_EXTERN PlanifySearchProvider* planify_search_provider_new (void);
VALA_EXTERN PlanifySearchProvider* planify_search_provider_construct (GType object_type);
static gboolean planify_search_provider_real_dbus_register (GApplication* base,
                                                     GDBusConnection* connection,
                                                     const gchar* object_path,
                                                     GError** error);
VALA_EXTERN gchar** planify_search_provider_get_initial_result_set (PlanifySearchProvider* self,
                                                        gchar** terms,
                                                        gint terms_length1,
                                                        gint* result_length1,
                                                        GError** error);
VALA_EXTERN gchar** planify_search_repository_search (PlanifySearchRepository* self,
                                          const gchar* query,
                                          gint* result_length1);
VALA_EXTERN gchar** planify_search_provider_get_subsearch_result_set (PlanifySearchProvider* self,
                                                          gchar** previous_results,
                                                          gint previous_results_length1,
                                                          gchar** terms,
                                                          gint terms_length1,
                                                          gint* result_length1,
                                                          GError** error);
VALA_EXTERN GHashTable** planify_search_provider_get_result_metas (PlanifySearchProvider* self,
                                                       gchar** identifiers,
                                                       gint identifiers_length1,
                                                       gint* result_length1,
                                                       GError** error);
static void _g_hash_table_unref0_ (gpointer var);
VALA_EXTERN GType planify_search_repository_result_meta_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PlanifySearchRepositoryResultMeta* planify_search_repository_result_meta_dup (const PlanifySearchRepositoryResultMeta* self);
VALA_EXTERN void planify_search_repository_result_meta_free (PlanifySearchRepositoryResultMeta* self);
VALA_EXTERN void planify_search_repository_result_meta_copy (const PlanifySearchRepositoryResultMeta* self,
                                                 PlanifySearchRepositoryResultMeta* dest);
VALA_EXTERN void planify_search_repository_result_meta_destroy (PlanifySearchRepositoryResultMeta* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (PlanifySearchRepositoryResultMeta, planify_search_repository_result_meta_destroy)
VALA_EXTERN PlanifySearchRepositoryResultMeta* planify_search_repository_get_meta (PlanifySearchRepository* self,
                                                                       const gchar* identifier);
static void _g_free0_ (gpointer var);
static void _g_variant_unref0_ (gpointer var);
static GHashTable** _vala_array_dup1 (GHashTable** self,
                               gssize length);
VALA_EXTERN void planify_search_provider_activate_result (PlanifySearchProvider* self,
                                              const gchar* identifier,
                                              gchar** terms,
                                              gint terms_length1,
                                              guint32 timestamp,
                                              GError** error);
static void planify_search_provider_launch_planify (PlanifySearchProvider* self,
                                             const gchar* uri);
VALA_EXTERN void planify_search_provider_launch_search (PlanifySearchProvider* self,
                                            gchar** terms,
                                            gint terms_length1,
                                            guint32 timestamp,
                                            GError** error);
static GObject * planify_search_provider_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
VALA_EXTERN PlanifySearchRepository* planify_search_repository_new (void);
VALA_EXTERN PlanifySearchRepository* planify_search_repository_construct (GType object_type);
static void planify_search_provider_finalize (GObject * obj);
static GType planify_search_provider_get_type_once (void);
static void _dbus_planify_search_provider_get_initial_result_set (PlanifySearchProvider* self,
                                                           GVariant* _parameters_,
                                                           GDBusMethodInvocation* invocation);
static void _dbus_planify_search_provider_get_subsearch_result_set (PlanifySearchProvider* self,
                                                             GVariant* _parameters_,
                                                             GDBusMethodInvocation* invocation);
static void _dbus_planify_search_provider_get_result_metas (PlanifySearchProvider* self,
                                                     GVariant* _parameters_,
                                                     GDBusMethodInvocation* invocation);
static void _dbus_planify_search_provider_activate_result (PlanifySearchProvider* self,
                                                    GVariant* _parameters_,
                                                    GDBusMethodInvocation* invocation);
static void _dbus_planify_search_provider_launch_search (PlanifySearchProvider* self,
                                                  GVariant* _parameters_,
                                                  GDBusMethodInvocation* invocation);
static void planify_search_provider_dbus_interface_method_call (GDBusConnection* connection,
                                                         const gchar* sender,
                                                         const gchar* object_path,
                                                         const gchar* interface_name,
                                                         const gchar* method_name,
                                                         GVariant* parameters,
                                                         GDBusMethodInvocation* invocation,
                                                         gpointer user_data);
static GVariant* planify_search_provider_dbus_interface_get_property (GDBusConnection* connection,
                                                               const gchar* sender,
                                                               const gchar* object_path,
                                                               const gchar* interface_name,
                                                               const gchar* property_name,
                                                               GError** error,
                                                               gpointer user_data);
static gboolean planify_search_provider_dbus_interface_set_property (GDBusConnection* connection,
                                                              const gchar* sender,
                                                              const gchar* object_path,
                                                              const gchar* interface_name,
                                                              const gchar* property_name,
                                                              GVariant* value,
                                                              GError** error,
                                                              gpointer user_data);
static void _planify_search_provider_unregister_object (gpointer user_data);
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 const GDBusArgInfo _planify_search_provider_dbus_arg_info_get_initial_result_set_terms = {-1, "terms", "as", NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_get_initial_result_set_result = {-1, "result", "as", NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_get_initial_result_set_in[] = {&_planify_search_provider_dbus_arg_info_get_initial_result_set_terms, NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_get_initial_result_set_out[] = {&_planify_search_provider_dbus_arg_info_get_initial_result_set_result, NULL};
static const GDBusMethodInfo _planify_search_provider_dbus_method_info_get_initial_result_set = {-1, "GetInitialResultSet", (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_get_initial_result_set_in), (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_get_initial_result_set_out), NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_get_subsearch_result_set_previous_results = {-1, "previous_results", "as", NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_get_subsearch_result_set_terms = {-1, "terms", "as", NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_get_subsearch_result_set_result = {-1, "result", "as", NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_get_subsearch_result_set_in[] = {&_planify_search_provider_dbus_arg_info_get_subsearch_result_set_previous_results, &_planify_search_provider_dbus_arg_info_get_subsearch_result_set_terms, NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_get_subsearch_result_set_out[] = {&_planify_search_provider_dbus_arg_info_get_subsearch_result_set_result, NULL};
static const GDBusMethodInfo _planify_search_provider_dbus_method_info_get_subsearch_result_set = {-1, "GetSubsearchResultSet", (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_get_subsearch_result_set_in), (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_get_subsearch_result_set_out), NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_get_result_metas_identifiers = {-1, "identifiers", "as", NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_get_result_metas_result = {-1, "result", "aa{sv}", NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_get_result_metas_in[] = {&_planify_search_provider_dbus_arg_info_get_result_metas_identifiers, NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_get_result_metas_out[] = {&_planify_search_provider_dbus_arg_info_get_result_metas_result, NULL};
static const GDBusMethodInfo _planify_search_provider_dbus_method_info_get_result_metas = {-1, "GetResultMetas", (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_get_result_metas_in), (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_get_result_metas_out), NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_activate_result_identifier = {-1, "identifier", "s", NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_activate_result_terms = {-1, "terms", "as", NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_activate_result_timestamp = {-1, "timestamp", "u", NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_activate_result_in[] = {&_planify_search_provider_dbus_arg_info_activate_result_identifier, &_planify_search_provider_dbus_arg_info_activate_result_terms, &_planify_search_provider_dbus_arg_info_activate_result_timestamp, NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_activate_result_out[] = {NULL};
static const GDBusMethodInfo _planify_search_provider_dbus_method_info_activate_result = {-1, "ActivateResult", (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_activate_result_in), (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_activate_result_out), NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_launch_search_terms = {-1, "terms", "as", NULL};
static const GDBusArgInfo _planify_search_provider_dbus_arg_info_launch_search_timestamp = {-1, "timestamp", "u", NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_launch_search_in[] = {&_planify_search_provider_dbus_arg_info_launch_search_terms, &_planify_search_provider_dbus_arg_info_launch_search_timestamp, NULL};
static const GDBusArgInfo * const _planify_search_provider_dbus_arg_info_launch_search_out[] = {NULL};
static const GDBusMethodInfo _planify_search_provider_dbus_method_info_launch_search = {-1, "LaunchSearch", (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_launch_search_in), (GDBusArgInfo **) (&_planify_search_provider_dbus_arg_info_launch_search_out), NULL};
static const GDBusMethodInfo * const _planify_search_provider_dbus_method_info[] = {&_planify_search_provider_dbus_method_info_get_initial_result_set, &_planify_search_provider_dbus_method_info_get_subsearch_result_set, &_planify_search_provider_dbus_method_info_get_result_metas, &_planify_search_provider_dbus_method_info_activate_result, &_planify_search_provider_dbus_method_info_launch_search, NULL};
static const GDBusSignalInfo * const _planify_search_provider_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _planify_search_provider_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _planify_search_provider_dbus_interface_info = {-1, "org.gnome.Shell.SearchProvider2", (GDBusMethodInfo **) (&_planify_search_provider_dbus_method_info), (GDBusSignalInfo **) (&_planify_search_provider_dbus_signal_info), (GDBusPropertyInfo **) (&_planify_search_provider_dbus_property_info), NULL};
static const GDBusInterfaceVTable _planify_search_provider_dbus_interface_vtable = {planify_search_provider_dbus_interface_method_call, planify_search_provider_dbus_interface_get_property, planify_search_provider_dbus_interface_set_property};

static inline gpointer
planify_search_provider_get_instance_private (PlanifySearchProvider* self)
{
	return G_STRUCT_MEMBER_P (self, PlanifySearchProvider_private_offset);
}

PlanifySearchProvider*
planify_search_provider_construct (GType object_type)
{
	PlanifySearchProvider * self = NULL;
	self = (PlanifySearchProvider*) g_object_new (object_type, "application-id", BUILD_APPLICATION_ID ".SearchProvider", "flags", G_APPLICATION_IS_SERVICE, "inactivity-timeout", 10000, NULL);
	return self;
}

PlanifySearchProvider*
planify_search_provider_new (void)
{
	return planify_search_provider_construct (PLANIFY_TYPE_SEARCH_PROVIDER);
}

static gboolean
planify_search_provider_real_dbus_register (GApplication* base,
                                            GDBusConnection* connection,
                                            const gchar* object_path,
                                            GError** error)
{
	PlanifySearchProvider * self;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (PlanifySearchProvider*) base;
	g_return_val_if_fail (connection != NULL, FALSE);
	g_return_val_if_fail (object_path != NULL, FALSE);
	G_APPLICATION_CLASS (planify_search_provider_parent_class)->dbus_register (G_TYPE_CHECK_INSTANCE_CAST (self, g_application_get_type (), GApplication), connection, object_path, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp0_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp0_;
	}
	{
		planify_search_provider_register_object (self, connection, object_path, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp1_ = FALSE;
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp1_;
		}
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("search-provider.vala:45: Could not register search provider: %s", _tmp3_);
		g_application_quit ((GApplication*) self);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp4_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp4_;
	}
	result = TRUE;
	return result;
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

gchar**
planify_search_provider_get_initial_result_set (PlanifySearchProvider* self,
                                                gchar** terms,
                                                gint terms_length1,
                                                gint* result_length1,
                                                GError** error)
{
	PlanifySearchRepository* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_ = 0;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->repository;
	_tmp1_ = _vala_g_strjoinv (" ", terms, (gint) terms_length1);
	_tmp2_ = _tmp1_;
	_tmp4_ = planify_search_repository_search (_tmp0_, _tmp2_, &_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _tmp3_;
	_g_free0 (_tmp2_);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp5__length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}

gchar**
planify_search_provider_get_subsearch_result_set (PlanifySearchProvider* self,
                                                  gchar** previous_results,
                                                  gint previous_results_length1,
                                                  gchar** terms,
                                                  gint terms_length1,
                                                  gint* result_length1,
                                                  GError** error)
{
	PlanifySearchRepository* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_ = 0;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->repository;
	_tmp1_ = _vala_g_strjoinv (" ", terms, (gint) terms_length1);
	_tmp2_ = _tmp1_;
	_tmp4_ = planify_search_repository_search (_tmp0_, _tmp2_, &_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _tmp3_;
	_g_free0 (_tmp2_);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp5__length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}

static void
_g_hash_table_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL));
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_g_variant_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_variant_unref (var), NULL));
}

static gpointer
_g_hash_table_ref0 (gpointer self)
{
	return self ? g_hash_table_ref (self) : NULL;
}

static GHashTable**
_vala_array_dup1 (GHashTable** self,
                  gssize length)
{
	if (length >= 0) {
		GHashTable** result;
		gssize i;
		result = g_new0 (GHashTable*, length + 1);
		for (i = 0; i < length; i++) {
			GHashTable* _tmp0_;
			_tmp0_ = _g_hash_table_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

GHashTable**
planify_search_provider_get_result_metas (PlanifySearchProvider* self,
                                          gchar** identifiers,
                                          gint identifiers_length1,
                                          gint* result_length1,
                                          GError** error)
{
	GPtrArray* results = NULL;
	GPtrArray* _tmp0_;
	GPtrArray* _tmp26_;
	gpointer* _tmp27_;
	gint _tmp27__length1;
	GHashTable** _tmp28_;
	gint _tmp28__length1;
	GHashTable** _tmp29_;
	gint _tmp29__length1;
	GHashTable** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_ptr_array_new_full ((guint) 0, _g_hash_table_unref0_);
	results = _tmp0_;
	{
		gchar** id_collection = NULL;
		gint id_collection_length1 = 0;
		gint _id_collection_size_ = 0;
		gint id_it = 0;
		id_collection = identifiers;
		id_collection_length1 = identifiers_length1;
		for (id_it = 0; id_it < id_collection_length1; id_it = id_it + 1) {
			gchar* _tmp1_;
			gchar* id = NULL;
			_tmp1_ = g_strdup (id_collection[id_it]);
			id = _tmp1_;
			{
				PlanifySearchRepositoryResultMeta* meta_data = NULL;
				PlanifySearchRepository* _tmp2_;
				const gchar* _tmp3_;
				PlanifySearchRepositoryResultMeta* _tmp4_;
				PlanifySearchRepositoryResultMeta* _tmp5_;
				GHashTable* meta = NULL;
				GHashFunc _tmp6_;
				GEqualFunc _tmp7_;
				GHashTable* _tmp8_;
				GHashTable* _tmp9_;
				gchar* _tmp10_;
				const gchar* _tmp11_;
				GVariant* _tmp12_;
				GHashTable* _tmp13_;
				gchar* _tmp14_;
				PlanifySearchRepositoryResultMeta* _tmp15_;
				const gchar* _tmp16_;
				GVariant* _tmp17_;
				GHashTable* _tmp18_;
				gchar* _tmp19_;
				PlanifySearchRepositoryResultMeta* _tmp20_;
				const gchar* _tmp21_;
				GVariant* _tmp22_;
				GPtrArray* _tmp23_;
				GHashTable* _tmp24_;
				GHashTable* _tmp25_;
				_tmp2_ = self->priv->repository;
				_tmp3_ = id;
				_tmp4_ = planify_search_repository_get_meta (_tmp2_, _tmp3_);
				meta_data = _tmp4_;
				_tmp5_ = meta_data;
				if (_tmp5_ == NULL) {
					_planify_search_repository_result_meta_free0 (meta_data);
					_g_free0 (id);
					continue;
				}
				_tmp6_ = g_str_hash;
				_tmp7_ = g_str_equal;
				_tmp8_ = g_hash_table_new_full (_tmp6_, _tmp7_, _g_free0_, _g_variant_unref0_);
				meta = _tmp8_;
				_tmp9_ = meta;
				_tmp10_ = g_strdup ("id");
				_tmp11_ = id;
				_tmp12_ = g_variant_new_string (_tmp11_);
				g_variant_ref_sink (_tmp12_);
				g_hash_table_insert (_tmp9_, _tmp10_, _tmp12_);
				_tmp13_ = meta;
				_tmp14_ = g_strdup ("name");
				_tmp15_ = meta_data;
				_tmp16_ = (*_tmp15_).name;
				_tmp17_ = g_variant_new_string (_tmp16_);
				g_variant_ref_sink (_tmp17_);
				g_hash_table_insert (_tmp13_, _tmp14_, _tmp17_);
				_tmp18_ = meta;
				_tmp19_ = g_strdup ("description");
				_tmp20_ = meta_data;
				_tmp21_ = (*_tmp20_).description;
				_tmp22_ = g_variant_new_string (_tmp21_);
				g_variant_ref_sink (_tmp22_);
				g_hash_table_insert (_tmp18_, _tmp19_, _tmp22_);
				_tmp23_ = results;
				_tmp24_ = meta;
				_tmp25_ = _g_hash_table_ref0 (_tmp24_);
				g_ptr_array_add (_tmp23_, _tmp25_);
				_g_hash_table_unref0 (meta);
				_planify_search_repository_result_meta_free0 (meta_data);
				_g_free0 (id);
			}
		}
	}
	_tmp26_ = results;
	_tmp27_ = _tmp26_->pdata;
	_tmp27__length1 = _tmp26_->len;
	_tmp28_ = (_tmp27_ != NULL) ? _vala_array_dup1 (_tmp27_, _tmp27__length1) : _tmp27_;
	_tmp28__length1 = _tmp27__length1;
	_tmp29_ = _tmp28_;
	_tmp29__length1 = _tmp28__length1;
	if (result_length1) {
		*result_length1 = _tmp29__length1;
	}
	result = _tmp29_;
	_g_ptr_array_unref0 (results);
	return result;
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

void
planify_search_provider_activate_result (PlanifySearchProvider* self,
                                         const gchar* identifier,
                                         gchar** terms,
                                         gint terms_length1,
                                         guint32 timestamp,
                                         GError** error)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (identifier != NULL);
	if (g_str_has_prefix (identifier, "project-")) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp0_ = string_substring (identifier, (glong) 8, (glong) -1);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_strconcat ("planify://project/", _tmp1_, NULL);
		_tmp3_ = _tmp2_;
		planify_search_provider_launch_planify (self, _tmp3_);
		_g_free0 (_tmp3_);
		_g_free0 (_tmp1_);
	} else {
		if (g_str_has_prefix (identifier, "item-")) {
			gchar* _tmp4_;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			_tmp4_ = string_substring (identifier, (glong) 5, (glong) -1);
			_tmp5_ = _tmp4_;
			_tmp6_ = g_strconcat ("planify://item/", _tmp5_, NULL);
			_tmp7_ = _tmp6_;
			planify_search_provider_launch_planify (self, _tmp7_);
			_g_free0 (_tmp7_);
			_g_free0 (_tmp5_);
		} else {
			planify_search_provider_launch_planify (self, "planify://");
		}
	}
}

void
planify_search_provider_launch_search (PlanifySearchProvider* self,
                                       gchar** terms,
                                       gint terms_length1,
                                       guint32 timestamp,
                                       GError** error)
{
	g_return_if_fail (self != NULL);
	planify_search_provider_launch_planify (self, "planify://");
}

static void
planify_search_provider_launch_planify (PlanifySearchProvider* self,
                                        const gchar* uri)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	{
		g_app_info_launch_default_for_uri (uri, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		{
			g_spawn_command_line_async ("flatpak run " BUILD_APPLICATION_ID, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == G_SPAWN_ERROR) {
					goto __catch1_g_spawn_error;
				}
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
		}
		goto __finally1;
		__catch1_g_spawn_error:
		{
			GError* se = NULL;
			GError* _tmp0_;
			const gchar* _tmp1_;
			se = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp0_ = se;
			_tmp1_ = _tmp0_->message;
			g_warning ("search-provider.vala:100: Could not launch Planify: %s", _tmp1_);
			_g_error_free0 (se);
		}
		__finally1:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static GObject *
planify_search_provider_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PlanifySearchProvider * self;
	PlanifySearchRepository* _tmp0_;
	parent_class = G_OBJECT_CLASS (planify_search_provider_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PLANIFY_TYPE_SEARCH_PROVIDER, PlanifySearchProvider);
	_tmp0_ = planify_search_repository_new ();
	_g_object_unref0 (self->priv->repository);
	self->priv->repository = _tmp0_;
	return obj;
}

static void
planify_search_provider_class_init (PlanifySearchProviderClass * klass,
                                    gpointer klass_data)
{
	planify_search_provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PlanifySearchProvider_private_offset);
	((GApplicationClass *) klass)->dbus_register = (gboolean (*) (GApplication*, GDBusConnection*, const gchar*, GError**)) planify_search_provider_real_dbus_register;
	G_OBJECT_CLASS (klass)->constructor = planify_search_provider_constructor;
	G_OBJECT_CLASS (klass)->finalize = planify_search_provider_finalize;
}

static void
planify_search_provider_instance_init (PlanifySearchProvider * self,
                                       gpointer klass)
{
	self->priv = planify_search_provider_get_instance_private (self);
}

static void
planify_search_provider_finalize (GObject * obj)
{
	PlanifySearchProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PLANIFY_TYPE_SEARCH_PROVIDER, PlanifySearchProvider);
	_g_object_unref0 (self->priv->repository);
	G_OBJECT_CLASS (planify_search_provider_parent_class)->finalize (obj);
}

static GType
planify_search_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PlanifySearchProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) planify_search_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PlanifySearchProvider), 0, (GInstanceInitFunc) planify_search_provider_instance_init, NULL };
	GType planify_search_provider_type_id;
	planify_search_provider_type_id = g_type_register_static (g_application_get_type (), "PlanifySearchProvider", &g_define_type_info, 0);
	g_type_set_qdata (planify_search_provider_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) planify_search_provider_register_object);
	PlanifySearchProvider_private_offset = g_type_add_instance_private (planify_search_provider_type_id, sizeof (PlanifySearchProviderPrivate));
	return planify_search_provider_type_id;
}

GType
planify_search_provider_get_type (void)
{
	static volatile gsize planify_search_provider_type_id__once = 0;
	if (g_once_init_enter (&planify_search_provider_type_id__once)) {
		GType planify_search_provider_type_id;
		planify_search_provider_type_id = planify_search_provider_get_type_once ();
		g_once_init_leave (&planify_search_provider_type_id__once, planify_search_provider_type_id);
	}
	return planify_search_provider_type_id__once;
}

static void
_dbus_planify_search_provider_get_initial_result_set (PlanifySearchProvider* self,
                                                      GVariant* _parameters_,
                                                      GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar** terms = NULL;
	gint terms_length1 = 0;
	GVariant* _tmp0_;
	gchar** _tmp1_;
	gint _tmp1__length;
	gint _tmp1__size;
	gint _tmp1__length1;
	GVariantIter _tmp2_;
	GVariant* _tmp3_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	gchar** result;
	gint result_length1 = 0;
	gchar** _tmp4_;
	GVariantBuilder _tmp5_;
	gint _tmp6_;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp0_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp1_ = g_new (gchar*, 5);
	_tmp1__length = 0;
	_tmp1__size = 4;
	_tmp1__length1 = 0;
	g_variant_iter_init (&_tmp2_, _tmp0_);
	for (; (_tmp3_ = g_variant_iter_next_value (&_tmp2_)) != NULL; _tmp1__length1++) {
		if (_tmp1__size == _tmp1__length) {
			_tmp1__size = 2 * _tmp1__size;
			_tmp1_ = g_renew (gchar*, _tmp1_, _tmp1__size + 1);
		}
		_tmp1_[_tmp1__length++] = g_variant_dup_string (_tmp3_, NULL);
		g_variant_unref (_tmp3_);
	}
	terms_length1 = _tmp1__length1;
	_tmp1_[_tmp1__length] = NULL;
	terms = _tmp1_;
	g_variant_unref (_tmp0_);
	result = planify_search_provider_get_initial_result_set (self, terms, terms_length1, &result_length1, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_tmp4_ = result;
	g_variant_builder_init (&_tmp5_, G_VARIANT_TYPE ("as"));
	for (_tmp6_ = 0; _tmp6_ < result_length1; _tmp6_++) {
		g_variant_builder_add_value (&_tmp5_, g_variant_new_string (*_tmp4_));
		_tmp4_++;
	}
	g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp5_));
	result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_free), NULL);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	terms = (_vala_array_free (terms, terms_length1, (GDestroyNotify) g_free), NULL);
	;
}

static void
_dbus_planify_search_provider_get_subsearch_result_set (PlanifySearchProvider* self,
                                                        GVariant* _parameters_,
                                                        GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar** previous_results = NULL;
	gint previous_results_length1 = 0;
	GVariant* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length;
	gint _tmp8__size;
	gint _tmp8__length1;
	GVariantIter _tmp9_;
	GVariant* _tmp10_;
	gchar** terms = NULL;
	gint terms_length1 = 0;
	GVariant* _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length;
	gint _tmp12__size;
	gint _tmp12__length1;
	GVariantIter _tmp13_;
	GVariant* _tmp14_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	gchar** result;
	gint result_length1 = 0;
	gchar** _tmp15_;
	GVariantBuilder _tmp16_;
	gint _tmp17_;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp7_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp8_ = g_new (gchar*, 5);
	_tmp8__length = 0;
	_tmp8__size = 4;
	_tmp8__length1 = 0;
	g_variant_iter_init (&_tmp9_, _tmp7_);
	for (; (_tmp10_ = g_variant_iter_next_value (&_tmp9_)) != NULL; _tmp8__length1++) {
		if (_tmp8__size == _tmp8__length) {
			_tmp8__size = 2 * _tmp8__size;
			_tmp8_ = g_renew (gchar*, _tmp8_, _tmp8__size + 1);
		}
		_tmp8_[_tmp8__length++] = g_variant_dup_string (_tmp10_, NULL);
		g_variant_unref (_tmp10_);
	}
	previous_results_length1 = _tmp8__length1;
	_tmp8_[_tmp8__length] = NULL;
	previous_results = _tmp8_;
	g_variant_unref (_tmp7_);
	_tmp11_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp12_ = g_new (gchar*, 5);
	_tmp12__length = 0;
	_tmp12__size = 4;
	_tmp12__length1 = 0;
	g_variant_iter_init (&_tmp13_, _tmp11_);
	for (; (_tmp14_ = g_variant_iter_next_value (&_tmp13_)) != NULL; _tmp12__length1++) {
		if (_tmp12__size == _tmp12__length) {
			_tmp12__size = 2 * _tmp12__size;
			_tmp12_ = g_renew (gchar*, _tmp12_, _tmp12__size + 1);
		}
		_tmp12_[_tmp12__length++] = g_variant_dup_string (_tmp14_, NULL);
		g_variant_unref (_tmp14_);
	}
	terms_length1 = _tmp12__length1;
	_tmp12_[_tmp12__length] = NULL;
	terms = _tmp12_;
	g_variant_unref (_tmp11_);
	result = planify_search_provider_get_subsearch_result_set (self, previous_results, previous_results_length1, terms, terms_length1, &result_length1, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_tmp15_ = result;
	g_variant_builder_init (&_tmp16_, G_VARIANT_TYPE ("as"));
	for (_tmp17_ = 0; _tmp17_ < result_length1; _tmp17_++) {
		g_variant_builder_add_value (&_tmp16_, g_variant_new_string (*_tmp15_));
		_tmp15_++;
	}
	g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp16_));
	result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_free), NULL);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	previous_results = (_vala_array_free (previous_results, previous_results_length1, (GDestroyNotify) g_free), NULL);
	terms = (_vala_array_free (terms, terms_length1, (GDestroyNotify) g_free), NULL);
	;
}

static void
_dbus_planify_search_provider_get_result_metas (PlanifySearchProvider* self,
                                                GVariant* _parameters_,
                                                GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar** identifiers = NULL;
	gint identifiers_length1 = 0;
	GVariant* _tmp18_;
	gchar** _tmp19_;
	gint _tmp19__length;
	gint _tmp19__size;
	gint _tmp19__length1;
	GVariantIter _tmp20_;
	GVariant* _tmp21_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	GHashTable** result;
	gint result_length1 = 0;
	GHashTable** _tmp22_;
	GVariantBuilder _tmp23_;
	gint _tmp24_;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp18_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp19_ = g_new (gchar*, 5);
	_tmp19__length = 0;
	_tmp19__size = 4;
	_tmp19__length1 = 0;
	g_variant_iter_init (&_tmp20_, _tmp18_);
	for (; (_tmp21_ = g_variant_iter_next_value (&_tmp20_)) != NULL; _tmp19__length1++) {
		if (_tmp19__size == _tmp19__length) {
			_tmp19__size = 2 * _tmp19__size;
			_tmp19_ = g_renew (gchar*, _tmp19_, _tmp19__size + 1);
		}
		_tmp19_[_tmp19__length++] = g_variant_dup_string (_tmp21_, NULL);
		g_variant_unref (_tmp21_);
	}
	identifiers_length1 = _tmp19__length1;
	_tmp19_[_tmp19__length] = NULL;
	identifiers = _tmp19_;
	g_variant_unref (_tmp18_);
	result = planify_search_provider_get_result_metas (self, identifiers, identifiers_length1, &result_length1, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_tmp22_ = result;
	g_variant_builder_init (&_tmp23_, G_VARIANT_TYPE ("aa{sv}"));
	for (_tmp24_ = 0; _tmp24_ < result_length1; _tmp24_++) {
		GVariantBuilder _tmp25_;
		GHashTableIter _tmp26_;
		gpointer _tmp27_;
		gpointer _tmp28_;
		g_hash_table_iter_init (&_tmp26_, *_tmp22_);
		g_variant_builder_init (&_tmp25_, G_VARIANT_TYPE ("a{sv}"));
		while (g_hash_table_iter_next (&_tmp26_, &_tmp27_, &_tmp28_)) {
			gchar* _key;
			GVariant* _value;
			_key = (gchar*) _tmp27_;
			_value = (GVariant*) _tmp28_;
			g_variant_builder_add (&_tmp25_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
		}
		g_variant_builder_add_value (&_tmp23_, g_variant_builder_end (&_tmp25_));
		_tmp22_++;
	}
	g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp23_));
	result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_hash_table_unref), NULL);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	identifiers = (_vala_array_free (identifiers, identifiers_length1, (GDestroyNotify) g_free), NULL);
	;
}

static void
_dbus_planify_search_provider_activate_result (PlanifySearchProvider* self,
                                               GVariant* _parameters_,
                                               GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar* identifier = NULL;
	GVariant* _tmp29_;
	gchar** terms = NULL;
	gint terms_length1 = 0;
	GVariant* _tmp30_;
	gchar** _tmp31_;
	gint _tmp31__length;
	gint _tmp31__size;
	gint _tmp31__length1;
	GVariantIter _tmp32_;
	GVariant* _tmp33_;
	guint32 timestamp = 0U;
	GVariant* _tmp34_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp29_ = g_variant_iter_next_value (&_arguments_iter);
	identifier = g_variant_dup_string (_tmp29_, NULL);
	g_variant_unref (_tmp29_);
	_tmp30_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp31_ = g_new (gchar*, 5);
	_tmp31__length = 0;
	_tmp31__size = 4;
	_tmp31__length1 = 0;
	g_variant_iter_init (&_tmp32_, _tmp30_);
	for (; (_tmp33_ = g_variant_iter_next_value (&_tmp32_)) != NULL; _tmp31__length1++) {
		if (_tmp31__size == _tmp31__length) {
			_tmp31__size = 2 * _tmp31__size;
			_tmp31_ = g_renew (gchar*, _tmp31_, _tmp31__size + 1);
		}
		_tmp31_[_tmp31__length++] = g_variant_dup_string (_tmp33_, NULL);
		g_variant_unref (_tmp33_);
	}
	terms_length1 = _tmp31__length1;
	_tmp31_[_tmp31__length] = NULL;
	terms = _tmp31_;
	g_variant_unref (_tmp30_);
	_tmp34_ = g_variant_iter_next_value (&_arguments_iter);
	timestamp = g_variant_get_uint32 (_tmp34_);
	g_variant_unref (_tmp34_);
	planify_search_provider_activate_result (self, identifier, terms, terms_length1, timestamp, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	_g_free0 (identifier);
	terms = (_vala_array_free (terms, terms_length1, (GDestroyNotify) g_free), NULL);
	;
}

static void
_dbus_planify_search_provider_launch_search (PlanifySearchProvider* self,
                                             GVariant* _parameters_,
                                             GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar** terms = NULL;
	gint terms_length1 = 0;
	GVariant* _tmp35_;
	gchar** _tmp36_;
	gint _tmp36__length;
	gint _tmp36__size;
	gint _tmp36__length1;
	GVariantIter _tmp37_;
	GVariant* _tmp38_;
	guint32 timestamp = 0U;
	GVariant* _tmp39_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp35_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp36_ = g_new (gchar*, 5);
	_tmp36__length = 0;
	_tmp36__size = 4;
	_tmp36__length1 = 0;
	g_variant_iter_init (&_tmp37_, _tmp35_);
	for (; (_tmp38_ = g_variant_iter_next_value (&_tmp37_)) != NULL; _tmp36__length1++) {
		if (_tmp36__size == _tmp36__length) {
			_tmp36__size = 2 * _tmp36__size;
			_tmp36_ = g_renew (gchar*, _tmp36_, _tmp36__size + 1);
		}
		_tmp36_[_tmp36__length++] = g_variant_dup_string (_tmp38_, NULL);
		g_variant_unref (_tmp38_);
	}
	terms_length1 = _tmp36__length1;
	_tmp36_[_tmp36__length] = NULL;
	terms = _tmp36_;
	g_variant_unref (_tmp35_);
	_tmp39_ = g_variant_iter_next_value (&_arguments_iter);
	timestamp = g_variant_get_uint32 (_tmp39_);
	g_variant_unref (_tmp39_);
	planify_search_provider_launch_search (self, terms, terms_length1, timestamp, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	terms = (_vala_array_free (terms, terms_length1, (GDestroyNotify) g_free), NULL);
	;
}

static void
planify_search_provider_dbus_interface_method_call (GDBusConnection* connection,
                                                    const gchar* sender,
                                                    const gchar* object_path,
                                                    const gchar* interface_name,
                                                    const gchar* method_name,
                                                    GVariant* parameters,
                                                    GDBusMethodInvocation* invocation,
                                                    gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "GetInitialResultSet") == 0) {
		_dbus_planify_search_provider_get_initial_result_set (object, parameters, invocation);
	} else if (strcmp (method_name, "GetSubsearchResultSet") == 0) {
		_dbus_planify_search_provider_get_subsearch_result_set (object, parameters, invocation);
	} else if (strcmp (method_name, "GetResultMetas") == 0) {
		_dbus_planify_search_provider_get_result_metas (object, parameters, invocation);
	} else if (strcmp (method_name, "ActivateResult") == 0) {
		_dbus_planify_search_provider_activate_result (object, parameters, invocation);
	} else if (strcmp (method_name, "LaunchSearch") == 0) {
		_dbus_planify_search_provider_launch_search (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
planify_search_provider_dbus_interface_get_property (GDBusConnection* connection,
                                                     const gchar* sender,
                                                     const gchar* object_path,
                                                     const gchar* interface_name,
                                                     const gchar* property_name,
                                                     GError** error,
                                                     gpointer user_data)
{
	return NULL;
}

static gboolean
planify_search_provider_dbus_interface_set_property (GDBusConnection* connection,
                                                     const gchar* sender,
                                                     const gchar* object_path,
                                                     const gchar* interface_name,
                                                     const gchar* property_name,
                                                     GVariant* value,
                                                     GError** error,
                                                     gpointer user_data)
{
	return FALSE;
}

guint
planify_search_provider_register_object (gpointer object,
                                         GDBusConnection* connection,
                                         const gchar* path,
                                         GError** error)
{
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_planify_search_provider_dbus_interface_info), &_planify_search_provider_dbus_interface_vtable, data, _planify_search_provider_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_planify_search_provider_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

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);
}

