Commit 0bc44c44 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

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.
parent 0cb4c4ea
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "akonadicore_debug.h" #include "akonadicore_debug.h"
#include <Kdelibs4ConfigMigrator> #include <Kdelibs4ConfigMigrator>
#include <KLocalizedString>
#include "private/protocol_p.h" #include "private/protocol_p.h"
#include "private/standarddirs_p.h" #include "private/standarddirs_p.h"
...@@ -128,6 +129,7 @@ public: ...@@ -128,6 +129,7 @@ public:
QScopedPointer<QTimer> mSafetyTimer; QScopedPointer<QTimer> mSafetyTimer;
Firstrun *mFirstRunner; Firstrun *mFirstRunner;
static Internal::ClientType clientType; static Internal::ClientType clientType;
QString mBrokenReason;
}; };
int ServerManagerPrivate::serverProtocolVersion = -1; int ServerManagerPrivate::serverProtocolVersion = -1;
...@@ -235,6 +237,7 @@ ServerManager::State ServerManager::state() ...@@ -235,6 +237,7 @@ ServerManager::State ServerManager::state()
ServerManager::State previousState = NotRunning; 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 if (sInstance.exists()) { // be careful, this is called from the ServerManager::Private ctor, so using sInstance unprotected can cause infinite recursion
previousState = sInstance->mState; previousState = sInstance->mState;
sInstance->mBrokenReason.clear();
} }
const bool serverUpgrading = KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(ServerManager::serviceName(ServerManager::UpgradeIndicator)); const bool serverUpgrading = KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(ServerManager::serviceName(ServerManager::UpgradeIndicator));
...@@ -248,7 +251,10 @@ ServerManager::State ServerManager::state() ...@@ -248,7 +251,10 @@ ServerManager::State ServerManager::state()
// check if the server protocol is recent enough // check if the server protocol is recent enough
if (sInstance.exists()) { if (sInstance.exists()) {
if (Internal::serverProtocolVersion() >= 0 && 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; return Broken;
} }
} }
...@@ -262,6 +268,9 @@ ServerManager::State ServerManager::state() ...@@ -262,6 +268,9 @@ ServerManager::State ServerManager::state()
return Running; return Running;
} }
} }
if (sInstance.exists()) {
sInstance->mBrokenReason = i18n("There are no Akonadi Agents available. Please verify your KDE PIM installation.");
}
return Broken; return Broken;
} else { } else {
return Running; return Running;
...@@ -288,6 +297,14 @@ ServerManager::State ServerManager::state() ...@@ -288,6 +297,14 @@ ServerManager::State ServerManager::state()
return NotRunning; return NotRunning;
} }
QString ServerManager::brokenReason()
{
if (sInstance.exists()) {
return sInstance->mBrokenReason;
}
return QString();
}
QString ServerManager::instanceIdentifier() QString ServerManager::instanceIdentifier()
{ {
return Instance::identifier(); return Instance::identifier();
......
...@@ -95,6 +95,17 @@ public: ...@@ -95,6 +95,17 @@ public:
*/ */
static State state(); 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 * 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 * an empty string (representing the default instance), unless you have explicitly set
......
...@@ -234,6 +234,11 @@ void ErrorOverlay::serverStateChanged(ServerManager::State state) ...@@ -234,6 +234,11 @@ void ErrorOverlay::serverStateChanged(ServerManager::State state)
break; break;
case ServerManager::Broken: case ServerManager::Broken:
ui->stackWidget->setCurrentWidget(ui->brokenPage); 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; break;
case ServerManager::Starting: case ServerManager::Starting:
ui->progressPage->setToolTip(i18n("Personal information management service is starting...")); ui->progressPage->setToolTip(i18n("Personal information management service is starting..."));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment