Move MIME DB code back from registrar to src/kits/storage/mime
* Together with database_{access,support}.cpp it is built into a static library. * Add new interfaces MimeSniffer and Database::NotificationListener for plugging in registrar specific functionality (the sniffer add-on support and the notification mechanism).
This commit is contained in:
parent
a625f557c5
commit
9cda9c9905
@ -21,9 +21,12 @@ namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
class MimeSniffer;
|
||||
|
||||
|
||||
class AssociatedTypes {
|
||||
public:
|
||||
AssociatedTypes();
|
||||
AssociatedTypes(MimeSniffer* mimeSniffer);
|
||||
~AssociatedTypes();
|
||||
|
||||
status_t GetAssociatedTypes(const char *extension, BMessage *types);
|
||||
@ -45,8 +48,10 @@ private:
|
||||
|
||||
std::map<std::string, std::set<std::string> > fFileExtensions; // mime type => set of associated file extensions
|
||||
std::map<std::string, std::set<std::string> > fAssociatedTypes; // file extension => set of associated mime types
|
||||
|
||||
bool fHaveDoneFullBuild;
|
||||
|
||||
private:
|
||||
MimeSniffer* fMimeSniffer;
|
||||
bool fHaveDoneFullBuild;
|
||||
};
|
||||
|
||||
} // namespace Mime
|
@ -18,12 +18,11 @@
|
||||
#include <Messenger.h>
|
||||
#include <StorageDefs.h>
|
||||
|
||||
#include <mime/AssociatedTypes.h>
|
||||
#include <mime/database_access.h>
|
||||
|
||||
#include "AssociatedTypes.h"
|
||||
#include "InstalledTypes.h"
|
||||
#include "SnifferRules.h"
|
||||
#include "SupportingApps.h"
|
||||
#include <mime/InstalledTypes.h>
|
||||
#include <mime/SnifferRules.h>
|
||||
#include <mime/SupportingApps.h>
|
||||
|
||||
|
||||
class BNode;
|
||||
@ -37,6 +36,8 @@ namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
class MimeSniffer;
|
||||
|
||||
// types of mime update functions that may be run asynchronously
|
||||
typedef enum {
|
||||
B_REG_UPDATE_MIME_INFO,
|
||||
@ -45,7 +46,11 @@ typedef enum {
|
||||
|
||||
class Database {
|
||||
public:
|
||||
Database();
|
||||
class NotificationListener;
|
||||
|
||||
public:
|
||||
Database(MimeSniffer* mimeSniffer,
|
||||
NotificationListener* notificationListener);
|
||||
~Database();
|
||||
|
||||
status_t InitCheck() const;
|
||||
@ -137,6 +142,7 @@ class Database {
|
||||
|
||||
private:
|
||||
status_t fStatus;
|
||||
NotificationListener* fNotificationListener;
|
||||
std::set<BMessenger> fMonitorMessengers;
|
||||
AssociatedTypes fAssociatedTypes;
|
||||
InstalledTypes fInstalledTypes;
|
||||
@ -169,6 +175,16 @@ class InstallNotificationDeferrer {
|
||||
const char* fType;
|
||||
};
|
||||
|
||||
|
||||
class Database::NotificationListener {
|
||||
public:
|
||||
virtual ~NotificationListener();
|
||||
|
||||
virtual status_t Notify(BMessage* message,
|
||||
const BMessenger& target) = 0;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Mime
|
||||
} // namespace Storage
|
||||
} // namespace BPrivate
|
@ -12,6 +12,11 @@
|
||||
#include <MergedDirectory.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
|
||||
class DatabaseDirectory : public BMergedDirectory {
|
||||
public:
|
||||
DatabaseDirectory();
|
||||
@ -29,4 +34,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Mime
|
||||
} // namespace Storage
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // DATABASE_DIRECTORY_H
|
@ -10,11 +10,14 @@
|
||||
#ifndef _MIME_INSTALLED_TYPES_H
|
||||
#define _MIME_INSTALLED_TYPES_H
|
||||
|
||||
#include "Supertype.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <mime/Supertype.h>
|
||||
|
||||
|
||||
class BMessage;
|
||||
|
43
headers/private/storage/mime/MimeSniffer.h
Normal file
43
headers/private/storage/mime/MimeSniffer.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <ingo_weinhold@gmx.de>
|
||||
*/
|
||||
#ifndef _MIME_MIME_SNIFFER_H
|
||||
#define _MIME_MIME_SNIFFER_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
class BFile;
|
||||
class BMimeType;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
|
||||
class MimeSniffer {
|
||||
public:
|
||||
virtual ~MimeSniffer();
|
||||
|
||||
virtual size_t MinimalBufferSize() = 0;
|
||||
|
||||
virtual float GuessMimeType(const char* fileName,
|
||||
BMimeType* type) = 0;
|
||||
virtual float GuessMimeType(BFile* file,
|
||||
const void* buffer, int32 length,
|
||||
BMimeType* type) = 0;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Mime
|
||||
} // namespace Storage
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _MIME_MIME_SNIFFER_H
|
@ -25,9 +25,12 @@ namespace Sniffer {
|
||||
|
||||
namespace Mime {
|
||||
|
||||
class MimeSniffer;
|
||||
|
||||
|
||||
class SnifferRules {
|
||||
public:
|
||||
SnifferRules();
|
||||
SnifferRules(MimeSniffer* mimeSniffer);
|
||||
~SnifferRules();
|
||||
|
||||
status_t GuessMimeType(const entry_ref *ref, BString *type);
|
||||
@ -54,8 +57,11 @@ private:
|
||||
status_t ProcessType(const char *type, ssize_t *bytesNeeded);
|
||||
|
||||
std::list<sniffer_rule> fRuleList;
|
||||
ssize_t fMaxBytesNeeded;
|
||||
bool fHaveDoneFullBuild;
|
||||
|
||||
private:
|
||||
MimeSniffer* fMimeSniffer;
|
||||
ssize_t fMaxBytesNeeded;
|
||||
bool fHaveDoneFullBuild;
|
||||
};
|
||||
|
||||
} // namespace Mime
|
@ -35,6 +35,8 @@ SharedLibrary libbe.so : :
|
||||
<libbe>storage_kit.o
|
||||
<libbe>support_kit.o
|
||||
|
||||
libstorage_kit_mime.a
|
||||
|
||||
libicon.a
|
||||
libagg.a
|
||||
|
||||
|
@ -44,10 +44,6 @@ MergeObject <libbe>storage_kit.o :
|
||||
VolumeRoster.cpp
|
||||
storage_support.cpp
|
||||
|
||||
# mime
|
||||
database_access.cpp
|
||||
database_support.cpp
|
||||
|
||||
# sniffer
|
||||
CharStream.cpp
|
||||
Err.cpp
|
||||
@ -90,3 +86,5 @@ MergeObject <libbe>storage_kit.o :
|
||||
SetStringJob.cpp
|
||||
UninitializeJob.cpp
|
||||
;
|
||||
|
||||
HaikuSubInclude mime ;
|
||||
|
@ -7,7 +7,7 @@
|
||||
AssociatedTypes class implementation
|
||||
*/
|
||||
|
||||
#include "AssociatedTypes.h"
|
||||
#include <mime/AssociatedTypes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -16,15 +16,14 @@
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <Message.h>
|
||||
#include <mime/database_support.h>
|
||||
#include <mime/DatabaseDirectory.h>
|
||||
#include <mime/MimeSniffer.h>
|
||||
#include <MimeType.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
#include <mime/database_support.h>
|
||||
#include <storage_support.h>
|
||||
|
||||
#include "DatabaseDirectory.h"
|
||||
#include "MimeSnifferAddonManager.h"
|
||||
|
||||
|
||||
#define DBG(x) x
|
||||
//#define DBG(x)
|
||||
@ -41,8 +40,10 @@ namespace Mime {
|
||||
|
||||
// Constructor
|
||||
//! Constructs a new AssociatedTypes object
|
||||
AssociatedTypes::AssociatedTypes()
|
||||
: fHaveDoneFullBuild(false)
|
||||
AssociatedTypes::AssociatedTypes(MimeSniffer* mimeSniffer)
|
||||
:
|
||||
fMimeSniffer(mimeSniffer),
|
||||
fHaveDoneFullBuild(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -106,16 +107,13 @@ AssociatedTypes::GuessMimeType(const char *filename, BString *result)
|
||||
if (!err && !fHaveDoneFullBuild)
|
||||
err = BuildAssociatedTypesTable();
|
||||
|
||||
// if we have an MimeSnifferAddonManager, let's give it a shot first
|
||||
if (!err) {
|
||||
MimeSnifferAddonManager* manager = MimeSnifferAddonManager::Default();
|
||||
if (manager) {
|
||||
BMimeType mimeType;
|
||||
float priority = manager->GuessMimeType(filename, &mimeType);
|
||||
if (priority >= 0) {
|
||||
*result = mimeType.Type();
|
||||
return B_OK;
|
||||
}
|
||||
// if we have a mime sniffer, let's give it a shot first
|
||||
if (!err && fMimeSniffer != NULL) {
|
||||
BMimeType mimeType;
|
||||
float priority = fMimeSniffer->GuessMimeType(filename, &mimeType);
|
||||
if (priority >= 0) {
|
||||
*result = mimeType.Type();
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "Database.h"
|
||||
#include <mime/Database.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
@ -34,7 +34,6 @@
|
||||
#include <mime/database_support.h>
|
||||
#include <storage_support.h>
|
||||
|
||||
#include "MessageDeliverer.h"
|
||||
|
||||
//#define DBG(x) x
|
||||
#define DBG(x)
|
||||
@ -45,6 +44,12 @@ namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
|
||||
Database::NotificationListener::~NotificationListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class Database
|
||||
\brief Mime::Database is the master of the MIME data base.
|
||||
@ -59,9 +64,13 @@ namespace Mime {
|
||||
// constructor
|
||||
/*! \brief Creates and initializes a Mime::Database object.
|
||||
*/
|
||||
Database::Database()
|
||||
Database::Database(MimeSniffer* mimeSniffer,
|
||||
NotificationListener* notificationListener)
|
||||
:
|
||||
fStatus(B_NO_INIT),
|
||||
fNotificationListener(notificationListener),
|
||||
fAssociatedTypes(mimeSniffer),
|
||||
fSnifferRules(mimeSniffer),
|
||||
fDeferredInstallNotificationsLocker("deferred install notifications"),
|
||||
fDeferredInstallNotifications()
|
||||
{
|
||||
@ -1472,16 +1481,17 @@ Database::_SendMonitorUpdate(int32 which, const char *type, int32 action)
|
||||
status_t
|
||||
Database::_SendMonitorUpdate(BMessage &msg)
|
||||
{
|
||||
// DBG(OUT("Database::_SendMonitorUpdate(BMessage&)\n"));
|
||||
if (fNotificationListener == NULL)
|
||||
return B_OK;
|
||||
|
||||
status_t err;
|
||||
std::set<BMessenger>::const_iterator i;
|
||||
for (i = fMonitorMessengers.begin(); i != fMonitorMessengers.end(); i++) {
|
||||
status_t err = MessageDeliverer::Default()->DeliverMessage(&msg, *i);
|
||||
status_t err = fNotificationListener->Notify(&msg, *i);
|
||||
if (err) {
|
||||
DBG(OUT("Database::_SendMonitorUpdate(BMessage&): DeliverMessage failed, 0x%lx\n", err));
|
||||
}
|
||||
}
|
||||
// DBG(OUT("Database::_SendMonitorUpdate(BMessage&) done\n"));
|
||||
err = B_OK;
|
||||
return err;
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "DatabaseDirectory.h"
|
||||
#include <mime/DatabaseDirectory.h>
|
||||
|
||||
#include <fs_attr.h>
|
||||
#include <Node.h>
|
||||
@ -16,6 +16,11 @@
|
||||
#include <mime/database_support.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
|
||||
DatabaseDirectory::DatabaseDirectory()
|
||||
:
|
||||
BMergedDirectory(B_COMPARE)
|
||||
@ -67,3 +72,8 @@ DatabaseDirectory::_IsValidMimeTypeEntry(const entry_ref& entry)
|
||||
return node.SetTo(&entry) == B_OK
|
||||
&& node.GetAttrInfo(BPrivate::Storage::Mime::kTypeAttr, &info) == B_OK;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Mime
|
||||
} // namespace Storage
|
||||
} // namespace BPrivate
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "InstalledTypes.h"
|
||||
#include <mime/InstalledTypes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -22,10 +22,9 @@
|
||||
#include <String.h>
|
||||
|
||||
#include <mime/database_support.h>
|
||||
#include <mime/DatabaseDirectory.h>
|
||||
#include <storage_support.h>
|
||||
|
||||
#include "DatabaseDirectory.h"
|
||||
|
||||
|
||||
#define DBG(x) x
|
||||
//#define DBG(x)
|
23
src/kits/storage/mime/Jamfile
Normal file
23
src/kits/storage/mime/Jamfile
Normal file
@ -0,0 +1,23 @@
|
||||
SubDir HAIKU_TOP src kits storage mime ;
|
||||
|
||||
SetSubDirSupportedPlatforms haiku libbe_test ;
|
||||
|
||||
UsePrivateHeaders app shared storage ;
|
||||
#UsePrivateHeaders app libroot shared storage ;
|
||||
#UsePrivateSystemHeaders ;
|
||||
|
||||
# for libbe_test
|
||||
#UsePublicHeaders [ FDirName add-ons registrar ] ;
|
||||
|
||||
StaticLibrary libstorage_kit_mime.a :
|
||||
AssociatedTypes.cpp
|
||||
Database.cpp
|
||||
DatabaseDirectory.cpp
|
||||
database_access.cpp
|
||||
database_support.cpp
|
||||
InstalledTypes.cpp
|
||||
MimeSniffer.cpp
|
||||
SnifferRules.cpp
|
||||
Supertype.cpp
|
||||
SupportingApps.cpp
|
||||
;
|
25
src/kits/storage/mime/MimeSniffer.cpp
Normal file
25
src/kits/storage/mime/MimeSniffer.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <ingo_weinhold@gmx.de>
|
||||
*/
|
||||
|
||||
|
||||
#include <mime/MimeSniffer.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
|
||||
MimeSniffer::~MimeSniffer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace Mime
|
||||
} // namespace Storage
|
||||
} // namespace BPrivate
|
@ -12,7 +12,7 @@
|
||||
SnifferRules class implementation
|
||||
*/
|
||||
|
||||
#include "SnifferRules.h"
|
||||
#include <mime/SnifferRules.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
@ -22,14 +22,14 @@
|
||||
#include <File.h>
|
||||
#include <MimeType.h>
|
||||
#include <mime/database_support.h>
|
||||
#include <mime/DatabaseDirectory.h>
|
||||
#include <mime/MimeSniffer.h>
|
||||
#include <sniffer/Parser.h>
|
||||
#include <sniffer/Rule.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <storage_support.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "DatabaseDirectory.h"
|
||||
#include "MimeSnifferAddonManager.h"
|
||||
|
||||
#define DBG(x) x
|
||||
//#define DBG(x)
|
||||
@ -112,8 +112,11 @@ bool operator<(SnifferRules::sniffer_rule &left, SnifferRules::sniffer_rule &rig
|
||||
|
||||
// Constructor
|
||||
//! Constructs a new SnifferRules object
|
||||
SnifferRules::SnifferRules()
|
||||
: fHaveDoneFullBuild(false)
|
||||
SnifferRules::SnifferRules(MimeSniffer* mimeSniffer)
|
||||
:
|
||||
fMimeSniffer(mimeSniffer),
|
||||
fMaxBytesNeeded(0),
|
||||
fHaveDoneFullBuild(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -449,15 +452,12 @@ SnifferRules::GuessMimeType(BFile* file, const void *buffer, int32 length,
|
||||
if (!err && !fHaveDoneFullBuild)
|
||||
err = BuildRuleList();
|
||||
|
||||
// first ask the MimeSnifferAddonManager for a suitable type
|
||||
// first ask the MIME sniffer for a suitable type
|
||||
float addonPriority = -1;
|
||||
BMimeType mimeType;
|
||||
if (!err) {
|
||||
MimeSnifferAddonManager* manager = MimeSnifferAddonManager::Default();
|
||||
if (manager) {
|
||||
addonPriority = manager->GuessMimeType(file, buffer, length,
|
||||
&mimeType);
|
||||
}
|
||||
if (!err && fMimeSniffer != NULL) {
|
||||
addonPriority = fMimeSniffer->GuessMimeType(file, buffer, length,
|
||||
&mimeType);
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
@ -520,10 +520,10 @@ SnifferRules::MaxBytesNeeded()
|
||||
ssize_t err = fHaveDoneFullBuild ? B_OK : BuildRuleList();
|
||||
if (!err) {
|
||||
err = fMaxBytesNeeded;
|
||||
MimeSnifferAddonManager* manager = MimeSnifferAddonManager::Default();
|
||||
if (manager) {
|
||||
|
||||
if (fMimeSniffer != NULL) {
|
||||
fMaxBytesNeeded = max_c(fMaxBytesNeeded,
|
||||
(ssize_t)manager->MinimalBufferSize());
|
||||
(ssize_t)fMimeSniffer->MinimalBufferSize());
|
||||
}
|
||||
}
|
||||
return err;
|
@ -7,7 +7,7 @@
|
||||
Supertype class implementation
|
||||
*/
|
||||
|
||||
#include "Supertype.h"
|
||||
#include <mime/Supertype.h>
|
||||
|
||||
#include <Message.h>
|
||||
#include <mime/database_support.h>
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "SupportingApps.h"
|
||||
#include <mime/SupportingApps.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -23,10 +23,9 @@
|
||||
#include <String.h>
|
||||
|
||||
#include <mime/database_support.h>
|
||||
#include <mime/DatabaseDirectory.h>
|
||||
#include <storage_support.h>
|
||||
|
||||
#include "DatabaseDirectory.h"
|
||||
|
||||
|
||||
#define DBG(x) x
|
||||
//#define DBG(x)
|
@ -12,6 +12,8 @@
|
||||
Mime database atomic read functions
|
||||
*/
|
||||
|
||||
#include <mime/database_access.h>
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Entry.h>
|
||||
#include <Directory.h>
|
||||
@ -30,7 +32,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include "mime/database_access.h"
|
||||
|
||||
#define DBG(x) x
|
||||
//#define DBG(x)
|
||||
|
@ -40,21 +40,15 @@ Server registrar
|
||||
WatchingService.cpp
|
||||
|
||||
# mime
|
||||
AssociatedTypes.cpp
|
||||
CreateAppMetaMimeThread.cpp
|
||||
Database.cpp
|
||||
DatabaseDirectory.cpp
|
||||
InstalledTypes.cpp
|
||||
MimeSnifferAddon.cpp
|
||||
MimeSnifferAddonManager.cpp
|
||||
MimeUpdateThread.cpp
|
||||
RegistrarThread.cpp
|
||||
RegistrarThreadManager.cpp
|
||||
SnifferRules.cpp
|
||||
Supertype.cpp
|
||||
SupportingApps.cpp
|
||||
UpdateMimeInfoThread.cpp
|
||||
:
|
||||
libstorage_kit_mime.a
|
||||
be
|
||||
$(TARGET_LIBSTDC++)
|
||||
$(HAIKU_LOCALE_LIBS)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include "CreateAppMetaMimeThread.h"
|
||||
#include "MessageDeliverer.h"
|
||||
#include "MimeSnifferAddonManager.h"
|
||||
#include "TextSnifferAddon.h"
|
||||
#include "UpdateMimeInfoThread.h"
|
||||
@ -38,23 +39,27 @@ using namespace BPrivate;
|
||||
*/
|
||||
|
||||
|
||||
static MimeSnifferAddonManager*
|
||||
init_mime_sniffer_add_on_manager()
|
||||
{
|
||||
if (MimeSnifferAddonManager::CreateDefault() != B_OK)
|
||||
return NULL;
|
||||
|
||||
MimeSnifferAddonManager* manager = MimeSnifferAddonManager::Default();
|
||||
manager->AddMimeSnifferAddon(new(nothrow) TextSnifferAddon());
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Creates and initializes a MIMEManager.
|
||||
*/
|
||||
MIMEManager::MIMEManager()
|
||||
:
|
||||
BLooper("main_mime"),
|
||||
fDatabase(),
|
||||
fDatabase(init_mime_sniffer_add_on_manager(), this),
|
||||
fThreadManager()
|
||||
{
|
||||
AddHandler(&fThreadManager);
|
||||
|
||||
// prepare the MimeSnifferAddonManager and the built-in add-ons
|
||||
status_t error = MimeSnifferAddonManager::CreateDefault();
|
||||
if (error == B_OK) {
|
||||
MimeSnifferAddonManager* addonManager
|
||||
= MimeSnifferAddonManager::Default();
|
||||
addonManager->AddMimeSnifferAddon(new(nothrow) TextSnifferAddon());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -298,6 +303,13 @@ MIMEManager::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MIMEManager::Notify(BMessage* message, const BMessenger& target)
|
||||
{
|
||||
return MessageDeliverer::Default()->DeliverMessage(message, target);
|
||||
}
|
||||
|
||||
|
||||
//! Handles all B_REG_MIME_SET_PARAM messages
|
||||
void
|
||||
MIMEManager::HandleSetParam(BMessage *message)
|
||||
|
@ -5,15 +5,23 @@
|
||||
|
||||
#include <Looper.h>
|
||||
|
||||
#include "Database.h"
|
||||
#include <mime/Database.h>
|
||||
|
||||
#include "RegistrarThreadManager.h"
|
||||
|
||||
class MIMEManager : public BLooper {
|
||||
|
||||
class MIMEManager : public BLooper,
|
||||
private BPrivate::Storage::Mime::Database::NotificationListener {
|
||||
public:
|
||||
MIMEManager();
|
||||
virtual ~MIMEManager();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
// Database::NotificationListener
|
||||
virtual status_t Notify(BMessage* message, const BMessenger& target);
|
||||
|
||||
private:
|
||||
void HandleSetParam(BMessage *message);
|
||||
void HandleDeleteParam(BMessage *message);
|
||||
|
@ -21,10 +21,9 @@
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <mime/Database.h>
|
||||
#include <mime/database_support.h>
|
||||
|
||||
#include "Database.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include <List.h>
|
||||
#include <Locker.h>
|
||||
|
||||
#include <mime/MimeSniffer.h>
|
||||
|
||||
|
||||
class BFile;
|
||||
class BMimeSnifferAddon;
|
||||
class BMimeType;
|
||||
@ -17,7 +20,7 @@ namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
|
||||
class MimeSnifferAddonManager {
|
||||
class MimeSnifferAddonManager : public BPrivate::Storage::Mime::MimeSniffer {
|
||||
private:
|
||||
MimeSnifferAddonManager();
|
||||
~MimeSnifferAddonManager();
|
||||
@ -29,14 +32,14 @@ public:
|
||||
|
||||
status_t AddMimeSnifferAddon(BMimeSnifferAddon* addon);
|
||||
|
||||
size_t MinimalBufferSize();
|
||||
virtual size_t MinimalBufferSize();
|
||||
|
||||
float GuessMimeType(const char* fileName,
|
||||
virtual float GuessMimeType(const char* fileName,
|
||||
BMimeType* type);
|
||||
float GuessMimeType(BFile* file,
|
||||
virtual float GuessMimeType(BFile* file,
|
||||
const void* buffer, int32 length,
|
||||
BMimeType* type);
|
||||
|
||||
|
||||
private:
|
||||
struct AddonReference;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user