* Only allowed application hints of B_MIME_TYPE_LENGTH instead of B_PATH_NAME_LENGTH.
* Introduced a _SetStringValue() to avoid code duplication. * The string types now check the original value, and don't write anything if the contents stay unchanged (with the current exception of the sniffer rules). * The monitor notfication methods no longer "clobber" the status result. * Major cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16432 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
91fe5e6e58
commit
98d9f1b483
@ -1,15 +1,14 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2002-2006, Haiku.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*
|
||||||
/*!
|
* Authors:
|
||||||
\file Database.cpp
|
* Tyler Dauwalder
|
||||||
Database class declarations
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MIME_DATABASE_H
|
#ifndef _MIME_DATABASE_H
|
||||||
#define _MIME_DATABASE_H
|
#define _MIME_DATABASE_H
|
||||||
|
|
||||||
|
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
#include <mime/AssociatedTypes.h>
|
#include <mime/AssociatedTypes.h>
|
||||||
#include <mime/InstalledTypes.h>
|
#include <mime/InstalledTypes.h>
|
||||||
@ -40,79 +39,87 @@ typedef enum {
|
|||||||
B_REG_CREATE_APP_META_MIME,
|
B_REG_CREATE_APP_META_MIME,
|
||||||
} mime_update_function;
|
} mime_update_function;
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
public:
|
public:
|
||||||
Database();
|
Database();
|
||||||
~Database();
|
~Database();
|
||||||
|
|
||||||
status_t InitCheck() const;
|
status_t InitCheck() const;
|
||||||
|
|
||||||
// Type management
|
// Type management
|
||||||
status_t Install(const char *type);
|
status_t Install(const char *type);
|
||||||
status_t Delete(const char *type);
|
status_t Delete(const char *type);
|
||||||
|
|
||||||
// Set()
|
// Set()
|
||||||
status_t SetAppHint(const char *type, const entry_ref *ref);
|
status_t SetAppHint(const char *type, const entry_ref *ref);
|
||||||
status_t SetAttrInfo(const char *type, const BMessage *info);
|
status_t SetAttrInfo(const char *type, const BMessage *info);
|
||||||
status_t SetShortDescription(const char *type, const char *description);
|
status_t SetShortDescription(const char *type, const char *description);
|
||||||
status_t SetLongDescription(const char *type, const char *description);
|
status_t SetLongDescription(const char *type, const char *description);
|
||||||
status_t SetFileExtensions(const char *type, const BMessage *extensions);
|
status_t SetFileExtensions(const char *type, const BMessage *extensions);
|
||||||
status_t SetIcon(const char *type, const void *data, size_t dataSize, icon_size which);
|
status_t SetIcon(const char *type, const void *data, size_t dataSize,
|
||||||
status_t SetIconForType(const char *type, const char *fileType, const void *data,
|
icon_size which);
|
||||||
size_t dataSize, icon_size which);
|
status_t SetIconForType(const char *type, const char *fileType, const void *data,
|
||||||
status_t SetPreferredApp(const char *type, const char *signature, app_verb verb = B_OPEN);
|
size_t dataSize, icon_size which);
|
||||||
status_t SetSnifferRule(const char *type, const char *rule);
|
status_t SetPreferredApp(const char *type, const char *signature,
|
||||||
status_t SetSupportedTypes(const char *type, const BMessage *types, bool fullSync);
|
app_verb verb = B_OPEN);
|
||||||
|
status_t SetSnifferRule(const char *type, const char *rule);
|
||||||
|
status_t SetSupportedTypes(const char *type, const BMessage *types, bool fullSync);
|
||||||
|
|
||||||
// Non-atomic Get()
|
// Non-atomic Get()
|
||||||
status_t GetInstalledSupertypes(BMessage *super_types);
|
status_t GetInstalledSupertypes(BMessage *super_types);
|
||||||
status_t GetInstalledTypes(BMessage *types);
|
status_t GetInstalledTypes(BMessage *types);
|
||||||
status_t GetInstalledTypes(const char *super_type,
|
status_t GetInstalledTypes(const char *super_type,
|
||||||
BMessage *subtypes);
|
BMessage *subtypes);
|
||||||
status_t GetSupportingApps(const char *type, BMessage *signatures);
|
status_t GetSupportingApps(const char *type, BMessage *signatures);
|
||||||
status_t GetAssociatedTypes(const char *extension, BMessage *types);
|
status_t GetAssociatedTypes(const char *extension, BMessage *types);
|
||||||
|
|
||||||
// Sniffer
|
// Sniffer
|
||||||
status_t GuessMimeType(const entry_ref *file, BString *result);
|
status_t GuessMimeType(const entry_ref *file, BString *result);
|
||||||
status_t GuessMimeType(const void *buffer, int32 length, BString *result);
|
status_t GuessMimeType(const void *buffer, int32 length, BString *result);
|
||||||
status_t GuessMimeType(const char *filename, BString *result);
|
status_t GuessMimeType(const char *filename, BString *result);
|
||||||
|
|
||||||
// Monitor
|
// Monitor
|
||||||
status_t StartWatching(BMessenger target);
|
status_t StartWatching(BMessenger target);
|
||||||
status_t StopWatching(BMessenger target);
|
status_t StopWatching(BMessenger target);
|
||||||
|
|
||||||
// Delete()
|
// Delete()
|
||||||
status_t DeleteAppHint(const char *type);
|
status_t DeleteAppHint(const char *type);
|
||||||
status_t DeleteAttrInfo(const char *type);
|
status_t DeleteAttrInfo(const char *type);
|
||||||
status_t DeleteShortDescription(const char *type);
|
status_t DeleteShortDescription(const char *type);
|
||||||
status_t DeleteLongDescription(const char *type);
|
status_t DeleteLongDescription(const char *type);
|
||||||
status_t DeleteFileExtensions(const char *type);
|
status_t DeleteFileExtensions(const char *type);
|
||||||
status_t DeleteIcon(const char *type, icon_size size);
|
status_t DeleteIcon(const char *type, icon_size size);
|
||||||
status_t DeleteIconForType(const char *type, const char *fileType, icon_size which);
|
status_t DeleteIconForType(const char *type, const char *fileType,
|
||||||
status_t DeletePreferredApp(const char *type, app_verb verb = B_OPEN);
|
icon_size which);
|
||||||
status_t DeleteSnifferRule(const char *type);
|
status_t DeletePreferredApp(const char *type, app_verb verb = B_OPEN);
|
||||||
status_t DeleteSupportedTypes(const char *type, bool fullSync);
|
status_t DeleteSnifferRule(const char *type);
|
||||||
|
status_t DeleteSupportedTypes(const char *type, bool fullSync);
|
||||||
private:
|
|
||||||
// Functions to send monitor notifications
|
private:
|
||||||
status_t SendInstallNotification(const char *type);
|
status_t _SetStringValue(const char *type, int32 what,
|
||||||
status_t SendDeleteNotification(const char *type);
|
const char* attribute, type_code attributeType,
|
||||||
status_t SendMonitorUpdate(int32 which, const char *type, const char *extraType,
|
size_t maxLength, const char *value);
|
||||||
bool largeIcon, int32 action);
|
|
||||||
status_t SendMonitorUpdate(int32 which, const char *type, const char *extraType,
|
// Functions to send monitor notifications
|
||||||
int32 action);
|
status_t _SendInstallNotification(const char *type);
|
||||||
status_t SendMonitorUpdate(int32 which, const char *type, bool largeIcon,
|
status_t _SendDeleteNotification(const char *type);
|
||||||
int32 action);
|
status_t _SendMonitorUpdate(int32 which, const char *type,
|
||||||
status_t SendMonitorUpdate(int32 which, const char *type,
|
const char *extraType, bool largeIcon, int32 action);
|
||||||
int32 action);
|
status_t _SendMonitorUpdate(int32 which, const char *type,
|
||||||
status_t SendMonitorUpdate(BMessage &msg);
|
const char *extraType, int32 action);
|
||||||
|
status_t _SendMonitorUpdate(int32 which, const char *type,
|
||||||
status_t fStatus;
|
bool largeIcon, int32 action);
|
||||||
std::set<BMessenger> fMonitorMessengers;
|
status_t _SendMonitorUpdate(int32 which, const char *type,
|
||||||
AssociatedTypes fAssociatedTypes;
|
int32 action);
|
||||||
InstalledTypes fInstalledTypes;
|
status_t _SendMonitorUpdate(BMessage &msg);
|
||||||
SnifferRules fSnifferRules;
|
|
||||||
SupportingApps fSupportingApps;
|
private:
|
||||||
|
status_t fStatus;
|
||||||
|
std::set<BMessenger> fMonitorMessengers;
|
||||||
|
AssociatedTypes fAssociatedTypes;
|
||||||
|
InstalledTypes fInstalledTypes;
|
||||||
|
SnifferRules fSnifferRules;
|
||||||
|
SupportingApps fSupportingApps;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Mime
|
} // namespace Mime
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -54,16 +54,20 @@ namespace Mime {
|
|||||||
status_t
|
status_t
|
||||||
get_app_hint(const char *type, entry_ref *ref)
|
get_app_hint(const char *type, entry_ref *ref)
|
||||||
{
|
{
|
||||||
char path[B_MIME_TYPE_LENGTH];
|
if (type == NULL || ref == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
char path[B_PATH_NAME_LENGTH];
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
ssize_t err = ref ? B_OK : B_BAD_VALUE;
|
ssize_t status = read_mime_attr(type, kAppHintAttr, path,
|
||||||
if (!err)
|
B_PATH_NAME_LENGTH, kAppHintType);
|
||||||
err = read_mime_attr(type, kAppHintAttr, path, B_MIME_TYPE_LENGTH, kAppHintType);
|
|
||||||
if (err >= 0)
|
if (status >= B_OK)
|
||||||
err = entry.SetTo(path);
|
status = entry.SetTo(path);
|
||||||
if (!err)
|
if (status == B_OK)
|
||||||
err = entry.GetRef(ref);
|
status = entry.GetRef(ref);
|
||||||
return err;
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_attr_info
|
// get_attr_info
|
||||||
|
Loading…
Reference in New Issue
Block a user