/*
 * 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 __PKGDEINSTALLENGINE_H
#define __PKGDEINSTALLENGINE_H

#include <package.h>

#include <qptrlist.h>

class UnixProcess;

/**
  * @brief Class for deinstallation automation.
  *
  * This class creates a QProcess that applies
  * specified actions on a given list of packages.
  *
  * The default is not to force a deinstallation
  * and not to delete empty directories.
  *
  * This class needs the portupgrade suite installed.
  * Commands like [-f] indicate the corresponding
  * pkg_deinstall(1) switch.
  */
class PkgDeinstallEngine{
public:
	PkgDeinstallEngine();

	UnixProcess * getProcess();


	/** Force removal of the given packages
		* even if dependencies are recorded or
		* deinstall scripts fail. [-f]
		*/
	void	setForce(bool b) { force = b;	}



	/** Also remove any directories that were emptied as a
		* result of removing the package. [-d]
		*/
	void	setRemoveEmptyDirs(bool b) {	rmEmptyDirs = b;	}



	/** Sets the packages that should be processed.
	  *
	  * This doesn't keep copies of the given objects, but
	  * only of pointers, so don't delete these objects!
	  */
	void	setPackages(QPtrList<Package>  pkgs) { packages = pkgs; }



private:
	bool	force;
	bool	rmEmptyDirs;
	QPtrList<Package>	packages;
};

#endif /* __PKGDEINSTALLENGINE_H */
