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 GetIcon(uint8** data, size_t* size) const; 81 status_t SetIcon(const uint8* data, size_t size); 82 83 status_t GetVersionInfo(version_info *info, version_kind kind) const; 84 status_t SetVersionInfo(const version_info *info, version_kind kind); 85 86 status_t GetIconForType(const char *type, BBitmap *icon, 87 icon_size which) const; 88 status_t GetIconForType(const char *type, uint8** data, 89 size_t* size) const; 90 status_t SetIconForType(const char *type, const BBitmap *icon, 91 icon_size which); 92 status_t SetIconForType(const char *type, const uint8* data, 93 size_t size); 94 95 void SetInfoLocation(info_location location); 96 bool IsUsingAttributes() const; 97 bool IsUsingResources() const; 98 99 private: 100 virtual void _ReservedAppFileInfo1(); 101 virtual void _ReservedAppFileInfo2(); 102 virtual void _ReservedAppFileInfo3(); 103 104 BAppFileInfo &operator=(const BAppFileInfo &); 105 BAppFileInfo(const BAppFileInfo &); 106 107 status_t GetMetaMime(BMimeType *meta) const; 108 109 status_t _ReadData(const char *name, int32 id, type_code type, 110 void *buffer, size_t bufferSize, 111 size_t &bytesRead, void **allocatedBuffer = NULL) const; 112 status_t _WriteData(const char *name, int32 id, type_code type, 113 const void *buffer, size_t bufferSize, 114 bool findID = false); 115 status_t _RemoveData(const char *name, type_code type); 116 117 BResources *fResources; 118 info_location fWhere; 119 uint32 _reserved[2]; 120 }; 121 122 #endif // _APP_FILE_INFO_H 123