/*
 * 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
 *
 */

#include "pkgdbupdateengine.h"

#include <unixprocess.h>

#define	PKGDB_CMD	"/usr/local/sbin/pkgdb"

PkgDBUpdateEngine::PkgDBUpdateEngine()
{
	update = true;
	fixMethod = None;
}


/** Returns a QProcess that acts on the pkgdb
  * as specified before.
  *
  * Returns NULL if no actions would be done.
  *
  * The returned QProcess must be deleted after use.
  */
UnixProcess * PkgDBUpdateEngine::getProcess()
{
	if(!update  &&  fixMethod == None)
		return  NULL;

	UnixProcess  *process = new UnixProcess(QString(PKGDB_CMD));

	if(update)
		process->addArgument("-u");

	if(fixMethod == AutoFix)
		process->addArgument("-aF");
	else if(fixMethod == Interactive)
		process->addArgument("-F");

	return  process;
}
