File indexing completed on 2024-04-21 16:29:34

0001 /***************************************************************************
0002  *   Copyright (C) 2008-2011 by Daniel Nicoletti                           *
0003  *   dantti12@gmail.com                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; see the file COPYING. If not, write to       *
0017  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
0018  *   Boston, MA 02110-1301, USA.                                           *
0019  ***************************************************************************/
0020 
0021 #ifndef TRANSACTION_WATCHER_H
0022 #define TRANSACTION_WATCHER_H
0023 
0024 //#include "AbstractIsRunning.h"
0025 
0026 #include <kuiserverjobtracker.h>
0027 
0028 #include <Transaction>
0029 
0030 #include <QAction>
0031 
0032 using namespace PackageKit;
0033 
0034 class TransactionJob;
0035 class TransactionWatcher : public QObject
0036 {
0037     Q_OBJECT
0038 public:
0039     explicit TransactionWatcher(bool packagekitIsRunning, QObject *parent = nullptr);
0040     ~TransactionWatcher() override;
0041 
0042 public Q_SLOTS:
0043     void watchTransactionInteractive(const QDBusObjectPath &tid);
0044     void watchTransaction(const QDBusObjectPath &tid, bool interactive = true);
0045     void transactionReady();
0046     void showRebootNotificationApt();
0047 
0048 private Q_SLOTS:
0049     void transactionListChanged(const QStringList &tids);
0050     void errorCode(PackageKit::Transaction::Error, const QString &);
0051     void errorActivated(uint action);
0052     void requireRestart(PackageKit::Transaction::Restart type, const QString &packageID);
0053     void finished(PackageKit::Transaction::Exit exit);
0054     void transactionChanged(Transaction *transaction = nullptr, bool interactive = false);
0055 
0056     void logout();
0057 
0058     void watchedCanceled();
0059 
0060 private:
0061     static void suppressSleep(bool enable, int &inhibitCookie, const QString &reason = QString());
0062 
0063     // Hash of transactions we are watching
0064     QHash<QDBusObjectPath, Transaction*> m_transactions;
0065     QHash<QDBusObjectPath, TransactionJob*> m_transactionJob;
0066 
0067     // cookie to suppress sleep
0068     int           m_inhibitCookie;
0069     KUiServerJobTracker *m_tracker;
0070 };
0071 
0072 #endif