xref: /haiku/headers/os/storage/AppFileInfo.h (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
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 
11 class BBitmap;
12 class BFile;
13 class BMessage;
14 class BResources;
15 
16 
17 struct 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 
27 enum 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 
36 enum 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 
42 enum 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 */
54 class 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 GetAppFlags(uint32 *flags) const;
69 		status_t SetAppFlags(uint32 flags);
70 
71 		status_t GetSupportedTypes(BMessage *types) const;
72 		status_t SetSupportedTypes(const BMessage *types, bool syncAll);
73 		status_t SetSupportedTypes(const BMessage *types);
74 		bool IsSupportedType(const char *type) const;
75 		bool Supports(BMimeType *type) const;
76 
77 		virtual status_t GetIcon(BBitmap *icon, icon_size which) const;
78 		virtual status_t SetIcon(const BBitmap *icon, icon_size which);
79 
80 		status_t GetVersionInfo(version_info *info, version_kind kind) const;
81 		status_t SetVersionInfo(const version_info *info, version_kind kind);
82 
83 		status_t GetIconForType(const char *type, BBitmap *icon,
84 					icon_size which) const;
85 		status_t SetIconForType(const char *type, const BBitmap *icon,
86 					icon_size which);
87 
88 		void SetInfoLocation(info_location location);
89 		bool IsUsingAttributes() const;
90 		bool IsUsingResources() const;
91 
92 	private:
93 		virtual void _ReservedAppFileInfo1();
94 		virtual void _ReservedAppFileInfo2();
95 		virtual void _ReservedAppFileInfo3();
96 
97 		BAppFileInfo &operator=(const BAppFileInfo &);
98 		BAppFileInfo(const BAppFileInfo &);
99 
100 		status_t GetMetaMime(BMimeType *meta) const;
101 
102 		status_t _ReadData(const char *name, int32 id, type_code type,
103 					void *buffer, size_t bufferSize,
104 					size_t &bytesRead, void **allocatedBuffer = NULL) const;
105 		status_t _WriteData(const char *name, int32 id, type_code type,
106 					const void *buffer, size_t bufferSize,
107 					bool findID = false);
108 		status_t _RemoveData(const char *name, type_code type);
109 
110 		BResources		*fResources;
111 		info_location	fWhere;
112 		uint32			_reserved[2];
113 };
114 
115 #endif	// _APP_FILE_INFO_H
116