xref: /haiku/headers/os/storage/AppFileInfo.h (revision f8499e9aac6f376b299c541639c2e0ffc70b9b74)
1*f8499e9aSAxel Dörfler /*
2*f8499e9aSAxel Dörfler  * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3*f8499e9aSAxel 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 
8*f8499e9aSAxel 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 
16*f8499e9aSAxel 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 
27*f8499e9aSAxel Dörfler enum info_variety {
28*f8499e9aSAxel Dörfler 	B_DEVELOPMENT_VERSION = 0,
29*f8499e9aSAxel Dörfler 	B_ALPHA_VERSION,
30*f8499e9aSAxel Dörfler 	B_BETA_VERSION,
31*f8499e9aSAxel Dörfler 	B_GAMMA_VERSION,
32*f8499e9aSAxel Dörfler 	B_GOLDEN_MASTER_VERSION,
33*f8499e9aSAxel Dörfler 	B_FINAL_VERSION
34*f8499e9aSAxel Dörfler };
35*f8499e9aSAxel 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);
70d6b205f3SIngo Weinhold 
71d6b205f3SIngo Weinhold 		status_t GetSupportedTypes(BMessage *types) const;
72d6b205f3SIngo Weinhold 		status_t SetSupportedTypes(const BMessage *types, bool syncAll);
73d6b205f3SIngo Weinhold 		status_t SetSupportedTypes(const BMessage *types);
74d6b205f3SIngo Weinhold 		bool IsSupportedType(const char *type) const;
75d6b205f3SIngo Weinhold 		bool Supports(BMimeType *type) const;
76d6b205f3SIngo Weinhold 
77d6b205f3SIngo Weinhold 		virtual status_t GetIcon(BBitmap *icon, icon_size which) const;
78d6b205f3SIngo Weinhold 		virtual status_t SetIcon(const BBitmap *icon, icon_size which);
79d6b205f3SIngo Weinhold 
80d6b205f3SIngo Weinhold 		status_t GetVersionInfo(version_info *info, version_kind kind) const;
81d6b205f3SIngo Weinhold 		status_t SetVersionInfo(const version_info *info, version_kind kind);
82d6b205f3SIngo Weinhold 
83d6b205f3SIngo Weinhold 		status_t GetIconForType(const char *type, BBitmap *icon,
84d6b205f3SIngo Weinhold 					icon_size which) const;
85d6b205f3SIngo Weinhold 		status_t SetIconForType(const char *type, const BBitmap *icon,
86d6b205f3SIngo Weinhold 					icon_size which);
87d6b205f3SIngo Weinhold 
88d6b205f3SIngo Weinhold 		void SetInfoLocation(info_location location);
89d6b205f3SIngo Weinhold 		bool IsUsingAttributes() const;
90d6b205f3SIngo Weinhold 		bool IsUsingResources() const;
91d6b205f3SIngo Weinhold 
92d6b205f3SIngo Weinhold 	private:
93d6b205f3SIngo Weinhold 		virtual void _ReservedAppFileInfo1();
94d6b205f3SIngo Weinhold 		virtual void _ReservedAppFileInfo2();
95d6b205f3SIngo Weinhold 		virtual void _ReservedAppFileInfo3();
96d6b205f3SIngo Weinhold 
97d6b205f3SIngo Weinhold 		BAppFileInfo &operator=(const BAppFileInfo &);
98d6b205f3SIngo Weinhold 		BAppFileInfo(const BAppFileInfo &);
99d6b205f3SIngo Weinhold 
10098da112cSIngo Weinhold 		status_t GetMetaMime(BMimeType *meta) const;
10198da112cSIngo Weinhold 
10298da112cSIngo Weinhold 		status_t _ReadData(const char *name, int32 id, type_code type,
10398da112cSIngo Weinhold 					void *buffer, size_t bufferSize,
10498da112cSIngo Weinhold 					size_t &bytesRead, void **allocatedBuffer = NULL) const;
10598da112cSIngo Weinhold 		status_t _WriteData(const char *name, int32 id, type_code type,
10698da112cSIngo Weinhold 					const void *buffer, size_t bufferSize,
10798da112cSIngo Weinhold 					bool findID = false);
10898da112cSIngo Weinhold 		status_t _RemoveData(const char *name, type_code type);
109d6b205f3SIngo Weinhold 
110d6b205f3SIngo Weinhold 		BResources		*fResources;
111d6b205f3SIngo Weinhold 		info_location	fWhere;
112d6b205f3SIngo Weinhold 		uint32			_reserved[2];
113d6b205f3SIngo Weinhold };
114d6b205f3SIngo Weinhold 
115d6b205f3SIngo Weinhold #endif	// _APP_FILE_INFO_H
116