1 //=========================================== 2 // Lumina-desktop source code 3 // Copyright (c) 2017, Ken Moore 4 // Available under the 3-clause BSD license 5 // See the LICENSE file for full details 6 //=========================================== 7 #include "plugins-screensaver.h" 8 9 // ============ 10 // SS PLUGIN 11 // ============ SSPlugin()12SSPlugin::SSPlugin(){ 13 14 } 15 ~SSPlugin()16SSPlugin::~SSPlugin(){ 17 18 } 19 isValid()20bool SSPlugin::isValid(){ 21 if(data.isEmpty()){ return false; } 22 bool ok = data.contains("name") && data.contains("qml") && data.contains("description"); 23 ok &= containsDefault("name"); 24 ok &= containsDefault("description"); 25 if(ok) { 26 QJsonObject tmp = data.value("qml").toObject(); 27 QStringList mustexist; 28 QString exec = tmp.value("exec").toString(); 29 if(exec.isEmpty() || !exec.endsWith(".qml")){ return false; } 30 mustexist << exec; 31 QJsonArray tmpA = data.value("additional_files").toArray(); 32 for(int i=0; i<tmpA.count(); i++){ mustexist << tmpA[i].toString(); } 33 QString reldir = currentfile.section("/",0,-2) + "/"; 34 for(int i=0; i<mustexist.length() && ok; i++){ 35 if(mustexist[i].startsWith("/")){ ok = QFile::exists(mustexist[i]); } 36 else { ok = QFile::exists(reldir+mustexist[i]); } 37 } 38 } 39 return ok; 40 } 41