xref: /haiku/headers/private/storage/mime/MimeSnifferAddonManager.h (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2006-2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _MINE_MIME_SNIFFER_ADDON_MANAGER_H
6 #define _MINE_MIME_SNIFFER_ADDON_MANAGER_H
7 
8 
9 #include <List.h>
10 #include <Locker.h>
11 
12 
13 #include <mime/MimeSniffer.h>
14 
15 
16 class BFile;
17 class BMimeSnifferAddon;
18 class BMimeType;
19 
20 
21 namespace BPrivate {
22 namespace Storage {
23 namespace Mime {
24 
25 
26 class MimeSnifferAddonManager : public BPrivate::Storage::Mime::MimeSniffer {
27 private:
28 								MimeSnifferAddonManager();
29 								~MimeSnifferAddonManager();
30 
31 public:
32 	static	MimeSnifferAddonManager* Default();
33 	static	status_t			CreateDefault();
34 	static	void				DeleteDefault();
35 
36 			status_t			AddMimeSnifferAddon(BMimeSnifferAddon* addon);
37 
38 	virtual	size_t				MinimalBufferSize();
39 
40 	virtual	float				GuessMimeType(const char* fileName,
41 									BMimeType* type);
42 	virtual	float				GuessMimeType(BFile* file,
43 									const void* buffer, int32 length,
44 									BMimeType* type);
45 
46 private:
47 			struct AddonReference;
48 
49 			status_t			_GetAddons(AddonReference**& references,
50 									int32& count);
51 			void				_PutAddons(AddonReference** references,
52 									int32 count);
53 
54 			static MimeSnifferAddonManager*	sManager;
55 
56 			BLocker				fLock;
57 			BList				fAddons;
58 			size_t				fMinimalBufferSize;
59 };
60 
61 }	// namespace Mime
62 }	// namespace Storage
63 }	// namespace BPrivate
64 
65 
66 #endif	// _MINE_MIME_SNIFFER_ADDON_MANAGER_H
67 
68