Example #1
0
void ScriptExtensionPlugin::initialize(const QString &key, QScriptEngine *engine)
{
	if (key != QLatin1String("qutim"))
		return;
	QScriptValue qutim = setupPackage(QLatin1String("qutim"), engine);
	qScriptRegisterSequenceMetaType<QSet<QString> >(engine);
	scriptRegisterQObject<Account>(engine);
	scriptRegisterQObject<ChatUnit>(engine);
	scriptRegisterQObject<Buddy>(engine);
	scriptRegisterQObject<Contact>(engine);
	scriptRegisterQObject<Conference>(engine);
	scriptRegisterQObject<ChatSession>(engine);
//	scriptRegisterEnum<InfoRequest::State>(engine);
	ScriptEngineData *data = ScriptEngineData::data(engine);
	data->message = new ScriptMessage(engine);
	data->services = new ScriptServices(engine);
	data->messageHandler = new ScriptMessageHandler(engine);
	data->dataItem = new ScriptDataItem(engine);
	qutim.setProperty(QLatin1String("services"), engine->newObject(data->services));
	qutim.setProperty(QLatin1String("protocol"), engine->newFunction(getProtocol, 1));
	qutim.setProperty(QLatin1String("requestInfo"), engine->newFunction(scriptRequestInfo));
	{
		QScriptValue settings = engine->newObject();
		settings.setProperty(QLatin1String("General"), Settings::General);
		settings.setProperty(QLatin1String("Protocol"), Settings::Protocol);
		settings.setProperty(QLatin1String("Appearance"), Settings::Appearance);
		settings.setProperty(QLatin1String("Plugin"), Settings::Plugin);
		settings.setProperty(QLatin1String("Special"), Settings::Special);
		settings.setProperty(QLatin1String("register"), engine->newFunction(scriptSettingsRegister, 1));
		settings.setProperty(QLatin1String("remove"), engine->newFunction(scriptSettingsRemove, 1));
		qutim.setProperty(QLatin1String("settings"), settings);
	}
//	QScriptValue global = engine->globalObject();
//	global.setProperty(QLatin1String("SettingsWidget"), engine->newFunction(createSettingsWidget));
//	{
//		QScriptValue object = engine->newFunction(createInfoRequest);
//		global.setProperty(QLatin1String("InfoRequest"), object);
//	}
}
Example #2
0
void SimplePlugin::initialize(const QString &key, QScriptEngine *engine)
{
    engine->globalObject().setProperty("pluginKey", key);
    QScriptValue package = setupPackage(key, engine);
    engine->globalObject().setProperty("package", package);
}