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

/*
 * Copyright (C) 2009-2012 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
 *                    2010-2012 Sebastian Krzyszkowiak <seba.dos1@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library 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
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 */

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


#define PROXIMITY_TYPE_N900 (proximity_n900_get_type ())
#define PROXIMITY_N900(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROXIMITY_TYPE_N900, ProximityN900))
#define PROXIMITY_N900_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROXIMITY_TYPE_N900, ProximityN900Class))
#define PROXIMITY_IS_N900(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROXIMITY_TYPE_N900))
#define PROXIMITY_IS_N900_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROXIMITY_TYPE_N900))
#define PROXIMITY_N900_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROXIMITY_TYPE_N900, ProximityN900Class))

typedef struct _ProximityN900 ProximityN900;
typedef struct _ProximityN900Class ProximityN900Class;
typedef struct _ProximityN900Private ProximityN900Private;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_io_channel_unref0(var) ((var == NULL) ? NULL : (var = (g_io_channel_unref (var), NULL)))
typedef struct _ProximityN900GetProximityData ProximityN900GetProximityData;
typedef struct _ProximityN900GetPowerData ProximityN900GetPowerData;
typedef struct _ProximityN900SetPowerData ProximityN900SetPowerData;

#define PROXIMITY_TYPE_PROXIMITY_RESOURCE (proximity_proximity_resource_get_type ())
#define PROXIMITY_PROXIMITY_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROXIMITY_TYPE_PROXIMITY_RESOURCE, ProximityProximityResource))
#define PROXIMITY_PROXIMITY_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROXIMITY_TYPE_PROXIMITY_RESOURCE, ProximityProximityResourceClass))
#define PROXIMITY_IS_PROXIMITY_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROXIMITY_TYPE_PROXIMITY_RESOURCE))
#define PROXIMITY_IS_PROXIMITY_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROXIMITY_TYPE_PROXIMITY_RESOURCE))
#define PROXIMITY_PROXIMITY_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROXIMITY_TYPE_PROXIMITY_RESOURCE, ProximityProximityResourceClass))

typedef struct _ProximityProximityResource ProximityProximityResource;
typedef struct _ProximityProximityResourceClass ProximityProximityResourceClass;
typedef struct _ProximityProximityResourcePrivate ProximityProximityResourcePrivate;
typedef struct _proximity_proximity_resource_enableResourceData proximity_proximity_resource_enableResourceData;
typedef struct _proximity_proximity_resource_disableResourceData proximity_proximity_resource_disableResourceData;
typedef struct _proximity_proximity_resource_suspendResourceData proximity_proximity_resource_suspendResourceData;
typedef struct _proximity_proximity_resource_resumeResourceData proximity_proximity_resource_resumeResourceData;

struct _ProximityN900 {
	FsoFrameworkAbstractObject parent_instance;
	ProximityN900Private * priv;
};

struct _ProximityN900Class {
	FsoFrameworkAbstractObjectClass parent_class;
};

struct _ProximityN900Private {
	FsoFrameworkSubsystem* subsystem;
	gchar* node;
	gchar* powernode;
	gint lastvalue;
	gint lasttimestamp;
};

struct _ProximityN900GetProximityData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ProximityN900* self;
	gint proximity;
	gint timestamp;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* value;
	gint _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gboolean _tmp11_;
	gint _tmp12_;
	GTimeVal _tmp13_;
	glong _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	GError * _inner_error_;
};

struct _ProximityN900GetPowerData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ProximityN900* self;
	gboolean result;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* contents;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gboolean _tmp9_;
};

struct _ProximityN900SetPowerData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ProximityN900* self;
	gboolean on;
	const gchar* _tmp0_;
	gboolean _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* contents;
	const gchar* _tmp4_;
};

struct _ProximityProximityResource {
	FsoFrameworkAbstractDBusResource parent_instance;
	ProximityProximityResourcePrivate * priv;
	gboolean on;
};

struct _ProximityProximityResourceClass {
	FsoFrameworkAbstractDBusResourceClass parent_class;
};

struct _ProximityProximityResourcePrivate {
	ProximityN900* instance;
};

struct _proximity_proximity_resource_enableResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ProximityProximityResource* self;
	gboolean _tmp0_;
	FsoFrameworkLogger* _tmp1_;
	gboolean _tmp2_;
	ProximityN900* _tmp3_;
};

struct _proximity_proximity_resource_disableResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ProximityProximityResource* self;
	gboolean _tmp0_;
	FsoFrameworkLogger* _tmp1_;
	gboolean _tmp2_;
	ProximityN900* _tmp3_;
};

struct _proximity_proximity_resource_suspendResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ProximityProximityResource* self;
};

struct _proximity_proximity_resource_resumeResourceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ProximityProximityResource* self;
};


static gpointer proximity_n900_parent_class = NULL;
static FreeSmartphoneDeviceProximityIface* proximity_n900_free_smartphone_device_proximity_parent_iface = NULL;
static FreeSmartphoneDevicePowerControlIface* proximity_n900_free_smartphone_device_power_control_parent_iface = NULL;
static GType proximity_n900_type_id = 0;
static gpointer proximity_proximity_resource_parent_class = NULL;
static GType proximity_proximity_resource_type_id = 0;

GType proximity_n900_get_type (void) G_GNUC_CONST;
GType proximity_n900_register_type (GTypeModule * module);
#define PROXIMITY_N900_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PROXIMITY_TYPE_N900, ProximityN900Private))
enum  {
	PROXIMITY_N900_DUMMY_PROPERTY
};
ProximityN900* proximity_n900_new (FsoFrameworkSubsystem* subsystem, const gchar* node);
ProximityN900* proximity_n900_construct (GType object_type, FsoFrameworkSubsystem* subsystem, const gchar* node);
gboolean proximity_n900_onInputEvent (ProximityN900* self, GIOChannel* source, GIOCondition condition);
static gboolean _proximity_n900_onInputEvent_gio_func (GIOChannel* source, GIOCondition condition, gpointer self);
static gchar* proximity_n900_real_repr (FsoFrameworkAbstractObject* base);
static void proximity_n900_real_get_proximity_data_free (gpointer _data);
static void proximity_n900_real_get_proximity (FreeSmartphoneDeviceProximity* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean proximity_n900_real_get_proximity_co (ProximityN900GetProximityData* _data_);
static void proximity_n900_real_get_power_data_free (gpointer _data);
static void proximity_n900_real_get_power (FreeSmartphoneDevicePowerControl* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean proximity_n900_real_get_power_co (ProximityN900GetPowerData* _data_);
static void proximity_n900_real_set_power_data_free (gpointer _data);
static void proximity_n900_real_set_power (FreeSmartphoneDevicePowerControl* base, gboolean on, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean proximity_n900_real_set_power_co (ProximityN900SetPowerData* _data_);
static void proximity_n900_finalize (GObject* obj);
GType proximity_proximity_resource_get_type (void) G_GNUC_CONST;
GType proximity_proximity_resource_register_type (GTypeModule * module);
#define PROXIMITY_PROXIMITY_RESOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PROXIMITY_TYPE_PROXIMITY_RESOURCE, ProximityProximityResourcePrivate))
enum  {
	PROXIMITY_PROXIMITY_RESOURCE_DUMMY_PROPERTY
};
ProximityProximityResource* proximity_proximity_resource_new (FsoFrameworkSubsystem* subsystem, ProximityN900* instance);
ProximityProximityResource* proximity_proximity_resource_construct (GType object_type, FsoFrameworkSubsystem* subsystem, ProximityN900* instance);
static void proximity_proximity_resource_real_enableResource_data_free (gpointer _data);
static void proximity_proximity_resource_real_enableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean proximity_proximity_resource_real_enableResource_co (proximity_proximity_resource_enableResourceData* _data_);
static void proximity_proximity_resource_real_disableResource_data_free (gpointer _data);
static void proximity_proximity_resource_real_disableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean proximity_proximity_resource_real_disableResource_co (proximity_proximity_resource_disableResourceData* _data_);
static void proximity_proximity_resource_real_suspendResource_data_free (gpointer _data);
static void proximity_proximity_resource_real_suspendResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean proximity_proximity_resource_real_suspendResource_co (proximity_proximity_resource_suspendResourceData* _data_);
static void proximity_proximity_resource_real_resumeResource_data_free (gpointer _data);
static void proximity_proximity_resource_real_resumeResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean proximity_proximity_resource_real_resumeResource_co (proximity_proximity_resource_resumeResourceData* _data_);
static void proximity_proximity_resource_finalize (GObject* obj);


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


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


static gchar* string_strip (const gchar* self) {
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _result_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	g_strstrip (_tmp1_);
	result = _result_;
	return result;
}


static gboolean _proximity_n900_onInputEvent_gio_func (GIOChannel* source, GIOCondition condition, gpointer self) {
	gboolean result;
	result = proximity_n900_onInputEvent (self, source, condition);
	return result;
}


ProximityN900* proximity_n900_construct (GType object_type, FsoFrameworkSubsystem* subsystem, const gchar* node) {
	ProximityN900 * self = NULL;
	FsoFrameworkSubsystem* _tmp0_;
	FsoFrameworkSubsystem* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp11_;
	gchar* _tmp12_ = NULL;
	const gchar* _tmp13_;
	gchar* _tmp14_ = NULL;
	FsoFrameworkLogger* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_ = NULL;
	gchar* _tmp18_ = NULL;
	gchar* _tmp19_;
	FsoFrameworkSubsystem* _tmp20_;
	const gchar* _tmp21_;
	GIOChannel* _tmp22_;
	GIOChannel* channel;
	gchar* _tmp23_;
	gchar* value;
	gsize c;
	GIOChannel* _tmp24_;
	gchar* _tmp25_ = NULL;
	gsize _tmp26_ = 0UL;
	GIOChannel* _tmp27_;
	gint _tmp28_ = 0;
	const gchar* _tmp29_;
	gchar* _tmp30_ = NULL;
	gchar* _tmp31_;
	gboolean _tmp32_;
	gint _tmp33_;
	GTimeVal _tmp34_ = {0};
	glong _tmp35_;
	GIOChannel* _tmp36_;
	FsoFrameworkLogger* _tmp37_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (subsystem != NULL, NULL);
	g_return_val_if_fail (node != NULL, NULL);
	self = (ProximityN900*) fso_framework_abstract_object_construct (object_type);
	_tmp0_ = subsystem;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->subsystem);
	self->priv->subsystem = _tmp1_;
	_tmp2_ = node;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (self->priv->node);
	self->priv->node = _tmp3_;
	self->priv->lastvalue = -1;
	self->priv->lasttimestamp = 0;
	_tmp4_ = self->priv->node;
	_tmp5_ = fso_framework_file_handling_isPresent (_tmp4_);
	if (!_tmp5_) {
		FsoFrameworkLogger* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		gchar* _tmp10_;
		_tmp6_ = ((FsoFrameworkAbstractObject*) self)->logger;
		_tmp7_ = self->priv->node;
		_tmp8_ = string_to_string (_tmp7_);
		_tmp9_ = g_strconcat ("Sysfs class is damaged, missing ", _tmp8_, "; skipping.", NULL);
		_tmp10_ = _tmp9_;
		fso_framework_logger_error (_tmp6_, _tmp10_);
		_g_free0 (_tmp10_);
		return self;
	}
	_tmp11_ = self->priv->node;
	_tmp12_ = g_build_filename (_tmp11_, "disable", NULL);
	_g_free0 (self->priv->powernode);
	self->priv->powernode = _tmp12_;
	_tmp13_ = self->priv->node;
	_tmp14_ = g_build_filename (_tmp13_, "state", NULL);
	_g_free0 (self->priv->node);
	self->priv->node = _tmp14_;
	_tmp15_ = ((FsoFrameworkAbstractObject*) self)->logger;
	_tmp16_ = self->priv->node;
	_tmp17_ = string_to_string (_tmp16_);
	_tmp18_ = g_strconcat ("Trying to read from ", _tmp17_, "...", NULL);
	_tmp19_ = _tmp18_;
	fso_framework_logger_debug (_tmp15_, _tmp19_);
	_g_free0 (_tmp19_);
	_tmp20_ = subsystem;
	fso_framework_subsystem_registerObjectForServiceWithPrefix (_tmp20_, FREE_SMARTPHONE_DEVICE_TYPE_PROXIMITY, (GBoxedCopyFunc) g_object_ref, g_object_unref, FSO_FRAMEWORK_DEVICE_ServiceDBusName, FSO_FRAMEWORK_DEVICE_ProximityServicePath, (FreeSmartphoneDeviceProximity*) self);
	_tmp21_ = self->priv->node;
	_tmp22_ = g_io_channel_new_file (_tmp21_, "r", &_inner_error_);
	channel = _tmp22_;
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp23_ = g_strdup ("");
	value = _tmp23_;
	c = (gsize) 0;
	_tmp24_ = channel;
	g_io_channel_read_to_end (_tmp24_, &_tmp25_, &_tmp26_, &_inner_error_);
	_g_free0 (value);
	value = _tmp25_;
	c = _tmp26_;
	if (_inner_error_ != NULL) {
		_g_free0 (value);
		_g_io_channel_unref0 (channel);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp27_ = channel;
	g_io_channel_seek_position (_tmp27_, (gint64) 0, G_SEEK_SET, &_inner_error_);
	if (_inner_error_ != NULL) {
		_g_free0 (value);
		_g_io_channel_unref0 (channel);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp29_ = value;
	_tmp30_ = string_strip (_tmp29_);
	_tmp31_ = _tmp30_;
	_tmp32_ = g_strcmp0 (_tmp31_, "closed") == 0;
	_g_free0 (_tmp31_);
	if (_tmp32_) {
		_tmp28_ = 100;
	} else {
		_tmp28_ = 0;
	}
	_tmp33_ = _tmp28_;
	self->priv->lastvalue = _tmp33_;
	g_get_current_time (&_tmp34_);
	_tmp35_ = _tmp34_.tv_sec;
	self->priv->lasttimestamp = (gint) _tmp35_;
	free_smartphone_device_power_control_set_power ((FreeSmartphoneDevicePowerControl*) self, FALSE, NULL, NULL);
	_tmp36_ = channel;
	g_io_add_watch (_tmp36_, (G_IO_IN | G_IO_PRI) | G_IO_ERR, _proximity_n900_onInputEvent_gio_func, self);
	_tmp37_ = ((FsoFrameworkAbstractObject*) self)->logger;
	fso_framework_logger_info (_tmp37_, "Created");
	_g_free0 (value);
	_g_io_channel_unref0 (channel);
	return self;
}


ProximityN900* proximity_n900_new (FsoFrameworkSubsystem* subsystem, const gchar* node) {
	return proximity_n900_construct (PROXIMITY_TYPE_N900, subsystem, node);
}


static gchar* proximity_n900_real_repr (FsoFrameworkAbstractObject* base) {
	ProximityN900 * self;
	gchar* result = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	self = (ProximityN900*) base;
	_tmp0_ = self->priv->node;
	_tmp1_ = string_to_string (_tmp0_);
	_tmp2_ = g_strconcat ("<", _tmp1_, ">", NULL);
	result = _tmp2_;
	return result;
}


gboolean proximity_n900_onInputEvent (ProximityN900* self, GIOChannel* source, GIOCondition condition) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GIOCondition _tmp1_;
	gboolean _tmp3_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (source != NULL, FALSE);
	_tmp1_ = condition;
	if ((_tmp1_ & G_IO_IN) == G_IO_IN) {
		_tmp0_ = TRUE;
	} else {
		GIOCondition _tmp2_;
		_tmp2_ = condition;
		_tmp0_ = (_tmp2_ & G_IO_PRI) == G_IO_PRI;
	}
	_tmp3_ = _tmp0_;
	if (_tmp3_) {
		gchar* _tmp4_;
		gchar* value;
		gsize c;
		GIOChannel* _tmp5_;
		gchar* _tmp6_ = NULL;
		gsize _tmp7_ = 0UL;
		FsoFrameworkLogger* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		gchar* _tmp12_;
		gint _tmp13_ = 0;
		const gchar* _tmp14_;
		gchar* _tmp15_ = NULL;
		gchar* _tmp16_;
		gboolean _tmp17_;
		gint _tmp18_;
		GTimeVal _tmp19_ = {0};
		glong _tmp20_;
		gint _tmp21_;
		GIOChannel* _tmp22_;
		_tmp4_ = g_strdup ("");
		value = _tmp4_;
		c = (gsize) 0;
		_tmp5_ = source;
		g_io_channel_read_line (_tmp5_, &_tmp6_, &_tmp7_, NULL, &_inner_error_);
		_g_free0 (value);
		value = _tmp6_;
		c = _tmp7_;
		if (_inner_error_ != NULL) {
			_g_free0 (value);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
		_tmp8_ = ((FsoFrameworkAbstractObject*) self)->logger;
		_tmp9_ = value;
		_tmp10_ = string_to_string (_tmp9_);
		_tmp11_ = g_strconcat ("got data from sysfs node: ", _tmp10_, NULL);
		_tmp12_ = _tmp11_;
		fso_framework_logger_debug (_tmp8_, _tmp12_);
		_g_free0 (_tmp12_);
		_tmp14_ = value;
		_tmp15_ = string_strip (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = g_strcmp0 (_tmp16_, "closed") == 0;
		_g_free0 (_tmp16_);
		if (_tmp17_) {
			_tmp13_ = 100;
		} else {
			_tmp13_ = 0;
		}
		_tmp18_ = _tmp13_;
		self->priv->lastvalue = _tmp18_;
		g_get_current_time (&_tmp19_);
		_tmp20_ = _tmp19_.tv_sec;
		self->priv->lasttimestamp = (gint) _tmp20_;
		_tmp21_ = self->priv->lastvalue;
		g_signal_emit_by_name ((FreeSmartphoneDeviceProximity*) self, "proximity", _tmp21_);
		_tmp22_ = source;
		g_io_channel_seek_position (_tmp22_, (gint64) 0, G_SEEK_SET, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_free0 (value);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
		result = TRUE;
		_g_free0 (value);
		return result;
	} else {
		FsoFrameworkLogger* _tmp23_;
		_tmp23_ = ((FsoFrameworkAbstractObject*) self)->logger;
		fso_framework_logger_error (_tmp23_, "onInputEvent error");
		result = FALSE;
		return result;
	}
}


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


static void proximity_n900_real_get_proximity (FreeSmartphoneDeviceProximity* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ProximityN900 * self;
	ProximityN900GetProximityData* _data_;
	ProximityN900* _tmp0_;
	self = (ProximityN900*) base;
	_data_ = g_slice_new0 (ProximityN900GetProximityData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, proximity_n900_real_get_proximity);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, proximity_n900_real_get_proximity_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proximity_n900_real_get_proximity_co (_data_);
}


static void proximity_n900_real_get_proximity_finish (FreeSmartphoneDeviceProximity* base, GAsyncResult* _res_, gint* proximity, gint* timestamp, GError** error) {
	ProximityN900GetProximityData* _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_));
	if (proximity) {
		*proximity = _data_->proximity;
	}
	if (timestamp) {
		*timestamp = _data_->timestamp;
	}
}


static gboolean proximity_n900_real_get_proximity_co (ProximityN900GetProximityData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->node;
		_data_->_tmp1_ = NULL;
		_data_->_tmp1_ = fso_framework_file_handling_read (_data_->_tmp0_);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = _data_->_tmp2_;
		if (_data_->_tmp3_ == NULL) {
			_data_->_tmp4_ = g_strdup ("");
			_g_free0 (_data_->_tmp2_);
			_data_->_tmp2_ = _data_->_tmp4_;
		}
		_data_->_tmp5_ = _data_->_tmp2_;
		_data_->_tmp6_ = g_strdup (_data_->_tmp5_);
		_data_->value = _data_->_tmp6_;
		_data_->_tmp8_ = _data_->value;
		_data_->_tmp9_ = NULL;
		_data_->_tmp9_ = string_strip (_data_->_tmp8_);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = g_strcmp0 (_data_->_tmp10_, "closed") == 0;
		_g_free0 (_data_->_tmp10_);
		if (_data_->_tmp11_) {
			_data_->_tmp7_ = 100;
		} else {
			_data_->_tmp7_ = 0;
		}
		_data_->_tmp12_ = _data_->_tmp7_;
		_data_->self->priv->lastvalue = _data_->_tmp12_;
		memset (&_data_->_tmp13_, 0, sizeof (GTimeVal));
		g_get_current_time (&_data_->_tmp13_);
		_data_->_tmp14_ = _data_->_tmp13_.tv_sec;
		_data_->self->priv->lasttimestamp = (gint) _data_->_tmp14_;
		_g_free0 (_data_->value);
		_g_free0 (_data_->_tmp2_);
	}
	__finally2:
	{
		_data_->_tmp15_ = _data_->self->priv->lastvalue;
		_data_->proximity = _data_->_tmp15_;
		_data_->_tmp16_ = _data_->self->priv->lasttimestamp;
		_data_->timestamp = _data_->_tmp16_;
	}
	if (_data_->_inner_error_ != NULL) {
		if (((_data_->_inner_error_->domain == FREE_SMARTPHONE_ERROR) || (_data_->_inner_error_->domain == G_DBUS_ERROR)) || (_data_->_inner_error_->domain == G_IO_ERROR)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			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;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return 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 proximity_n900_real_get_power_data_free (gpointer _data) {
	ProximityN900GetPowerData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ProximityN900GetPowerData, _data_);
}


static void proximity_n900_real_get_power (FreeSmartphoneDevicePowerControl* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ProximityN900 * self;
	ProximityN900GetPowerData* _data_;
	ProximityN900* _tmp0_;
	self = (ProximityN900*) base;
	_data_ = g_slice_new0 (ProximityN900GetPowerData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, proximity_n900_real_get_power);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, proximity_n900_real_get_power_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proximity_n900_real_get_power_co (_data_);
}


static gboolean proximity_n900_real_get_power_finish (FreeSmartphoneDevicePowerControl* base, GAsyncResult* _res_, GError** error) {
	gboolean result;
	ProximityN900GetPowerData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return FALSE;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	return result;
}


static gboolean proximity_n900_real_get_power_co (ProximityN900GetPowerData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->powernode;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = fso_framework_file_handling_read (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = _data_->_tmp2_;
	if (_data_->_tmp3_ == NULL) {
		_data_->_tmp4_ = g_strdup ("");
		_g_free0 (_data_->_tmp2_);
		_data_->_tmp2_ = _data_->_tmp4_;
	}
	_data_->_tmp5_ = _data_->_tmp2_;
	_data_->_tmp6_ = g_strdup (_data_->_tmp5_);
	_data_->contents = _data_->_tmp6_;
	_data_->_tmp7_ = NULL;
	_data_->_tmp7_ = string_strip (_data_->contents);
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = g_strcmp0 (_data_->_tmp8_, "0") == 0;
	_g_free0 (_data_->_tmp8_);
	_data_->result = _data_->_tmp9_;
	_g_free0 (_data_->contents);
	_g_free0 (_data_->_tmp2_);
	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;
	_g_free0 (_data_->contents);
	_g_free0 (_data_->_tmp2_);
	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 proximity_n900_real_set_power_data_free (gpointer _data) {
	ProximityN900SetPowerData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ProximityN900SetPowerData, _data_);
}


static void proximity_n900_real_set_power (FreeSmartphoneDevicePowerControl* base, gboolean on, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ProximityN900 * self;
	ProximityN900SetPowerData* _data_;
	ProximityN900* _tmp0_;
	gboolean _tmp1_;
	self = (ProximityN900*) base;
	_data_ = g_slice_new0 (ProximityN900SetPowerData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, proximity_n900_real_set_power);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, proximity_n900_real_set_power_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = on;
	_data_->on = _tmp1_;
	proximity_n900_real_set_power_co (_data_);
}


static void proximity_n900_real_set_power_finish (FreeSmartphoneDevicePowerControl* base, GAsyncResult* _res_, GError** error) {
	ProximityN900SetPowerData* _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 proximity_n900_real_set_power_co (ProximityN900SetPowerData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->on;
	if (_data_->_tmp1_) {
		_data_->_tmp0_ = "0";
	} else {
		_data_->_tmp0_ = "1";
	}
	_data_->_tmp2_ = _data_->_tmp0_;
	_data_->_tmp3_ = g_strdup (_data_->_tmp2_);
	_data_->contents = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->self->priv->powernode;
	fso_framework_file_handling_write (_data_->contents, _data_->_tmp4_, FALSE);
	_g_free0 (_data_->contents);
	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 proximity_n900_class_init (ProximityN900Class * klass) {
	proximity_n900_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ProximityN900Private));
	FSO_FRAMEWORK_ABSTRACT_OBJECT_CLASS (klass)->repr = proximity_n900_real_repr;
	G_OBJECT_CLASS (klass)->finalize = proximity_n900_finalize;
}


static void proximity_n900_free_smartphone_device_proximity_interface_init (FreeSmartphoneDeviceProximityIface * iface) {
	proximity_n900_free_smartphone_device_proximity_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_proximity = (void (*)(FreeSmartphoneDeviceProximity*, gint*, gint*, GError**)) proximity_n900_real_get_proximity;
	iface->get_proximity_finish = proximity_n900_real_get_proximity_finish;
}


static void proximity_n900_free_smartphone_device_power_control_interface_init (FreeSmartphoneDevicePowerControlIface * iface) {
	proximity_n900_free_smartphone_device_power_control_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_power = (gboolean (*)(FreeSmartphoneDevicePowerControl*, GError**)) proximity_n900_real_get_power;
	iface->get_power_finish = proximity_n900_real_get_power_finish;
	iface->set_power = (void (*)(FreeSmartphoneDevicePowerControl*, gboolean, GError**)) proximity_n900_real_set_power;
	iface->set_power_finish = proximity_n900_real_set_power_finish;
}


static void proximity_n900_instance_init (ProximityN900 * self) {
	self->priv = PROXIMITY_N900_GET_PRIVATE (self);
}


static void proximity_n900_finalize (GObject* obj) {
	ProximityN900 * self;
	self = PROXIMITY_N900 (obj);
	_g_object_unref0 (self->priv->subsystem);
	_g_free0 (self->priv->node);
	_g_free0 (self->priv->powernode);
	G_OBJECT_CLASS (proximity_n900_parent_class)->finalize (obj);
}


GType proximity_n900_get_type (void) {
	return proximity_n900_type_id;
}


GType proximity_n900_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (ProximityN900Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proximity_n900_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProximityN900), 0, (GInstanceInitFunc) proximity_n900_instance_init, NULL };
	static const GInterfaceInfo free_smartphone_device_proximity_info = { (GInterfaceInitFunc) proximity_n900_free_smartphone_device_proximity_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo free_smartphone_device_power_control_info = { (GInterfaceInitFunc) proximity_n900_free_smartphone_device_power_control_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	proximity_n900_type_id = g_type_module_register_type (module, FSO_FRAMEWORK_TYPE_ABSTRACT_OBJECT, "ProximityN900", &g_define_type_info, 0);
	g_type_module_add_interface (module, proximity_n900_type_id, FREE_SMARTPHONE_DEVICE_TYPE_PROXIMITY, &free_smartphone_device_proximity_info);
	g_type_module_add_interface (module, proximity_n900_type_id, FREE_SMARTPHONE_DEVICE_TYPE_POWER_CONTROL, &free_smartphone_device_power_control_info);
	return proximity_n900_type_id;
}


ProximityProximityResource* proximity_proximity_resource_construct (GType object_type, FsoFrameworkSubsystem* subsystem, ProximityN900* instance) {
	ProximityProximityResource * self = NULL;
	FsoFrameworkSubsystem* _tmp0_;
	ProximityN900* _tmp1_;
	ProximityN900* _tmp2_;
	g_return_val_if_fail (subsystem != NULL, NULL);
	g_return_val_if_fail (instance != NULL, NULL);
	_tmp0_ = subsystem;
	self = (ProximityProximityResource*) fso_framework_abstract_dbus_resource_construct (object_type, "Proximity", _tmp0_);
	_tmp1_ = instance;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (self->priv->instance);
	self->priv->instance = _tmp2_;
	return self;
}


ProximityProximityResource* proximity_proximity_resource_new (FsoFrameworkSubsystem* subsystem, ProximityN900* instance) {
	return proximity_proximity_resource_construct (PROXIMITY_TYPE_PROXIMITY_RESOURCE, subsystem, instance);
}


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


static void proximity_proximity_resource_real_enableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ProximityProximityResource * self;
	proximity_proximity_resource_enableResourceData* _data_;
	ProximityProximityResource* _tmp0_;
	self = (ProximityProximityResource*) base;
	_data_ = g_slice_new0 (proximity_proximity_resource_enableResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, proximity_proximity_resource_real_enableResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, proximity_proximity_resource_real_enableResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proximity_proximity_resource_real_enableResource_co (_data_);
}


static void proximity_proximity_resource_real_enableResource_finish (FsoFrameworkAbstractDBusResource* base, GAsyncResult* _res_, GError** error) {
	proximity_proximity_resource_enableResourceData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean proximity_proximity_resource_real_enableResource_co (proximity_proximity_resource_enableResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->on;
	if (_data_->_tmp0_) {
		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;
	}
	_data_->_tmp1_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
	_data_->_tmp2_ = FALSE;
	_data_->_tmp2_ = fso_framework_logger_debug (_data_->_tmp1_, "Enabling...");
	g_assert (_data_->_tmp2_);
	_data_->_tmp3_ = _data_->self->priv->instance;
	free_smartphone_device_power_control_set_power ((FreeSmartphoneDevicePowerControl*) _data_->_tmp3_, TRUE, NULL, NULL);
	_data_->self->on = 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 proximity_proximity_resource_real_disableResource_data_free (gpointer _data) {
	proximity_proximity_resource_disableResourceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (proximity_proximity_resource_disableResourceData, _data_);
}


static void proximity_proximity_resource_real_disableResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ProximityProximityResource * self;
	proximity_proximity_resource_disableResourceData* _data_;
	ProximityProximityResource* _tmp0_;
	self = (ProximityProximityResource*) base;
	_data_ = g_slice_new0 (proximity_proximity_resource_disableResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, proximity_proximity_resource_real_disableResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, proximity_proximity_resource_real_disableResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proximity_proximity_resource_real_disableResource_co (_data_);
}


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


static gboolean proximity_proximity_resource_real_disableResource_co (proximity_proximity_resource_disableResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->on;
	if (!_data_->_tmp0_) {
		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;
	}
	_data_->_tmp1_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
	_data_->_tmp2_ = FALSE;
	_data_->_tmp2_ = fso_framework_logger_debug (_data_->_tmp1_, "Disabling...");
	g_assert (_data_->_tmp2_);
	_data_->_tmp3_ = _data_->self->priv->instance;
	free_smartphone_device_power_control_set_power ((FreeSmartphoneDevicePowerControl*) _data_->_tmp3_, FALSE, NULL, NULL);
	_data_->self->on = 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 proximity_proximity_resource_real_suspendResource_data_free (gpointer _data) {
	proximity_proximity_resource_suspendResourceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (proximity_proximity_resource_suspendResourceData, _data_);
}


static void proximity_proximity_resource_real_suspendResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ProximityProximityResource * self;
	proximity_proximity_resource_suspendResourceData* _data_;
	ProximityProximityResource* _tmp0_;
	self = (ProximityProximityResource*) base;
	_data_ = g_slice_new0 (proximity_proximity_resource_suspendResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, proximity_proximity_resource_real_suspendResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, proximity_proximity_resource_real_suspendResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proximity_proximity_resource_real_suspendResource_co (_data_);
}


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


static gboolean proximity_proximity_resource_real_suspendResource_co (proximity_proximity_resource_suspendResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	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 proximity_proximity_resource_real_resumeResource_data_free (gpointer _data) {
	proximity_proximity_resource_resumeResourceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (proximity_proximity_resource_resumeResourceData, _data_);
}


static void proximity_proximity_resource_real_resumeResource (FsoFrameworkAbstractDBusResource* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ProximityProximityResource * self;
	proximity_proximity_resource_resumeResourceData* _data_;
	ProximityProximityResource* _tmp0_;
	self = (ProximityProximityResource*) base;
	_data_ = g_slice_new0 (proximity_proximity_resource_resumeResourceData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, proximity_proximity_resource_real_resumeResource);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, proximity_proximity_resource_real_resumeResource_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proximity_proximity_resource_real_resumeResource_co (_data_);
}


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


static gboolean proximity_proximity_resource_real_resumeResource_co (proximity_proximity_resource_resumeResourceData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	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 proximity_proximity_resource_class_init (ProximityProximityResourceClass * klass) {
	proximity_proximity_resource_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ProximityProximityResourcePrivate));
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->enableResource = proximity_proximity_resource_real_enableResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->enableResource_finish = proximity_proximity_resource_real_enableResource_finish;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->disableResource = proximity_proximity_resource_real_disableResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->disableResource_finish = proximity_proximity_resource_real_disableResource_finish;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->suspendResource = proximity_proximity_resource_real_suspendResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->suspendResource_finish = proximity_proximity_resource_real_suspendResource_finish;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->resumeResource = proximity_proximity_resource_real_resumeResource;
	FSO_FRAMEWORK_ABSTRACT_DBUS_RESOURCE_CLASS (klass)->resumeResource_finish = proximity_proximity_resource_real_resumeResource_finish;
	G_OBJECT_CLASS (klass)->finalize = proximity_proximity_resource_finalize;
}


static void proximity_proximity_resource_instance_init (ProximityProximityResource * self) {
	self->priv = PROXIMITY_PROXIMITY_RESOURCE_GET_PRIVATE (self);
}


static void proximity_proximity_resource_finalize (GObject* obj) {
	ProximityProximityResource * self;
	self = PROXIMITY_PROXIMITY_RESOURCE (obj);
	_g_object_unref0 (self->priv->instance);
	G_OBJECT_CLASS (proximity_proximity_resource_parent_class)->finalize (obj);
}


/**
     * Implementation of org.freesmartphone.Resource for the Proximity Resource
     **/
GType proximity_proximity_resource_get_type (void) {
	return proximity_proximity_resource_type_id;
}


GType proximity_proximity_resource_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (ProximityProximityResourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proximity_proximity_resource_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProximityProximityResource), 0, (GInstanceInitFunc) proximity_proximity_resource_instance_init, NULL };
	proximity_proximity_resource_type_id = g_type_module_register_type (module, FSO_FRAMEWORK_TYPE_ABSTRACT_DBUS_RESOURCE, "ProximityProximityResource", &g_define_type_info, 0);
	return proximity_proximity_resource_type_id;
}



