//=========================================== // Lumina-desktop source code // Copyright (c) 2017, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "plugins-screensaver.h" #include //Relative directory to search along the XDG paths for screensavers #define REL_DIR QString("/lumina-desktop/screensavers") // ============ // SS PLUGIN // ============ SSPlugin::SSPlugin(){ } SSPlugin::~SSPlugin(){ } void SSPlugin::loadFile(QString path){ data = QJsonObject(); currentfile = path; SSPlugin SSP; QFile file(path); if(!file.exists() || !file.open(QIODevice::ReadOnly)){ return SSP; } SSP.data = QJsonDocument::fromJson(file.readAll()).object(); file.close(); return SSP; } bool SSPlugin::isLoaded(){ return !data.isEmpty(); } bool SSPlugin::isValid(){ if(data.isEmpty()){ return false; } bool ok = data.contains("name") && data.contains("qml") && data.contains("description"); if(ok){ //go to the next name level and see if required sub-items exist QJsonObject tmp = data.value("name").toObject(); ok = tmp.contains("default"); } if(ok){ //go to the next description level and see if required sub-items exist QJsonObject tmp = data.value("description").toObject(); ok = tmp.contains("default"); } if(ok){ //go to the next qml level and see if required sub-items exist QJsonObject tmp = data.value("qml").toObject(); QStringList mustexist; mustexist << tmp.value("exec").toString(); ok = !mustexist.isEmpty(); //exec file should **always** be listed QJsonArray tmpA = data.value("additional_files").toArray(); for(int i=0; i SSPluginSystem::findAllPlugins(bool validonly = true){ QList LIST; //Get the list of directories to search QStringList dirs; dirs << QString(getenv("XDG_DATA_HOME")) << QString(getenv("XDG_DATA_DIRS")).split(":"); //Look for that file within these directories and return the first one found for(int i=0; i