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

/*
 * Copyright (C) 2011-2012 Simon Busch <morphis@gravedo.de>
 *
 * 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 <stdlib.h>
#include <string.h>
#include <fsobasics.h>
#include <fsodevice.h>
#include <fsoresource.h>
#include <fsoframework.h>


#define HERRING_TYPE_RESUME_HANDLER (herring_resume_handler_get_type ())
#define HERRING_RESUME_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HERRING_TYPE_RESUME_HANDLER, HerringResumeHandler))
#define HERRING_RESUME_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HERRING_TYPE_RESUME_HANDLER, HerringResumeHandlerClass))
#define HERRING_IS_RESUME_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HERRING_TYPE_RESUME_HANDLER))
#define HERRING_IS_RESUME_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HERRING_TYPE_RESUME_HANDLER))
#define HERRING_RESUME_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HERRING_TYPE_RESUME_HANDLER, HerringResumeHandlerClass))

typedef struct _HerringResumeHandler HerringResumeHandler;
typedef struct _HerringResumeHandlerClass HerringResumeHandlerClass;

#define HERRING_TYPE_WI_FI_POWER_CONTROL (herring_wi_fi_power_control_get_type ())
#define HERRING_WI_FI_POWER_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HERRING_TYPE_WI_FI_POWER_CONTROL, HerringWiFiPowerControl))
#define HERRING_WI_FI_POWER_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HERRING_TYPE_WI_FI_POWER_CONTROL, HerringWiFiPowerControlClass))
#define HERRING_IS_WI_FI_POWER_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HERRING_TYPE_WI_FI_POWER_CONTROL))
#define HERRING_IS_WI_FI_POWER_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HERRING_TYPE_WI_FI_POWER_CONTROL))
#define HERRING_WI_FI_POWER_CONTROL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HERRING_TYPE_WI_FI_POWER_CONTROL, HerringWiFiPowerControlClass))

typedef struct _HerringWiFiPowerControl HerringWiFiPowerControl;
typedef struct _HerringWiFiPowerControlClass HerringWiFiPowerControlClass;

#define HERRING_TYPE_ALSA_POWER_CONTROL (herring_alsa_power_control_get_type ())
#define HERRING_ALSA_POWER_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HERRING_TYPE_ALSA_POWER_CONTROL, HerringAlsaPowerControl))
#define HERRING_ALSA_POWER_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HERRING_TYPE_ALSA_POWER_CONTROL, HerringAlsaPowerControlClass))
#define HERRING_IS_ALSA_POWER_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HERRING_TYPE_ALSA_POWER_CONTROL))
#define HERRING_IS_ALSA_POWER_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HERRING_TYPE_ALSA_POWER_CONTROL))
#define HERRING_ALSA_POWER_CONTROL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HERRING_TYPE_ALSA_POWER_CONTROL, HerringAlsaPowerControlClass))

typedef struct _HerringAlsaPowerControl HerringAlsaPowerControl;
typedef struct _HerringAlsaPowerControlClass HerringAlsaPowerControlClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))


extern HerringResumeHandler* resumehandler;
HerringResumeHandler* resumehandler = NULL;
extern HerringWiFiPowerControl* wifipowercontrol;
HerringWiFiPowerControl* wifipowercontrol = NULL;
extern HerringAlsaPowerControl* alsapowercontrol;
HerringAlsaPowerControl* alsapowercontrol = NULL;

#define HERRING_MODULE_NAME "fsodevice.herring_quirks"
GType herring_resume_handler_get_type (void) G_GNUC_CONST;
GType herring_resume_handler_register_type (GTypeModule * module);
GType herring_wi_fi_power_control_get_type (void) G_GNUC_CONST;
GType herring_wi_fi_power_control_register_type (GTypeModule * module);
GType herring_alsa_power_control_get_type (void) G_GNUC_CONST;
GType herring_alsa_power_control_register_type (GTypeModule * module);
gchar* fso_factory_function (FsoFrameworkSubsystem* subsystem, GError** error);
HerringResumeHandler* herring_resume_handler_new (void);
HerringResumeHandler* herring_resume_handler_construct (GType object_type);
HerringWiFiPowerControl* herring_wi_fi_power_control_new (FsoFrameworkSubsystem* subsystem);
HerringWiFiPowerControl* herring_wi_fi_power_control_construct (GType object_type, FsoFrameworkSubsystem* subsystem);
HerringAlsaPowerControl* herring_alsa_power_control_new (FsoFrameworkSubsystem* subsystem);
HerringAlsaPowerControl* herring_alsa_power_control_construct (GType object_type, FsoFrameworkSubsystem* subsystem);
void fso_register_function (GTypeModule* module);


/**
 * This function gets called on plugin initialization time.
 * @return the name of your plugin here
 * @note that it needs to be a name in the format <subsystem>.<plugin>
 * else your module will be unloaded immediately.
 **/
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;
}


gchar* fso_factory_function (FsoFrameworkSubsystem* subsystem, GError** error) {
	gchar* result = NULL;
	FsoFrameworkSmartKeyFile* _tmp0_;
	FsoFrameworkSmartKeyFile* _tmp1_;
	FsoFrameworkSmartKeyFile* config;
	FsoFrameworkSmartKeyFile* _tmp2_;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_;
	FsoFrameworkSmartKeyFile* _tmp9_;
	const gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_;
	gboolean _tmp13_ = FALSE;
	gboolean _tmp14_;
	FsoFrameworkSmartKeyFile* _tmp17_;
	const gchar* _tmp18_ = NULL;
	gchar* _tmp19_ = NULL;
	gchar* _tmp20_;
	gboolean _tmp21_ = FALSE;
	gboolean _tmp22_;
	gchar* _tmp25_;
	g_return_val_if_fail (subsystem != NULL, NULL);
	_tmp0_ = fso_framework_theConfig;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	config = _tmp1_;
	_tmp2_ = config;
	_tmp3_ = string_to_string (HERRING_MODULE_NAME);
	_tmp4_ = g_strconcat (_tmp3_, "/resume_handler", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = fso_framework_smart_key_file_hasSection (_tmp2_, _tmp5_);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	if (_tmp7_) {
		HerringResumeHandler* _tmp8_;
		_tmp8_ = herring_resume_handler_new ();
		_g_object_unref0 (resumehandler);
		resumehandler = _tmp8_;
	}
	_tmp9_ = config;
	_tmp10_ = string_to_string (HERRING_MODULE_NAME);
	_tmp11_ = g_strconcat (_tmp10_, "/wifi_power_control", NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = fso_framework_smart_key_file_hasSection (_tmp9_, _tmp12_);
	_tmp14_ = _tmp13_;
	_g_free0 (_tmp12_);
	if (_tmp14_) {
		FsoFrameworkSubsystem* _tmp15_;
		HerringWiFiPowerControl* _tmp16_;
		_tmp15_ = subsystem;
		_tmp16_ = herring_wi_fi_power_control_new (_tmp15_);
		_g_object_unref0 (wifipowercontrol);
		wifipowercontrol = _tmp16_;
	}
	_tmp17_ = config;
	_tmp18_ = string_to_string (HERRING_MODULE_NAME);
	_tmp19_ = g_strconcat (_tmp18_, "/alsa_power_control", NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = fso_framework_smart_key_file_hasSection (_tmp17_, _tmp20_);
	_tmp22_ = _tmp21_;
	_g_free0 (_tmp20_);
	if (_tmp22_) {
		FsoFrameworkSubsystem* _tmp23_;
		HerringAlsaPowerControl* _tmp24_;
		_tmp23_ = subsystem;
		_tmp24_ = herring_alsa_power_control_new (_tmp23_);
		_g_object_unref0 (alsapowercontrol);
		alsapowercontrol = _tmp24_;
	}
	_tmp25_ = g_strdup (HERRING_MODULE_NAME);
	result = _tmp25_;
	_g_object_unref0 (config);
	return result;
}


void fso_register_function (GTypeModule* module) {
	FsoFrameworkLogger* _tmp0_;
	g_return_if_fail (module != NULL);
	herring_resume_handler_register_type (module);
	herring_alsa_pcm_device_allocator_register_type (module);
	herring_alsa_power_control_register_type (module);
	herring_wi_fi_power_control_register_type (module);
	_tmp0_ = fso_framework_theLogger;
	fso_framework_logger_debug (_tmp0_, "fsodevice.herring_quirks fso_register_function()");
}



