|
|
652846 |
diff --git a/powerdevil/daemon/powerdevilactionpool.cpp b/powerdevil/daemon/powerdevilactionpool.cpp
|
|
|
ff3475 |
index 970aa18..6ca0d57 100644
|
|
|
652846 |
--- a/powerdevil/daemon/powerdevilactionpool.cpp
|
|
|
652846 |
+++ b/powerdevil/daemon/powerdevilactionpool.cpp
|
|
|
ff3475 |
@@ -82,6 +82,7 @@ void ActionPool::clearCache()
|
|
|
652846 |
i.value()->deleteLater();
|
|
|
652846 |
i = m_actionPool.erase(i);
|
|
|
652846 |
}
|
|
|
652846 |
+ m_initErrors.clear();
|
|
|
652846 |
}
|
|
|
652846 |
|
|
|
652846 |
void ActionPool::init(PowerDevil::Core *parent)
|
|
|
ff3475 |
@@ -99,6 +100,7 @@ void ActionPool::init(PowerDevil::Core *parent)
|
|
|
652846 |
if (!retaction) {
|
|
|
652846 |
// Troubles...
|
|
|
652846 |
kWarning() << "failed to load" << offer->desktopEntryName();
|
|
|
652846 |
+ m_initErrors.insert(actionId, LoadFailed);
|
|
|
652846 |
continue;
|
|
|
652846 |
}
|
|
|
652846 |
|
|
|
ff3475 |
@@ -106,6 +108,7 @@ void ActionPool::init(PowerDevil::Core *parent)
|
|
|
652846 |
if (!retaction->isSupported()) {
|
|
|
652846 |
// Skip that
|
|
|
652846 |
retaction->deleteLater();
|
|
|
652846 |
+ m_initErrors.insert(actionId, NotSupported);
|
|
|
652846 |
continue;
|
|
|
652846 |
}
|
|
|
652846 |
|
|
|
ff3475 |
@@ -169,7 +172,13 @@ Action* ActionPool::loadAction(const QString& actionId, const KConfigGroup& grou
|
|
|
652846 |
|
|
|
652846 |
return retaction;
|
|
|
652846 |
} else {
|
|
|
652846 |
- // Hmm... troubles in configuration. Np, let's just return 0 and let the core handle this
|
|
|
652846 |
+ // may be a misconfiguration.
|
|
|
652846 |
+ // Set the error code and return 0 and let the caller handle this as it sees fit
|
|
|
652846 |
+ if (m_initErrors.contains(actionId)) {
|
|
|
652846 |
+ m_error = m_initErrors[actionId];
|
|
|
652846 |
+ } else { // no error recorded during initialisation, therefore action does not exist
|
|
|
652846 |
+ m_error = NoAction;
|
|
|
652846 |
+ }
|
|
|
652846 |
return 0;
|
|
|
652846 |
}
|
|
|
652846 |
}
|
|
|
ff3475 |
@@ -183,4 +192,9 @@ void ActionPool::unloadAllActiveActions()
|
|
|
652846 |
m_activeActions.clear();
|
|
|
652846 |
}
|
|
|
652846 |
|
|
|
652846 |
+ActionPool::ErrorCode ActionPool::error()
|
|
|
652846 |
+{
|
|
|
652846 |
+ return m_error;
|
|
|
652846 |
+}
|
|
|
ff3475 |
+
|
|
|
ff3475 |
}
|
|
|
ff3475 |
diff --git a/powerdevil/daemon/powerdevilactionpool.h b/powerdevil/daemon/powerdevilactionpool.h
|
|
|
ff3475 |
index ca436ff..816449e 100644
|
|
|
ff3475 |
--- a/powerdevil/daemon/powerdevilactionpool.h
|
|
|
ff3475 |
+++ b/powerdevil/daemon/powerdevilactionpool.h
|
|
|
ff3475 |
@@ -36,6 +36,11 @@ class Action;
|
|
|
ff3475 |
class KDE_EXPORT ActionPool
|
|
|
ff3475 |
{
|
|
|
ff3475 |
public:
|
|
|
ff3475 |
+ enum ErrorCode {
|
|
|
ff3475 |
+ NoAction,
|
|
|
ff3475 |
+ LoadFailed,
|
|
|
ff3475 |
+ NotSupported
|
|
|
ff3475 |
+ };
|
|
|
ff3475 |
static ActionPool *instance();
|
|
|
ff3475 |
|
|
|
ff3475 |
virtual ~ActionPool();
|
|
|
ff3475 |
@@ -48,11 +53,15 @@ public:
|
|
|
ff3475 |
|
|
|
ff3475 |
void clearCache();
|
|
|
ff3475 |
|
|
|
ff3475 |
+ ErrorCode error();
|
|
|
ff3475 |
+
|
|
|
ff3475 |
private:
|
|
|
ff3475 |
ActionPool();
|
|
|
ff3475 |
|
|
|
ff3475 |
QHash< QString, Action* > m_actionPool;
|
|
|
ff3475 |
QStringList m_activeActions;
|
|
|
ff3475 |
+ ErrorCode m_error;
|
|
|
ff3475 |
+ QHash< QString, ErrorCode > m_initErrors;
|
|
|
ff3475 |
};
|
|
|
ff3475 |
|
|
|
652846 |
}
|
|
|
652846 |
diff --git a/powerdevil/daemon/powerdevilcore.cpp b/powerdevil/daemon/powerdevilcore.cpp
|
|
|
ff3475 |
index d096d74..c35b29d 100644
|
|
|
652846 |
--- a/powerdevil/daemon/powerdevilcore.cpp
|
|
|
652846 |
+++ b/powerdevil/daemon/powerdevilcore.cpp
|
|
|
ff3475 |
@@ -357,11 +357,23 @@ void Core::loadProfile(bool force)
|
|
|
652846 |
if (action) {
|
|
|
652846 |
action->onProfileLoad();
|
|
|
652846 |
} else {
|
|
|
652846 |
- // Ouch, error. But let's just warn and move on anyway
|
|
|
ff3475 |
- //TODO Maybe Remove from the configuration if unsupported
|
|
|
ff3475 |
- kWarning() << "The profile " << profileId << "tried to activate"
|
|
|
ff3475 |
- << actionName << "a non existent action. This is usually due to an installation problem"
|
|
|
ff3475 |
- " or to a configuration problem. or simlpy the action is not supported";
|
|
|
652846 |
+ switch (ActionPool::instance()->error()) {
|
|
|
652846 |
+ case ActionPool::NotSupported:
|
|
|
652846 |
+ kWarning().nospace() << "Attempted to load unsupported action " << actionName
|
|
|
652846 |
+ << ", skipping";
|
|
|
652846 |
+ break;
|
|
|
652846 |
+ case ActionPool::LoadFailed:
|
|
|
652846 |
+ kWarning() << "Action" << actionName << "failed during initialisation";
|
|
|
652846 |
+ // fallthrough
|
|
|
652846 |
+ case ActionPool::NoAction:
|
|
|
652846 |
+ default:
|
|
|
652846 |
+ // Ouch, error. But let's just warn and move on anyway
|
|
|
be9597 |
+ //TODO Maybe Remove from the configuration if unsupported
|
|
|
be9597 |
+ kWarning() << "The profile " << profileId << "tried to activate"
|
|
|
be9597 |
+ << actionName << "a non existent action. This is usually due to an installation problem"
|
|
|
be9597 |
+ " or to a configuration problem. or simlpy the action is not supported";
|
|
|
652846 |
+ break;
|
|
|
652846 |
+ }
|
|
|
652846 |
}
|
|
|
652846 |
}
|
|
|
652846 |
|