Ejemplo n.º 1
0
scene::SMesh* mdlLoaderV0::load(const  core::string& fileName)
{
	if(!canLoad(fileName))return 0;
	OS::IStreamPtr file=gFileSystem.openFile(fileName,OS::BIN_READ);
	if(!file)return 0;
	return load(file);
}
scene::Skeleton* SkeletonLoader::load(const  core::string& filename){
	if(!canLoad(filename))return 0;
	OS::IStreamPtr file=gFileSystem.openFile(filename);
	if(!file->isOpen())return 0;

	return load(file);
}
// returns true if plugin was loaded successfully
bool KDecorationPlugins::loadPlugin(QString nameStr)
{
    KConfigGroup group(config, QString("Style"));
    if (nameStr.isEmpty()) {
        nameStr = group.readEntry("PluginLib", defaultPlugin);
    }

    // Check if this library is not already loaded.
    if (pluginStr == nameStr)
        return true;

    KLibrary *oldLibrary = library;
    KDecorationFactory* oldFactory = fact;

    if (!canLoad(nameStr, &library)) {
        // If that fails, fall back to the default plugin
        nameStr = defaultPlugin;
        if (!canLoad(nameStr, &library)) {
            // big time trouble!
            // -> exit kwin with an error message
            error(i18n("The default decoration plugin is corrupt and could not be loaded."));
            return false;
        }
    }

    // guarded by "canLoad"
    KLibrary::void_function_ptr create_func = library->resolveFunction("create_factory");
    if (create_func)
        create_ptr = (KDecorationFactory * (*)())create_func;
    if (!create_ptr) {  // this means someone probably attempted to load "some" kwin plugin/lib as deco
                        // and thus cheated on the "isLoaded" shortcut -> try the default and yell a warning
        if (nameStr != defaultPlugin) {
            kWarning(1212) << i18n("The library %1 was attempted to be loaded as a decoration plugin but it is NOT", nameStr);
            return loadPlugin(defaultPlugin);
        } else {
            // big time trouble!
            // -> exit kwin with an error message
            error(i18n("The default decoration plugin is corrupt and could not be loaded."));
            return false;
        }
    }

    fact = create_ptr();
    fact->checkRequirements(this);   // let it check what is supported

    pluginStr = nameStr;

    // For clients in kdeartwork
    QString catalog = nameStr;
    catalog.replace("kwin3_", "kwin_");
    KGlobal::locale()->insertCatalog(catalog);
    // For KCommonDecoration based clients
    KGlobal::locale()->insertCatalog("libkdecorations");
    // For clients in kdebase
    KGlobal::locale()->insertCatalog("kwin_clients");
    // For clients in kdeartwork
    KGlobal::locale()->insertCatalog("kwin_art_clients");

    old_library = oldLibrary; // save for delayed destroying
    old_fact = oldFactory;

    return true;
}