
#include "xesam2.h"
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus-glib.h>
#include <stdio.h>

typedef struct _DBusObjectVTable _DBusObjectVTable;

struct _DBusObjectVTable {
	void (*register_object) (DBusConnection*, const char*, void*);
};



enum  {
	SEARCHER_DUMMY_PROPERTY
};
static gpointer searcher_parent_class = NULL;
void _searcher_dbus_unregister (DBusConnection* connection, void* user_data);
static DBusMessage* _dbus_searcher_introspect (Searcher* self, DBusConnection* connection, DBusMessage* message);
static DBusMessage* _dbus_searcher_property_get_all (Searcher* self, DBusConnection* connection, DBusMessage* message);
static DBusMessage* _dbus_searcher_NewSearch (Searcher* self, DBusConnection* connection, DBusMessage* message);
static DBusMessage* _dbus_searcher_NewSearchBySortKey (Searcher* self, DBusConnection* connection, DBusMessage* message);
enum  {
	SEARCH_DUMMY_PROPERTY
};
static gpointer search_parent_class = NULL;
void _search_dbus_unregister (DBusConnection* connection, void* user_data);
static DBusMessage* _dbus_search_introspect (Search* self, DBusConnection* connection, DBusMessage* message);
static DBusMessage* _dbus_search_property_get_all (Search* self, DBusConnection* connection, DBusMessage* message);
static DBusMessage* _dbus_search_GetHits (Search* self, DBusConnection* connection, DBusMessage* message);
static DBusMessage* _dbus_search_GetHitsBySortKey (Search* self, DBusConnection* connection, DBusMessage* message);
static DBusMessage* _dbus_search_Close (Search* self, DBusConnection* connection, DBusMessage* message);
guint _dynamic_request_name0 (DBusGProxy* self, const char* param1, guint param2, GError** error);
static void _main (void);
static void _vala_dbus_register_object (DBusConnection* connection, const char* path, void* object);

static const DBusObjectPathVTable _searcher_dbus_path_vtable = {_searcher_dbus_unregister, searcher_dbus_message};
static const _DBusObjectVTable _searcher_dbus_vtable = {searcher_dbus_register_object};
static const DBusObjectPathVTable _search_dbus_path_vtable = {_search_dbus_unregister, search_dbus_message};
static const _DBusObjectVTable _search_dbus_vtable = {search_dbus_register_object};


void searcher_NewSearch (Searcher* self, const char* search_object_path, const char* query_xml, char** fields_to_monitor, int fields_to_monitor_length1, guint offset, guint count, gboolean is_live, const char* search_to_close, guint* hit_count, char*** field_map, int* field_map_length1, char**** hit_data, int* hit_data_length1) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (search_object_path != NULL);
	g_return_if_fail (query_xml != NULL);
	g_return_if_fail (search_to_close != NULL);
}


/* QueryHint[] query_hints, */
void searcher_NewSearchBySortKey (Searcher* self, const char* search_object_path, const char* query_xml, char** fields_to_monitor, int fields_to_monitor_length1, const char* start_sortkey, const char* end_sortkey, guint offset, guint count, gboolean is_live, const char* search_to_close, guint* hit_count, char*** field_map, int* field_map_length1, char**** hit_data, int* hit_data_length1) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (search_object_path != NULL);
	g_return_if_fail (query_xml != NULL);
	g_return_if_fail (start_sortkey != NULL);
	g_return_if_fail (end_sortkey != NULL);
	g_return_if_fail (search_to_close != NULL);
}


/* 
public struct QueryHint {
string query;
Value value;
}
*/
Searcher* searcher_construct (GType object_type) {
	Searcher * self;
	self = g_object_newv (object_type, 0, NULL);
	return self;
}


Searcher* searcher_new (void) {
	return searcher_construct (TYPE_SEARCHER);
}


void _searcher_dbus_unregister (DBusConnection* connection, void* user_data) {
}


static DBusMessage* _dbus_searcher_introspect (Searcher* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessage* reply;
	DBusMessageIter iter;
	GString* xml_data;
	char** children;
	int i;
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &iter);
	xml_data = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n");
	g_string_append (xml_data, "<node>\n<interface name=\"org.freedesktop.DBus.Introspectable\">\n  <method name=\"Introspect\">\n    <arg name=\"data\" direction=\"out\" type=\"s\"/>\n  </method>\n</interface>\n<interface name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n    <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n    <arg name=\"propname\" direction=\"in\" type=\"s\"/>\n    <arg name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method name=\"Set\">\n    <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n    <arg name=\"propname\" direction=\"in\" type=\"s\"/>\n    <arg name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <method name=\"GetAll\">\n    <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n    <arg name=\"props\" direction=\"out\" type=\"a{sv}\"/>\n  </method>\n</interface>\n<interface name=\"org.freedesktop.xesam.Searcher\">\n  <method name=\"NewSearch\">\n    <arg name=\"search_object_path\" type=\"o\" direction=\"in\"/>\n    <arg name=\"query_xml\" type=\"s\" direction=\"in\"/>\n    <arg name=\"fields_to_monitor\" type=\"as\" direction=\"in\"/>\n    <arg name=\"offset\" type=\"u\" direction=\"in\"/>\n    <arg name=\"count\" type=\"u\" direction=\"in\"/>\n    <arg name=\"is_live\" type=\"b\" direction=\"in\"/>\n    <arg name=\"search_to_close\" type=\"o\" direction=\"in\"/>\n    <arg name=\"hit_count\" type=\"u\" direction=\"out\"/>\n    <arg name=\"field_map\" type=\"as\" direction=\"out\"/>\n    <arg name=\"hit_data\" type=\"aas\" direction=\"out\"/>\n  </method>\n  <method name=\"NewSearchBySortKey\">\n    <arg name=\"search_object_path\" type=\"o\" direction=\"in\"/>\n    <arg name=\"query_xml\" type=\"s\" direction=\"in\"/>\n    <arg name=\"fields_to_monitor\" type=\"as\" direction=\"in\"/>\n    <arg name=\"start_sortkey\" type=\"s\" direction=\"in\"/>\n    <arg name=\"end_sortkey\" type=\"s\" direction=\"in\"/>\n    <arg name=\"offset\" type=\"u\" direction=\"in\"/>\n    <arg name=\"count\" type=\"u\" direction=\"in\"/>\n    <arg name=\"is_live\" type=\"b\" direction=\"in\"/>\n    <arg name=\"search_to_close\" type=\"o\" direction=\"in\"/>\n    <arg name=\"hit_count\" type=\"u\" direction=\"out\"/>\n    <arg name=\"field_map\" type=\"as\" direction=\"out\"/>\n    <arg name=\"hit_data\" type=\"aas\" direction=\"out\"/>\n  </method>\n</interface>\n");
	dbus_connection_list_registered (connection, g_object_get_data ((GObject *) self, "dbus_object_path"), &children);
	for (i = 0; children[i]; i++) {
		g_string_append_printf (xml_data, "<node name=\"%s\"/>\n", children[i]);
	}
	g_string_append (xml_data, "</node>\n");
	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &xml_data->str);
	g_string_free (xml_data, TRUE);
	return reply;
}


static DBusMessage* _dbus_searcher_property_get_all (Searcher* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessage* reply;
	DBusMessageIter iter, reply_iter, subiter;
	char* interface_name;
	const char* _tmp0;
	if (strcmp (dbus_message_get_signature (message), "s")) {
		return NULL;
	}
	dbus_message_iter_init (message, &iter);
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &reply_iter);
	dbus_message_iter_get_basic (&iter, &_tmp0);
	dbus_message_iter_next (&iter);
	interface_name = g_strdup (_tmp0);
	if (strcmp (interface_name, "org.freedesktop.xesam.Searcher") == 0) {
		dbus_message_iter_open_container (&reply_iter, DBUS_TYPE_ARRAY, "{sv}", &subiter);
		dbus_message_iter_close_container (&reply_iter, &subiter);
	} else {
		return NULL;
	}
	return reply;
}


static DBusMessage* _dbus_searcher_NewSearch (Searcher* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessageIter iter;
	GError* error;
	const char* search_object_path;
	const char* _tmp1;
	const char* query_xml;
	const char* _tmp2;
	char** fields_to_monitor;
	int fields_to_monitor_length1;
	char** _tmp3;
	int _tmp3_length;
	int _tmp3_size;
	int _tmp3_length1;
	DBusMessageIter _tmp4;
	guint offset;
	dbus_uint32_t _tmp6;
	guint count;
	dbus_uint32_t _tmp7;
	gboolean is_live;
	dbus_bool_t _tmp8;
	const char* search_to_close;
	const char* _tmp9;
	guint hit_count;
	char** field_map;
	int field_map_length1;
	char*** hit_data;
	int hit_data_length1;
	DBusMessage* reply;
	dbus_uint32_t _tmp10;
	DBusMessageIter _tmp11;
	int _tmp12;
	DBusMessageIter _tmp14;
	int _tmp15;
	error = NULL;
	if (strcmp (dbus_message_get_signature (message), "osasuubo")) {
		return NULL;
	}
	dbus_message_iter_init (message, &iter);
	search_object_path = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp1);
	dbus_message_iter_next (&iter);
	search_object_path = g_strdup (_tmp1);
	query_xml = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp2);
	dbus_message_iter_next (&iter);
	query_xml = g_strdup (_tmp2);
	fields_to_monitor = NULL;
	fields_to_monitor_length1 = 0;
	_tmp3 = NULL;
	_tmp3_length = 0;
	_tmp3_size = 0;
	_tmp3_length1 = 0;
	dbus_message_iter_recurse (&iter, &_tmp4);
	for (; dbus_message_iter_get_arg_type (&_tmp4); _tmp3_length1++) {
		const char* _tmp5;
		if (_tmp3_size == _tmp3_length) {
			_tmp3_size = (_tmp3_size > 0) ? (2 * _tmp3_size) : 4;
			_tmp3 = g_renew (char*, _tmp3, _tmp3_size);
		}
		dbus_message_iter_get_basic (&_tmp4, &_tmp5);
		dbus_message_iter_next (&_tmp4);
		_tmp3[_tmp3_length++] = g_strdup (_tmp5);
	}
	fields_to_monitor_length1 = _tmp3_length1;
	dbus_message_iter_next (&iter);
	fields_to_monitor = _tmp3;
	offset = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp6);
	dbus_message_iter_next (&iter);
	offset = _tmp6;
	count = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp7);
	dbus_message_iter_next (&iter);
	count = _tmp7;
	is_live = FALSE;
	dbus_message_iter_get_basic (&iter, &_tmp8);
	dbus_message_iter_next (&iter);
	is_live = _tmp8;
	search_to_close = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp9);
	dbus_message_iter_next (&iter);
	search_to_close = g_strdup (_tmp9);
	hit_count = 0U;
	field_map = NULL;
	field_map_length1 = 0;
	hit_data = NULL;
	hit_data_length1 = 0;
	searcher_NewSearch (self, search_object_path, query_xml, fields_to_monitor, fields_to_monitor_length1, offset, count, is_live, search_to_close, &hit_count, &field_map, &field_map_length1, &hit_data, &hit_data_length1);
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &iter);
	_tmp10 = hit_count;
	dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &_tmp10);
	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "s", &_tmp11);
	for (_tmp12 = 0; _tmp12 < field_map_length1; _tmp12++) {
		const char* _tmp13;
		_tmp13 = field_map[_tmp12];
		dbus_message_iter_append_basic (&_tmp11, DBUS_TYPE_STRING, &_tmp13);
	}
	dbus_message_iter_close_container (&iter, &_tmp11);
	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "as", &_tmp14);
	for (_tmp15 = 0; _tmp15 < hit_data_length1; _tmp15++) {
		DBusMessageIter _tmp16;
		int _tmp17;
		dbus_message_iter_open_container (&_tmp14, DBUS_TYPE_ARRAY, "s", &_tmp16);
		for (_tmp17 = 0; ; _tmp17++) {
			const char* _tmp18;
			_tmp18 = hit_data[_tmp15][_tmp17];
			dbus_message_iter_append_basic (&_tmp16, DBUS_TYPE_STRING, &_tmp18);
		}
		dbus_message_iter_close_container (&_tmp14, &_tmp16);
	}
	dbus_message_iter_close_container (&iter, &_tmp14);
	return reply;
}


static DBusMessage* _dbus_searcher_NewSearchBySortKey (Searcher* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessageIter iter;
	GError* error;
	const char* search_object_path;
	const char* _tmp19;
	const char* query_xml;
	const char* _tmp20;
	char** fields_to_monitor;
	int fields_to_monitor_length1;
	char** _tmp21;
	int _tmp21_length;
	int _tmp21_size;
	int _tmp21_length1;
	DBusMessageIter _tmp22;
	const char* start_sortkey;
	const char* _tmp24;
	const char* end_sortkey;
	const char* _tmp25;
	guint offset;
	dbus_uint32_t _tmp26;
	guint count;
	dbus_uint32_t _tmp27;
	gboolean is_live;
	dbus_bool_t _tmp28;
	const char* search_to_close;
	const char* _tmp29;
	guint hit_count;
	char** field_map;
	int field_map_length1;
	char*** hit_data;
	int hit_data_length1;
	DBusMessage* reply;
	dbus_uint32_t _tmp30;
	DBusMessageIter _tmp31;
	int _tmp32;
	DBusMessageIter _tmp34;
	int _tmp35;
	error = NULL;
	if (strcmp (dbus_message_get_signature (message), "osasssuubo")) {
		return NULL;
	}
	dbus_message_iter_init (message, &iter);
	search_object_path = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp19);
	dbus_message_iter_next (&iter);
	search_object_path = g_strdup (_tmp19);
	query_xml = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp20);
	dbus_message_iter_next (&iter);
	query_xml = g_strdup (_tmp20);
	fields_to_monitor = NULL;
	fields_to_monitor_length1 = 0;
	_tmp21 = NULL;
	_tmp21_length = 0;
	_tmp21_size = 0;
	_tmp21_length1 = 0;
	dbus_message_iter_recurse (&iter, &_tmp22);
	for (; dbus_message_iter_get_arg_type (&_tmp22); _tmp21_length1++) {
		const char* _tmp23;
		if (_tmp21_size == _tmp21_length) {
			_tmp21_size = (_tmp21_size > 0) ? (2 * _tmp21_size) : 4;
			_tmp21 = g_renew (char*, _tmp21, _tmp21_size);
		}
		dbus_message_iter_get_basic (&_tmp22, &_tmp23);
		dbus_message_iter_next (&_tmp22);
		_tmp21[_tmp21_length++] = g_strdup (_tmp23);
	}
	fields_to_monitor_length1 = _tmp21_length1;
	dbus_message_iter_next (&iter);
	fields_to_monitor = _tmp21;
	start_sortkey = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp24);
	dbus_message_iter_next (&iter);
	start_sortkey = g_strdup (_tmp24);
	end_sortkey = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp25);
	dbus_message_iter_next (&iter);
	end_sortkey = g_strdup (_tmp25);
	offset = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp26);
	dbus_message_iter_next (&iter);
	offset = _tmp26;
	count = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp27);
	dbus_message_iter_next (&iter);
	count = _tmp27;
	is_live = FALSE;
	dbus_message_iter_get_basic (&iter, &_tmp28);
	dbus_message_iter_next (&iter);
	is_live = _tmp28;
	search_to_close = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp29);
	dbus_message_iter_next (&iter);
	search_to_close = g_strdup (_tmp29);
	hit_count = 0U;
	field_map = NULL;
	field_map_length1 = 0;
	hit_data = NULL;
	hit_data_length1 = 0;
	searcher_NewSearchBySortKey (self, search_object_path, query_xml, fields_to_monitor, fields_to_monitor_length1, start_sortkey, end_sortkey, offset, count, is_live, search_to_close, &hit_count, &field_map, &field_map_length1, &hit_data, &hit_data_length1);
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &iter);
	_tmp30 = hit_count;
	dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &_tmp30);
	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "s", &_tmp31);
	for (_tmp32 = 0; _tmp32 < field_map_length1; _tmp32++) {
		const char* _tmp33;
		_tmp33 = field_map[_tmp32];
		dbus_message_iter_append_basic (&_tmp31, DBUS_TYPE_STRING, &_tmp33);
	}
	dbus_message_iter_close_container (&iter, &_tmp31);
	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "as", &_tmp34);
	for (_tmp35 = 0; _tmp35 < hit_data_length1; _tmp35++) {
		DBusMessageIter _tmp36;
		int _tmp37;
		dbus_message_iter_open_container (&_tmp34, DBUS_TYPE_ARRAY, "s", &_tmp36);
		for (_tmp37 = 0; ; _tmp37++) {
			const char* _tmp38;
			_tmp38 = hit_data[_tmp35][_tmp37];
			dbus_message_iter_append_basic (&_tmp36, DBUS_TYPE_STRING, &_tmp38);
		}
		dbus_message_iter_close_container (&_tmp34, &_tmp36);
	}
	dbus_message_iter_close_container (&iter, &_tmp34);
	return reply;
}


DBusHandlerResult searcher_dbus_message (DBusConnection* connection, DBusMessage* message, void* object) {
	DBusMessage* reply;
	reply = NULL;
	if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
		reply = _dbus_searcher_introspect (object, connection, message);
	} else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Properties", "GetAll")) {
		reply = _dbus_searcher_property_get_all (object, connection, message);
	} else if (dbus_message_is_method_call (message, "org.freedesktop.xesam.Searcher", "NewSearch")) {
		reply = _dbus_searcher_NewSearch (object, connection, message);
	} else if (dbus_message_is_method_call (message, "org.freedesktop.xesam.Searcher", "NewSearchBySortKey")) {
		reply = _dbus_searcher_NewSearchBySortKey (object, connection, message);
	}
	if (reply) {
		dbus_connection_send (connection, reply, NULL);
		dbus_message_unref (reply);
		return DBUS_HANDLER_RESULT_HANDLED;
	} else {
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	}
}


void searcher_dbus_register_object (DBusConnection* connection, const char* path, void* object) {
	if (!g_object_get_data (object, "dbus_object_path")) {
		g_object_set_data (object, "dbus_object_path", g_strdup (path));
		dbus_connection_register_object_path (connection, path, &_searcher_dbus_path_vtable, object);
	}
}


static void searcher_class_init (SearcherClass * klass) {
	searcher_parent_class = g_type_class_peek_parent (klass);
	g_type_set_qdata (TYPE_SEARCHER, g_quark_from_static_string ("DBusObjectVTable"), (void*) (&_searcher_dbus_vtable));
}


static void searcher_instance_init (Searcher * self) {
}


GType searcher_get_type (void) {
	static GType searcher_type_id = 0;
	if (searcher_type_id == 0) {
		static const GTypeInfo g_define_type_info = { sizeof (SearcherClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) searcher_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Searcher), 0, (GInstanceInitFunc) searcher_instance_init, NULL };
		searcher_type_id = g_type_register_static (G_TYPE_OBJECT, "Searcher", &g_define_type_info, 0);
	}
	return searcher_type_id;
}


void search_GetHits (Search* self, guint offset, guint count, char**** hits, int* hits_length1) {
	g_return_if_fail (self != NULL);
}


void search_GetHitsBySortKey (Search* self, const char* start_sortkey, const char* end_sortkey, guint offset, guint count, char**** hits, int* hits_length1) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (start_sortkey != NULL);
	g_return_if_fail (end_sortkey != NULL);
}


void search_Close (Search* self) {
	g_return_if_fail (self != NULL);
}


/* QueryHint[] query_hints, */
Search* search_construct (GType object_type) {
	Search * self;
	self = g_object_newv (object_type, 0, NULL);
	return self;
}


Search* search_new (void) {
	return search_construct (TYPE_SEARCH);
}


void _search_dbus_unregister (DBusConnection* connection, void* user_data) {
}


static DBusMessage* _dbus_search_introspect (Search* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessage* reply;
	DBusMessageIter iter;
	GString* xml_data;
	char** children;
	int i;
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &iter);
	xml_data = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n");
	g_string_append (xml_data, "<node>\n<interface name=\"org.freedesktop.DBus.Introspectable\">\n  <method name=\"Introspect\">\n    <arg name=\"data\" direction=\"out\" type=\"s\"/>\n  </method>\n</interface>\n<interface name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n    <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n    <arg name=\"propname\" direction=\"in\" type=\"s\"/>\n    <arg name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method name=\"Set\">\n    <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n    <arg name=\"propname\" direction=\"in\" type=\"s\"/>\n    <arg name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <method name=\"GetAll\">\n    <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n    <arg name=\"props\" direction=\"out\" type=\"a{sv}\"/>\n  </method>\n</interface>\n<interface name=\"org.freedesktop.xesam.Search\">\n  <method name=\"GetHits\">\n    <arg name=\"offset\" type=\"u\" direction=\"in\"/>\n    <arg name=\"count\" type=\"u\" direction=\"in\"/>\n    <arg name=\"hits\" type=\"aas\" direction=\"out\"/>\n  </method>\n  <method name=\"GetHitsBySortKey\">\n    <arg name=\"start_sortkey\" type=\"s\" direction=\"in\"/>\n    <arg name=\"end_sortkey\" type=\"s\" direction=\"in\"/>\n    <arg name=\"offset\" type=\"u\" direction=\"in\"/>\n    <arg name=\"count\" type=\"u\" direction=\"in\"/>\n    <arg name=\"hits\" type=\"aas\" direction=\"out\"/>\n  </method>\n  <method name=\"Close\">\n  </method>\n</interface>\n");
	dbus_connection_list_registered (connection, g_object_get_data ((GObject *) self, "dbus_object_path"), &children);
	for (i = 0; children[i]; i++) {
		g_string_append_printf (xml_data, "<node name=\"%s\"/>\n", children[i]);
	}
	g_string_append (xml_data, "</node>\n");
	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &xml_data->str);
	g_string_free (xml_data, TRUE);
	return reply;
}


static DBusMessage* _dbus_search_property_get_all (Search* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessage* reply;
	DBusMessageIter iter, reply_iter, subiter;
	char* interface_name;
	const char* _tmp39;
	if (strcmp (dbus_message_get_signature (message), "s")) {
		return NULL;
	}
	dbus_message_iter_init (message, &iter);
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &reply_iter);
	dbus_message_iter_get_basic (&iter, &_tmp39);
	dbus_message_iter_next (&iter);
	interface_name = g_strdup (_tmp39);
	if (strcmp (interface_name, "org.freedesktop.xesam.Search") == 0) {
		dbus_message_iter_open_container (&reply_iter, DBUS_TYPE_ARRAY, "{sv}", &subiter);
		dbus_message_iter_close_container (&reply_iter, &subiter);
	} else {
		return NULL;
	}
	return reply;
}


static DBusMessage* _dbus_search_GetHits (Search* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessageIter iter;
	GError* error;
	guint offset;
	dbus_uint32_t _tmp40;
	guint count;
	dbus_uint32_t _tmp41;
	char*** hits;
	int hits_length1;
	DBusMessage* reply;
	DBusMessageIter _tmp42;
	int _tmp43;
	error = NULL;
	if (strcmp (dbus_message_get_signature (message), "uu")) {
		return NULL;
	}
	dbus_message_iter_init (message, &iter);
	offset = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp40);
	dbus_message_iter_next (&iter);
	offset = _tmp40;
	count = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp41);
	dbus_message_iter_next (&iter);
	count = _tmp41;
	hits = NULL;
	hits_length1 = 0;
	search_GetHits (self, offset, count, &hits, &hits_length1);
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &iter);
	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "as", &_tmp42);
	for (_tmp43 = 0; _tmp43 < hits_length1; _tmp43++) {
		DBusMessageIter _tmp44;
		int _tmp45;
		dbus_message_iter_open_container (&_tmp42, DBUS_TYPE_ARRAY, "s", &_tmp44);
		for (_tmp45 = 0; ; _tmp45++) {
			const char* _tmp46;
			_tmp46 = hits[_tmp43][_tmp45];
			dbus_message_iter_append_basic (&_tmp44, DBUS_TYPE_STRING, &_tmp46);
		}
		dbus_message_iter_close_container (&_tmp42, &_tmp44);
	}
	dbus_message_iter_close_container (&iter, &_tmp42);
	return reply;
}


static DBusMessage* _dbus_search_GetHitsBySortKey (Search* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessageIter iter;
	GError* error;
	const char* start_sortkey;
	const char* _tmp47;
	const char* end_sortkey;
	const char* _tmp48;
	guint offset;
	dbus_uint32_t _tmp49;
	guint count;
	dbus_uint32_t _tmp50;
	char*** hits;
	int hits_length1;
	DBusMessage* reply;
	DBusMessageIter _tmp51;
	int _tmp52;
	error = NULL;
	if (strcmp (dbus_message_get_signature (message), "ssuu")) {
		return NULL;
	}
	dbus_message_iter_init (message, &iter);
	start_sortkey = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp47);
	dbus_message_iter_next (&iter);
	start_sortkey = g_strdup (_tmp47);
	end_sortkey = NULL;
	dbus_message_iter_get_basic (&iter, &_tmp48);
	dbus_message_iter_next (&iter);
	end_sortkey = g_strdup (_tmp48);
	offset = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp49);
	dbus_message_iter_next (&iter);
	offset = _tmp49;
	count = 0U;
	dbus_message_iter_get_basic (&iter, &_tmp50);
	dbus_message_iter_next (&iter);
	count = _tmp50;
	hits = NULL;
	hits_length1 = 0;
	search_GetHitsBySortKey (self, start_sortkey, end_sortkey, offset, count, &hits, &hits_length1);
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &iter);
	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "as", &_tmp51);
	for (_tmp52 = 0; _tmp52 < hits_length1; _tmp52++) {
		DBusMessageIter _tmp53;
		int _tmp54;
		dbus_message_iter_open_container (&_tmp51, DBUS_TYPE_ARRAY, "s", &_tmp53);
		for (_tmp54 = 0; ; _tmp54++) {
			const char* _tmp55;
			_tmp55 = hits[_tmp52][_tmp54];
			dbus_message_iter_append_basic (&_tmp53, DBUS_TYPE_STRING, &_tmp55);
		}
		dbus_message_iter_close_container (&_tmp51, &_tmp53);
	}
	dbus_message_iter_close_container (&iter, &_tmp51);
	return reply;
}


static DBusMessage* _dbus_search_Close (Search* self, DBusConnection* connection, DBusMessage* message) {
	DBusMessageIter iter;
	GError* error;
	DBusMessage* reply;
	error = NULL;
	if (strcmp (dbus_message_get_signature (message), "")) {
		return NULL;
	}
	dbus_message_iter_init (message, &iter);
	search_Close (self);
	reply = dbus_message_new_method_return (message);
	dbus_message_iter_init_append (reply, &iter);
	return reply;
}


DBusHandlerResult search_dbus_message (DBusConnection* connection, DBusMessage* message, void* object) {
	DBusMessage* reply;
	reply = NULL;
	if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
		reply = _dbus_search_introspect (object, connection, message);
	} else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Properties", "GetAll")) {
		reply = _dbus_search_property_get_all (object, connection, message);
	} else if (dbus_message_is_method_call (message, "org.freedesktop.xesam.Search", "GetHits")) {
		reply = _dbus_search_GetHits (object, connection, message);
	} else if (dbus_message_is_method_call (message, "org.freedesktop.xesam.Search", "GetHitsBySortKey")) {
		reply = _dbus_search_GetHitsBySortKey (object, connection, message);
	} else if (dbus_message_is_method_call (message, "org.freedesktop.xesam.Search", "Close")) {
		reply = _dbus_search_Close (object, connection, message);
	}
	if (reply) {
		dbus_connection_send (connection, reply, NULL);
		dbus_message_unref (reply);
		return DBUS_HANDLER_RESULT_HANDLED;
	} else {
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	}
}


void search_dbus_register_object (DBusConnection* connection, const char* path, void* object) {
	if (!g_object_get_data (object, "dbus_object_path")) {
		g_object_set_data (object, "dbus_object_path", g_strdup (path));
		dbus_connection_register_object_path (connection, path, &_search_dbus_path_vtable, object);
	}
}


static void search_class_init (SearchClass * klass) {
	search_parent_class = g_type_class_peek_parent (klass);
	g_signal_new ("hits_added", TYPE_SEARCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_INT);
	g_signal_new ("hits_modified", TYPE_SEARCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_INT);
	g_signal_new ("hits_removed", TYPE_SEARCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_INT);
	g_type_set_qdata (TYPE_SEARCH, g_quark_from_static_string ("DBusObjectVTable"), (void*) (&_search_dbus_vtable));
}


static void search_instance_init (Search * self) {
}


GType search_get_type (void) {
	static GType search_type_id = 0;
	if (search_type_id == 0) {
		static const GTypeInfo g_define_type_info = { sizeof (SearchClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) search_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Search), 0, (GInstanceInitFunc) search_instance_init, NULL };
		search_type_id = g_type_register_static (G_TYPE_OBJECT, "Search", &g_define_type_info, 0);
	}
	return search_type_id;
}


guint _dynamic_request_name0 (DBusGProxy* self, const char* param1, guint param2, GError** error) {
	guint result;
	dbus_g_proxy_call (self, "RequestName", error, G_TYPE_STRING, param1, G_TYPE_UINT, param2, G_TYPE_INVALID, G_TYPE_UINT, &result, G_TYPE_INVALID);
	if (*error) {
		return 0U;
	}
	return result;
}


static void _main (void) {
	GError * inner_error;
	GMainLoop* loop;
	inner_error = NULL;
	loop = g_main_loop_new (NULL, FALSE);
	{
		DBusGConnection* conn;
		DBusGProxy* bus;
		guint request_name_result;
		conn = dbus_g_bus_get (DBUS_BUS_SESSION, &inner_error);
		if (inner_error != NULL) {
			goto __catch0_g_error;
		}
		bus = dbus_g_proxy_new_for_name (conn, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
		request_name_result = _dynamic_request_name0 (bus, "org.freedesktop.xesam", (guint) 0, &inner_error);
		if (inner_error != NULL) {
			goto __catch0_g_error;
		}
		if (request_name_result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
			DBusGProxy* dbus_searcher;
			char* path;
			Searcher* searcher;
			Search* search;
			char* _tmp0;
			DBusGProxy* _tmp1;
			dbus_searcher = NULL;
			path = NULL;
			/*string [] fields = new string[0];
			 QueryHint[] hints = new QueryHint[0]; 
			string [] field_map;
			string[][] hit_data;
			uint hit_count;*/
			searcher = searcher_new ();
			search = search_new ();
			_tmp0 = NULL;
			path = (_tmp0 = g_strdup ("/my/application/xesam/Search"), path = (g_free (path), NULL), _tmp0);
			_vala_dbus_register_object (dbus_g_connection_get_connection (conn), "/org/freedesktop/xesam/Searcher", (GObject*) searcher);
			_vala_dbus_register_object (dbus_g_connection_get_connection (conn), path, (GObject*) search);
			_tmp1 = NULL;
			dbus_searcher = (_tmp1 = dbus_g_proxy_new_for_name (conn, "org.freedesktop.xesam", "/org/freedesktop/xesam/Searcher", "org.freedesktop.xesam.Searcher"), (dbus_searcher == NULL) ? NULL : (dbus_searcher = (g_object_unref (dbus_searcher), NULL)), _tmp1);
			/*dbus_searcher.NewSearch (path, /* hints, */ "query", fields, 0, 0, false, path, out hit_count, out field_map, out hit_data);*/
			g_main_loop_run (loop);
			(dbus_searcher == NULL) ? NULL : (dbus_searcher = (g_object_unref (dbus_searcher), NULL));
			path = (g_free (path), NULL);
			(searcher == NULL) ? NULL : (searcher = (g_object_unref (searcher), NULL));
			(search == NULL) ? NULL : (search = (g_object_unref (search), NULL));
		}
		(conn == NULL) ? NULL : (conn = (dbus_g_connection_unref (conn), NULL));
		(bus == NULL) ? NULL : (bus = (g_object_unref (bus), NULL));
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError * e;
		e = inner_error;
		inner_error = NULL;
		{
			fprintf (stderr, "Oops: %s\n", e->message);
			(e == NULL) ? NULL : (e = (g_error_free (e), NULL));
		}
	}
	__finally0:
	;
	(loop == NULL) ? NULL : (loop = (g_main_loop_unref (loop), NULL));
}


int main (int argc, char ** argv) {
	g_type_init ();
	_main ();
	return 0;
}


static void _vala_dbus_register_object (DBusConnection* connection, const char* path, void* object) {
	const _DBusObjectVTable * vtable;
	vtable = g_type_get_qdata (G_TYPE_FROM_INSTANCE (object), g_quark_from_static_string ("DBusObjectVTable"));
	vtable->register_object (connection, path, object);
}




