Example #1
0
EXPORT_API int appcore_init(const char *name, const struct ui_ops *ops,
			    int argc, char **argv)
{
	int r;
	char dirname[PATH_MAX];

	if (core.state != 0) {
		_ERR("Already in use");
		errno = EALREADY;
		return -1;
	}

	if (ops == NULL || ops->cb_app == NULL) {
		_ERR("ops or callback function is null");
		errno = EINVAL;
		return -1;
	}

	r = __get_dir_name(dirname);
	r = set_i18n(name, dirname);
	_retv_if(r == -1, -1);

	r = __add_vconf(&core);
	if (r == -1) {
		_ERR("Add vconf callback failed");
		goto err;
	}

	r = aul_launch_init(__aul_handler, &core);
	if (r < 0) {
		_ERR("Aul init failed: %d", r);
		goto err;
	}

	r = aul_launch_argv_handler(argc, argv);
	if (r < 0) {
		_ERR("Aul argv handler failed: %d", r);
		goto err;
	}

	core.ops = ops;
	core.state = 1;		/* TODO: use enum value */

	_pid = getpid();

	return 0;
 err:
	__del_vconf();
	__clear(&core);
	return -1;
}
SLPAPI int aul_launch_app_with_result(const char *pkgname, bundle *kb,
			       void (*cbfunc) (bundle *, int, void *),
			       void *data)
{
	int ret;

	if (!aul_is_initialized()) {
		if (aul_launch_init(NULL, NULL) < 0)
			return AUL_R_ENOINIT;
	}

	if (pkgname == NULL || cbfunc == NULL || kb == NULL)
		return AUL_R_EINVAL;

	ret = app_request_to_launchpad(APP_START_RES, pkgname, kb);

	if (ret > 0)
		__add_resultcb(ret, cbfunc, data);

	return ret;
}