1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
bool Plugin::_loadLibrary()
{
QStringList nameFilters;
Streamit::IPlugin *instance;
// List the possible extensions
nameFilters << "*.dll" << "*.so" << "*.a" << "*.sl" << "*.dylib" << "*.bundle";
QStringListIterator dir(QDir(this->path).entryList(nameFilters, QDir::Files));
// Iterate over the files of the plugin directory
while (dir.hasNext() && !this->loader)
{
// If the file name has the good extension
if (QLibrary::isLibrary(dir.peekNext()))
{
this->loader = new QPluginLoader(this->path + dir.peekNext());
this->libraryName = dir.peekNext();
// If the plugin implements IPlugin
if (!(instance = dynamic_cast<Streamit::IPlugin *>(this->loader->instance())))
{
std::cerr << "QPluginLoader::Error: " << this->loader->errorString() << std::endl;
delete this->loader;
this->loader = NULL;
}
delete instance;
}
dir.next();
}
if (!this->loader)
{
Log::error(tr("Unable to find the plugin library"), Properties("id", this->id).add("file", this->path + this->libraryName), "Plugin", "_load");
return (false);
}
Log::trace(tr("Plugin library found"), Properties("id", this->id).add("file", this->path + this->libraryName), "Plugin", "_load");
return (true);
} |