diff options
author | Ken Moore <moorekou@gmail.com> | 2015-05-01 13:44:00 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-05-01 13:44:00 -0400 |
commit | 23ea2d2de84298a3fdd6198966f424e984e01874 (patch) | |
tree | cadf01ae70bd17d1b2baecb13d354e8c2c651bbd /libLumina/LuminaXDG.cpp | |
parent | Merge pull request #105 from william-os4y/fileinfo2 (diff) | |
parent | improve the decision regarding valid desktop files by check if Name and Type ... (diff) | |
download | lumina-23ea2d2de84298a3fdd6198966f424e984e01874.tar.gz lumina-23ea2d2de84298a3fdd6198966f424e984e01874.tar.bz2 lumina-23ea2d2de84298a3fdd6198966f424e984e01874.zip |
Merge pull request #104 from william-os4y/fileinfo
LXDG::loadDesktopFile improvement proposition
Diffstat (limited to 'libLumina/LuminaXDG.cpp')
-rw-r--r-- | libLumina/LuminaXDG.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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; } |