Comment 17 for bug 353278

Revision history for this message
gwydion.dot (gwydion-dot) wrote :

      if ( Transaction *t = m_client->updateSystem() ) {
            KpkTransaction *frm = new KpkTransaction(t, KpkTransaction::Modal | KpkTransaction::CloseOnFinish, this);
            connect(frm, SIGNAL(kTransactionFinished(KpkTransaction::ExitStatus)),
                    this, SLOT(displayUpdates(KpkTransaction::ExitStatus)));
            frm->show();
        } else {
            KMessageBox::sorry(this,
                               i18n("You don't have the necessary privileges to perform this action."),
                               i18n("Failed to update system"));
        }

Yay, I found it again.

"if ( Transaction *t = m_client->updateSystem() ) "
"if ( Transaction *t = Client::instance()->installFiles(files, true))"

"PackageKit::Transaction" Ok, here we use packagekit.

updateSystem() will do this:

Transaction* Client::updateSystem()
{
 if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_UPDATE)) {
  emit authError(AUTH_SYSTEM_UPDATE);
  return NULL;
 }

 Transaction* t = d->createNewTransaction();

 t->d->p->UpdateSystem();

 return t;
}

A sweet bool:
bool getAuth(const QString& action);

Some more about getAuth().
#ifdef USE_SECURITY_POLKIT
bool PolkitClient::getAuth(const QString &action) {
 DBusError e;
 dbus_error_init(&e);

 if(polkit_check_auth(QCoreApplication::applicationPid(), action.toAscii().data(), NULL))
  return true;

 bool auth = polkit_auth_obtain(action.toAscii().data(), 0, QCoreApplication::applicationPid(), &e);
 if(!auth) {
  qDebug() << "Authentification error :" << e.name << ":" << e.message;
 }

 return auth;
}
#else
bool PolkitClient::getAuth(const QString &action) {
 qDebug() << "Not configured with PolicyKit support";
 return false;
}
#endif

Now, the big question, why it will not work?