1/*
2 * Copyright 2002-2006, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Tyler Dauwalder
7 *		Ingo Weinhold, bonefish@users.sf.net
8 *		Axel D��rfler, axeld@pinc-software.de
9 */
10#ifndef _MIME_INSTALLED_TYPES_H
11#define _MIME_INSTALLED_TYPES_H
12
13
14#include <map>
15#include <string>
16
17#include <SupportDefs.h>
18
19#include <mime/Supertype.h>
20
21
22class BMessage;
23
24namespace BPrivate {
25namespace Storage {
26namespace Mime {
27
28
29class DatabaseLocation;
30
31
32class InstalledTypes {
33	public:
34		InstalledTypes(DatabaseLocation* databaseLocation);
35		~InstalledTypes();
36
37		status_t GetInstalledTypes(BMessage *types);
38		status_t GetInstalledTypes(const char *supertype, BMessage *types);
39		status_t GetInstalledSupertypes(BMessage *types);
40
41		status_t AddType(const char *type);
42		status_t RemoveType(const char *type);
43
44	private:
45		status_t _AddSupertype(const char *super,
46					std::map<std::string, Supertype>::iterator &i);
47		status_t _AddSubtype(const char *super, const char *sub);
48		status_t _AddSubtype(Supertype &super, const char *sub);
49
50		status_t _RemoveSupertype(const char *super);
51		status_t _RemoveSubtype(const char *super, const char *sub);
52
53		void _Unset();
54		void _ClearCachedMessages();
55
56		status_t _CreateMessageWithTypes(BMessage **result) const;
57		status_t _CreateMessageWithSupertypes(BMessage **result) const;
58		void _FillMessageWithSupertypes(BMessage *msg);
59
60		status_t _BuildInstalledTypesList();
61
62private:
63		DatabaseLocation* fDatabaseLocation;
64		std::map<std::string, Supertype> fSupertypes;
65		BMessage *fCachedMessage;
66		BMessage *fCachedSupertypesMessage;
67		bool fHaveDoneFullBuild;
68};
69
70} // namespace Mime
71} // namespace Storage
72} // namespace BPrivate
73
74#endif	// _MIME_INSTALLED_TYPES_H
75