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