Esempio n. 1
0
extern "C" OS_SDK_API os_result osiris_parse_link(const char *link, char *value, os_uint32 *size)
{
	if(Application::exists() == false || Engine::exists() == false)
		return OS_SDK_ERROR_NOT_INITIALIZED;

	if((link == NULL) || (size == NULL))
		return OS_SDK_ERROR_INVALID_PARAM;

	String tmp;	

	OsirisLink shellLink;
	if(shellLink.parse(tmp.from_utf8(link).to_ascii()) == false)
		return OS_SDK_ERROR_ILLEGAL_VALUE;

	tmp.clear();
	if(Engine::instance()->processLink(shellLink, tmp) == false)
		return OS_SDK_ERROR_GENERIC;

	std::string out_value = tmp.to_utf8();

	os_result result = OS_SDK_OK;

	os_uint32 out_size = static_cast<os_uint32>(out_value.size());

	if(value != NULL)
	{
		if(*size < out_size)
			result = OS_SDK_ERROR_BUFFER_TOO_SMALL;
		else
			memcpy(value, out_value.data(), out_size);			
	}

	*size = out_size;

	return result;
}
Esempio n. 2
0
void Subscribe::onSubscribe()
{
	if(m_driver == nullptr)
	{
		reportError(httpStatusServiceUnavailable);
		return;
	}

	PortalID portalID = m_portalID->getValue().to_ascii();
	String portalName = m_portalName->getValue();
	PovID portalPov = m_portalPov->getValue().to_ascii();

	if(m_showPortalParams->getCheck() == false)
	{
		OsirisLink link;
		if(link.parse(m_portalLink->getValue().to_ascii()) == false || (link.getType() != OsirisLink::linkPortal))
		{
			showError(getText("main.pages.subscribe.error.invalidPortalLink"));
			return;
		}
		
		portalID = link.getPortal();
		portalName = link.getName();
		portalPov = link.getPov();
	}

	shared_ptr<Portal> currentPortal = PortalsSystem::instance()->getPortal(portalID, portalPov);
	if(currentPortal != nullptr)
	{
		redirect(currentPortal->getLink("view"));
		return;
	}

	if(m_driverOptions != nullptr)
	{
		const ordered_map<String, String> &driverParams = m_driverOptions->getParams();
		for(ordered_map<String, String>::const_iterator i = driverParams.begin(); i != driverParams.end(); ++i)
		{
			shared_ptr<IHtmlInput> optionControl = getDriverOptionControl(m_driver->getName(), i->first);
			if(optionControl != nullptr)
			{
				const String &paramValue = optionControl->getValue();
				if(paramValue.empty() == false)
					m_driverOptions->setParam(i->first, paramValue);
			}
		}
	}

	shared_ptr<PortalOptions> options(OS_NEW PortalOptions());
	options->setPortalID(portalID);
	options->setPovID(portalPov);
	options->setName(portalName);
	options->setPassword(m_portalPassword->getValue());
	OS_ASSERT(m_driver->getName() == m_databaseDriver->getValue());
	options->setDatabaseDriver(m_driver->getName());
	options->setDatabaseOptions(m_driverOptions);

	shared_ptr<Portal> portal = PortalsSystem::instance()->subscribePortal(options);
	if(portal != nullptr)
		//redirect(PortalsSystem::instance()->getAccountsLink(PortalsSystem::instance()->getPortal(portalID, portalUser)));
		redirect(PortalsSystem::instance()->getPortalLink(portal, "view"));
	else
		showError(getText("main.pages.subscribe.error.cannotCreate"));
}