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 @@
#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();
......
......@@ -95,6 +95,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
......
......@@ -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..."));
......
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