xref: /haiku/headers/private/storage/mime/database_support.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1 /*
2  * Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _MIME_DATABASE_SUPPORT_H
6 #define _MIME_DATABASE_SUPPORT_H
7 
8 
9 #include <StorageDefs.h>
10 
11 #include <string>
12 
13 class BNode;
14 class BMessage;
15 class BString;
16 
17 
18 namespace BPrivate {
19 namespace Storage {
20 namespace Mime {
21 
22 // Database directory
23 const std::string get_database_directory();
24 const std::string get_application_database_directory();
25 
26 // Attribute Prefixes
27 extern const char *kMiniIconAttrPrefix;
28 extern const char *kLargeIconAttrPrefix;
29 extern const char *kIconAttrPrefix;
30 
31 // Attribute names
32 extern const char *kFileTypeAttr;
33 extern const char *kTypeAttr;
34 extern const char *kAttrInfoAttr;
35 extern const char *kAppHintAttr;
36 extern const char *kShortDescriptionAttr;
37 extern const char *kLongDescriptionAttr;
38 extern const char *kFileExtensionsAttr;
39 extern const char *kMiniIconAttr;
40 extern const char *kLargeIconAttr;
41 extern const char *kIconAttr;
42 extern const char *kPreferredAppAttr;
43 extern const char *kSnifferRuleAttr;
44 extern const char *kSupportedTypesAttr;
45 
46 // Attribute Datatypes
47 extern const int32 kFileTypeType;
48 extern const int32 kTypeType;
49 extern const int32 kAppHintType;
50 extern const int32 kAttrInfoType;
51 extern const int32 kShortDescriptionType;
52 extern const int32 kLongDescriptionType;
53 extern const int32 kFileExtensionsType;
54 extern const int32 kMiniIconType;
55 extern const int32 kLargeIconType;
56 extern const int32 kIconType;
57 extern const int32 kPreferredAppType;
58 extern const int32 kSnifferRuleType;
59 extern const int32 kSupportedTypesType;
60 
61 // Message fields
62 extern const char *kApplicationsField;
63 extern const char *kExtensionsField;
64 extern const char *kSupertypesField;
65 extern const char *kSupportingAppsSubCountField;
66 extern const char *kSupportingAppsSuperCountField;
67 extern const char *kTypesField;
68 
69 // Mime types
70 extern const char *kGenericFileType;
71 extern const char *kDirectoryType;
72 extern const char *kSymlinkType;
73 extern const char *kMetaMimeType;
74 
75 // Error codes (to be used only by BPrivate::Storage::Mime members)
76 extern const status_t kMimeGuessFailureError;
77 
78 std::string type_to_filename(const char *type);
79 
80 status_t open_type(const char *type, BNode *result);
81 status_t open_or_create_type(const char *type, BNode *result, bool *didCreate);
82 
83 ssize_t read_mime_attr(const char *type, const char *attr, void *data,
84                        size_t len, type_code datatype);
85 status_t read_mime_attr_message(const char *type, const char *attr, BMessage *msg);
86 status_t read_mime_attr_string(const char *type, const char *attr, BString *str);
87 status_t write_mime_attr(const char *type, const char *attr, const void *data,
88 						     size_t len, type_code datatype, bool *didCreate);
89 status_t write_mime_attr_message(const char *type, const char *attr,
90 									const BMessage *msg, bool *didCreate);
91 
92 status_t delete_attribute(const char *type, const char *attr);
93 
94 } // namespace Mime
95 } // namespace Storage
96 } // namespace BPrivate
97 
98 #endif	// _MIME_DATABASE_SUPPORT_H
99