1 /* 2 * Copyright 2002-2014, 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 12 class BBitmap; 13 class BFile; 14 class BMessage; 15 class BResources; 16 17 18 struct version_info { 19 uint32 major; 20 uint32 middle; 21 uint32 minor; 22 uint32 variety; 23 uint32 internal; 24 char short_info[64]; 25 char long_info[256]; 26 }; 27 28 enum info_variety { 29 B_DEVELOPMENT_VERSION = 0, 30 B_ALPHA_VERSION, 31 B_BETA_VERSION, 32 B_GAMMA_VERSION, 33 B_GOLDEN_MASTER_VERSION, 34 B_FINAL_VERSION 35 }; 36 37 enum info_location { 38 B_USE_ATTRIBUTES = 0x1, 39 B_USE_RESOURCES = 0x2, 40 B_USE_BOTH_LOCATIONS = 0x3 // == B_USE_ATTRIBUTES | B_USE_RESOURCES 41 }; 42 43 enum version_kind { 44 B_APP_VERSION_KIND, 45 B_SYSTEM_VERSION_KIND 46 }; 47 48 49 class BAppFileInfo: public BNodeInfo { 50 public: 51 BAppFileInfo(); 52 BAppFileInfo(BFile* file); 53 virtual ~BAppFileInfo(); 54 55 status_t SetTo(BFile* file); 56 57 virtual status_t GetType(char* type) const; 58 virtual status_t SetType(const char* type); 59 60 status_t GetSignature(char* signature) const; 61 status_t SetSignature(const char* signature); 62 63 status_t GetCatalogEntry(char* catalogEntry) const; 64 status_t SetCatalogEntry(const char* catalogEntry); 65 66 status_t GetAppFlags(uint32* flags) const; 67 status_t SetAppFlags(uint32 flags); 68 status_t RemoveAppFlags(); 69 70 status_t GetSupportedTypes(BMessage* types) const; 71 status_t SetSupportedTypes(const BMessage* types, 72 bool updateMimeDB, bool syncAll); 73 status_t SetSupportedTypes(const BMessage* types, 74 bool syncAll); 75 status_t SetSupportedTypes(const BMessage* types); 76 bool IsSupportedType(const char* type) const; 77 bool Supports(BMimeType* type) const; 78 79 virtual status_t GetIcon(BBitmap* icon, icon_size which) const; 80 status_t SetIcon(const BBitmap* icon, icon_size which, 81 bool updateMimeDB); 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 bool updateMimeDB); 87 status_t SetIcon(const uint8* data, size_t size); 88 89 status_t GetVersionInfo(version_info* info, 90 version_kind kind) const; 91 status_t SetVersionInfo(const version_info* info, 92 version_kind kind); 93 94 status_t GetIconForType(const char* type, BBitmap* icon, 95 icon_size which) const; 96 status_t GetIconForType(const char* type, uint8** data, 97 size_t* size) const; 98 status_t SetIconForType(const char* type, 99 const BBitmap* icon, icon_size which, 100 bool updateMimeDB); 101 status_t SetIconForType(const char* type, 102 const BBitmap* icon, icon_size which); 103 status_t SetIconForType(const char* type, 104 const uint8* data, size_t size, 105 bool updateMimeDB); 106 status_t SetIconForType(const char* type, 107 const uint8* data, size_t size); 108 109 void SetInfoLocation(info_location location); 110 bool IsUsingAttributes() const; 111 bool IsUsingResources() const; 112 113 private: 114 virtual void _ReservedAppFileInfo1(); 115 virtual void _ReservedAppFileInfo2(); 116 virtual void _ReservedAppFileInfo3(); 117 118 BAppFileInfo& operator=(const BAppFileInfo&); 119 BAppFileInfo(const BAppFileInfo&); 120 121 status_t GetMetaMime(BMimeType* meta) const; 122 123 status_t _ReadData(const char* name, int32 id, 124 type_code type, void* buffer, 125 size_t bufferSize, size_t& bytesRead, 126 void** allocatedBuffer = NULL) const; 127 status_t _WriteData(const char* name, int32 id, 128 type_code type, const void* buffer, 129 size_t bufferSize, bool findID = false); 130 status_t _RemoveData(const char* name, type_code type); 131 132 private: 133 BResources* fResources; 134 info_location fWhere; 135 uint32 _reserved[2]; 136 }; 137 138 139 #endif // _APP_FILE_INFO_H 140