Commit ad0fa0cf authored by Lukas Appelhans's avatar Lukas Appelhans

Fix the last 2 todos

parent c3c4e0f6
......@@ -38,7 +38,7 @@ class PolkitInstallOperation::Private
delete iface;
}
void __k__error(const QString &archive, const QString &message);
void __k__error(const QString &archive, int type, const QString &message);
void __k__installFinished(const QString &archive, bool success);
void __k__installProgress(const QString &archive, int progress);
void __k__installMessage(const QString &archive, const QString &message);
......@@ -83,7 +83,7 @@ void PolkitInstallOperation::run()
qDebug() << "Now let's do the dbus stuff";
if (!Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract")) {
if (!Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.install")) {
setErrors(Error::List() << Error(Error::PermissionError, QObject::tr("There has been an error with your polkit configuration!"), this));
setFinished(false);
return;
......@@ -92,7 +92,7 @@ void PolkitInstallOperation::run()
connect(d->iface, SIGNAL(finished(QString,bool)), SLOT(__k__installFinished(QString,bool)));
connect(d->iface, SIGNAL(newMessage(QString, QString)), SLOT(__k__installMessage(QString, QString)));
connect(d->iface, SIGNAL(updateProgress(QString, int)), SLOT(__k__installProgress(QString, int)));
connect(d->iface, SIGNAL(error(QString, QString)), SLOT(__k__error(QString,QString)));
connect(d->iface, SIGNAL(error(QString, int, QString)), SLOT(__k__error(QString, int, QString)));
d->iface->asyncCall("install", d->package->pathToArchive(), Akabei::Config::instance()->root(), (int) processingOptions(), d->reason, Akabei::Backend::instance()->localDatabase()->name());
}
......@@ -108,10 +108,10 @@ void PolkitInstallOperation::Private::__k__installMessage(const QString &archive
q->addMessage(message);
}
void PolkitInstallOperation::Private::__k__error(const QString& archive, const QString& message)
void PolkitInstallOperation::Private::__k__error(const QString& archive, int type, const QString& message)
{
if (archive == package->pathToArchive()) {
q->setErrors(q->errors() << Akabei::Error(Error::AkabeiInternalError, message, q));//FIXME: Also the error enum?
q->setErrors(q->errors() << Akabei::Error((Error::Type)type, message, q));//FIXME: Also the error enum?
}
}
......
......@@ -39,7 +39,7 @@ private:
Q_PRIVATE_SLOT(d, void __k__installFinished(QString, bool))
Q_PRIVATE_SLOT(d, void __k__installProgress(QString, int))
Q_PRIVATE_SLOT(d, void __k__installMessage(QString, QString))
Q_PRIVATE_SLOT(d, void __k__error(QString, QString))
Q_PRIVATE_SLOT(d, void __k__error(QString, int, QString))
};
}
......
......@@ -36,7 +36,7 @@ public:
void __k__polkitFinished(const QString &archive, bool success);
void __k__progressUpdated(const QString &archive, int progress);
void __k__newMessage(const QString &archive, const QString &message);
void __k__error(const QString &archive, const QString &error);
void __k__error(const QString &archive, int type, const QString &error);
void __k__removeFileProgress(int progress);
void __k__removeFileFinished();
void __k__removeFileErrors(const QStringList &errors);
......@@ -131,7 +131,7 @@ void PolkitReInstallOperation::Private::__k__removeFileFinished()
qDebug() << "Now let's do the dbus stuff";
if (!Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract")) {
if (!Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.install")) {
q->setErrors(Error::List() << Error(Error::PermissionError, QObject::tr("There has been an error with your polkit configuration!"), q));
q->setFinished(false);
return;
......@@ -140,7 +140,7 @@ void PolkitReInstallOperation::Private::__k__removeFileFinished()
q->connect(iface, SIGNAL(finished(QString, bool)), SLOT(__k__polkitFinished(QString, bool)));
q->connect(iface, SIGNAL(newMessage(QString, QString)), SLOT(__k__newMessage(QString, QString)));
q->connect(iface, SIGNAL(updateProgress(QString, int)), SLOT(__k__progressUpdated(QString, int)));
q->connect(iface, SIGNAL(error(QString,QString)), SLOT(__k__error(QString,QString)));
q->connect(iface, SIGNAL(error(QString,int,QString)), SLOT(__k__error(QString,int,QString)));
Package::InstallReason reason = package->installReason();
if (q->processingOptions().testFlag(InstallAsDependencies)) {
......@@ -161,7 +161,7 @@ void PolkitReInstallOperation::Private::__k__polkitFinished(const QString &archi
q->disconnect(iface, SIGNAL(finished(QString, bool)), q, SLOT(__k__polkitFinished(QString, bool)));
q->disconnect(iface, SIGNAL(newMessage(QString, QString)), q, SLOT(__k__newMessage(QString, QString)));
q->disconnect(iface, SIGNAL(updateProgress(QString, int)), q, SLOT(__k__progressUpdated(QString, int)));
q->disconnect(iface, SIGNAL(error(QString,QString)), q, SLOT(__k__error(QString,QString)));
q->disconnect(iface, SIGNAL(error(QString,int,QString)), q, SLOT(__k__error(QString,int,QString)));
// Done!
qDebug() << "Before log" << QTime::currentTime();
......@@ -183,10 +183,10 @@ void PolkitReInstallOperation::Private::__k__newMessage(const QString &archive,
q->addMessage(message);
}
void PolkitReInstallOperation::Private::__k__error(const QString &archive, const QString &error)
void PolkitReInstallOperation::Private::__k__error(const QString &archive, int type, const QString &error)
{
if (archive == package->pathToArchive()) {
q->setErrors(q->errors() << Error(Error::AkabeiInternalError, error, q));
q->setErrors(q->errors() << Error((Error::Type)type, error, q));
}
}
......
......@@ -37,7 +37,7 @@ private:
Q_PRIVATE_SLOT(d, void __k__polkitFinished(QString, bool))
Q_PRIVATE_SLOT(d, void __k__progressUpdated(QString, int))
Q_PRIVATE_SLOT(d, void __k__newMessage(QString, QString))
Q_PRIVATE_SLOT(d, void __k__error(QString,QString))
Q_PRIVATE_SLOT(d, void __k__error(QString,int,QString))
Q_PRIVATE_SLOT(d, void __k__removeFileProgress(int))
Q_PRIVATE_SLOT(d, void __k__removeFileFinished())
Q_PRIVATE_SLOT(d, void __k__removeFileErrors(QStringList))
......
......@@ -41,7 +41,7 @@ class PolkitUpgradeOperation::Private
void __k__polkitFinished(const QString &archive, bool success);
void __k__progressUpdated(const QString &archive, int progress);
void __k__newMessage(const QString &archive, const QString &message);
void __k__error(const QString &archive, const QString &error);
void __k__error(const QString &archive, int type, const QString &error);
void __k__removeFileProgress(int progress);
void __k__removeFileFinished();
void __k__removeFileErrors(const QStringList &errors);
......@@ -137,7 +137,7 @@ void PolkitUpgradeOperation::Private::__k__removeFileFinished()
qDebug() << "Now let's do the dbus stuff";
if (!Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract")) {
if (!Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.install")) {
q->setErrors(Error::List() << Error(Error::PermissionError, QObject::tr("There has been an error with your polkit configuration!"), q));
q->setFinished(false);
return;
......@@ -146,7 +146,7 @@ void PolkitUpgradeOperation::Private::__k__removeFileFinished()
q->connect(iface, SIGNAL(finished(QString, bool)), SLOT(__k__polkitFinished(QString, bool)));
q->connect(iface, SIGNAL(newMessage(QString, QString)), SLOT(__k__newMessage(QString, QString)));
q->connect(iface, SIGNAL(updateProgress(QString, int)), SLOT(__k__progressUpdated(QString, int)));
q->connect(iface, SIGNAL(error(QString,QString)), SLOT(__k__error(QString,QString)));
q->connect(iface, SIGNAL(error(QString,int,QString)), SLOT(__k__error(QString,int,QString)));
Package::InstallReason reason = from->installReason();
if (q->processingOptions().testFlag(InstallAsDependencies)) {
......@@ -167,7 +167,7 @@ void PolkitUpgradeOperation::Private::__k__polkitFinished(const QString &archive
q->disconnect(iface, SIGNAL(finished(QString)), q, SLOT(__k__polkitFinished(QString)));
q->disconnect(iface, SIGNAL(newMessage(QString, QString)), q, SLOT(__k__newMessage(QString, QString)));
q->disconnect(iface, SIGNAL(updateProgress(QString, int)), q, SLOT(__k__progressUpdated(QString, int)));
q->disconnect(iface, SIGNAL(error(QString,QString)), q, SLOT(__k__error(QString,QString)));
q->disconnect(iface, SIGNAL(error(QString,int,QString)), q, SLOT(__k__error(QString,int,QString)));
if (!(q->processingOptions().testFlag(Akabei::DatabaseOnly))) {
// Add the archive to the cache.
......@@ -196,11 +196,11 @@ void PolkitUpgradeOperation::Private::__k__newMessage(const QString &archive, co
q->addMessage(message);
}
void PolkitUpgradeOperation::Private::__k__error(const QString &archive, const QString &message)
void PolkitUpgradeOperation::Private::__k__error(const QString &archive, int type, const QString &message)
{
if (archive != to->pathToArchive())
return;
q->setErrors(Error::List() << q->errors() << Error(Error::GenericError, message, q));
q->setErrors(Error::List() << q->errors() << Error((Error::Type)type, message, q));
}
void PolkitUpgradeOperation::validate()
......
......@@ -38,7 +38,7 @@ private:
Q_PRIVATE_SLOT(d, void __k__polkitFinished(QString, bool))
Q_PRIVATE_SLOT(d, void __k__progressUpdated(QString, int))
Q_PRIVATE_SLOT(d, void __k__newMessage(QString, QString))
Q_PRIVATE_SLOT(d, void __k__error(QString, QString))
Q_PRIVATE_SLOT(d, void __k__error(QString, int, QString))
Q_PRIVATE_SLOT(d, void __k__removeFileProgress(int))
Q_PRIVATE_SLOT(d, void __k__removeFileFinished())
Q_PRIVATE_SLOT(d, void __k__removeFileErrors(QStringList))
......
/*TODO: Stream error types over dbus
* Change polkit policies used to new ones
*/
/*
* <one line to give the library's name and an idea of what it does.>
* Copyright 2013 Lukas Appelhans <l.appelhans@gmx.de>
......@@ -61,8 +57,7 @@ void InstallHelper::setFinished(const QString &archive, bool success)
void InstallHelper::install(const QString& filename, const QString& root, int processingOptions, int reason, const QString &localdatabase)
{
qDebug() << "CALLED";
//FIXME: Change the policy to a new one?
PolkitQt1::Authority::Result auth = PolkitQt1::Authority::instance()->checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract",
PolkitQt1::Authority::Result auth = PolkitQt1::Authority::instance()->checkAuthorizationSync("org.chakraproject.akabeicorehelper.install",
PolkitQt1::SystemBusNameSubject(message().service()),
PolkitQt1::Authority::AllowUserInteraction);
if (auth != PolkitQt1::Authority::Yes || !CHECK_PID) {
......@@ -105,7 +100,7 @@ void InstallHelper::install(const QString& filename, const QString& root, int pr
int ret = Akabei::Helpers::QueryPerformer::beginTransaction(con);
if (ret != SQLITE_OK) {
// Problems...
emit error(filename, QObject::tr("Could not begin database transaction!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not begin database transaction!"));
setFinished(filename, false);
return;
}
......@@ -116,7 +111,7 @@ void InstallHelper::install(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not add package to database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not add package to database!"));
setFinished(filename, false);
return;
}
......@@ -126,7 +121,7 @@ void InstallHelper::install(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not add files to database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not add files to database!"));
setFinished(filename, false);
return;
}
......@@ -137,7 +132,7 @@ void InstallHelper::install(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not add scriptlet to database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not add scriptlet to database!"));
setFinished(filename, false);
return;
}
......@@ -148,7 +143,7 @@ void InstallHelper::install(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not commit the transaction!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not commit the transaction!"));
setFinished(filename, false);
return;
}
......@@ -162,8 +157,7 @@ void InstallHelper::install(const QString& filename, const QString& root, int pr
void InstallHelper::upgrade(const QString& filename, const QString& root, int processingOptions, int reason, const QString &localdatabase)
{
qDebug() << "CALLED upgrade";
//FIXME: Change the policy to a new one?
PolkitQt1::Authority::Result auth = PolkitQt1::Authority::instance()->checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract",
PolkitQt1::Authority::Result auth = PolkitQt1::Authority::instance()->checkAuthorizationSync("org.chakraproject.akabeicorehelper.install",
PolkitQt1::SystemBusNameSubject(message().service()),
PolkitQt1::Authority::AllowUserInteraction);
if (auth != PolkitQt1::Authority::Yes || !CHECK_PID) {
......@@ -207,7 +201,7 @@ void InstallHelper::upgrade(const QString& filename, const QString& root, int pr
int ret = Akabei::Helpers::QueryPerformer::beginTransaction(con);
if (ret != SQLITE_OK) {
// Problems...
emit error(filename, QObject::tr("Could not begin database transaction!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not begin database transaction!"));
setFinished(filename, false);
return;
}
......@@ -220,7 +214,7 @@ void InstallHelper::upgrade(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not update package in database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not update package in database!"));
setFinished(filename, false);
return;
}
......@@ -230,7 +224,7 @@ void InstallHelper::upgrade(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not update files in database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not update files in database!"));
setFinished(filename, false);
return;
}
......@@ -244,7 +238,7 @@ void InstallHelper::upgrade(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not update scriptlet in database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not update scriptlet in database!"));
setFinished(filename, false);
return;
}
......@@ -254,7 +248,7 @@ void InstallHelper::upgrade(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not add scriptlet to database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not add scriptlet to database!"));
setFinished(filename, false);
return;
}
......@@ -264,7 +258,7 @@ void InstallHelper::upgrade(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not remove scriplet from database!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not remove scriplet from database!"));
setFinished(filename, false);
return;
}
......@@ -275,7 +269,7 @@ void InstallHelper::upgrade(const QString& filename, const QString& root, int pr
if (ret != SQLITE_OK) {
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(con);
emit error(filename, QObject::tr("Could not commit the transaction!"));
emit error(filename, Akabei::Error::DatabaseError, QObject::tr("Could not commit the transaction!"));
setFinished(filename, false);
return;
}
......
......@@ -40,7 +40,7 @@ public Q_SLOTS:
void upgrade(const QString &filename, const QString &root, int processingOptions, int reason, const QString &localdatabase);
signals:
void error(const QString &archive, const QString &errorMessage);
void error(const QString &archive, int type, const QString &errorMessage);
void finished(const QString &archive, bool success);
void newMessage(const QString &archive, const QString &message);
void updateProgress(const QString &archive, int progress);
......
......@@ -99,4 +99,14 @@
<allow_inactive>auth_admin_keep</allow_inactive>
</defaults>
</action>
<action id="org.chakraproject.akabeicorehelper.install" >
<description>Installs a package</description>
<message>Allows akabei to install a package</message>
<defaults>
<allow_any>yes</allow_any>
<allow_active>yes</allow_active>
<allow_inactive>yes</allow_inactive>
</defaults>
</action>
</policyconfig>
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