[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kcm-grub2] src: *FIXED: Check for the memtest script in the helper.
From:       Konstantinos Smanis <konstantinos.smanis () gmail ! com>
Date:       2013-10-11 9:14:36
Message-ID: E1VUYns-0001Mi-Of () scm ! kde ! org
[Download RAW message or body]

Git commit 27322ef961eb6737d1d28e8686c87ecb40476344 by Konstantinos Smanis.
Committed on 11/10/2013 at 09:10.
Pushed by ksmanis into branch 'master'.

*FIXED: Check for the memtest script in the helper.

If the memtest script can't be found, make a request to the helper to
check if it really exists. There are cases (e.g. in Fedora Rawhide)
where the script is invisible to the user because of the permissions of
the directory holding it (drwx------ root:root).

M  +7    -0    src/helper/helper.cpp
M  +39   -18   src/kcm_grub2.cpp
M  +6    -1    src/kcm_grub2.h

http://commits.kde.org/kcm-grub2/27322ef961eb6737d1d28e8686c87ecb40476344

diff --git a/src/helper/helper.cpp b/src/helper/helper.cpp
index 20316a9..f9397bb 100644
--- a/src/helper/helper.cpp
+++ b/src/helper/helper.cpp
@@ -134,6 +134,13 @@ ActionReply Helper::load(QVariantMap args)
     case GrubEnvironmentFile:
         fileName = GRUB_ENV;
         break;
+    case GrubMemtestFile:
+        bool memtest = QFile::exists(GRUB_MEMTEST);
+        reply.addData("memtest", memtest);
+        if (memtest) {
+            reply.addData("memtestOn", (bool)(QFile::permissions(GRUB_MEMTEST) & \
(QFile::ExeOwner | QFile::ExeGroup | QFile::ExeOther))); +        }
+        return reply;
     }
 
     QFile file(fileName);
diff --git a/src/kcm_grub2.cpp b/src/kcm_grub2.cpp
index b6b324d..1189a98 100644
--- a/src/kcm_grub2.cpp
+++ b/src/kcm_grub2.cpp
@@ -36,7 +36,6 @@
 #include <KPluginFactory>
 #include <KProgressDialog>
 #include <KAuth/ActionWatcher>
-using namespace KAuth;
 
 //Project
 #include "common.h"
@@ -97,6 +96,7 @@ void KCMGRUB2::load()
     readEntries();
     readSettings();
     readEnv();
+    readMemtest();
 #if HAVE_HD
     readResolutions();
 #endif
@@ -191,12 +191,8 @@ void KCMGRUB2::load()
     }
 
     ui->checkBox_recovery->setChecked(unquoteWord(m_settings.value("GRUB_DISABLE_RECOVERY")).compare("true") \
                != 0);
-    if (QFile::exists(GRUB_MEMTEST)) {
-        ui->checkBox_memtest->setVisible(true);
-        ui->checkBox_memtest->setChecked(QFile::permissions(GRUB_MEMTEST) & \
                (QFile::ExeOwner | QFile::ExeGroup | QFile::ExeOther));
-    } else {
-        ui->checkBox_memtest->setVisible(false);
-    }
+    ui->checkBox_memtest->setVisible(m_memtest);
+    ui->checkBox_memtest->setChecked(m_memtestOn);
     ui->checkBox_osProber->setChecked(unquoteWord(m_settings.value("GRUB_DISABLE_OS_PROBER")).compare("true") \
!= 0);  
     m_resolutions.append("640x480");
@@ -960,6 +956,19 @@ QString KCMGRUB2::convertToLocalFileName(const QString \
&grubFileName)  return fileName;
 }
 
+ActionReply KCMGRUB2::loadFile(GrubFile grubFile)
+{
+    Action loadAction("org.kde.kcontrol.kcmgrub2.load");
+    loadAction.setHelperID("org.kde.kcontrol.kcmgrub2");
+    loadAction.addArgument("grubFile", grubFile);
+#if KDE_IS_VERSION(4,6,0)
+    loadAction.setParentWidget(this);
+#endif
+
+    ActionReply reply = loadAction.execute();
+    processReply(reply);
+    return reply;
+}
 QString KCMGRUB2::readFile(GrubFile grubFile)
 {
     QString fileName;
@@ -983,17 +992,9 @@ QString KCMGRUB2::readFile(GrubFile grubFile)
         return stream.readAll();
     }
 
-    Action loadAction("org.kde.kcontrol.kcmgrub2.load");
-    loadAction.setHelperID("org.kde.kcontrol.kcmgrub2");
-    loadAction.addArgument("grubFile", grubFile);
-#if KDE_IS_VERSION(4,6,0)
-    loadAction.setParentWidget(this);
-#endif
-
-    ActionReply reply = loadAction.execute();
-    processReply(reply);
+    ActionReply reply = loadFile(grubFile);
     if (reply.failed()) {
-        kError() << "Error reading:" << fileName;
+        kError() << "Error loading:" << fileName;
         kError() << "Error description:" << reply.errorDescription();
         return QString();
     }
@@ -1020,6 +1021,26 @@ void KCMGRUB2::readEnv()
     m_env.clear();
     parseEnv(fileContents);
 }
+void KCMGRUB2::readMemtest()
+{
+    bool memtest = QFile::exists(GRUB_MEMTEST);
+    if (memtest) {
+        m_memtest = true;
+        m_memtestOn = (bool)(QFile::permissions(GRUB_MEMTEST) & (QFile::ExeOwner | \
QFile::ExeGroup | QFile::ExeOther)); +        return;
+    }
+
+    ActionReply reply = loadFile(GrubMemtestFile);
+    if (reply.failed()) {
+        kError() << "Error loading:" << GRUB_MEMTEST;
+        kError() << "Error description:" << reply.errorDescription();
+        return;
+    }
+    m_memtest = reply.data().value("memtest").toBool();
+    if (m_memtest) {
+        m_memtestOn = reply.data().value("memtestOn").toBool();
+    }
+}
 void KCMGRUB2::readDevices()
 {
     QStringList mountPoints;
@@ -1120,7 +1141,7 @@ void KCMGRUB2::showResolutions()
     }
 }
 
-void KCMGRUB2::processReply(KAuth::ActionReply &reply)
+void KCMGRUB2::processReply(ActionReply &reply)
 {
     if (reply.type() == ActionReply::Success || reply.type() == \
ActionReply::KAuthError) {  return;
diff --git a/src/kcm_grub2.h b/src/kcm_grub2.h
index 6afb0e0..5b2bff8 100644
--- a/src/kcm_grub2.h
+++ b/src/kcm_grub2.h
@@ -27,6 +27,7 @@ namespace KAuth
 {
     class ActionReply;
 }
+using namespace KAuth;
 
 //Project
 #include "config.h"
@@ -88,17 +89,19 @@ private:
     QString convertToGRUBFileName(const QString &fileName);
     QString convertToLocalFileName(const QString &grubFileName);
 
+    ActionReply loadFile(GrubFile grubFile);
     QString readFile(GrubFile grubFile);
     void readEntries();
     void readSettings();
     void readEnv();
+    void readMemtest();
     void readDevices();
     void readResolutions();
 
     void sortResolutions();
     void showResolutions();
 
-    void processReply(KAuth::ActionReply &reply);
+    void processReply(ActionReply &reply);
     QString parseTitle(const QString &line);
     void parseEntries(const QString &config);
     void parseSettings(const QString &config);
@@ -136,6 +139,8 @@ private:
     QList<Entry> m_entries;
     QHash<QString, QString> m_settings;
     QHash<QString, QString> m_env;
+    bool m_memtest;
+    bool m_memtestOn;
     QHash<QString, QString> m_devices;
     QStringList m_resolutions;
 };


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic