1/*
2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _APP_FILE_INFO_H
6#define _APP_FILE_INFO_H
7
8
9#include <NodeInfo.h>
10
11class BBitmap;
12class BFile;
13class BMessage;
14class BResources;
15
16
17struct version_info {
18	uint32	major;
19	uint32	middle;
20	uint32	minor;
21	uint32	variety;
22	uint32	internal;
23	char	short_info[64];
24	char	long_info[256];
25};
26
27enum info_variety {
28	B_DEVELOPMENT_VERSION = 0,
29	B_ALPHA_VERSION,
30	B_BETA_VERSION,
31	B_GAMMA_VERSION,
32	B_GOLDEN_MASTER_VERSION,
33	B_FINAL_VERSION
34};
35
36enum info_location {
37	B_USE_ATTRIBUTES		= 0x1,
38	B_USE_RESOURCES			= 0x2,
39	B_USE_BOTH_LOCATIONS	= 0x3	// == B_USE_ATTRIBUTES | B_USE_RESOURCES
40};
41
42enum version_kind {
43	B_APP_VERSION_KIND,
44	B_SYSTEM_VERSION_KIND
45};
46
47/*!	\brief Executable meta information handling.
48	The BAppFileInfo class provides access to meta data that can be associated
49	with executables, libraries and add-ons.
50
51	\author <a href='bonefish@users.sf.net'>Ingo Weinhold</a>
52	\version 0.0.0
53*/
54class BAppFileInfo: public BNodeInfo {
55	public:
56		BAppFileInfo();
57		BAppFileInfo(BFile *file);
58		virtual ~BAppFileInfo();
59
60		status_t SetTo(BFile *file);
61
62		virtual status_t GetType(char *type) const;
63		virtual status_t SetType(const char *type);
64
65		status_t GetSignature(char *signature) const;
66		status_t SetSignature(const char *signature);
67
68		status_t GetCatalogEntry(char *catalogEntry) const;
69		status_t SetCatalogEntry(const char *catalogEntry);
70
71		status_t GetAppFlags(uint32 *flags) const;
72		status_t SetAppFlags(uint32 flags);
73		status_t RemoveAppFlags();
74
75		status_t GetSupportedTypes(BMessage *types) const;
76		status_t SetSupportedTypes(const BMessage *types, bool syncAll);
77		status_t SetSupportedTypes(const BMessage *types);
78		bool IsSupportedType(const char *type) const;
79		bool Supports(BMimeType *type) const;
80
81		virtual status_t GetIcon(BBitmap *icon, icon_size which) const;
82		virtual status_t SetIcon(const BBitmap *icon, icon_size which);
83
84				status_t GetIcon(uint8** data, size_t* size) const;
85				status_t SetIcon(const uint8* data, size_t size);
86
87		status_t GetVersionInfo(version_info *info, version_kind kind) const;
88		status_t SetVersionInfo(const version_info *info, version_kind kind);
89
90		status_t GetIconForType(const char *type, BBitmap *icon,
91					icon_size which) const;
92		status_t GetIconForType(const char *type, uint8** data,
93					size_t* size) const;
94		status_t SetIconForType(const char *type, const BBitmap *icon,
95					icon_size which);
96		status_t SetIconForType(const char *type, const uint8* data,
97					size_t size);
98
99		void SetInfoLocation(info_location location);
100		bool IsUsingAttributes() const;
101		bool IsUsingResources() const;
102
103	private:
104		virtual void _ReservedAppFileInfo1();
105		virtual void _ReservedAppFileInfo2();
106		virtual void _ReservedAppFileInfo3();
107
108		BAppFileInfo &operator=(const BAppFileInfo &);
109		BAppFileInfo(const BAppFileInfo &);
110
111		status_t GetMetaMime(BMimeType *meta) const;
112
113		status_t _ReadData(const char *name, int32 id, type_code type,
114					void *buffer, size_t bufferSize,
115					size_t &bytesRead, void **allocatedBuffer = NULL) const;
116		status_t _WriteData(const char *name, int32 id, type_code type,
117					const void *buffer, size_t bufferSize,
118					bool findID = false);
119		status_t _RemoveData(const char *name, type_code type);
120
121		BResources		*fResources;
122		info_location	fWhere;
123		uint32			_reserved[2];
124};
125
126#endif	// _APP_FILE_INFO_H
127