[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [apper] /: Fix --nofork option by calling Apper::addCmdLineOptions(); sooner
From:       Daniel Nicoletti <dantti12 () gmail ! com>
Date:       2012-06-30 22:23:44
Message-ID: 20120630222344.CF692A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit 56b5225738a4e0f82834c6371bd3a2cb39dd0a88 by Daniel Nicoletti.
Committed on 01/07/2012 at 00:21.
Pushed by dantti into branch 'master'.

Fix --nofork option by calling Apper::addCmdLineOptions(); sooner
Fix update details by fixing signal signature
Disable AutoRemove feature by default
Fix removal of simulate flag
Fix ProgresView to properly update the last non-finished package

M  +1    -2    Apper/main.cpp
M  +3    -3    ApperKCM/Updater/UpdateDetails.cpp
M  +1    -1    CMakeLists.txt
M  +82   -94   libapper/PkTransaction.cpp
M  +3    -3    libapper/PkTransaction.h
M  +4    -5    libapper/ProgressView.cpp
M  +7    -2    libapper/SimulateModel.cpp
M  +4    -4    libapper/SimulateModel.h

http://commits.kde.org/apper/56b5225738a4e0f82834c6371bd3a2cb39dd0a88

diff --git a/Apper/main.cpp b/Apper/main.cpp
index a1a0f43..f15ded4 100644
--- a/Apper/main.cpp
+++ b/Apper/main.cpp
@@ -74,6 +74,7 @@ int main(int argc, char **argv)
     options.add("remove-package-by-file <filename>", ki18n("Single package \
remover"));  options.add("+[package]", ki18n("Package file to install"));
     KCmdLineArgs::addCmdLineOptions(options);
+    Apper::addCmdLineOptions();
 
     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
@@ -123,8 +124,6 @@ int main(int argc, char **argv)
         return invoke("RemovePackageByFiles", \
args->getOptionList("remove-package-by-file"));  }
 
-    Apper::addCmdLineOptions();
-
     if (!Apper::start())
     {
         qDebug() << "Apper is already running!";
diff --git a/ApperKCM/Updater/UpdateDetails.cpp b/ApperKCM/Updater/UpdateDetails.cpp
index b872d4f..2428d4d 100644
--- a/ApperKCM/Updater/UpdateDetails.cpp
+++ b/ApperKCM/Updater/UpdateDetails.cpp
@@ -105,8 +105,8 @@ void UpdateDetails::setPackage(const QString &packageId, \
Package::Info updateInf  
     Package package(m_packageId);
     m_transaction = new Transaction(this);
-    connect(m_transaction, SIGNAL(package(PackageKit::Package)),
-            this, SLOT(updateDetail(PackageKit::Package)));
+    connect(m_transaction, \
SIGNAL(packageUpdateDetails(PackageKit::PackageUpdateDetails)), +            this, \
                SLOT(updateDetail(PackageKit::PackageUpdateDetails)));
     connect(m_transaction, SIGNAL(finished(PackageKit::Transaction::Exit,uint)),
             this, SLOT(display()));
     m_transaction->getUpdateDetail(package);
@@ -319,7 +319,7 @@ QString UpdateDetails::getLinkList(const QStringList &urls) const
         if (!ret.isEmpty()) {
             ret += "<br/>";
         }
-        ret += QString::fromUtf8(" \xE2\x80\xA2 <a href=\"") % url % \
QLatin1String("\"></a>"); +        ret += QString::fromUtf8(" \xE2\x80\xA2 <a \
href=\"") % url % QLatin1String("\">") % url % QLatin1String("</a>");  }
     return ret;
 }
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 144feae..992a45b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ include (MacroLibrary)
 option(DEBCONF_SUPPORT "Build Apper with debconf support" OFF)
 
 # Yum does not support this
-option(AUTOREMOVE "Build Apper with auto remove enabled" ON)
+option(AUTOREMOVE "Build Apper with auto remove enabled" OFF)
 set(HAVE_AUTOREMOVE ${AUTOREMOVE})
 message(STATUS "Building Apper with auto remove: " ${AUTOREMOVE})
 
diff --git a/libapper/PkTransaction.cpp b/libapper/PkTransaction.cpp
index 82ab32f..1748ef3 100644
--- a/libapper/PkTransaction.cpp
+++ b/libapper/PkTransaction.cpp
@@ -59,7 +59,7 @@ public:
     Transaction::Role role;
     Transaction::Role originalRole;
     Transaction::Error error;
-    QList<Package> packages;
+    PackageList packages;
     QStringList packagesToResolve;
     ApplicationLauncher *launcher;
     QStringList files;
@@ -86,7 +86,7 @@ PkTransaction::PkTransaction(QWidget *parent)
 
     // for sanity we are finished till some transaction is set
     d->finished = true;
-    d->simulateModel = 0;
+    d->simulateModel = new SimulateModel(this);
     d->launcher = 0;
     d->originalRole = Transaction::RoleUnknown;
     d->role = Transaction::RoleUnknown;
@@ -115,7 +115,6 @@ void PkTransaction::installFiles(const QStringList &files)
         d->files = files;
         d->flags = Transaction::TransactionFlagOnlyTrusted;
         d->flags |= Transaction::TransactionFlagSimulate;
-        d->simulateModel = new SimulateModel(this, d->packages);
 
         // Create the simulate transaction and it's model
         Transaction *trans = new Transaction(this);
@@ -130,14 +129,13 @@ void PkTransaction::installFiles(const QStringList &files)
     }
 }
 
-void PkTransaction::installPackages(const QList<Package> &packages)
+void PkTransaction::installPackages(const PackageList &packages)
 {
     if (Daemon::actions() & Transaction::RoleInstallPackages) {
         d->originalRole = Transaction::RoleInstallPackages;
         d->packages = packages;
         d->flags = Transaction::TransactionFlagOnlyTrusted;
         d->flags |= Transaction::TransactionFlagSimulate;
-        d->simulateModel = new SimulateModel(this, d->packages);
 
         // Create the depends transaction and it's model
         Transaction *trans = new Transaction(this);
@@ -152,7 +150,7 @@ void PkTransaction::installPackages(const QList<Package> \
&packages)  }
 }
 
-void PkTransaction::removePackages(const QList<Package> &packages)
+void PkTransaction::removePackages(const PackageList &packages)
 {
     if (Daemon::actions() & Transaction::RoleRemovePackages) {
         d->originalRole = Transaction::RoleRemovePackages;
@@ -160,7 +158,6 @@ void PkTransaction::removePackages(const QList<Package> \
&packages)  d->packages = packages;
         d->flags = Transaction::TransactionFlagOnlyTrusted;
         d->flags |= Transaction::TransactionFlagSimulate;
-        d->simulateModel = new SimulateModel(this, d->packages);
 
         // Create the requirements transaction and it's model
         Transaction *trans = new Transaction(this);
@@ -175,14 +172,13 @@ void PkTransaction::removePackages(const QList<Package> \
&packages)  }
 }
 
-void PkTransaction::updatePackages(const QList<Package> &packages)
+void PkTransaction::updatePackages(const PackageList &packages)
 {
     if (Daemon::actions() & Transaction::RoleUpdatePackages) {
         d->originalRole = Transaction::RoleUpdatePackages;
         d->packages = packages;
         d->flags = Transaction::TransactionFlagOnlyTrusted;
         d->flags |= Transaction::TransactionFlagSimulate;
-        d->simulateModel = new SimulateModel(this, d->packages);
 
         Transaction *trans = new Transaction(this);
         setTransaction(trans, Transaction::RoleUpdatePackages);
@@ -308,13 +304,19 @@ void PkTransaction::setTransaction(Transaction *trans, \
Transaction::Role role)  emit titleChanged(PkStrings::action(role));
     }
 
-    // enable the Details button just on these roles
-    if (role == Transaction::RoleInstallPackages ||
-        role == Transaction::RoleInstallFiles ||
-        role == Transaction::RoleRemovePackages ||
-        role == Transaction::RoleUpdatePackages ||
-        role == Transaction::RoleUpdateSystem ||
-        role == Transaction::RoleRefreshCache) {
+    // Setup the simulate model if we are simulating
+    if (d->flags & Transaction::TransactionFlagSimulate) {
+        // DISCONNECT THIS SIGNAL BEFORE SETTING A NEW ONE
+        d->simulateModel->clear();
+        d->simulateModel->setSkipPackages(d->packages);
+        connect(m_trans, SIGNAL(package(PackageKit::Package)),
+                d->simulateModel, SLOT(addPackage(PackageKit::Package)));
+    } else if (role == Transaction::RoleInstallPackages ||
+               role == Transaction::RoleInstallFiles ||
+               role == Transaction::RoleRemovePackages ||
+               role == Transaction::RoleUpdatePackages ||
+               role == Transaction::RoleUpdateSystem ||
+               role == Transaction::RoleRefreshCache) {
         // DISCONNECT THIS SIGNAL BEFORE SETTING A NEW ONE
         if (role == Transaction::RoleRefreshCache) {
             connect(m_trans, SIGNAL(repoDetail(QString,QString,bool)),
@@ -322,25 +324,11 @@ void PkTransaction::setTransaction(Transaction *trans, \
Transaction::Role role)  ui->progressView->handleRepo(true);
         } else {
             connect(m_trans, SIGNAL(package(PackageKit::Package)),
-                ui->progressView, SLOT(currentPackage(PackageKit::Package)));
+                    ui->progressView, SLOT(currentPackage(PackageKit::Package)));
             connect(m_trans, SIGNAL(ItemProgress(QString,uint,uint)),
                     ui->progressView, SLOT(itemProgress(QString,uint,uint)));
             ui->progressView->handleRepo(false);
         }
-
-        if (d->simulateModel) {
-            d->packagesToResolve.append(d->simulateModel->newPackages());
-            d->simulateModel->deleteLater();
-            d->simulateModel = 0;
-        }
-    } else if (d->flags & Transaction::TransactionFlagSimulate) {
-        // DISCONNECT THIS SIGNAL BEFORE SETTING A NEW ONE
-        if (d->simulateModel == 0) {
-            d->simulateModel = new SimulateModel(this, d->packages);
-        }
-        d->simulateModel->clear();
-        connect(m_trans, SIGNAL(package(PackageKit::Package)),
-                d->simulateModel, SLOT(addPackage(PackageKit::Package)));
     }
 
     // sets the action icon to be the window icon
@@ -501,7 +489,7 @@ void PkTransaction::errorCode(Transaction::Error error, const \
                QString &details)
                                             i18n("Installing unsigned software"));
         if (ret == KMessageBox::Yes) {
             // Set only trusted to false, to do as the user asked
-            d->flags &= Transaction::TransactionFlagOnlyTrusted;
+            d->flags ^= Transaction::TransactionFlagOnlyTrusted;
             requeueTransaction();
         } else {
             setExitStatus(Cancelled);
@@ -620,20 +608,21 @@ void PkTransaction::transactionFinished(Transaction::Exit \
status)  Requirements *requires = 0;
     m_trans = 0;
 
-    kDebug() << status << trans->role();
+    Transaction::Role role = trans->role();
+    kDebug() << status << role;
     d->finished = true;
     switch(status) {
     case Transaction::ExitSuccess :
-    {
-        Transaction::Role role = trans->role();
         ui->progressBar->setMaximum(100);
         ui->progressBar->setValue(100);
 
-        // If the simulate model exists we were simulating
-        if (d->simulateModel) {
+        // Check if we are just simulating
+        if (d->flags & Transaction::TransactionFlagSimulate) {
             // Disable the simulate flag
-            d->flags &= Transaction::TransactionFlagSimulate;
-            kDebug() << "We have a simulate model";
+            d->flags ^= Transaction::TransactionFlagSimulate;
+
+            kDebug() << "Simulate Finished";
+            d->packagesToResolve.append(d->simulateModel->newPackages());
             requires = new Requirements(d->simulateModel, this);
             connect(requires, SIGNAL(rejected()), this, SLOT(reject()));
             if (requires->shouldShow()) {
@@ -677,64 +666,63 @@ void PkTransaction::transactionFinished(Transaction::Exit \
status)  default:
                 break;
             }
-        }
-
-        KConfig config("apper");
-        KConfigGroup transactionGroup(&config, "Transaction");
-        bool showApp = transactionGroup.readEntry("ShowApplicationLauncher", true);
-        if (showApp &&
-            !d->packagesToResolve.isEmpty() &&
-               (role == Transaction::RoleInstallPackages ||
-                role == Transaction::RoleInstallFiles ||
-                role == Transaction::RoleRemovePackages ||
-                role == Transaction::RoleUpdatePackages)) {
-            // When installing files or updates that involves new packages
-            // try to resolve the available packages at simulation time
-            // to maybe show the user the new applications that where installed
-            if (d->launcher == 0) {
-                d->launcher = new ApplicationLauncher(this);
-            }
+        } else {
+            KConfig config("apper");
+            KConfigGroup transactionGroup(&config, "Transaction");
+            bool showApp = transactionGroup.readEntry("ShowApplicationLauncher", \
true); +            if (showApp &&
+                    !d->packagesToResolve.isEmpty() &&
+                    (role == Transaction::RoleInstallPackages ||
+                     role == Transaction::RoleInstallFiles ||
+                     role == Transaction::RoleRemovePackages ||
+                     role == Transaction::RoleUpdatePackages)) {
+                // When installing files or updates that involves new packages
+                // try to resolve the available packages at simulation time
+                // to maybe show the user the new applications that where installed
+                if (d->launcher == 0) {
+                    d->launcher = new ApplicationLauncher(this);
+                }
 
-            Transaction *transaction = new Transaction(this);
-            connect(transaction, SIGNAL(package(PackageKit::Package)),
-                    d->launcher, SLOT(addPackage(PackageKit::Package)));
-            setTransaction(transaction, Transaction::RoleResolve);
-            transaction->resolve(d->packagesToResolve, \
                Transaction::FilterInstalled);
-            if (!transaction->error()) {
-                return; // avoid the exit code
-            }
-        } else if (showApp &&
-                   d->launcher &&
-                   !d->launcher->packages().isEmpty() &&
-                   role == Transaction::RoleResolve &&
-                   d->originalRole != Transaction::RoleUnknown) {
-            // Let's try to find some desktop files
-            Transaction *transaction = new Transaction(this);
-            connect(transaction, SIGNAL(files(PackageKit::Package,QStringList)),
-                    d->launcher, SLOT(files(PackageKit::Package,QStringList)));
-            setTransaction(transaction, Transaction::RoleGetFiles);
-            transaction->getFiles(d->launcher->packages());
-            if (!transaction->error()) {
-                return; // avoid the exit code
+                Transaction *transaction = new Transaction(this);
+                connect(transaction, SIGNAL(package(PackageKit::Package)),
+                        d->launcher, SLOT(addPackage(PackageKit::Package)));
+                setTransaction(transaction, Transaction::RoleResolve);
+                transaction->resolve(d->packagesToResolve, \
Transaction::FilterInstalled); +                if (!transaction->error()) {
+                    return; // avoid the exit code
+                }
+            } else if (showApp &&
+                       d->launcher &&
+                       !d->launcher->packages().isEmpty() &&
+                       role == Transaction::RoleResolve &&
+                       d->originalRole != Transaction::RoleUnknown) {
+                // Let's try to find some desktop files
+                Transaction *transaction = new Transaction(this);
+                connect(transaction, SIGNAL(files(PackageKit::Package,QStringList)),
+                        d->launcher, SLOT(files(PackageKit::Package,QStringList)));
+                setTransaction(transaction, Transaction::RoleGetFiles);
+                transaction->getFiles(d->launcher->packages());
+                if (!transaction->error()) {
+                    return; // avoid the exit code
+                }
+            } else if (showApp &&
+                       d->launcher &&
+                       d->launcher->hasApplications() &&
+                       role == Transaction::RoleGetFiles &&
+                       d->originalRole != Transaction::RoleUnknown) {
+                showDialog(d->launcher);
+                connect(d->launcher, SIGNAL(accepted()),
+                        this, SLOT(setExitStatus()));
+                return;
+            } else if (role == Transaction::RoleAcceptEula ||
+                       role == Transaction::RoleInstallSignature) {
+                kDebug() << "EULA or Signature accepted";
+                d->finished = false;
+                requeueTransaction();
+                return;
             }
-        } else if (showApp &&
-                   d->launcher &&
-                   d->launcher->hasApplications() &&
-                   role == Transaction::RoleGetFiles &&
-                   d->originalRole != Transaction::RoleUnknown) {
-            showDialog(d->launcher);
-            connect(d->launcher, SIGNAL(accepted()),
-                    this, SLOT(setExitStatus()));
-            return;
-        } else if (role == Transaction::RoleAcceptEula ||
-                   role == Transaction::RoleInstallSignature) {
-            kDebug() << "EULA or Signature accepted";
-            d->finished = false;
-            requeueTransaction();
-            return;
+            setExitStatus(Success);
         }
-        setExitStatus(Success);
-    }
         break;
     case Transaction::ExitCancelled :
         ui->progressBar->setMaximum(100);
diff --git a/libapper/PkTransaction.h b/libapper/PkTransaction.h
index 767f25f..ca99492 100644
--- a/libapper/PkTransaction.h
+++ b/libapper/PkTransaction.h
@@ -50,10 +50,10 @@ public:
     void setTransaction(Transaction *trans, Transaction::Role role);
     void hideCancelButton();
 
-    void installPackages(const QList<Package> &packages);
+    void installPackages(const PackageList &packages);
     void installFiles(const QStringList &files);
-    void removePackages(const QList<Package> &packages);
-    void updatePackages(const QList<Package> &packages);
+    void removePackages(const PackageList &packages);
+    void updatePackages(const PackageList &packages);
     void refreshCache(bool force = false);
 
     QString title() const;
diff --git a/libapper/ProgressView.cpp b/libapper/ProgressView.cpp
index c806ec6..532b74e 100644
--- a/libapper/ProgressView.cpp
+++ b/libapper/ProgressView.cpp
@@ -204,13 +204,12 @@ void ProgressView::rangeChanged(int min, int max)
 
 QStandardItem* ProgressView::findLastItem(const QString &packageId)
 {
-    QStandardItem *ret = 0;
     int rows = m_model->rowCount() - 1;
     for (int i = rows; i >= 0; --i) {
-        if (m_model->item(i)->data(RoleId).toString() == packageId) {
-            // Go on till the last we can find
-            ret = m_model->item(i);
+        QStandardItem *item = m_model->item(i);
+        if (item->data(RoleId).toString() == packageId) {
+            return item;
         }
     }
-    return ret;
+    return 0;
 }
diff --git a/libapper/SimulateModel.cpp b/libapper/SimulateModel.cpp
index 8b8ed4f..cfe0a28 100644
--- a/libapper/SimulateModel.cpp
+++ b/libapper/SimulateModel.cpp
@@ -26,9 +26,8 @@
 
 using namespace PackageKit;
 
-SimulateModel::SimulateModel(QObject *parent, QList<Package> skipPackages)
+SimulateModel::SimulateModel(QObject *parent)
 : QAbstractTableModel(parent),
-  m_skipPackages(skipPackages),
   m_currentInfo(Package::InfoUnknown)
 {
 //     setSortRole(Qt::DisplayRole);
@@ -144,6 +143,11 @@ QVariant SimulateModel::headerData(int section, Qt::Orientation \
orientation, int  return QVariant();
 }
 
+void SimulateModel::setSkipPackages(const PackageList &skipPackages)
+{
+    m_skipPackages = skipPackages;
+}
+
 QStringList SimulateModel::newPackages() const
 {
     return m_newPackages;
@@ -152,6 +156,7 @@ QStringList SimulateModel::newPackages() const
 void SimulateModel::clear()
 {
     m_packages.clear();
+    m_skipPackages.clear();
     m_currentInfo = Package::InfoUnknown;
     reset();
 }
diff --git a/libapper/SimulateModel.h b/libapper/SimulateModel.h
index 01e4af0..45e57a3 100644
--- a/libapper/SimulateModel.h
+++ b/libapper/SimulateModel.h
@@ -32,14 +32,14 @@ class KDE_EXPORT SimulateModel : public QAbstractTableModel
 {
     Q_OBJECT
 public:
-    explicit SimulateModel(QObject *parent = 0,
-                              QList<Package> skipPackages = QList<Package>());
+    explicit SimulateModel(QObject *parent = 0);
 
     int rowCount(const QModelIndex &parent = QModelIndex()) const;
     int columnCount(const QModelIndex &parent = QModelIndex()) const;
     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     QVariant headerData(int section, Qt::Orientation orientation, int role = \
Qt::DisplayRole) const;  
+    void setSkipPackages(const PackageList &skipPackages);
     QStringList newPackages() const;
     Package::Info currentInfo() const;
     void setCurrentInfo(Package::Info currentInfo);
@@ -50,8 +50,8 @@ public slots:
     void addPackage(const PackageKit::Package &package);
 
 private:
-    QHash<Package::Info, QList<Package> > m_packages;
-    QList<Package> m_skipPackages;
+    QHash<Package::Info, PackageList> m_packages;
+    PackageList m_skipPackages;
     QStringList m_newPackages;
     Package::Info m_currentInfo;
 };


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic