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