| 25 | } |
| 26 | |
| 27 | void IPPluginManager::loadPlugins(QString pluginPath, IPProcessFactory* factory) |
| 28 | { |
| 29 | // plugin loading doesn't work in debug mode |
| 30 | #ifdef QT_DEBUG |
| 31 | return; |
| 32 | #endif |
| 33 | |
| 34 | #if defined(_WIN32) |
| 35 | static const auto pluginFilter = QStringList() << "*.dll"; |
| 36 | #else |
| 37 | static const auto pluginFilter = QStringList() << "*.so"; |
| 38 | #endif |
| 39 | |
| 40 | qDebug() << "IPPluginManager::loadPlugins: " << pluginPath; |
| 41 | |
| 42 | _pluginPath = pluginPath; |
| 43 | _factory = factory; |
| 44 | _loadedPlugins.clear(); |
| 45 | |
| 46 | QDir pluginsDir(_pluginPath); |
| 47 | |
| 48 | // watch the original dll for changes |
| 49 | // _pluginFileSystemWatcher->addPath(pluginPath()); |
| 50 | |
| 51 | QDateTime now = QDateTime::currentDateTime(); |
| 52 | _pluginTmpPath = _pluginPath + "/tmp/"; |
| 53 | QDir tmpPluginsDir(_pluginTmpPath); |
| 54 | |
| 55 | // delete old tmp directory |
| 56 | if(!removeDir(_pluginTmpPath)) |
| 57 | { |
| 58 | qWarning() << "Could not remove old plugin dir: " << _pluginTmpPath; |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | // create new directory, copy dlls |
| 63 | if(!tmpPluginsDir.exists()) |
| 64 | tmpPluginsDir.mkpath("."); |
| 65 | |
| 66 | pluginsDir.setNameFilters(pluginFilter); |
| 67 | foreach (QString fileName, pluginsDir.entryList(QDir::Files)) |
| 68 | { |
| 69 | QFile file(pluginsDir.filePath(fileName)); |
| 70 | file.copy(tmpPluginsDir.filePath(fileName)); |
| 71 | } |
| 72 | |
| 73 | if(tmpPluginsDir.exists()) |
| 74 | { |
| 75 | tmpPluginsDir.setNameFilters(pluginFilter); |
| 76 | |
| 77 | foreach (QString fileName, tmpPluginsDir.entryList(QDir::Files)) |
| 78 | { |
| 79 | QString pluginFilePath = _pluginTmpPath + "/" + fileName; |
| 80 | pugg::Kernel* kernel = new pugg::Kernel; |
| 81 | _kernels.push_back(kernel); |
| 82 | kernel->add_server(IPLProcess::server_name(), IPLProcess::version); |
| 83 | kernel->load_plugin(pluginFilePath.toStdString()); |
| 84 |
no test coverage detected