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 PACKAGEINFO_H
9#define PACKAGEINFO_H
10
11#include "PackageItem.h"
12#include <List.h>
13#include <String.h>
14#include <File.h>
15#include <DataIO.h>
16#include <Path.h>
17
18
19struct pkg_profile;
20
21
22class PackageInfo {
23	public:
24		PackageInfo();
25		PackageInfo(const entry_ref *ref);
26		~PackageInfo();
27
28		const char *GetName() { return fName.String(); }
29		const char *GetDescription() { return fDescription.String(); }
30		const char *GetShortDescription() { return fShortDesc.String(); }
31		const char *GetVersion() { return fVersion.String(); }
32		const char *GetDisclaimer() { return fDisclaimer.String(); }
33		BMallocIO *GetSplashScreen() { return fHasImage ? &fImage : NULL; }
34		int32 GetProfileCount() { return fProfiles.CountItems(); }
35		pkg_profile *GetProfile(int32 num) {
36			return static_cast<pkg_profile *>(fProfiles.ItemAt(num)); }
37		int32 GetScriptCount() { return fScripts.CountItems(); }
38		PackageScript *GetScript(int32 num) {
39			return static_cast<PackageScript *>(fScripts.ItemAt(num)); }
40
41		status_t Parse();
42		status_t InitCheck() { return fStatus; }
43
44	private:
45		void _AddItem(PackageItem *item, uint64 size, uint32 groups,
46			uint32 path, uint32 cust);
47
48		status_t fStatus;
49
50		BFile *fPackageFile;
51		BString fName;
52		BString fDescription;
53		BList fProfiles;
54
55		BString fShortDesc;
56		BString fDeveloper;
57		BString fVersion;
58		BString fDisclaimer;
59		BMallocIO fImage;
60		bool fHasImage;
61
62		BList fFiles; // Holds all files in the package
63		BList fScripts;
64};
65
66
67// #pragma mark -
68
69
70struct pkg_profile {
71	pkg_profile() : items(10), space_needed(0), path_type(P_SYSTEM_PATH) {}
72	~pkg_profile() {}
73
74	BString name;
75	BString description;
76	BList items;
77	uint64 space_needed;
78
79	uint8 path_type;
80};
81
82#endif
83
84