From d845c59e78ae6f1ebe831d896a760e9e4839ca4e Mon Sep 17 00:00:00 2001 From: wi Date: Thu, 30 Apr 2015 19:38:51 +0200 Subject: improve the decision regarding valid desktop files by check if Name and Type are well present. --- libLumina/LuminaXDG.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libLumina') diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index 57757fc9..95d3ab02 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -16,6 +16,8 @@ static qint64 mimechecktime; XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ //Create the outputs ok=false; + //following the specifications, Name and Type are the mandatory in any .desktop file + bool hasName=false, hasType=false; XDGDesktop DF; DF.isHidden=false; DF.useTerminal=false; @@ -51,6 +53,7 @@ XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ if(var=="Name"){ if(DF.name.isEmpty() && loc.isEmpty()){ DF.name = val; } else if(loc == lang){ DF.name = val; } + hasName = true; }else if(var=="GenericName"){ if(DF.genericName.isEmpty() && loc.isEmpty()){ DF.genericName = val; } else if(loc == lang){ DF.genericName = val; } @@ -84,6 +87,7 @@ XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ else if(val.toLower()=="link"){ DF.type = XDGDesktop::LINK; } else if(val.toLower()=="dir"){ DF.type = XDGDesktop::DIR; } else{ DF.type = XDGDesktop::BAD; } //Unknown type + hasType = true; } } //end reading file file.close(); @@ -105,7 +109,7 @@ XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ DF.catList << "Wine"; //Internal Lumina category only (not in XDG specs as of 11/14/14) } //Return the structure - ok=true; + if (hasName && hasType) ok = true; //without Name and Type, the structure cannot be a valid .desktop file return DF; } -- cgit