Esempio n. 1
0
	XdevLModule* createModule(const XdevLPluginDescriptor& pluginDescriptor, XdevLModuleDescriptor& moduleDescriptor, const XdevLFileName& pluginPath) {

		XdevLSharedLibrary* sharedLibrary = new XdevLSharedLibrary();
		XdevLFileName pluginName("");

		// Did the user specify a plugin folder?
		if(pluginPath != XdevLFileName()) {
			pluginName = pluginPath;
			pluginName += XdevLFileName("/");
		}

#ifdef XDEVL_PLATFORM_ANDROID
		pluginName += xdl::XdevLFileName("lib");
#endif

		pluginName += pluginDescriptor.getName() + STRING("-") + XdevLString(pluginDescriptor.getVersion().toString());
#ifdef XDEVL_DEBUG
		pluginName += STRING("d");
#endif
		pluginName += XdevLSharedLibrary::extension;
		std::string tmp(pluginName.toString());

		xdl_int ret;
		if((ret = checkLocal(tmp, sharedLibrary)) != RET_SUCCESS) {
			std::cerr << "## Could not find XdevLCore plugin at all." << std::endl;
			exit(-1);
		}

		//
		// Get the plugins create and delte function pointer.
		//
		moduleDescriptor.create = (CREATE_XDEVL_MODULE)(sharedLibrary->getFunctionAddress("_createModule"));
		if(!moduleDescriptor.create) {
			return nullptr;
		}
		moduleDescriptor.destroy = (DELETE_XDEVL_MODULE)(sharedLibrary->getFunctionAddress("_delete"));
		if(!moduleDescriptor.destroy) {
			return nullptr;
		}

		moduleDescriptor.setLibrary(sharedLibrary);

		return moduleDescriptor.create(pluginDescriptor, moduleDescriptor);

	}
Esempio n. 2
0
EmailValidator::State EmailValidator::validate(QString &str, int &pos2)const {
	if(str.isEmpty())
		return set("Empty email");
	int pos = 0;
	const int indexA = str.indexOf('@');
	if(-1 == indexA) {
		return set(tr("No '@' character"));
	}
	if(str.count('@') != 1)
		return set(tr("More than one '@' characters"));
	QString local = str.left(indexA);
	QString domain = str.mid(indexA + 1);
	auto ret = checkLocal(local, pos);
	if(ret!=Acceptable)
		return ret;
	ret = checkDomain(domain, pos);
	if(ret != Acceptable) {
		pos += local.length() + 1;
		return ret;
	}
	return Acceptable;
}
Esempio n. 3
0
	//
	// Check the local path for the XdevLCore plugin.
	//
	xdl_int checkLocal(std::string& pluginFilename) {
		return checkLocal(pluginFilename, &dynamicLibraryLoader);
	}
Esempio n. 4
0
	XdevLCore* createCore(xdl_int argc,
	                      xdl_char* argv[],
	                      xdl_int xmlBufferSize,
	                      xdl_uint8* xmlBuffer,
	                      xdl_uint numberOfUserData,
	                      XdevLUserData* userDataList[]) {

		std::stringstream vn;
		vn << XDEVL_MAJOR_VERSION << "." << XDEVL_MINOR_VERSION << "." << XDEVL_PATCH_VERSION;
		version_number = vn.str();

		//
		// All command line specified values will override values specified in the
		// xml file or default values. The following values can be overwritten.
		//
		//	- XML filename
		//	- XdevLPlugins plugins path
		// 	- XdevLCore plugins version number
		//

		xdl::XdevLCommandLineParser cmdParser(argc, argv);

		//
		// Set default parameters.
		//
		xdl::XdevLStringParameter versionNumberParameter("v", "The path to the plugins folder.", version_number);
		xdl::XdevLStringParameter pluginsPathParameter("pp", "The path to the plugins folder.", ".");
		xdl::XdevLStringParameter fileNameParameter("f", "The filename of the XML file.", xml_file);

		// Parse the command line arguments.
		cmdParser.add(&versionNumberParameter);
		cmdParser.add(&pluginsPathParameter);
		cmdParser.add(&fileNameParameter);
		cmdParser.parse();

		// Assign the values.
		version_number		= versionNumberParameter.getValue();
		std::cout << "XdevLCore     : " << version_number << std::endl;
		xdevl_plugin_path = pluginsPathParameter.getValue();
		std::cout << "Plugins Folder: " << xdevl_plugin_path << std::endl;
		xml_file 					= fileNameParameter.getValue();

		//
		// Check if there is a main XML file where the user may have specified.
		// XdevLCore related information.
		// TODO The not specified comparision must be changed.
		if(xmlBuffer != nullptr) {

			TiXmlDocument xmlDocument;
			if(!xmlDocument.Parse((char*)xmlBuffer)) {
				std::cerr << "## Couldn't parse the specified XML file." << std::endl;
				exit(-1);
			}

			TiXmlHandle docHandle(&xmlDocument);
			TiXmlElement* root = docHandle.FirstChild("XdevLCoreProperties").ToElement();
			if(!root) {
				std::cerr << "## XML format not correct." << std::endl;
				exit(-1);
			}

			//
			// Do we have a version forces to use by the user?
			//
			if(!versionNumberParameter.getSet()) {
				if(root->Attribute("version")) {
					// Use the one from the xml file.
					version_number = root->Attribute("version");
					std::cout << ">> Using version specified in XML file." << std::endl;
				}
			}
			if(!pluginsPathParameter.getSet()) {
				if(root->Attribute("plugins_path")) {
					// Use the one from the xml file.
					xdevl_plugin_path = root->Attribute("plugins_path");
					std::cout << ">> Using plugins folder specified in XML file." << std::endl;
				}
			}
		}

		//
		// Create the filename.
		//
		createXdevLCoreFilename(xdevl_plugin_path, version_number, xdevlcore_filename);

		// Load the XdevLCore plugin.
		xdl_int ret;
		if((ret = checkLocal(xdevlcore_filename)) != RET_SUCCESS) {
			std::cerr << "## Could not find XdevLCore plugin at all." << std::endl;
			exit(-1);
		}


		//
		// Get the plugins create and delte function pointer.
		//
		create_xdevl_core = (XdevLCreateModuleFunction)(dynamicLibraryLoader.getFunctionAddress("_create"));
		if(!create_xdevl_core) {
			std::cerr << "## XdevLCore plugin method format wrong: CREATE_XDEVL_CORE not found." <<  std::endl;
			exit(-1);
		}
		delete_xdevL_core = (DELETE_XDEVL_CORE)(dynamicLibraryLoader.getFunctionAddress("_delete"));
		if(!delete_xdevL_core) {
			std::cerr << "## XdevLCore plugin method format wrong: DELETE_XDEVL_CORE not found." << std::endl;
			exit(-1);
		}

		//
		// Create the XdevLCore object.
		//
		//	cmdl = new xdl::XdevLCommandLineParser(argc, argv);
		XdevLUserData userData;

		userData.id = XdevLID("XDEVL_COMMAND_LINE_PARSER");
		userData.data = (void*)&cmdParser;


		XdevLModuleCreateParameter parameter;
		XdevLID CoreID("XdevLCoreMain");
		parameter.setPluginName(xdl::XdevLPluginName("XdevLCore"));
		parameter.setModuleName(xdl::XdevLModuleName("XdevLCore"));
		parameter.setUserParameter(&userData);
		parameter.setModuleId(CoreID);

		if(create_xdevl_core(&parameter) != RET_SUCCESS) {
			std::cerr << "## Couldn't create XdevLCore object." << std::endl;
			exit(-1);
		}
		XdevLCore* xdevlCoreObject = static_cast<XdevLCore*>(parameter.getModuleInstance());


		XdevLEvent moduleInit;
		moduleInit.type = XDEVL_MODULE_EVENT;
		moduleInit.module.sender = CoreID.getHashCode();
		moduleInit.module.event = XDEVL_MODULE_INIT;
		xdevlCoreObject->notify(moduleInit);

		//
		// Initialize the XdevLCore system.
		//
		XdevLCoreParameters parameters;
		parameters.xmlBuffer = std::vector<xdl_uint8>(xmlBuffer, xmlBuffer + xmlBufferSize);
		parameters.pluginsPath 			= xdevl_plugin_path;
		parameters.userDataList 		= userDataList;
		parameters.numberOfUserData = numberOfUserData;

		if(xdevlCoreObject->setParameters(parameters) != RET_SUCCESS) {
			std::cerr << "## Couldn't initialize XdevLCore object." << std::endl;
			exit(-1);
		}

		return xdevlCoreObject;
	}
Esempio n. 5
0
    bool DialogueManager::isMatching (const MWWorld::Ptr& actor,
        const ESM::DialInfo::SelectStruct& select) const
    {
        char type = select.selectRule[1];

        if (type!='0')
        {
            char comp = select.selectRule[4];
            std::string name = select.selectRule.substr (5);

            // TODO types 4, 5, 6, 7, 8, 9, A, B, C

            switch (type)
            {
                case '1': // function

                    return false; // TODO implement functions

                case '2': // global

                    if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
                        select.type==ESM::VT_Long)
                    {
                        if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld))
                            return false;
                    }
                    else if (select.type==ESM::VT_Float)
                    {
                        if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld))
                            return false;
                    }
                    else
                        throw std::runtime_error (
                            "unsupported variable type in dialogue info select");

                    return true;

                case '3': // local

                    if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
                        select.type==ESM::VT_Long)
                    {
                        if (!checkLocal (comp, toLower (name), select.i, actor,
                            mEnvironment.mWorld->getStore()))
                            return false;
                    }
                    else if (select.type==ESM::VT_Float)
                    {
                        if (!checkLocal (comp, toLower (name), select.f, actor,
                            mEnvironment.mWorld->getStore()))
                            return false;
                    }
                    else
                        throw std::runtime_error (
                            "unsupported variable type in dialogue info select");

                    return true;

                default:

                    std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl;
            }
        }

        return true;
    }