| 298 | } |
| 299 | |
| 300 | int CManager::LoadPlugin(const QString &szPath) |
| 301 | { |
| 302 | int nRet = -1; |
| 303 | QPluginLoader loader(szPath); |
| 304 | QObject *plugin = loader.instance(); |
| 305 | if (plugin) { |
| 306 | CPlugin* p = qobject_cast<CPlugin*>(plugin); |
| 307 | if(p) |
| 308 | { |
| 309 | if(m_Plugins.find(p->Id()) == m_Plugins.end()) |
| 310 | { |
| 311 | qInfo(log) << "Success: Load plugin" |
| 312 | << p->Name() << "from" << szPath; |
| 313 | AppendPlugin(p); |
| 314 | } |
| 315 | else |
| 316 | qWarning(log) << "The plugin [" << p->Name() << "] is exist."; |
| 317 | return 0; |
| 318 | } else |
| 319 | qCritical(log) << "The plugin is not \"CPlugin\":" << szPath; |
| 320 | } else { |
| 321 | QString szMsg; |
| 322 | szMsg = "Error: Load plugin fail from " + szPath; |
| 323 | if(!loader.errorString().isEmpty()) |
| 324 | szMsg += "; Error: " + loader.errorString(); |
| 325 | qCritical(log) << szMsg.toStdString().c_str(); |
| 326 | } |
| 327 | return nRet; |
| 328 | } |
| 329 | |
| 330 | int CManager::AppendPlugin(CPlugin *p) |
| 331 | { |
nothing calls this directly
no test coverage detected