Commit 35dba2bc authored by pvuorela's avatar pvuorela

Merge branch 'jb30284' into 'master'

[ssucli] Improve warnings when D-Bus is unavailable. Contribute to JB#30284

See merge request !8
parents 253ffd6f a3a07a77
...@@ -99,7 +99,7 @@ void SsuCli::optFlavour(QStringList opt) ...@@ -99,7 +99,7 @@ void SsuCli::optFlavour(QStringList opt)
QDBusPendingReply<> reply = ssuProxy->setFlavour(opt.at(2)); QDBusPendingReply<> reply = ssuProxy->setFlavour(opt.at(2));
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
ssu.setFlavour(opt.at(2)); ssu.setFlavour(opt.at(2));
SsuRepoManager repoManager; SsuRepoManager repoManager;
...@@ -156,7 +156,7 @@ void SsuCli::optMode(QStringList opt) ...@@ -156,7 +156,7 @@ void SsuCli::optMode(QStringList opt)
QDBusPendingReply<> reply = ssuProxy->setDeviceMode(opt.at(2).toInt()); QDBusPendingReply<> reply = ssuProxy->setDeviceMode(opt.at(2).toInt());
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
ssu.setDeviceMode(Ssu::DeviceModeFlags(opt.at(2).toInt())); ssu.setDeviceMode(Ssu::DeviceModeFlags(opt.at(2).toInt()));
SsuRepoManager repoManager; SsuRepoManager repoManager;
...@@ -193,7 +193,7 @@ void SsuCli::optModifyRepo(enum Actions action, QStringList opt) ...@@ -193,7 +193,7 @@ void SsuCli::optModifyRepo(enum Actions action, QStringList opt)
QDBusPendingReply<> reply = ssuProxy->modifyRepo(action, opt.at(2)); QDBusPendingReply<> reply = ssuProxy->modifyRepo(action, opt.at(2));
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
switch (action) { switch (action) {
case Add: case Add:
...@@ -235,7 +235,7 @@ void SsuCli::optModifyRepo(enum Actions action, QStringList opt) ...@@ -235,7 +235,7 @@ void SsuCli::optModifyRepo(enum Actions action, QStringList opt)
QDBusPendingReply<> reply = ssuProxy->addRepo(repo, url); QDBusPendingReply<> reply = ssuProxy->addRepo(repo, url);
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
repoManager.add(repo, url); repoManager.add(repo, url);
repoManager.update(); repoManager.update();
uidWarning(); uidWarning();
...@@ -278,8 +278,7 @@ void SsuCli::optRegister(QStringList opt) ...@@ -278,8 +278,7 @@ void SsuCli::optRegister(QStringList opt)
QDBusPendingReply<> reply = ssuProxy->registerDevice(username, password); QDBusPendingReply<> reply = ssuProxy->registerDevice(username, password);
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
qerr << reply.error().message() << endl;
ssu.sendRegistration(username, password); ssu.sendRegistration(username, password);
} }
...@@ -303,7 +302,7 @@ void SsuCli::optRelease(QStringList opt) ...@@ -303,7 +302,7 @@ void SsuCli::optRelease(QStringList opt)
QDBusPendingReply<> reply = ssuProxy->setRelease(opt.at(2), false); QDBusPendingReply<> reply = ssuProxy->setRelease(opt.at(2), false);
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
ssu.setRelease(opt.at(2)); ssu.setRelease(opt.at(2));
SsuRepoManager repoManager; SsuRepoManager repoManager;
...@@ -324,7 +323,7 @@ void SsuCli::optRelease(QStringList opt) ...@@ -324,7 +323,7 @@ void SsuCli::optRelease(QStringList opt)
QDBusPendingReply<> reply = ssuProxy->setRelease(opt.at(3), true); QDBusPendingReply<> reply = ssuProxy->setRelease(opt.at(3), true);
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
ssu.setRelease(opt.at(3), true); ssu.setRelease(opt.at(3), true);
SsuRepoManager repoManager; SsuRepoManager repoManager;
...@@ -594,7 +593,7 @@ void SsuCli::optUpdateRepos(QStringList opt) ...@@ -594,7 +593,7 @@ void SsuCli::optUpdateRepos(QStringList opt)
QDBusPendingReply<> reply = ssuProxy->updateRepos(); QDBusPendingReply<> reply = ssuProxy->updateRepos();
reply.waitForFinished(); reply.waitForFinished();
if (reply.isError()) { if (reply.isError()) {
qerr << "DBus call failed, falling back to libssu" << endl; qerr << fallingBackToDirectUse(reply.error()) << endl;
SsuRepoManager repoManager; SsuRepoManager repoManager;
repoManager.update(); repoManager.update();
uidWarning(); uidWarning();
...@@ -738,3 +737,11 @@ void SsuCli::usage(QString message) ...@@ -738,3 +737,11 @@ void SsuCli::usage(QString message)
qout.flush(); qout.flush();
QCoreApplication::exit(1); QCoreApplication::exit(1);
} }
QString SsuCli::fallingBackToDirectUse(const QDBusError &reason) const
{
if (reason.type() == QDBusError::Disconnected)
return QStringLiteral("DBus unavailable, falling back to libssu");
else
return QStringLiteral("WARNING: DBus call failed, falling back to libssu: ") + reason.message();
}
...@@ -78,6 +78,8 @@ private: ...@@ -78,6 +78,8 @@ private:
UserError UserError
}; };
QString fallingBackToDirectUse(const QDBusError &error) const;
private slots: private slots:
void handleResponse(); void handleResponse();
void handleDBusResponse(); void handleDBusResponse();
......
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