MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / loadPlugins

Method loadPlugins

nixnote.cpp:3846–3893  ·  view source on GitHub ↗

Check to see if plugins are avaialble and they match the correct version expected. Load them if possible.

Source from the content-addressed store, hash-verified

3844// Check to see if plugins are avaialble and they match
3845// the correct version expected. Load them if possible.
3846void NixNote::loadPlugins() {
3847 webcamPluginAvailable = false;
3848
3849 QStringList dirList;
3850 dirList.append(global.fileManager.getProgramDirPath(""));
3851 dirList.append(global.fileManager.getProgramDirPath("")+"/plugins");
3852 dirList.append("/usr/lib/nixnote2/");
3853 dirList.append("/usr/local/lib/nixnote2/");
3854 dirList.append("/usr/local/lib");
3855 dirList.append("/usr/lib");
3856
3857 // Start loading plugins
3858 for (int i=0; i<dirList.size(); i++) {
3859 QDir pluginsDir(dirList[i]);
3860 QStringList filter;
3861 filter.append("libwebcamplugin.so");
3862 filter.append("libhunspellplugin.so");
3863 foreach (QString fileName, pluginsDir.entryList(filter)) {
3864 QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
3865 QObject *plugin = pluginLoader.instance();
3866 if (fileName == "libwebcamplugin.so") {
3867 if (plugin) {
3868 webcamInterface = qobject_cast<WebCamInterface *>(plugin);
3869 if (webcamInterface) {
3870 webcamPluginAvailable = true;
3871 }
3872 } else {
3873 QLOG_ERROR() << tr("Error loading Webcam plugin: ") << pluginLoader.errorString();
3874 }
3875 }
3876
3877 // The Hunspell plugin isn't actually used here. We just use this as a
3878 // check to be sure that the menu should be available.
3879 if (fileName == "libhunspellplugin.so") {
3880 if (plugin) {
3881 HunspellInterface *hunspellInterface;
3882 hunspellInterface = qobject_cast<HunspellInterface *>(plugin);
3883 if (hunspellInterface) {
3884 hunspellPluginAvailable = true;
3885 }
3886 delete hunspellInterface;
3887 } else {
3888 QLOG_ERROR() << tr("Error loading Hunspell plugin: ") << pluginLoader.errorString();
3889 }
3890 }
3891 }
3892 }
3893}
3894
3895
3896

Callers 1

NixNoteMethod · 0.95

Calls 1

getProgramDirPathMethod · 0.45

Tested by

no test coverage detected