aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <[email protected]>2017-04-10 16:52:37 +0200
committerDaniel Vrátil <[email protected]>2017-04-10 16:52:37 +0200
commit0bc44c448a302cf28f770e8c63d56c352a80b8d8 (patch)
treee1df77d9ff0ede7fa48bb62f5a190efdbe832448
parent0cb4c4ea316edc290f2426c893933a6149a83a97 (diff)
Show more detailed 'Broken' reason in ErrorOverlay
Try to provide some more details as to why the server is considered to be 'Broken' with possible hint to the user how to fix it.
-rw-r--r--src/core/servermanager.cpp19
-rw-r--r--src/core/servermanager.h11
-rw-r--r--src/widgets/erroroverlay.cpp5
3 files changed, 34 insertions, 1 deletions
diff --git a/src/core/servermanager.cpp b/src/core/servermanager.cpp
index d988b3c..a9f2801 100644
--- a/src/core/servermanager.cpp
+++ b/src/core/servermanager.cpp
@@ -29,6 +29,7 @@
#include "akonadicore_debug.h"
#include <Kdelibs4ConfigMigrator>
+#include <KLocalizedString>
#include "private/protocol_p.h"
#include "private/standarddirs_p.h"
@@ -128,6 +129,7 @@ public:
QScopedPointer<QTimer> mSafetyTimer;
Firstrun *mFirstRunner;
static Internal::ClientType clientType;
+ QString mBrokenReason;
};
int ServerManagerPrivate::serverProtocolVersion = -1;
@@ -235,6 +237,7 @@ ServerManager::State ServerManager::state()
ServerManager::State previousState = NotRunning;
if (sInstance.exists()) { // be careful, this is called from the ServerManager::Private ctor, so using sInstance unprotected can cause infinite recursion
previousState = sInstance->mState;
+ sInstance->mBrokenReason.clear();
}
const bool serverUpgrading = KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(ServerManager::serviceName(ServerManager::UpgradeIndicator));
@@ -248,7 +251,10 @@ ServerManager::State ServerManager::state()
// check if the server protocol is recent enough
if (sInstance.exists()) {
if (Internal::serverProtocolVersion() >= 0 &&
- Internal::serverProtocolVersion() < Protocol::version()) {
+ Internal::serverProtocolVersion() != Protocol::version()) {
+ sInstance->mBrokenReason = i18n("The Akonadi server protocol version differs from the protocol version used by this application.\n"
+ "If you recently updated your system please log out and back in to make sure all applications use the "
+ "correct protocol version.");
return Broken;
}
}
@@ -262,6 +268,9 @@ ServerManager::State ServerManager::state()
return Running;
}
}
+ if (sInstance.exists()) {
+ sInstance->mBrokenReason = i18n("There are no Akonadi Agents available. Please verify your KDE PIM installation.");
+ }
return Broken;
} else {
return Running;
@@ -288,6 +297,14 @@ ServerManager::State ServerManager::state()
return NotRunning;
}
+QString ServerManager::brokenReason()
+{
+ if (sInstance.exists()) {
+ return sInstance->mBrokenReason;
+ }
+ return QString();
+}
+
QString ServerManager::instanceIdentifier()
{
return Instance::identifier();
diff --git a/src/core/servermanager.h b/src/core/servermanager.h
index 6568e2e..a3a18eb 100644
--- a/src/core/servermanager.h
+++ b/src/core/servermanager.h
@@ -96,6 +96,17 @@ public:
static State state();
/**
+ * Returns the reason why the Server is broken, if known.
+ *
+ * If state() is @p Broken, then you can use this method to obtain a more
+ * detailed description of the problem and present it to users. Note that
+ * the message can be empty if the reason is not known.
+ *
+ * @since 5.6
+ */
+ static QString brokenReason();
+
+ /**
* Returns the identifier of the Akonadi instance we are connected to. This is usually
* an empty string (representing the default instance), unless you have explicitly set
* the AKONADI_INSTANCE environment variable to connect to a different one.
diff --git a/src/widgets/erroroverlay.cpp b/src/widgets/erroroverlay.cpp
index b07ade3..ba0ab2f 100644
--- a/src/widgets/erroroverlay.cpp
+++ b/src/widgets/erroroverlay.cpp
@@ -234,6 +234,11 @@ void ErrorOverlay::serverStateChanged(ServerManager::State state)
break;
case ServerManager::Broken:
ui->stackWidget->setCurrentWidget(ui->brokenPage);
+ if (!ServerManager::brokenReason().isEmpty()) {
+ ui->brokenDescription->setText(
+ i18nc("%1 is a reason why", "Cannot connect to the Personal information management service.\n\n%1",
+ ServerManager::brokenReason()));
+ }
break;
case ServerManager::Starting:
ui->progressPage->setToolTip(i18n("Personal information management service is starting..."));