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?
if ( Transaction *t = m_client- >updateSystem( ) ) {
KpkTransac tion *frm = new KpkTransaction(t, KpkTransaction: :Modal | KpkTransaction: :CloseOnFinish, this);
connect( frm, SIGNAL( kTransactionFin ished(KpkTransa ction:: ExitStatus) ),
this, SLOT(displayUpd ates(KpkTransac tion::ExitStatu s)));
frm- >show() ;
KMessageBo x::sorry( this,
i18n( "You don't have the necessary privileges to perform this action."),
i18n( "Failed to update system"));
} else {
}
Yay, I found it again.
"if ( Transaction *t = m_client- >updateSystem( ) ) " :instance( )->installFiles (files, true))"
"if ( Transaction *t = Client:
"PackageKit: :Transaction" Ok, here we use packagekit.
updateSystem() will do this:
Transaction* Client: :updateSystem( ) nt::instance( )->getAuth( AUTH_SYSTEM_ UPDATE) ) { AUTH_SYSTEM_ UPDATE) ;
{
if(!PolkitClie
emit authError(
return NULL;
}
Transaction* t = d->createNewTra nsaction( );
t->d-> p->UpdateSystem ();
return t;
}
A sweet bool:
bool getAuth(const QString& action);
Some more about getAuth(). :getAuth( const QString &action) { init(&e) ;
#ifdef USE_SECURITY_POLKIT
bool PolkitClient:
DBusError e;
dbus_error_
if(polkit_ check_auth( QCoreApplicatio n::applicationP id(), action. toAscii( ).data( ), NULL))
return true;
bool auth = polkit_ auth_obtain( action. toAscii( ).data( ), 0, QCoreApplicatio n::applicationP id(), &e);
if(!auth) {
qDebug() << "Authentification error :" << e.name << ":" << e.message;
}
return auth; :getAuth( const QString &action) {
}
#else
bool PolkitClient:
qDebug() << "Not configured with PolicyKit support";
return false;
}
#endif
Now, the big question, why it will not work?