Added GetSupportingApps()/SetSupportedTypes() functionality
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@923 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
682805b291
commit
41b9ba9155
@ -11,6 +11,7 @@
|
||||
#define _MIME_DATABASE_H
|
||||
|
||||
#include <mime/InstalledTypes.h>
|
||||
#include <mime/SupportingApps.h>
|
||||
#include <Mime.h>
|
||||
#include <Messenger.h>
|
||||
#include <StorageDefs.h>
|
||||
@ -49,7 +50,7 @@ public:
|
||||
size_t dataSize, icon_size which);
|
||||
status_t SetPreferredApp(const char *type, const char *signature, app_verb verb = B_OPEN);
|
||||
// status_t SetSnifferRule(const char *);
|
||||
status_t SetSupportedTypes(const char *type, const BMessage *types);
|
||||
status_t SetSupportedTypes(const char *type, const BMessage *types, bool fullSync);
|
||||
|
||||
// Non-atomic Get()
|
||||
status_t GetInstalledSupertypes(BMessage *super_types);
|
||||
@ -96,8 +97,9 @@ private:
|
||||
status_t SendMonitorUpdate(BMessage &msg);
|
||||
|
||||
status_t fCStatus;
|
||||
std::set<BMessenger> fMonitorSet;
|
||||
std::set<BMessenger> fMonitorMessengers;
|
||||
InstalledTypes fInstalledTypes;
|
||||
SupportingApps fSupportingApps;
|
||||
};
|
||||
|
||||
} // namespace Mime
|
||||
|
@ -370,13 +370,18 @@ Database::SetPreferredApp(const char *type, const char *signature, app_verb verb
|
||||
|
||||
// SetSupportedTypes
|
||||
status_t
|
||||
Database::SetSupportedTypes(const char *type, const BMessage *types)
|
||||
Database::SetSupportedTypes(const char *type, const BMessage *types, bool fullSync)
|
||||
{
|
||||
DBG(OUT("Database::SetSupportedTypes()\n"));
|
||||
bool didCreate = false;
|
||||
status_t err = (type && types) ? B_OK : B_BAD_VALUE;
|
||||
// Write the attr
|
||||
if (!err)
|
||||
err = write_mime_attr_message(type, kSupportedTypesAttr, types, &didCreate);
|
||||
// Update the supporting apps map
|
||||
if (!err)
|
||||
err = fSupportingApps.SetSupportedTypes(type, types, fullSync);
|
||||
// Notify the monitor
|
||||
if (!err)
|
||||
err = SendMonitorUpdate(B_SUPPORTED_TYPES_CHANGED, type, B_META_MIME_MODIFIED);
|
||||
return err;
|
||||
@ -403,7 +408,7 @@ Database::GetInstalledTypes(const char *supertype, BMessage *subtypes)
|
||||
status_t
|
||||
Database::GetSupportingApps(const char *type, BMessage *signatures)
|
||||
{
|
||||
return B_ERROR;
|
||||
return fSupportingApps.GetSupportingApps(type, signatures);
|
||||
}
|
||||
|
||||
|
||||
@ -492,7 +497,7 @@ Database::StartWatching(BMessenger target)
|
||||
DBG(OUT("Database::StartWatching()\n"));
|
||||
status_t err = target.IsValid() ? B_OK : B_BAD_VALUE;
|
||||
if (!err)
|
||||
fMonitorSet.insert(target);
|
||||
fMonitorMessengers.insert(target);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -504,9 +509,9 @@ status_t
|
||||
Database::StopWatching(BMessenger target)
|
||||
{
|
||||
DBG(OUT("Database::StopWatching()\n"));
|
||||
status_t err = fMonitorSet.find(target) != fMonitorSet.end() ? B_OK : B_ENTRY_NOT_FOUND;
|
||||
status_t err = fMonitorMessengers.find(target) != fMonitorMessengers.end() ? B_OK : B_ENTRY_NOT_FOUND;
|
||||
if (!err)
|
||||
fMonitorSet.erase(target);
|
||||
fMonitorMessengers.erase(target);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -744,7 +749,7 @@ Database::SendMonitorUpdate(BMessage &msg) {
|
||||
DBG(OUT("Database::SendMonitorUpdate(BMessage&)\n"));
|
||||
status_t err;
|
||||
std::set<BMessenger>::const_iterator i;
|
||||
for (i = fMonitorSet.begin(); i != fMonitorSet.end(); i++) {
|
||||
for (i = fMonitorMessengers.begin(); i != fMonitorMessengers.end(); i++) {
|
||||
status_t err = (*i).SendMessage(&msg, (BHandler*)NULL);
|
||||
if (err)
|
||||
DBG(OUT("Database::SendMonitorUpdate(BMessage&): BMessenger::SendMessage failed, %p\n", err));
|
||||
|
Loading…
Reference in New Issue
Block a user