e4f35acf7c
representing the interface for, well, MIME sniffer add-ons. * Implemented the respective add-on manager and make use of it in the MIME database code. Unfortunately the MIME DB code completely lives in libbe.so and hence I had to put my code there too. IMHO we should (one day) remove the direct (read-only) MIME DB access from libbe and move everything into the registrar. Currently the add-on manager supports built-in add-ons only; it doesn't really load anything from disk ATM. * Added a built-in text sniffer add-on to the registrar. It's based upon the BSD file tool code. This closes bug #250 (plain text files are identified as such, now). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17784 a95241bf-73f2-0310-859d-f6bbb57e9c96
63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
/*
|
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef MIME_SNIFFER_ADDON_MANAGER_H
|
|
#define MIME_SNIFFER_ADDON_MANAGER_H
|
|
|
|
#include <List.h>
|
|
#include <Locker.h>
|
|
|
|
class BFile;
|
|
class BMimeSnifferAddon;
|
|
class BMimeType;
|
|
|
|
namespace BPrivate {
|
|
namespace Storage {
|
|
namespace Mime {
|
|
|
|
|
|
class MimeSnifferAddonManager {
|
|
private:
|
|
MimeSnifferAddonManager();
|
|
~MimeSnifferAddonManager();
|
|
|
|
public:
|
|
static MimeSnifferAddonManager* Default();
|
|
static status_t CreateDefault();
|
|
static void DeleteDefault();
|
|
|
|
status_t AddMimeSnifferAddon(BMimeSnifferAddon* addon);
|
|
|
|
size_t MinimalBufferSize();
|
|
|
|
float GuessMimeType(const char* fileName,
|
|
BMimeType* type);
|
|
float GuessMimeType(BFile* file,
|
|
const void* buffer, int32 length,
|
|
BMimeType* type);
|
|
|
|
private:
|
|
struct AddonReference;
|
|
|
|
status_t _GetAddons(AddonReference**& references,
|
|
int32& count);
|
|
void _PutAddons(AddonReference** references,
|
|
int32 count);
|
|
|
|
static MimeSnifferAddonManager* sManager;
|
|
|
|
BLocker fLock;
|
|
BList fAddons;
|
|
size_t fMinimalBufferSize;
|
|
};
|
|
|
|
} // namespace Mime
|
|
} // namespace Storage
|
|
} // namespace BPrivate
|
|
|
|
using BPrivate::Storage::Mime::MimeSnifferAddonManager;
|
|
|
|
#endif // MIME_SNIFFER_ADDON_MANAGER_H
|
|
|