1/* 2 * Copyright 2002-2007, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _MIME_ASSOCIATED_TYPES_H 6#define _MIME_ASSOCIATED_TYPES_H 7 8 9#include <SupportDefs.h> 10 11#include <map> 12#include <set> 13#include <string> 14 15class BMessage; 16class BString; 17struct entry_ref; 18 19 20namespace BPrivate { 21namespace Storage { 22namespace Mime { 23 24class AssociatedTypes { 25public: 26 AssociatedTypes(); 27 ~AssociatedTypes(); 28 29 status_t GetAssociatedTypes(const char *extension, BMessage *types); 30 status_t GuessMimeType(const char *filename, BString *result); 31 status_t GuessMimeType(const entry_ref *ref, BString *result); 32 33 status_t SetFileExtensions(const char *type, const BMessage *extensions); 34 status_t DeleteFileExtensions(const char *type); 35 36 void PrintToStream() const; 37private: 38 status_t AddAssociatedType(const char *extension, const char *type); 39 status_t RemoveAssociatedType(const char *extension, const char *type); 40 41 status_t BuildAssociatedTypesTable(); 42 43 status_t ProcessType(const char *type); 44 std::string PrepExtension(const char *extension) const; 45 46 std::map<std::string, std::set<std::string> > fFileExtensions; // mime type => set of associated file extensions 47 std::map<std::string, std::set<std::string> > fAssociatedTypes; // file extension => set of associated mime types 48 49 bool fHaveDoneFullBuild; 50}; 51 52} // namespace Mime 53} // namespace Storage 54} // namespace BPrivate 55 56#endif // _MIME_ASSOCIATED_TYPES_H 57