1b94857b3SIngo Weinhold /* 2b94857b3SIngo Weinhold * Copyright 2013, Haiku, Inc. All Rights Reserved. 3b94857b3SIngo Weinhold * Distributed under the terms of the MIT License. 4b94857b3SIngo Weinhold * 5b94857b3SIngo Weinhold * Authors: 6b94857b3SIngo Weinhold * Ingo Weinhold <ingo_weinhold@gmx.de> 7b94857b3SIngo Weinhold */ 8b94857b3SIngo Weinhold #ifndef _MIME_DATABASE_LOCATION_H 9b94857b3SIngo Weinhold #define _MIME_DATABASE_LOCATION_H 10b94857b3SIngo Weinhold 11b94857b3SIngo Weinhold 12b94857b3SIngo Weinhold #include <Mime.h> 13b94857b3SIngo Weinhold #include <StringList.h> 14b94857b3SIngo Weinhold 15b94857b3SIngo Weinhold 16b94857b3SIngo Weinhold namespace BPrivate { 17b94857b3SIngo Weinhold namespace Storage { 18b94857b3SIngo Weinhold namespace Mime { 19b94857b3SIngo Weinhold 20b94857b3SIngo Weinhold 21b94857b3SIngo Weinhold class DatabaseLocation { 22b94857b3SIngo Weinhold public: 23b94857b3SIngo Weinhold DatabaseLocation(); 24b94857b3SIngo Weinhold ~DatabaseLocation(); 25b94857b3SIngo Weinhold 26b94857b3SIngo Weinhold bool AddDirectory(const BString& directory); 27b94857b3SIngo Weinhold 28b94857b3SIngo Weinhold // paths 29b94857b3SIngo Weinhold Directories()30b94857b3SIngo Weinhold const BStringList& Directories() const 31b94857b3SIngo Weinhold { return fDirectories; } WritableDirectory()32b94857b3SIngo Weinhold BString WritableDirectory() const 33b94857b3SIngo Weinhold { return fDirectories.StringAt(0); } 34b94857b3SIngo Weinhold WritablePathForType(const char * type)35b94857b3SIngo Weinhold BString WritablePathForType(const char* type) const 36b94857b3SIngo Weinhold { return _TypeToFilename(type, 0); } 37b94857b3SIngo Weinhold 38b94857b3SIngo Weinhold // opening type nodes 39b94857b3SIngo Weinhold 40b94857b3SIngo Weinhold status_t OpenType(const char* type, BNode& _node) const; 41*701a5d6bSRene Gollent status_t OpenWritableType(const char* type, 42*701a5d6bSRene Gollent BNode& _node, bool create, 43*701a5d6bSRene Gollent bool* _didCreate = NULL) const; 44b94857b3SIngo Weinhold 45b94857b3SIngo Weinhold // generic type attributes access 46b94857b3SIngo Weinhold 47b94857b3SIngo Weinhold ssize_t ReadAttribute(const char* type, 48b94857b3SIngo Weinhold const char* attribute, void* data, 49b94857b3SIngo Weinhold size_t length, type_code datatype) const; 50b94857b3SIngo Weinhold status_t ReadMessageAttribute(const char* type, 51b94857b3SIngo Weinhold const char* attribute, BMessage& _message) 52b94857b3SIngo Weinhold const; 53b94857b3SIngo Weinhold status_t ReadStringAttribute(const char* type, 54b94857b3SIngo Weinhold const char* attribute, BString& _string) 55b94857b3SIngo Weinhold const; 56b94857b3SIngo Weinhold 57b94857b3SIngo Weinhold status_t WriteAttribute(const char* type, 58b94857b3SIngo Weinhold const char* attribute, const void* data, 59b94857b3SIngo Weinhold size_t length, type_code datatype, 60b94857b3SIngo Weinhold bool* _didCreate) const; 61b94857b3SIngo Weinhold status_t WriteMessageAttribute(const char* type, 62b94857b3SIngo Weinhold const char* attribute, 63b94857b3SIngo Weinhold const BMessage& message, bool* _didCreate) 64b94857b3SIngo Weinhold const; 65b94857b3SIngo Weinhold 66b94857b3SIngo Weinhold status_t DeleteAttribute(const char* type, 67b94857b3SIngo Weinhold const char* attribute) const; 68b94857b3SIngo Weinhold 69b94857b3SIngo Weinhold // type attribute convenience getters 70b94857b3SIngo Weinhold 71b94857b3SIngo Weinhold status_t GetAppHint(const char* type, entry_ref& _ref); 72b94857b3SIngo Weinhold status_t GetAttributesInfo(const char* type, 73b94857b3SIngo Weinhold BMessage& _info); 74b94857b3SIngo Weinhold status_t GetShortDescription(const char* type, 75b94857b3SIngo Weinhold char* description); 76b94857b3SIngo Weinhold status_t GetLongDescription(const char* type, 77b94857b3SIngo Weinhold char* description); 78b94857b3SIngo Weinhold status_t GetFileExtensions(const char* type, 79b94857b3SIngo Weinhold BMessage& _extensions); 80b94857b3SIngo Weinhold status_t GetIcon(const char* type, BBitmap& _icon, 81b94857b3SIngo Weinhold icon_size size); 82b94857b3SIngo Weinhold status_t GetIcon(const char* type, uint8*& _data, 83b94857b3SIngo Weinhold size_t& _size); 84b94857b3SIngo Weinhold status_t GetIconForType(const char* type, 85b94857b3SIngo Weinhold const char* fileType, BBitmap& _icon, 86b94857b3SIngo Weinhold icon_size which); 87b94857b3SIngo Weinhold status_t GetIconForType(const char* type, 88b94857b3SIngo Weinhold const char* fileType, uint8*& _data, 89b94857b3SIngo Weinhold size_t& _size); 90b94857b3SIngo Weinhold status_t GetPreferredApp(const char* type, 91b94857b3SIngo Weinhold char* signature, app_verb verb); 92b94857b3SIngo Weinhold status_t GetSnifferRule(const char* type, 93b94857b3SIngo Weinhold BString& _result); 94b94857b3SIngo Weinhold status_t GetSupportedTypes(const char* type, 95b94857b3SIngo Weinhold BMessage& _types); 96b94857b3SIngo Weinhold 97b94857b3SIngo Weinhold bool IsInstalled(const char* type); 98b94857b3SIngo Weinhold 99b94857b3SIngo Weinhold private: 100b94857b3SIngo Weinhold BString _TypeToFilename(const char* type, int32 index) 101b94857b3SIngo Weinhold const; 102b94857b3SIngo Weinhold status_t _OpenType(const char* type, BNode& _node, 103b94857b3SIngo Weinhold int32& _index) const; 104b94857b3SIngo Weinhold status_t _CreateTypeNode(const char* type, BNode& _node) 105b94857b3SIngo Weinhold const; 106b94857b3SIngo Weinhold status_t _CopyTypeNode(BNode& source, const char* type, 107b94857b3SIngo Weinhold BNode& _target) const; 108b94857b3SIngo Weinhold 109b94857b3SIngo Weinhold private: 110b94857b3SIngo Weinhold BStringList fDirectories; 111b94857b3SIngo Weinhold }; 112b94857b3SIngo Weinhold 113b94857b3SIngo Weinhold 114b94857b3SIngo Weinhold } // namespace Mime 115b94857b3SIngo Weinhold } // namespace Storage 116b94857b3SIngo Weinhold } // namespace BPrivate 117b94857b3SIngo Weinhold 118b94857b3SIngo Weinhold 119b94857b3SIngo Weinhold #endif // _MIME_DATABASE_LOCATION_H 120