/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Author: Peter Hofer <ph@desktopbsd.net>
 *         (C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#ifndef __PKGUPGRADECONTROLLER_H
#define __PKGUPGRADECONTROLLER_H

#include <qobject.h>

struct kinfo_proc;

class PkgUpgradeController : public QObject {
	Q_OBJECT

public:
	PkgUpgradeController(QObject * parent = 0, const char * name = 0);
	void processChanged();

signals:
	void informationMessage(const QString &);
	void warningMessage(const QString &);
	void progressMessage(const QString &);
	void userInputRequired(const QString &);

	void currentPackageChanged(const QString &);
	void overallProgressChanged(int percent);
	void operationProgressChanged(int percent);

public slots:
	virtual void outputReceived(const QString &);
	virtual int killAll();
	virtual int killAll(int signal);

private:
	void recalculateProgress();

	void killAllRecursive(kinfo_proc *pinfo, int pcount, pid_t parent, int signal);

	/* portupgrade process */
	pid_t processID;
	void findPortupgradeProcess();

	int overallProgress;
	QString currentPackage;
};

#endif /* __PKGUPGRADECONTROLLER_H */
