xref: /haiku/headers/build/private/storage/mime/database_support.h (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 //----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the OpenBeOS license.
4 //---------------------------------------------------------------------
5 /*!
6 	\file database_support.h
7 	Private mime database function and constant declarations
8 */
9 
10 #ifndef _MIME_DATABASE_SUPPORT_H
11 #define _MIME_DATABASE_SUPPORT_H
12 
13 #include <StorageDefs.h>
14 
15 #include <string>
16 
17 class BNode;
18 class BMessage;
19 
20 namespace BPrivate {
21 namespace Storage {
22 namespace Mime {
23 
24 // Database directory
25 extern const std::string kDatabaseDir;
26 extern const std::string kApplicationDatabaseDir;
27 
28 // Attribute Prefixes
29 extern const char *kMiniIconAttrPrefix;
30 extern const char *kLargeIconAttrPrefix;
31 
32 // Attribute names
33 extern const char *kFileTypeAttr;
34 extern const char *kTypeAttr;
35 extern const char *kAttrInfoAttr;
36 extern const char *kAppHintAttr;
37 extern const char *kShortDescriptionAttr;
38 extern const char *kLongDescriptionAttr;
39 extern const char *kFileExtensionsAttr;
40 extern const char *kMiniIconAttr;
41 extern const char *kLargeIconAttr;
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 kPreferredAppType;
57 extern const int32 kSnifferRuleType;
58 extern const int32 kSupportedTypesType;
59 
60 // Message fields
61 extern const char *kApplicationsField;
62 extern const char *kExtensionsField;
63 extern const char *kSupertypesField;
64 extern const char *kSupportingAppsSubCountField;
65 extern const char *kSupportingAppsSuperCountField;
66 extern const char *kTypesField;
67 
68 // Mime types
69 extern const char *kGenericFileType;
70 extern const char *kDirectoryType;
71 extern const char *kSymlinkType;
72 extern const char *kMetaMimeType;
73 
74 // Error codes (to be used only by BPrivate::Storage::Mime members)
75 extern const status_t kMimeGuessFailureError;
76 
77 std::string type_to_filename(const char *type);
78 
79 status_t open_type(const char *type, BNode *result);
80 status_t open_or_create_type(const char *type, BNode *result, bool *didCreate);
81 
82 ssize_t read_mime_attr(const char *type, const char *attr, void *data,
83                        size_t len, type_code datatype);
84 status_t read_mime_attr_message(const char *type, const char *attr, BMessage *msg);
85 status_t read_mime_attr_string(const char *type, const char *attr, BString *str);
86 status_t write_mime_attr(const char *type, const char *attr, const void *data,
87 						     size_t len, type_code datatype, bool *didCreate);
88 status_t write_mime_attr_message(const char *type, const char *attr,
89 									const BMessage *msg, bool *didCreate);
90 
91 status_t delete_attribute(const char *type, const char *attr);
92 
93 } // namespace Mime
94 } // namespace Storage
95 } // namespace BPrivate
96 
97 #endif	// _MIME_DATABASE_SUPPORT_H
98