1/*
2 * Copyright (c) 2007, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
4 *
5 * Author:
6 *		��ukasz 'Sil2100' Zemczak <sil2100@vexillium.org>
7 */
8#ifndef INSTALLED_PACKAGE_INFO_H
9#define INSTALLED_PACKAGE_INFO_H
10
11#include <File.h>
12#include <String.h>
13#include <List.h>
14#include <Path.h>
15
16
17#define P_BUSY_TRIES 10
18
19enum {
20	P_PACKAGE_INFO = 'ppki'
21};
22
23extern const char * kPackagesDir;
24
25
26// Useful function for fetching the package name and version without parsing all
27// other data
28status_t info_get_package_name(const char* filename, BString& name);
29status_t info_get_package_version(const char* filename, BString& name);
30
31
32class InstalledPackageInfo {
33public:
34								InstalledPackageInfo();
35								InstalledPackageInfo(const char* packageName,
36									const char* version = NULL,
37									bool create = false);
38								~InstalledPackageInfo();
39
40			status_t			InitCheck();
41			status_t			SetTo(const char* packageName,
42									const char* version = NULL,
43									bool create = false);
44
45			void				SetName(const char* name)
46									{ fName = name; }
47			const char*			Name()
48									{ return fName.String(); }
49			void				SetDescription(const char* description)
50									{ fDescription = description; }
51			const char*			Description()
52									{ return fDescription.String(); }
53			const char*			Version()
54									{ return fVersion.String(); }
55			void				SetSpaceNeeded(uint64 size)
56									{ fSpaceNeeded = size; }
57			uint64				SpaceNeeded()
58									{ return fSpaceNeeded; }
59
60			status_t			AddItem(const char* itemName);
61
62			status_t			Uninstall();
63			status_t			Save();
64
65private:
66			void				_ClearItemList();
67
68private:
69			status_t			fStatus;
70			bool				fIsUpToDate;
71			bool				fCreate;
72
73			BString				fName;
74			BString				fDescription;
75			BString				fVersion;
76			uint64				fSpaceNeeded;
77			BList				fInstalledItems;
78
79			BPath				fPathToInfo;
80};
81
82
83#endif // INSTALLED_PACKAGE_INFO_H
84
85