30 {
31 QStringList plugins;
32 QStringList plugindirs;
33 plugindirs << QCoreApplication::applicationDirPath()+"/plugins";
34 plugindirs << "/usr/lib/fotomonserver/plugins";
35 for (int i=0; i<plugindirs.size(); i++) {
36 QDir dir(plugindirs[i]);
37 PDEBUG << "path:" << dir.absolutePath();
38 QStringList files = dir.entryList(QStringList() << "lib*.so", QDir::Files);
39 for (int f=0; f<files.size(); f++) {
40 plugins << dir.absolutePath()+"/"+files[f];
41 }
42 }
43
44 for (int i=0; i<plugins.size(); i++) {
45 const QString& filename = plugins[i];
46 QPluginLoader *loader = new QPluginLoader(this);
47 loader->setFileName(filename);
48
49 if (!loader->load()) {
50 PDEBUG << filename << loader->errorString();
51 return;
52 }
53 QObject *x = loader->instance();
54 if (x == NULL) {
55 PDEBUG << "Loader instance() == NULL" << filename;
56 return;
57 }
59 if (plugin == NULL) {
60 PDEBUG << "plugin == NULL" << filename;
61 return;
62 }
63 m_plugins << plugin;
64
65 PDEBUG << "Loaded" << plugin->description();
66 }
67
68}
Interface pro pluginy serveru.