コード例 #1
0
ファイル: batterylib.c プロジェクト: Andolamin/nyx-modules
nyx_error_t nyx_module_open (nyx_instance_t i, nyx_device_t** d)
{
	if (nyxDev) {
		nyx_info("Battery device already open");
		*d = (nyx_device_t*)nyxDev;
		return NYX_ERROR_NONE;
	}

	nyxDev = (nyx_device_t*)calloc(sizeof(nyx_device_t), 1);
	if (NULL == nyxDev) {
		return NYX_ERROR_OUT_OF_MEMORY;
	}

	nyx_module_register_method(i, (nyx_device_t*)nyxDev, NYX_BATTERY_QUERY_BATTERY_STATUS_MODULE_METHOD,
		"battery_query_battery_status");

	nyx_module_register_method(i, (nyx_device_t*)nyxDev, NYX_BATTERY_REGISTER_BATTERY_STATUS_CALLBACK_MODULE_METHOD,
		"battery_register_battery_status_callback");

	nyx_module_register_method(i, (nyx_device_t*)nyxDev, NYX_BATTERY_AUTHENTICATE_BATTERY_MODULE_METHOD,
		"battery_authenticate_battery");

	nyx_module_register_method(i, (nyx_device_t*)nyxDev, NYX_BATTERY_GET_CTIA_PARAMETERS_MODULE_METHOD,
		"battery_get_ctia_parameters");

	nyx_module_register_method(i, (nyx_device_t*)nyxDev, NYX_BATTERY_SET_WAKEUP_PARAMETERS_MODULE_METHOD,
		"battery_set_wakeup_percentage");

	*d = (nyx_device_t*)nyxDev;
	battery_read_init();

	return NYX_ERROR_NONE;
}
コード例 #2
0
ファイル: touchpanel.c プロジェクト: Andolamin/nyx-modules
nyx_error_t nyx_module_open(nyx_instance_t i, nyx_device_t** d)
{

	touchpanel_device_t* touchpanel_device = (touchpanel_device_t *) calloc(
				sizeof(touchpanel_device_t), 1);

    	if (G_UNLIKELY(!touchpanel_device)) {
		return NYX_ERROR_OUT_OF_MEMORY;
	}


	int ret = nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
			NYX_GET_EVENT_SOURCE_MODULE_METHOD, "touchpanel_get_event_source");

	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
		NYX_GET_EVENT_MODULE_METHOD, "touchpanel_get_event");
	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
		NYX_RELEASE_EVENT_MODULE_METHOD, "touchpanel_release_event");
	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
	        NYX_SET_OPERATING_MODE_MODULE_METHOD, "touchpanel_set_operating_mode");
	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
        	NYX_TOUCHPANEL_SET_ACTIVE_SCAN_RATE_MODULE_METHOD, "touchpanel_set_active_scan_rate");
    	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
            	NYX_TOUCHPANEL_SET_IDLE_SCAN_RATE_MODULE_METHOD, "touchpanel_set_idle_scan_rate");
    	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
            	NYX_TOUCHPANEL_GET_IDLE_SCAN_RATE_MODULE_METHOD, "touchpanel_get_idle_scan_rate");
    	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
            	NYX_TOUCHPANEL_GET_ACTIVE_SCAN_RATE_MODULE_METHOD, "touchpanel_get_active_scan_rate");
    	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
            	NYX_TOUCHPANEL_SET_MODE_MODULE_METHOD, "touchpanel_set_mode");
    	nyx_module_register_method(i, (nyx_device_t*) touchpanel_device,
            	NYX_TOUCHPANEL_GET_MODE_MODULE_METHOD, "touchpanel_get_mode");

	*d = (nyx_device_t*) touchpanel_device;

	if(init_touchpanel() < 0)
		goto fail_unlock_settings;

	return NYX_ERROR_NONE;

fail_unlock_settings:
	return NYX_ERROR_GENERIC;
}
コード例 #3
0
ファイル: security.c プロジェクト: ctbrowser/nyx-modules
nyx_error_t nyx_module_open(nyx_instance_t i, nyx_device_t **d)
{
	if ((NULL == d) || (NULL != *d))
	{
		return NYX_ERROR_INVALID_VALUE;
	}

	*d = (nyx_device_t *) calloc(sizeof(nyx_device_t), 1);

	if (NULL == *d)
	{
		return NYX_ERROR_OUT_OF_MEMORY;
	}

	/* register methods */
	struct
	{
		module_method_t method;
		const char *function;
	} methods[] =
	{
		{ NYX_SECURITY_CREATE_AES_KEY_MODULE_METHOD, "security_create_aes_key" },
		{ NYX_SECURITY_CREATE_RSA_KEY_MODULE_METHOD, "security_create_rsa_key" },
		{ NYX_SECURITY_CRYPT_AES_MODULE_METHOD,      "security_aes_crypt" },
		{ NYX_SECURITY_CRYPT_RSA_MODULE_METHOD,      "security_rsa_crypt" },
		{ NYX_SECURITY_INIT_HASH_MODULE_METHOD,      "security_init_hash" },
		{ NYX_SECURITY_UPDATE_HASH_MODULE_METHOD,    "security_update_hash" },
		{ NYX_SECURITY_FINALIZE_HASH_MODULE_METHOD,  "security_finalize_hash" },
	};

	int m;

	for (m = 0; m < sizeof(methods) / sizeof(methods[0]); ++m)
	{
		nyx_error_t result = nyx_module_register_method(i, *d, methods[m].method,
		                     methods[m].function);

		if (result != NYX_ERROR_NONE)
		{
			return result;
		}
	}

	ERR_load_crypto_strings();

	/* initialize keystore */
	nyx_error_t result = keystore_init(&keystore);

	if (result == NYX_ERROR_NONE)
	{
		result = keystore_load(&keystore);
	}

	if (result != NYX_ERROR_NONE)
	{
		keystore_destroy(&keystore);
		free(*d);
	}

	return result;
}