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

#include "pantheon-files-core.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <zeitgeist.h>
#include <zeitgeist-datamodel.h>

#define FILES_ZEITGEIST_MANAGER_FILES_ACTOR "application://" FILES_APP_DESKTOP
#define FILES_ZEITGEIST_MANAGER_ATTRS G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	FILES_ZEITGEIST_MANAGER_0_PROPERTY,
	FILES_ZEITGEIST_MANAGER_NUM_PROPERTIES
};
static GParamSpec* files_zeitgeist_manager_properties[FILES_ZEITGEIST_MANAGER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block30Data Block30Data;
#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_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

struct _Block30Data {
	int _ref_count_;
	GFile* file;
	gchar* uri;
	gchar* interpretation;
};

static gpointer files_zeitgeist_manager_parent_class = NULL;

static Block30Data* block30_data_ref (Block30Data* _data30_);
static void block30_data_unref (void * _userdata_);
static void __lambda43_ (Block30Data* _data30_,
                  GObject* obj,
                  GAsyncResult* res);
static void ___lambda43__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static GType files_zeitgeist_manager_get_type_once (void);

static Block30Data*
block30_data_ref (Block30Data* _data30_)
{
	g_atomic_int_inc (&_data30_->_ref_count_);
	return _data30_;
}

static void
block30_data_unref (void * _userdata_)
{
	Block30Data* _data30_;
	_data30_ = (Block30Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data30_->_ref_count_)) {
		_g_object_unref0 (_data30_->file);
		_g_free0 (_data30_->uri);
		_g_free0 (_data30_->interpretation);
		g_slice_free (Block30Data, _data30_);
	}
}

static void
__lambda43_ (Block30Data* _data30_,
             GObject* obj,
             GAsyncResult* res)
{
	GFileInfo* info = NULL;
	ZeitgeistLog* log = NULL;
	ZeitgeistLog* _tmp5_;
	ZeitgeistSubject* subject = NULL;
	ZeitgeistSubject* _tmp6_;
	ZeitgeistSubject* _tmp7_;
	ZeitgeistSubject* _tmp8_;
	ZeitgeistSubject* _tmp9_;
	GFileInfo* _tmp10_;
	const gchar* _tmp11_;
	ZeitgeistSubject* _tmp12_;
	GFileInfo* _tmp13_;
	const gchar* _tmp14_;
	ZeitgeistSubject* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	ZeitgeistSubject* _tmp18_;
	ZeitgeistSubject* _tmp19_;
	ZeitgeistEvent* event = NULL;
	ZeitgeistEvent* _tmp20_;
	ZeitgeistEvent* _tmp21_;
	ZeitgeistEvent* _tmp22_;
	ZeitgeistEvent* _tmp23_;
	ZeitgeistEvent* _tmp24_;
	GDateTime* _tmp25_;
	GDateTime* _tmp26_;
	ZeitgeistEvent* _tmp27_;
	ZeitgeistSubject* _tmp28_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		GFileInfo* _tmp0_ = NULL;
		GFileInfo* _tmp1_;
		GFileInfo* _tmp2_;
		_tmp1_ = g_file_query_info_finish (_data30_->file, res, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (info);
		info = _tmp2_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_debug ("ZeitgeistManager.vala:32: Fetching file info folder loggin to zeitgeis" \
"t failed: %s", _tmp4_);
		_g_error_free0 (e);
		_g_object_unref0 (info);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (info);
		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;
	}
	_tmp5_ = zeitgeist_log_get_default ();
	log = _tmp5_;
	_tmp6_ = zeitgeist_subject_new ();
	subject = _tmp6_;
	_tmp7_ = subject;
	_tmp8_ = subject;
	zeitgeist_subject_set_uri (_tmp8_, _data30_->uri);
	zeitgeist_subject_set_current_uri (_tmp7_, _data30_->uri);
	_tmp9_ = subject;
	_tmp10_ = info;
	_tmp11_ = g_file_info_get_display_name (_tmp10_);
	zeitgeist_subject_set_text (_tmp9_, _tmp11_);
	_tmp12_ = subject;
	_tmp13_ = info;
	_tmp14_ = g_file_info_get_attribute_string (_tmp13_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
	zeitgeist_subject_set_mimetype (_tmp12_, _tmp14_);
	_tmp15_ = subject;
	_tmp16_ = g_path_get_dirname (_data30_->uri);
	_tmp17_ = _tmp16_;
	zeitgeist_subject_set_origin (_tmp15_, _tmp17_);
	_g_free0 (_tmp17_);
	_tmp18_ = subject;
	zeitgeist_subject_set_manifestation (_tmp18_, ZEITGEIST_NFO_FILE_DATA_OBJECT);
	_tmp19_ = subject;
	zeitgeist_subject_set_interpretation (_tmp19_, ZEITGEIST_NFO_FOLDER);
	_tmp20_ = zeitgeist_event_new ();
	event = _tmp20_;
	_tmp21_ = event;
	zeitgeist_event_set_interpretation (_tmp21_, _data30_->interpretation);
	_tmp22_ = event;
	zeitgeist_event_set_manifestation (_tmp22_, ZEITGEIST_ZG_USER_ACTIVITY);
	_tmp23_ = event;
	zeitgeist_event_set_actor (_tmp23_, FILES_ZEITGEIST_MANAGER_FILES_ACTOR);
	_tmp24_ = event;
	_tmp25_ = g_date_time_new_now_local ();
	_tmp26_ = _tmp25_;
	zeitgeist_event_set_timestamp (_tmp24_, g_date_time_to_unix (_tmp26_) * 1000);
	_g_date_time_unref0 (_tmp26_);
	_tmp27_ = event;
	_tmp28_ = subject;
	zeitgeist_event_add_subject (_tmp27_, _tmp28_);
	{
		ZeitgeistLog* _tmp29_;
		ZeitgeistEvent* _tmp30_;
		_tmp29_ = log;
		_tmp30_ = event;
		zeitgeist_log_insert_event_no_reply (_tmp29_, _tmp30_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp31_;
		const gchar* _tmp32_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp31_ = e;
		_tmp32_ = _tmp31_->message;
		g_warning ("ZeitgeistManager.vala:55: %s", _tmp32_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (event);
		_g_object_unref0 (subject);
		_g_object_unref0 (log);
		_g_object_unref0 (info);
		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;
	}
	_g_object_unref0 (event);
	_g_object_unref0 (subject);
	_g_object_unref0 (log);
	_g_object_unref0 (info);
}

static void
___lambda43__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda43_ (self, source_object, res);
	block30_data_unref (self);
}

void
files_zeitgeist_manager_report_event (const gchar* uri,
                                      const gchar* interpretation)
{
	Block30Data* _data30_;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GFile* _tmp2_;
	g_return_if_fail (uri != NULL);
	g_return_if_fail (interpretation != NULL);
	_data30_ = g_slice_new0 (Block30Data);
	_data30_->_ref_count_ = 1;
	_tmp0_ = g_strdup (uri);
	_g_free0 (_data30_->uri);
	_data30_->uri = _tmp0_;
	_tmp1_ = g_strdup (interpretation);
	_g_free0 (_data30_->interpretation);
	_data30_->interpretation = _tmp1_;
	_tmp2_ = g_file_new_for_commandline_arg (_data30_->uri);
	_data30_->file = _tmp2_;
	g_file_query_info_async (_data30_->file, FILES_ZEITGEIST_MANAGER_ATTRS, 0, G_PRIORITY_DEFAULT, NULL, ___lambda43__gasync_ready_callback, block30_data_ref (_data30_));
	block30_data_unref (_data30_);
	_data30_ = NULL;
}

FilesZeitgeistManager*
files_zeitgeist_manager_construct (GType object_type)
{
	FilesZeitgeistManager * self = NULL;
	self = (FilesZeitgeistManager*) g_object_new (object_type, NULL);
	return self;
}

FilesZeitgeistManager*
files_zeitgeist_manager_new (void)
{
	return files_zeitgeist_manager_construct (FILES_TYPE_ZEITGEIST_MANAGER);
}

static void
files_zeitgeist_manager_class_init (FilesZeitgeistManagerClass * klass,
                                    gpointer klass_data)
{
	files_zeitgeist_manager_parent_class = g_type_class_peek_parent (klass);
}

static void
files_zeitgeist_manager_instance_init (FilesZeitgeistManager * self,
                                       gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
files_zeitgeist_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FilesZeitgeistManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) files_zeitgeist_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FilesZeitgeistManager), 0, (GInstanceInitFunc) files_zeitgeist_manager_instance_init, NULL };
	GType files_zeitgeist_manager_type_id;
	files_zeitgeist_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "FilesZeitgeistManager", &g_define_type_info, 0);
	return files_zeitgeist_manager_type_id;
}

GType
files_zeitgeist_manager_get_type (void)
{
	static volatile gsize files_zeitgeist_manager_type_id__once = 0;
	if (g_once_init_enter (&files_zeitgeist_manager_type_id__once)) {
		GType files_zeitgeist_manager_type_id;
		files_zeitgeist_manager_type_id = files_zeitgeist_manager_get_type_once ();
		g_once_init_leave (&files_zeitgeist_manager_type_id__once, files_zeitgeist_manager_type_id);
	}
	return files_zeitgeist_manager_type_id__once;
}

