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

#ifndef __PACKAGE_H
#define __PACKAGE_H

#include <size.h>

#include <qstring.h>
#include <qstringlist.h>

template <class T> class QPtrList;

/** @brief Port from the FreeBSD ports collection.
  *
  * This class provides functionality to acquire information
  * about available or installed ports.
  *
  * Because the ports collection is very large, some properties
  * from the ports system are not used because of the large
  * data amount (~ 14000 objects when all packages are read in).
  */
class Package {
public:
	enum InstallStatus {
		Installed,
		InstalledOutdated,
		InstalledNewer,
		NotInstalled,
		Undefined
	};

	QString		getName() const					{ return name;						};
	QString		getWebsite() const				{ return website;					};
	QString		getLatestVersion() const		{ return latestVersion;			};
	QString		getInstalledVersion() const	{ return installedVersion;		};
	QString		getShortDescr() const			{ return shortDescr;				};
	QString		getMainCategory() const			{ return mainCategory;			};
	size_t		getRequiredByCount() const		{ return requiredBy.count();	};
	QStringList	getRequiredBy() const			{ return requiredBy;				};
	InstallStatus	getInstallStatus() const	{ return instStatus;				};

	/* Not used in UI
	QStringList	getCategories() const			{ return categories;				};
	*/

	QString		getID() const;
	QString		getLongDescr();

	bool		isRequiredBy(const Package &);

	bool		isInstalledSizeSet();
	Size		getInstalledSize();

	void	mergeInstalledPackage(const Package &);

	static Package  *fromINDEXLine(const QString &);
	static Package  *fromPkgDb(const QString &);

	static QPtrList<Package>	getInstalledPackages();

private:
	Package();

	/* General properties */
	QString	name;
	QString	latestVersion;
	QString	shortDescr;
	QString	website;
	QString	mainCategory;
	
	/* Properties of installed packages */
	QStringList  requiredBy;
	InstallStatus  instStatus;
	QString	installedName;
	QString	installedVersion;
	Size		installedSize;
	bool		installedSizeSet;

	QString	longDescr;
	bool		longDescrSet;

	/* Not used in UI
	QStringList categories;
	QString	mail;
	*/
};


#endif /* __PACKAGE_H */
