summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <mirttex85-pk@yahoo.com.br>2008-07-03 21:20:03 -0300
committerDaniel Nicoletti <mirttex85-pk@yahoo.com.br>2008-07-03 21:20:03 -0300
commitc5de7ac75eb2e7e1bc4d0a869e1303a5b26ae82b (patch)
tree8e44bc667b908694165bde72b1ec5c65df9fe65d
parent75e125d8f6af2436289acb8fc7b0aa5d0f228ccd (diff)
Some fixes, and returning bool from the auth
-rwxr-xr-xgui/AddRm/PkAddRm.cpp1
-rw-r--r--gui/AddRm/PkAddRm.ui26
-rwxr-xr-xgui/AddRm/PkReviewChanges.cpp23
-rw-r--r--gui/AddRm/PkReviewChanges.ui2
-rw-r--r--lib/Daemon.cpp16
-rw-r--r--lib/Daemon.h4
-rw-r--r--lib/Transaction.cpp195
-rw-r--r--lib/Transaction.h30
8 files changed, 176 insertions, 121 deletions
diff --git a/gui/AddRm/PkAddRm.cpp b/gui/AddRm/PkAddRm.cpp
index 9a40e60..579d0c9 100755
--- a/gui/AddRm/PkAddRm.cpp
+++ b/gui/AddRm/PkAddRm.cpp
@@ -115,6 +115,7 @@ PkAddRm::PkAddRm( QWidget *parent )
// set fucus on the search lineEdit
lineEdit->setFocus(Qt::OtherFocusReason);
+ findPB->setDefault(true);
findPB->setIcon(m_findIcon);
infoHide();
}
diff --git a/gui/AddRm/PkAddRm.ui b/gui/AddRm/PkAddRm.ui
index 7c5ab6a..63d6010 100644
--- a/gui/AddRm/PkAddRm.ui
+++ b/gui/AddRm/PkAddRm.ui
@@ -150,7 +150,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex" >
- <number>0</number>
+ <number>3</number>
</property>
<property name="elideMode" >
<enum>Qt::ElideNone</enum>
@@ -182,8 +182,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>517</width>
- <height>141</height>
+ <width>513</width>
+ <height>142</height>
</rect>
</property>
<attribute name="title" >
@@ -207,8 +207,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>517</width>
- <height>141</height>
+ <width>513</width>
+ <height>142</height>
</rect>
</property>
<attribute name="title" >
@@ -235,8 +235,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>517</width>
- <height>141</height>
+ <width>513</width>
+ <height>142</height>
</rect>
</property>
<attribute name="title" >
@@ -334,6 +334,18 @@
<header>ktextbrowser.h</header>
</customwidget>
</customwidgets>
+ <tabstops>
+ <tabstop>lineEdit</tabstop>
+ <tabstop>findPB</tabstop>
+ <tabstop>filtersTB</tabstop>
+ <tabstop>groupsCB</tabstop>
+ <tabstop>packageView</tabstop>
+ <tabstop>tabWidget</tabstop>
+ <tabstop>descriptionKTB</tabstop>
+ <tabstop>filesPTE</tabstop>
+ <tabstop>dependsOnLV</tabstop>
+ <tabstop>requiredByLV</tabstop>
+ </tabstops>
<resources/>
<connections/>
</ui>
diff --git a/gui/AddRm/PkReviewChanges.cpp b/gui/AddRm/PkReviewChanges.cpp
index a00dadc..91ee5b4 100755
--- a/gui/AddRm/PkReviewChanges.cpp
+++ b/gui/AddRm/PkReviewChanges.cpp
@@ -181,10 +181,14 @@ void PkReviewChanges::removePackages()
{
qDebug() << "removePackages";
m_trans = m_daemon->newTransaction();
- PkTransaction *frm = new PkTransaction(m_trans, i18n("Remove Packages"), this);
- connect( frm, SIGNAL( Finished(bool) ), this, SLOT( remFinished(bool) ) );
- m_trans->removePackages(m_remPackages);
- frm->show();
+ if ( m_trans->removePackages(m_remPackages) ) {
+ PkTransaction *frm = new PkTransaction(m_trans, i18n("Remove Packages"), this);
+ connect( frm, SIGNAL( Finished(bool) ), this, SLOT( remFinished(bool) ) );
+ m_trans->removePackages(m_remPackages);
+ frm->show();
+ }
+ else
+ KMessageBox::error( this, i18n("Authentication failed"), i18n("KPackageKit") );
qDebug() << "finished remove";
}
@@ -223,10 +227,13 @@ void PkReviewChanges::installPackages()
{
qDebug() << "installPackages";
m_trans = m_daemon->newTransaction();
- PkTransaction *frm = new PkTransaction(m_trans, QString(i18n("Install Packages")), this);
- connect( frm, SIGNAL( Finished(bool) ), this, SLOT( addFinished(bool) ) );
- m_trans->installPackages(m_addPackages);
- frm->show();
+ if ( m_trans->installPackages(m_addPackages) ) {
+ PkTransaction *frm = new PkTransaction(m_trans, QString(i18n("Install Packages")), this);
+ connect( frm, SIGNAL( Finished(bool) ), this, SLOT( addFinished(bool) ) );
+ frm->show();
+ }
+ else
+ KMessageBox::error( this, i18n("Authentication failed"), i18n("KPackageKit") );
qDebug() << "finished install";
}
diff --git a/gui/AddRm/PkReviewChanges.ui b/gui/AddRm/PkReviewChanges.ui
index f992070..9cdc570 100644
--- a/gui/AddRm/PkReviewChanges.ui
+++ b/gui/AddRm/PkReviewChanges.ui
@@ -23,7 +23,7 @@
</font>
</property>
<property name="text" >
- <string>You selected the folowwing packages to be INSTALLED/REMOVED, press ok to proced:</string>
+ <string>You selected the folowing packages to be INSTALLED/REMOVED, press ok to proced:</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
diff --git a/lib/Daemon.cpp b/lib/Daemon.cpp
index a224857..b2065a6 100644
--- a/lib/Daemon.cpp
+++ b/lib/Daemon.cpp
@@ -66,11 +66,13 @@ bool Daemon::getNetworkState() {
return (state == "online");
}
-void Daemon::setProxy(const QString &http_proxy, const QString &ftp_proxy) {
- qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_SETPROXY)) emit AuthRefused("Cannot get authorization to set proxy");;
- qDebug() << "We're authentificated";
- proxy->SetProxy(http_proxy, ftp_proxy);
+bool Daemon::setProxy(const QString &http_proxy, const QString &ftp_proxy) {
+ qDebug() << "Trying to get authorization...";
+ if (polkit->getAuth(AUTH_SETPROXY))
+ proxy->SetProxy(http_proxy, ftp_proxy);
+ else
+ return false;
+ return true;
}
void Daemon::suggestQuit() {
@@ -89,10 +91,6 @@ QString Daemon::getTid() {
return proxy->GetTid();
}
-void Daemon::sendAuthRefused(const QString &message) {
- emit AuthRefused(message);
-}
-
void Daemon::NetworkStateChanged_cb(const QString &status) {
emit NetworkStateChanged((status == "online"));
}
diff --git a/lib/Daemon.h b/lib/Daemon.h
index 6a1ad49..30cad70 100644
--- a/lib/Daemon.h
+++ b/lib/Daemon.h
@@ -43,7 +43,7 @@ public:
uint getTimeSinceAction(Role::Value role);
bool getNetworkState();
- void setProxy(const QString &http_proxy, const QString &ftp_proxy);
+ bool setProxy(const QString &http_proxy, const QString &ftp_proxy);
void suggestQuit();
void stateHasChanged(const QString &reason);
@@ -51,7 +51,6 @@ public:
protected:
QString getTid();
- void sendAuthRefused(const QString &message);
private:
CentralProxy *proxy;
@@ -66,7 +65,6 @@ signals:
void TransactionListChanged(const QStringList &tids);
void RepoListChanged();
void RestartSchedule();
- void AuthRefused(const QString &message); // Called when PolicyKit auth fails
};
diff --git a/lib/Transaction.cpp b/lib/Transaction.cpp
index 498fba8..1d39793 100644
--- a/lib/Transaction.cpp
+++ b/lib/Transaction.cpp
@@ -129,85 +129,112 @@ void Transaction::resolve(const QString &filter, Package *p) {
proxy->Resolve(filter, p->id());
}
-void Transaction::installPackages(const QList<Package*> &packages) {
+bool Transaction::installPackages(const QList<Package*> &packages) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_INSTALL)) parent->sendAuthRefused("Cannot get authorization to install packages");
- qDebug() << "We're authentificated";
- renewTid();
- QStringList pids;
- for(int i = 0 ; i < packages.size() ; ++i) pids << packages.at(i)->id();
- proxy->InstallPackages(pids);
-}
-
-void Transaction::installPackage(Package *p) {
+ if (polkit->getAuth(AUTH_INSTALL)) {
+ renewTid();
+ QStringList pids;
+ for(int i = 0 ; i < packages.size() ; ++i) pids << packages.at(i)->id();
+ proxy->InstallPackages(pids);
+ }
+ else
+ return false;
+ return true;
+}
+
+bool Transaction::installPackage(Package *p) {
QList<Package*> packages;
packages << p;
- installPackages(packages);
+ return installPackages(packages);
}
-void Transaction::installSignature(const SignatureType::Value &type, const QString &key_id, Package *p) {
+bool Transaction::installSignature(const SignatureType::Value &type, const QString &key_id, Package *p) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_INSTALLSIGNATURE)) parent->sendAuthRefused("Cannot get authorization to install signature");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->InstallSignature(EnumToString<SignatureType>(type), key_id, p->id());
+ if (polkit->getAuth(AUTH_INSTALLSIGNATURE)) {
+ renewTid();
+ proxy->InstallSignature(EnumToString<SignatureType>(type), key_id, p->id());
+ }
+ else
+ return false;
+ return true;
}
-void Transaction::updatePackages(const QList<Package*> &packages) {
+bool Transaction::updatePackages(const QList<Package*> &packages) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_UPDATEPACKAGE)) parent->sendAuthRefused("Cannot get authorization to update packages");
- qDebug() << "We're authentificated";
- renewTid();
- QStringList pids;
- for(int i = 0 ; i < packages.size() ; ++i) pids << packages.at(i)->id();
- proxy->UpdatePackages(pids);
-}
-
-void Transaction::updatePackage(Package *p) {
- renewTid();
- QStringList pids;
- pids << p->id();
- proxy->UpdatePackages(pids);
-}
-
-void Transaction::installFiles(const QStringList& files, bool trusted) {
+ if (polkit->getAuth(AUTH_UPDATEPACKAGE)) {
+ renewTid();
+ QStringList pids;
+ for(int i = 0 ; i < packages.size() ; ++i) pids << packages.at(i)->id();
+ proxy->UpdatePackages(pids);
+ }
+ else
+ return false;
+ return true;
+}
+
+bool Transaction::updatePackage(Package *p) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth((trusted ? AUTH_LOCALINSTALLTRUSTED : AUTH_LOCALINSTALLUNTRUSTED))) parent->sendAuthRefused("Cannot get authorization to install files");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->InstallFiles(trusted, files);
-}
-
-void Transaction::removePackages(const QList<Package*> &packages, bool allow_deps, bool autoremove) {
+ if (polkit->getAuth(AUTH_UPDATEPACKAGE)) {
+ renewTid();
+ QStringList pids;
+ pids << p->id();
+ proxy->UpdatePackages(pids);
+ }
+ else
+ return false;
+ return true;
+}
+
+bool Transaction::installFiles(const QStringList& files, bool trusted) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_REMOVE)) parent->sendAuthRefused("Cannot get authorization to remove packages");
- qDebug() << "We're authentificated";
- renewTid();
- QStringList pids;
- for(int i = 0 ; i < packages.size() ; ++i) pids << packages.at(i)->id();
- proxy->RemovePackages(pids, allow_deps, autoremove);
+ if (polkit->getAuth((trusted ? AUTH_LOCALINSTALLTRUSTED : AUTH_LOCALINSTALLUNTRUSTED))) {
+ renewTid();
+ proxy->InstallFiles(trusted, files);
+ }
+ else
+ return false;
+ return true;
}
-void Transaction::removePackage(Package *p, bool allow_deps, bool autoremove) {
+bool Transaction::removePackages(const QList<Package*> &packages, bool allow_deps, bool autoremove) {
+ qDebug() << "Trying to get authorization...";
+ if (polkit->getAuth(AUTH_REMOVE)) {
+ renewTid();
+ QStringList pids;
+ for(int i = 0 ; i < packages.size() ; ++i) pids << packages.at(i)->id();
+ proxy->RemovePackages(pids, allow_deps, autoremove);
+ }
+ else
+ return false;
+ return true;
+}
+
+bool Transaction::removePackage(Package *p, bool allow_deps, bool autoremove) {
QList<Package*> packages;
packages << p;
- removePackages(packages, allow_deps, autoremove);
+ return removePackages(packages, allow_deps, autoremove);
}
-void Transaction::updateSystem() {
+bool Transaction::updateSystem() {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_UPDATESYSTEM)) parent->sendAuthRefused("Cannot get authorization to update system");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->UpdateSystem();
+ if (polkit->getAuth(AUTH_UPDATESYSTEM)) {
+ renewTid();
+ proxy->UpdateSystem();
+ }
+ else
+ return false;
+ return true;
}
-void Transaction::rollback(const QString &tid) {
+bool Transaction::rollback(const QString &tid) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_ROLLBACK)) parent->sendAuthRefused("Cannot get authorization to rollback a transaction");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->Rollback(tid);
+ if (polkit->getAuth(AUTH_ROLLBACK)) {
+ renewTid();
+ proxy->Rollback(tid);
+ }
+ else
+ return false;
+ return true;
}
void Transaction::getUpdates(const QString& filter) {
@@ -220,12 +247,15 @@ void Transaction::getUpdateDetail(const QString& package_id) {
proxy->GetUpdateDetail(package_id);
}
-void Transaction::refreshCache(bool force) {
+bool Transaction::refreshCache(bool force) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_REFRESHCACHE)) parent->sendAuthRefused("Cannot get authorization to refresh cache");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->RefreshCache(force);
+ if (polkit->getAuth(AUTH_REFRESHCACHE)) {
+ renewTid();
+ proxy->RefreshCache(force);
+ }
+ else
+ return false;
+ return true;
}
void Transaction::getProgress(uint &percentage, uint &subpercentage, uint &elapsed, uint &remaining) {
@@ -237,20 +267,26 @@ void Transaction::getRepoList(const QString &filter) {
proxy->GetRepoList(filter);
}
-void Transaction::repoEnable(const QString &repo_id, bool enabled) {
+bool Transaction::repoEnable(const QString &repo_id, bool enabled) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_REPOCHANGE)) parent->sendAuthRefused("Cannot get authorization to change a repository");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->RepoEnable(repo_id, enabled);
+ if (polkit->getAuth(AUTH_REPOCHANGE)) {
+ renewTid();
+ proxy->RepoEnable(repo_id, enabled);
+ }
+ else
+ return false;
+ return true;
}
-void Transaction::repoSetData(const QString &repo_id, const QString &parameter, const QString &value) {
+bool Transaction::repoSetData(const QString &repo_id, const QString &parameter, const QString &value) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_REPOCHANGE)) parent->sendAuthRefused("Cannot get authorization to change a repository");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->RepoSetData(repo_id, parameter, value);
+ if (polkit->getAuth(AUTH_REPOCHANGE)) {
+ renewTid();
+ proxy->RepoSetData(repo_id, parameter, value);
+ }
+ else
+ return false;
+ return true;
}
bool Transaction::isCallerActive() {
@@ -263,12 +299,15 @@ void Transaction::getOldTransactions(uint number) {
proxy->GetOldTransactions(number);
}
-void Transaction::acceptEula(const QString &id) {
+bool Transaction::acceptEula(const QString &id) {
qDebug() << "Trying to get authorization...";
- if(!polkit->getAuth(AUTH_ACCEPTEULA)) parent->sendAuthRefused("Cannot get authorization to accept an EULA");
- qDebug() << "We're authentificated";
- renewTid();
- proxy->AcceptEula(id);
+ if (polkit->getAuth(AUTH_ACCEPTEULA)) {
+ renewTid();
+ proxy->AcceptEula(id);
+ }
+ else
+ return false;
+ return true;
}
// Signal callbacks
diff --git a/lib/Transaction.h b/lib/Transaction.h
index b6a49b6..6bc0cf7 100644
--- a/lib/Transaction.h
+++ b/lib/Transaction.h
@@ -57,29 +57,29 @@ public:
void whatProvides(const QString &filter, const Provides::Value &type, const QString& search);
void resolve(const QString &filter, Package *p);
- void installPackages(const QList<Package*> &packages);
- void installPackage(Package *p);
- void installSignature(const SignatureType::Value &type, const QString &key_id, Package *p);
- void updatePackages(const QList<Package*> &packages);
- void updatePackage(Package *p);
- void installFiles(const QStringList& files, bool trusted = false);
- void removePackages(const QList<Package*> &packages, bool allow_deps = false, bool autoremove = false);
- void removePackage(Package *p, bool allow_deps = false, bool autoremove = false);
-
- void updateSystem();
- void rollback(const QString &tid);
+ bool installPackages(const QList<Package*> &packages);
+ bool installPackage(Package *p);
+ bool installSignature(const SignatureType::Value &type, const QString &key_id, Package *p);
+ bool updatePackages(const QList<Package*> &packages);
+ bool updatePackage(Package *p);
+ bool installFiles(const QStringList& files, bool trusted = false);
+ bool removePackages(const QList<Package*> &packages, bool allow_deps = false, bool autoremove = false);
+ bool removePackage(Package *p, bool allow_deps = false, bool autoremove = false);
+
+ bool updateSystem();
+ bool rollback(const QString &tid);
void getUpdates(const QString& filter);
void getUpdateDetail(const QString& package_id);
- void refreshCache(bool force = false);
+ bool refreshCache(bool force = false);
void getProgress(uint &percentage, uint &subpercentage, uint &elapsed, uint &remaining);
void getRepoList(const QString &filter);
- void repoEnable(const QString &repo_id, bool enabled);
- void repoSetData(const QString &repo_id, const QString &parameter, const QString &value);
+ bool repoEnable(const QString &repo_id, bool enabled);
+ bool repoSetData(const QString &repo_id, const QString &parameter, const QString &value);
bool isCallerActive();
void getOldTransactions(uint number);
- void acceptEula(const QString &id);
+ bool acceptEula(const QString &id);
signals:
void GotPackage(Package *p);