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


#include <glib.h>
#include <glib-object.h>
#include <fsoresource.h>
#include <freesmartphone.h>
#include <stdlib.h>
#include <string.h>
#include <fsoframework.h>
#include <gio/gio.h>
#include <fsobasics.h>


#define FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE (fso_device_base_power_control_resource_get_type ())
#define FSO_DEVICE_BASE_POWER_CONTROL_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE, FsoDeviceBasePowerControlResource))
#define FSO_DEVICE_BASE_POWER_CONTROL_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE, FsoDeviceBasePowerControlResourceClass))
#define FSO_DEVICE_IS_BASE_POWER_CONTROL_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE))
#define FSO_DEVICE_IS_BASE_POWER_CONTROL_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE))
#define FSO_DEVICE_BASE_POWER_CONTROL_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE, FsoDeviceBasePowerControlResourceClass))

typedef struct _FsoDeviceBasePowerControlResource FsoDeviceBasePowerControlResource;
typedef struct _FsoDeviceBasePowerControlResourceClass FsoDeviceBasePowerControlResourceClass;
typedef struct _FsoDeviceBasePowerControlResourcePrivate FsoDeviceBasePowerControlResourcePrivate;

#define FSO_DEVICE_TYPE_ISIMPLE_POWER_CONTROL (fso_device_isimple_power_control_get_type ())
#define FSO_DEVICE_ISIMPLE_POWER_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FSO_DEVICE_TYPE_ISIMPLE_POWER_CONTROL, FsoDeviceISimplePowerControl))
#define FSO_DEVICE_IS_ISIMPLE_POWER_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FSO_DEVICE_TYPE_ISIMPLE_POWER_CONTROL))
#define FSO_DEVICE_ISIMPLE_POWER_CONTROL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FSO_DEVICE_TYPE_ISIMPLE_POWER_CONTROL, FsoDeviceISimplePowerControlIface))

typedef struct _FsoDeviceISimplePowerControl FsoDeviceISimplePowerControl;
typedef struct _FsoDeviceISimplePowerControlIface FsoDeviceISimplePowerControlIface;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _fso_device_base_power_control_resource_enableResourceData fso_device_base_power_control_resource_enableResourceData;
typedef struct _fso_device_base_power_control_resource_disableResourceData fso_device_base_power_control_resource_disableResourceData;
typedef struct _fso_device_base_power_control_resource_suspendResourceData fso_device_base_power_control_resource_suspendResourceData;
typedef struct _fso_device_base_power_control_resource_resumeResourceData fso_device_base_power_control_resource_resumeResourceData;

struct _FsoDeviceBasePowerControlResource {
	FsoFrameworkAbstractDBusResource parent_instance;
	FsoDeviceBasePowerControlResourcePrivate * priv;
};

struct _FsoDeviceBasePowerControlResourceClass {
	FsoFrameworkAbstractDBusResourceClass parent_class;
};

struct _FsoDeviceISimplePowerControlIface {
	GTypeInterface parent_iface;
	gboolean (*getPower) (FsoDeviceISimplePowerControl* self);
	void (*setPower) (FsoDeviceISimplePowerControl* self, gboolean on);
};

struct _FsoDeviceBasePowerControlResourcePrivate {
	FsoDeviceISimplePowerControl* bpc;
	FreeSmartphoneUsageResourcePolicy policy;
};

struct _fso_device_base_power_control_resource_enableResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FsoDeviceBasePowerControlResource* self;
	FsoFrameworkLogger* _tmp0_;
	FsoDeviceISimplePowerControl* _tmp1_;
};

struct _fso_device_base_power_control_resource_disableResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FsoDeviceBasePowerControlResource* self;
	FsoFrameworkLogger* _tmp0_;
	FsoDeviceISimplePowerControl* _tmp1_;
};

struct _fso_device_base_power_control_resource_suspendResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FsoDeviceBasePowerControlResource* self;
	FsoFrameworkLogger* _tmp0_;
};

struct _fso_device_base_power_control_resource_resumeResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FsoDeviceBasePowerControlResource* self;
	FsoFrameworkLogger* _tmp0_;
};


static gpointer fso_device_base_power_control_resource_parent_class = NULL;

GType fso_device_base_power_control_resource_get_type (void) G_GNUC_CONST;
GType fso_device_isimple_power_control_get_type (void) G_GNUC_CONST;
#define FSO_DEVICE_BASE_POWER_CONTROL_RESOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE, FsoDeviceBasePowerControlResourcePrivate))
enum  {
	FSO_DEVICE_BASE_POWER_CONTROL_RESOURCE_DUMMY_PROPERTY
};
FsoDeviceBasePowerControlResource* fso_device_base_power_control_resource_new (FsoDeviceISimplePowerControl* bpc, const gchar* name, FsoFrameworkSubsystem* subsystem, FreeSmartphoneUsageResourcePolicy policy);
FsoDeviceBasePowerControlResource* fso_device_base_power_control_resource_construct (GType object_type, FsoDeviceISimplePowerControl* bpc, const gchar* name, FsoFrameworkSubsystem* subsystem, FreeSmartphoneUsageResourcePolicy policy);
static void fso_device_base_power_control_resource_real_enableResource_data_free (gpointer _data);
static void fso_device_base_power_control_resource_real_enableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean fso_device_base_power_control_resource_real_enableResource_co (fso_device_base_power_control_resource_enableResourceData* _data_);
void fso_device_isimple_power_control_setPower (FsoDeviceISimplePowerControl* self, gboolean on);
static void fso_device_base_power_control_resource_real_disableResource_data_free (gpointer _data);
static void fso_device_base_power_control_resource_real_disableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean fso_device_base_power_control_resource_real_disableResource_co (fso_device_base_power_control_resource_disableResourceData* _data_);
static void fso_device_base_power_control_resource_real_suspendResource_data_free (gpointer _data);
static void fso_device_base_power_control_resource_real_suspendResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean fso_device_base_power_control_resource_real_suspendResource_co (fso_device_base_power_control_resource_suspendResourceData* _data_);
static void fso_device_base_power_control_resource_real_resumeResource_data_free (gpointer _data);
static void fso_device_base_power_control_resource_real_resumeResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean fso_device_base_power_control_resource_real_resumeResource_co (fso_device_base_power_control_resource_resumeResourceData* _data_);
static FreeSmartphoneUsageResourcePolicy fso_device_base_power_control_resource_real_default_policy (FsoFrameworkAbstractDBusResource* base);
static void fso_device_base_power_control_resource_finalize (GObject* obj);


FsoDeviceBasePowerControlResource* fso_device_base_power_control_resource_construct (GType object_type, FsoDeviceISimplePowerControl* bpc, const gchar* name, FsoFrameworkSubsystem* subsystem, FreeSmartphoneUsageResourcePolicy policy) {
	FsoDeviceBasePowerControlResource * self = NULL;
	const gchar* _tmp0_;
	FsoFrameworkSubsystem* _tmp1_;
	FsoDeviceISimplePowerControl* _tmp2_;
	FreeSmartphoneUsageResourcePolicy _tmp3_;
	g_return_val_if_fail (bpc != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (subsystem != NULL, NULL);
	_tmp0_ = name;
	_tmp1_ = subsystem;
	self = (FsoDeviceBasePowerControlResource*) fso_framework_abstract_dbus_resource_construct (object_type, _tmp0_, _tmp1_);
	_tmp2_ = bpc;
	self->priv->bpc = _tmp2_;
	_tmp3_ = policy;
	self->priv->policy = _tmp3_;
	return self;
}


FsoDeviceBasePowerControlResource* fso_device_base_power_control_resource_new (FsoDeviceISimplePowerControl* bpc, const gchar* name, FsoFrameworkSubsystem* subsystem, FreeSmartphoneUsageResourcePolicy policy) {
	return fso_device_base_power_control_resource_construct (FSO_DEVICE_TYPE_BASE_POWER_CONTROL_RESOURCE, bpc, name, subsystem, policy);
}


static void fso_device_base_power_control_resource_real_enableResource_data_free (gpointer _data) {
	fso_device_base_power_control_resource_enableResourceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (fso_device_base_power_control_resource_enableResourceData, _data_);
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void fso_device_base_power_control_resource_real_enableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FsoDeviceBasePowerControlResource * self;
	fso_device_base_power_control_resource_enableResourceData* _data_;
	FsoDeviceBasePowerControlResource* _tmp0_;
	self = (FsoDeviceBasePowerControlResource*) base;
	_data_ = g_slice_new0 (fso_device_base_power_control_resource_enableResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fso_device_base_power_control_resource_real_enableResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fso_device_base_power_control_resource_real_enableResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	fso_device_base_power_control_resource_real_enableResource_co (_data_);
}


static void fso_device_base_power_control_resource_real_enableResource_finish (FsoFrameworkAbstractDBusResource* base, GAsyncResult* _res_, GError** error) {
	fso_device_base_power_control_resource_enableResourceData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean fso_device_base_power_control_resource_real_enableResource_co (fso_device_base_power_control_resource_enableResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
	fso_framework_logger_debug (_data_->_tmp0_, "enabling...");
	_data_->_tmp1_ = _data_->self->priv->bpc;
	fso_device_isimple_power_control_setPower (_data_->_tmp1_, TRUE);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void fso_device_base_power_control_resource_real_disableResource_data_free (gpointer _data) {
	fso_device_base_power_control_resource_disableResourceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (fso_device_base_power_control_resource_disableResourceData, _data_);
}


static void fso_device_base_power_control_resource_real_disableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FsoDeviceBasePowerControlResource * self;
	fso_device_base_power_control_resource_disableResourceData* _data_;
	FsoDeviceBasePowerControlResource* _tmp0_;
	self = (FsoDeviceBasePowerControlResource*) base;
	_data_ = g_slice_new0 (fso_device_base_power_control_resource_disableResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fso_device_base_power_control_resource_real_disableResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fso_device_base_power_control_resource_real_disableResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	fso_device_base_power_control_resource_real_disableResource_co (_data_);
}


static void fso_device_base_power_control_resource_real_disableResource_finish (FsoFrameworkAbstractDBusResource* base, GAsyncResult* _res_) {
	fso_device_base_power_control_resource_disableResourceData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean fso_device_base_power_control_resource_real_disableResource_co (fso_device_base_power_control_resource_disableResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
	fso_framework_logger_debug (_data_->_tmp0_, "disabling...");
	_data_->_tmp1_ = _data_->self->priv->bpc;
	fso_device_isimple_power_control_setPower (_data_->_tmp1_, FALSE);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void fso_device_base_power_control_resource_real_suspendResource_data_free (gpointer _data) {
	fso_device_base_power_control_resource_suspendResourceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (fso_device_base_power_control_resource_suspendResourceData, _data_);
}


static void fso_device_base_power_control_resource_real_suspendResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FsoDeviceBasePowerControlResource * self;
	fso_device_base_power_control_resource_suspendResourceData* _data_;
	FsoDeviceBasePowerControlResource* _tmp0_;
	self = (FsoDeviceBasePowerControlResource*) base;
	_data_ = g_slice_new0 (fso_device_base_power_control_resource_suspendResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fso_device_base_power_control_resource_real_suspendResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fso_device_base_power_control_resource_real_suspendResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	fso_device_base_power_control_resource_real_suspendResource_co (_data_);
}


static void fso_device_base_power_control_resource_real_suspendResource_finish (FsoFrameworkAbstractDBusResource* base, GAsyncResult* _res_) {
	fso_device_base_power_control_resource_suspendResourceData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean fso_device_base_power_control_resource_real_suspendResource_co (fso_device_base_power_control_resource_suspendResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
	fso_framework_logger_debug (_data_->_tmp0_, "suspending...");
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void fso_device_base_power_control_resource_real_resumeResource_data_free (gpointer _data) {
	fso_device_base_power_control_resource_resumeResourceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (fso_device_base_power_control_resource_resumeResourceData, _data_);
}


static void fso_device_base_power_control_resource_real_resumeResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FsoDeviceBasePowerControlResource * self;
	fso_device_base_power_control_resource_resumeResourceData* _data_;
	FsoDeviceBasePowerControlResource* _tmp0_;
	self = (FsoDeviceBasePowerControlResource*) base;
	_data_ = g_slice_new0 (fso_device_base_power_control_resource_resumeResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fso_device_base_power_control_resource_real_resumeResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fso_device_base_power_control_resource_real_resumeResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	fso_device_base_power_control_resource_real_resumeResource_co (_data_);
}


static void fso_device_base_power_control_resource_real_resumeResource_finish (FsoFrameworkAbstractDBusResource* base, GAsyncResult* _res_) {
	fso_device_base_power_control_resource_resumeResourceData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean fso_device_base_power_control_resource_real_resumeResource_co (fso_device_base_power_control_resource_resumeResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
	fso_framework_logger_debug (_data_->_tmp0_, "resuming...");
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static FreeSmartphoneUsageResourcePolicy fso_device_base_power_control_resource_real_default_policy (FsoFrameworkAbstractDBusResource* base) {
	FsoDeviceBasePowerControlResource * self;
	FreeSmartphoneUsageResourcePolicy result = 0;
	FreeSmartphoneUsageResourcePolicy _tmp0_;
	self = (FsoDeviceBasePowerControlResource*) base;
	_tmp0_ = self->priv->policy;
	result = _tmp0_;
	return result;
}


static void fso_device_base_power_control_resource_class_init (FsoDeviceBasePowerControlResourceClass * klass) {
	fso_device_base_power_control_resource_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (FsoDeviceBasePowerControlResourcePrivate));
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->enableResource = fso_device_base_power_control_resource_real_enableResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->enableResource_finish = fso_device_base_power_control_resource_real_enableResource_finish;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->disableResource = fso_device_base_power_control_resource_real_disableResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->disableResource_finish = fso_device_base_power_control_resource_real_disableResource_finish;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->suspendResource = fso_device_base_power_control_resource_real_suspendResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->suspendResource_finish = fso_device_base_power_control_resource_real_suspendResource_finish;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->resumeResource = fso_device_base_power_control_resource_real_resumeResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->resumeResource_finish = fso_device_base_power_control_resource_real_resumeResource_finish;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->default_policy = fso_device_base_power_control_resource_real_default_policy;
	G_OBJECT_CLASS (klass)->finalize = fso_device_base_power_control_resource_finalize;
}


static void fso_device_base_power_control_resource_instance_init (FsoDeviceBasePowerControlResource * self) {
	self->priv = FSO_DEVICE_BASE_POWER_CONTROL_RESOURCE_GET_PRIVATE (self);
}


static void fso_device_base_power_control_resource_finalize (GObject* obj) {
	FsoDeviceBasePowerControlResource * self;
	self = FSO_DEVICE_BASE_POWER_CONTROL_RESOURCE (obj);
	G_OBJECT_CLASS (fso_device_base_power_control_resource_parent_class)->finalize (obj);
}


/**
 * BasePowerControlResource: Exports a BasePowerControl instance via the DBus Resource API
 */
GType fso_device_base_power_control_resource_get_type (void) {
	static volatile gsize fso_device_base_power_control_resource_type_id__volatile = 0;
	if (g_once_init_enter (&fso_device_base_power_control_resource_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FsoDeviceBasePowerControlResourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fso_device_base_power_control_resource_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FsoDeviceBasePowerControlResource), 0, (GInstanceInitFunc) fso_device_base_power_control_resource_instance_init, NULL };
		GType fso_device_base_power_control_resource_type_id;
		fso_device_base_power_control_resource_type_id = g_type_register_static (FSO_FRAMEWORK_TYPE_ABSTRACT_DBUS_RESOURCE, "FsoDeviceBasePowerControlResource", &g_define_type_info, 0);
		g_once_init_leave (&fso_device_base_power_control_resource_type_id__volatile, fso_device_base_power_control_resource_type_id);
	}
	return fso_device_base_power_control_resource_type_id__volatile;
}



