Commit c42cff3d authored by Adrián Chaves's avatar Adrián Chaves

Use PolkitQt1::Authority::checkAuthorizationSync

We where using the asynchronous version of the method, but we where using it synchronously,
probably coded before the synchronous version was implemented upstream.
parent 42011486
......@@ -405,39 +405,12 @@ Permissions permissionsOfPath(const QString &path)
return perm;
}
AuthorityLoop::AuthorityLoop(QObject* parent)
: QEventLoop(parent), m_result(PolkitQt1::Authority::No)
{
}
AuthorityLoop::~AuthorityLoop() {}
PolkitQt1::Authority::Result AuthorityLoop::result()
{
return m_result;
}
void AuthorityLoop::quit(PolkitQt1::Authority::Result res)
{
m_result = res;
QEventLoop::quit();
}
bool checkAuthorizationSync(const QString &action)
{
AuthorityLoop e;
QObject::connect(PolkitQt1::Authority::instance(), SIGNAL(checkAuthorizationFinished(PolkitQt1::Authority::Result)), &e, SLOT(quit(PolkitQt1::Authority::Result)));
PolkitQt1::Authority::instance()->checkAuthorization(action,
PolkitQt1::UnixProcessSubject(static_cast<uint>(QCoreApplication::applicationPid())),
PolkitQt1::Authority::AllowUserInteraction);
e.exec();
QObject::disconnect(PolkitQt1::Authority::instance(), SIGNAL(checkAuthorizationFinished(PolkitQt1::Authority::Result)), &e, SLOT(quit(PolkitQt1::Authority::Result)));
return e.result() == PolkitQt1::Authority::Yes;
return PolkitQt1::Authority::Yes == PolkitQt1::Authority::instance()->checkAuthorizationSync(
action,
PolkitQt1::UnixProcessSubject(static_cast<uint>(QCoreApplication::applicationPid())),
PolkitQt1::Authority::AllowUserInteraction);
}
///////
......
......@@ -24,23 +24,6 @@ namespace Helpers
int compare_versions(QString const& a, QString const& b);
QStringList stringlistFromDb(const QString &);
QByteArray md5sumOfFileWithoutPolkit(const QString &file);
class AuthorityLoop : public QEventLoop
{
Q_OBJECT
Q_DISABLE_COPY(AuthorityLoop)
public:
AuthorityLoop(QObject* parent = nullptr);
virtual ~AuthorityLoop();
PolkitQt1::Authority::Result result();
public Q_SLOTS:
virtual void quit(PolkitQt1::Authority::Result res);
private:
PolkitQt1::Authority::Result m_result;
};
}
}
......
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