//=========================================== // 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 #include #include #include #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; QFile file(path); if(!file.exists() || !file.open(QIODevice::ReadOnly)){ return; } data = QJsonDocument::fromJson(file.readAll()).object(); //qDebug() << "Loaded ScreenSaver Data:" << currentfile << data; file.close(); } 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; QString exec = tmp.value("exec").toString(); if(exec.isEmpty() || !exec.endsWith(".qml")){ return false; } mustexist << exec; QJsonArray tmpA = data.value("additional_files").toArray(); for(int i=0; i SSPluginSystem::findAllPlugins(bool validonly){ 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