xref: /haiku/headers/private/storage/mime/database_support.h (revision 2f470aec1c92ce6917b8a903e343795dc77af41f)
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 extern const char *kIconAttrPrefix;
32 
33 // Attribute names
34 extern const char *kFileTypeAttr;
35 extern const char *kTypeAttr;
36 extern const char *kAttrInfoAttr;
37 extern const char *kAppHintAttr;
38 extern const char *kShortDescriptionAttr;
39 extern const char *kLongDescriptionAttr;
40 extern const char *kFileExtensionsAttr;
41 extern const char *kMiniIconAttr;
42 extern const char *kLargeIconAttr;
43 extern const char *kIconAttr;
44 extern const char *kPreferredAppAttr;
45 extern const char *kSnifferRuleAttr;
46 extern const char *kSupportedTypesAttr;
47 
48 // Attribute Datatypes
49 extern const int32 kFileTypeType;
50 extern const int32 kTypeType;
51 extern const int32 kAppHintType;
52 extern const int32 kAttrInfoType;
53 extern const int32 kShortDescriptionType;
54 extern const int32 kLongDescriptionType;
55 extern const int32 kFileExtensionsType;
56 extern const int32 kMiniIconType;
57 extern const int32 kLargeIconType;
58 extern const int32 kIconType;
59 extern const int32 kPreferredAppType;
60 extern const int32 kSnifferRuleType;
61 extern const int32 kSupportedTypesType;
62 
63 // Message fields
64 extern const char *kApplicationsField;
65 extern const char *kExtensionsField;
66 extern const char *kSupertypesField;
67 extern const char *kSupportingAppsSubCountField;
68 extern const char *kSupportingAppsSuperCountField;
69 extern const char *kTypesField;
70 
71 // Mime types
72 extern const char *kGenericFileType;
73 extern const char *kDirectoryType;
74 extern const char *kSymlinkType;
75 extern const char *kMetaMimeType;
76 
77 // Error codes (to be used only by BPrivate::Storage::Mime members)
78 extern const status_t kMimeGuessFailureError;
79 
80 std::string type_to_filename(const char *type);
81 
82 status_t open_type(const char *type, BNode *result);
83 status_t open_or_create_type(const char *type, BNode *result, bool *didCreate);
84 
85 ssize_t read_mime_attr(const char *type, const char *attr, void *data,
86                        size_t len, type_code datatype);
87 status_t read_mime_attr_message(const char *type, const char *attr, BMessage *msg);
88 status_t read_mime_attr_string(const char *type, const char *attr, BString *str);
89 status_t write_mime_attr(const char *type, const char *attr, const void *data,
90 						     size_t len, type_code datatype, bool *didCreate);
91 status_t write_mime_attr_message(const char *type, const char *attr,
92 									const BMessage *msg, bool *didCreate);
93 
94 status_t delete_attribute(const char *type, const char *attr);
95 
96 } // namespace Mime
97 } // namespace Storage
98 } // namespace BPrivate
99 
100 #endif	// _MIME_DATABASE_SUPPORT_H
101