Add private MIME DB classes to libbe_build
* This pulls in some more stuff, like libicon and agg which are also included in libbe_build, now. * Update a few libbe_build classes and headers needed to get things building. * This likely breaks the <build>mimeset build on Haiku.
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
#include <../os/interface/Gradient.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../os/interface/IconUtils.h>
|
||||||
@@ -1,128 +1 @@
|
|||||||
//----------------------------------------------------------------------
|
#include <../os/storage/AppFileInfo.h>
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
|
||||||
// by the OpenBeOS license.
|
|
||||||
//---------------------------------------------------------------------
|
|
||||||
/*!
|
|
||||||
\file AppFileInfo.h
|
|
||||||
BAppFileInfo and related structures' interface declarations.
|
|
||||||
*/
|
|
||||||
#ifndef _APP_FILE_INFO_H
|
|
||||||
#define _APP_FILE_INFO_H
|
|
||||||
|
|
||||||
#include <NodeInfo.h>
|
|
||||||
|
|
||||||
class BBitmap;
|
|
||||||
class BFile;
|
|
||||||
class BMessage;
|
|
||||||
class BResources;
|
|
||||||
|
|
||||||
struct version_info {
|
|
||||||
uint32 major;
|
|
||||||
uint32 middle;
|
|
||||||
uint32 minor;
|
|
||||||
uint32 variety;
|
|
||||||
uint32 internal;
|
|
||||||
char short_info[64];
|
|
||||||
char long_info[256];
|
|
||||||
};
|
|
||||||
|
|
||||||
enum info_location {
|
|
||||||
B_USE_ATTRIBUTES = 0x1,
|
|
||||||
B_USE_RESOURCES = 0x2,
|
|
||||||
B_USE_BOTH_LOCATIONS = 0x3 // == B_USE_ATTRIBUTES | B_USE_RESOURCES
|
|
||||||
};
|
|
||||||
|
|
||||||
enum version_kind {
|
|
||||||
B_APP_VERSION_KIND,
|
|
||||||
B_SYSTEM_VERSION_KIND
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! \brief Executable meta information handling.
|
|
||||||
The BAppFileInfo class provides access to meta data that can be associated
|
|
||||||
with executables, libraries and add-ons.
|
|
||||||
|
|
||||||
\author <a href='[email protected]'>Ingo Weinhold</a>
|
|
||||||
\version 0.0.0
|
|
||||||
*/
|
|
||||||
class BAppFileInfo: public BNodeInfo {
|
|
||||||
public:
|
|
||||||
BAppFileInfo();
|
|
||||||
BAppFileInfo(BFile *file);
|
|
||||||
virtual ~BAppFileInfo();
|
|
||||||
|
|
||||||
status_t SetTo(BFile *file);
|
|
||||||
|
|
||||||
virtual status_t GetType(char *type) const;
|
|
||||||
virtual status_t SetType(const char *type);
|
|
||||||
|
|
||||||
status_t GetSignature(char *signature) const;
|
|
||||||
status_t SetSignature(const char *signature);
|
|
||||||
|
|
||||||
status_t GetCatalogEntry(char *catalogEntry) const;
|
|
||||||
status_t SetCatalogEntry(const char *catalogEntry);
|
|
||||||
|
|
||||||
status_t GetAppFlags(uint32 *flags) const;
|
|
||||||
status_t SetAppFlags(uint32 flags);
|
|
||||||
|
|
||||||
status_t GetSupportedTypes(BMessage *types) const;
|
|
||||||
status_t SetSupportedTypes(const BMessage *types, bool syncAll);
|
|
||||||
status_t SetSupportedTypes(const BMessage *types);
|
|
||||||
bool IsSupportedType(const char *type) const;
|
|
||||||
bool Supports(BMimeType *type) const;
|
|
||||||
|
|
||||||
virtual status_t GetIcon(BBitmap *icon, icon_size which) const;
|
|
||||||
virtual status_t SetIcon(const BBitmap *icon, icon_size which);
|
|
||||||
|
|
||||||
status_t GetVersionInfo(version_info *info, version_kind kind) const;
|
|
||||||
status_t SetVersionInfo(const version_info *info, version_kind kind);
|
|
||||||
|
|
||||||
status_t GetIconForType(const char *type, BBitmap *icon,
|
|
||||||
icon_size which) const;
|
|
||||||
status_t SetIconForType(const char *type, const BBitmap *icon,
|
|
||||||
icon_size which);
|
|
||||||
|
|
||||||
void SetInfoLocation(info_location location);
|
|
||||||
bool IsUsingAttributes() const;
|
|
||||||
bool IsUsingResources() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// uncomment when needed
|
|
||||||
// friend status_t _update_mime_info_(const char *, int32);
|
|
||||||
// friend status_t _real_update_app_(BAppFileInfo *, const char *, bool);
|
|
||||||
// friend status_t _query_for_app_(BMimeType *, const char *, entry_ref *,
|
|
||||||
// version_info *);
|
|
||||||
// friend class BRoster;
|
|
||||||
|
|
||||||
virtual void _ReservedAppFileInfo1();
|
|
||||||
virtual void _ReservedAppFileInfo2();
|
|
||||||
virtual void _ReservedAppFileInfo3();
|
|
||||||
|
|
||||||
// uncomment when needed
|
|
||||||
// static status_t SetSupTypesForAll(BMimeType *, const BMessage *);
|
|
||||||
|
|
||||||
BAppFileInfo &operator=(const BAppFileInfo &);
|
|
||||||
BAppFileInfo(const BAppFileInfo &);
|
|
||||||
|
|
||||||
// uncomment when needed
|
|
||||||
// status_t _SetSupportedTypes(const BMessage *types);
|
|
||||||
// status_t UpdateFromRsrc();
|
|
||||||
// status_t RealUpdateRsrcToAttr();
|
|
||||||
// status_t UpdateMetaMime(const char *path, bool force,
|
|
||||||
// uint32 *changesMask) const;
|
|
||||||
// bool IsApp();
|
|
||||||
status_t GetMetaMime(BMimeType *meta) const;
|
|
||||||
|
|
||||||
status_t _ReadData(const char *name, int32 id, type_code type,
|
|
||||||
void *buffer, size_t bufferSize,
|
|
||||||
size_t &bytesRead, void **allocatedBuffer = NULL) const;
|
|
||||||
status_t _WriteData(const char *name, int32 id, type_code type,
|
|
||||||
const void *buffer, size_t bufferSize,
|
|
||||||
bool findID = false);
|
|
||||||
status_t _RemoveData(const char *name, type_code type);
|
|
||||||
|
|
||||||
BResources *fResources;
|
|
||||||
info_location fWhere;
|
|
||||||
uint32 _reserved[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _APP_FILE_INFO_H
|
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public:
|
|||||||
status_t InitCheck() const;
|
status_t InitCheck() const;
|
||||||
bool Exists() const;
|
bool Exists() const;
|
||||||
|
|
||||||
|
const char* Name() const;
|
||||||
|
|
||||||
virtual status_t GetStat(struct stat *st) const;
|
virtual status_t GetStat(struct stat *st) const;
|
||||||
|
|
||||||
status_t SetTo(const BDirectory *dir, const char *path,
|
status_t SetTo(const BDirectory *dir, const char *path,
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../private/interface/Palette.h>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Ingo Weinhold <[email protected]>
|
||||||
|
*/
|
||||||
|
#ifndef _MERGED_DIRECTORY_H
|
||||||
|
#define _MERGED_DIRECTORY_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <EntryList.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BDirectory;
|
||||||
|
|
||||||
|
|
||||||
|
class BMergedDirectory : public BEntryList {
|
||||||
|
public:
|
||||||
|
// policy how to handle equally named entries in different
|
||||||
|
// directories
|
||||||
|
enum BPolicy {
|
||||||
|
B_ALLOW_DUPLICATES,
|
||||||
|
B_ALWAYS_FIRST,
|
||||||
|
B_COMPARE
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
BMergedDirectory(
|
||||||
|
BPolicy policy = B_ALWAYS_FIRST);
|
||||||
|
virtual ~BMergedDirectory();
|
||||||
|
|
||||||
|
status_t Init();
|
||||||
|
|
||||||
|
BPolicy Policy() const;
|
||||||
|
void SetPolicy(BPolicy policy);
|
||||||
|
|
||||||
|
status_t AddDirectory(BDirectory* directory);
|
||||||
|
status_t AddDirectory(const char* path);
|
||||||
|
|
||||||
|
virtual status_t GetNextEntry(BEntry* entry,
|
||||||
|
bool traverse = false);
|
||||||
|
virtual status_t GetNextRef(entry_ref* ref);
|
||||||
|
virtual int32 GetNextDirents(struct dirent* direntBuffer,
|
||||||
|
size_t bufferSize,
|
||||||
|
int32 maxEntries = INT_MAX);
|
||||||
|
virtual status_t Rewind();
|
||||||
|
virtual int32 CountEntries();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool ShallPreferFirstEntry(const entry_ref& entry1,
|
||||||
|
int32 index1, const entry_ref& entry2,
|
||||||
|
int32 index2);
|
||||||
|
// always invoked with index1 < index2
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef BObjectList<BDirectory> DirectoryList;
|
||||||
|
struct EntryNameSet;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _IsBestEntry(const char* name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DirectoryList fDirectories;
|
||||||
|
BPolicy fPolicy;
|
||||||
|
int32 fDirectoryIndex;
|
||||||
|
EntryNameSet* fVisitedEntries;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _MERGED_DIRECTORY_H
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/AppMetaMimeCreator.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/AssociatedTypes.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/Database.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/DatabaseDirectory.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/DatabaseLocation.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/InstalledTypes.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/MimeSniffer.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/SnifferRules.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/Supertype.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/mime/SupportingApps.h>
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
//----------------------------------------------------------------------
|
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
|
||||||
// by the OpenBeOS license.
|
|
||||||
//---------------------------------------------------------------------
|
|
||||||
/*!
|
|
||||||
\file database_access.h
|
|
||||||
Mime database atomic read functions and miscellany declarations
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MIME_DATABASE_ACCESS_H
|
|
||||||
#define _MIME_DATABASE_ACCESS_H
|
|
||||||
|
|
||||||
#include <Mime.h>
|
|
||||||
|
|
||||||
class BNode;
|
|
||||||
class BBitmap;
|
|
||||||
class BMessage;
|
|
||||||
|
|
||||||
namespace BPrivate {
|
|
||||||
namespace Storage {
|
|
||||||
namespace Mime {
|
|
||||||
|
|
||||||
// Get() functions
|
|
||||||
status_t get_app_hint(const char *type, entry_ref *ref);
|
|
||||||
status_t get_attr_info(const char *type, BMessage *info);
|
|
||||||
status_t get_short_description(const char *type, char *description);
|
|
||||||
status_t get_long_description(const char *type, char *description);
|
|
||||||
status_t get_file_extensions(const char *type, BMessage *extensions);
|
|
||||||
status_t get_icon(const char *type, BBitmap *icon, icon_size size);
|
|
||||||
status_t get_icon_for_type(const char *type, const char *fileType, BBitmap *icon,
|
|
||||||
icon_size which);
|
|
||||||
status_t get_preferred_app(const char *type, char *signature, app_verb verb);
|
|
||||||
status_t get_sniffer_rule(const char *type, BString *result);
|
|
||||||
status_t get_supported_types(const char *type, BMessage *types);
|
|
||||||
|
|
||||||
bool is_installed(const char *type);
|
|
||||||
|
|
||||||
// Called by BMimeType to get properly formatted icon data ready
|
|
||||||
// to be shipped off to SetIcon*() and written to the database
|
|
||||||
status_t get_icon_data(const BBitmap *icon, icon_size size, void **data, int32 *dataSize);
|
|
||||||
|
|
||||||
} // namespace Mime
|
|
||||||
} // namespace Storage
|
|
||||||
} // namespace BPrivate
|
|
||||||
|
|
||||||
#endif // _MIME_DATABASE_H
|
|
||||||
@@ -1,97 +1 @@
|
|||||||
//----------------------------------------------------------------------
|
#include <../../../private/storage/mime/database_support.h>
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
|
||||||
// by the OpenBeOS license.
|
|
||||||
//---------------------------------------------------------------------
|
|
||||||
/*!
|
|
||||||
\file database_support.h
|
|
||||||
Private mime database function and constant declarations
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MIME_DATABASE_SUPPORT_H
|
|
||||||
#define _MIME_DATABASE_SUPPORT_H
|
|
||||||
|
|
||||||
#include <StorageDefs.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class BNode;
|
|
||||||
class BMessage;
|
|
||||||
|
|
||||||
namespace BPrivate {
|
|
||||||
namespace Storage {
|
|
||||||
namespace Mime {
|
|
||||||
|
|
||||||
// Database directory
|
|
||||||
extern const std::string kDatabaseDir;
|
|
||||||
extern const std::string kApplicationDatabaseDir;
|
|
||||||
|
|
||||||
// Attribute Prefixes
|
|
||||||
extern const char *kMiniIconAttrPrefix;
|
|
||||||
extern const char *kLargeIconAttrPrefix;
|
|
||||||
|
|
||||||
// Attribute names
|
|
||||||
extern const char *kFileTypeAttr;
|
|
||||||
extern const char *kTypeAttr;
|
|
||||||
extern const char *kAttrInfoAttr;
|
|
||||||
extern const char *kAppHintAttr;
|
|
||||||
extern const char *kShortDescriptionAttr;
|
|
||||||
extern const char *kLongDescriptionAttr;
|
|
||||||
extern const char *kFileExtensionsAttr;
|
|
||||||
extern const char *kMiniIconAttr;
|
|
||||||
extern const char *kLargeIconAttr;
|
|
||||||
extern const char *kPreferredAppAttr;
|
|
||||||
extern const char *kSnifferRuleAttr;
|
|
||||||
extern const char *kSupportedTypesAttr;
|
|
||||||
|
|
||||||
// Attribute Datatypes
|
|
||||||
extern const int32 kFileTypeType;
|
|
||||||
extern const int32 kTypeType;
|
|
||||||
extern const int32 kAppHintType;
|
|
||||||
extern const int32 kAttrInfoType;
|
|
||||||
extern const int32 kShortDescriptionType;
|
|
||||||
extern const int32 kLongDescriptionType;
|
|
||||||
extern const int32 kFileExtensionsType;
|
|
||||||
extern const int32 kMiniIconType;
|
|
||||||
extern const int32 kLargeIconType;
|
|
||||||
extern const int32 kPreferredAppType;
|
|
||||||
extern const int32 kSnifferRuleType;
|
|
||||||
extern const int32 kSupportedTypesType;
|
|
||||||
|
|
||||||
// Message fields
|
|
||||||
extern const char *kApplicationsField;
|
|
||||||
extern const char *kExtensionsField;
|
|
||||||
extern const char *kSupertypesField;
|
|
||||||
extern const char *kSupportingAppsSubCountField;
|
|
||||||
extern const char *kSupportingAppsSuperCountField;
|
|
||||||
extern const char *kTypesField;
|
|
||||||
|
|
||||||
// Mime types
|
|
||||||
extern const char *kGenericFileType;
|
|
||||||
extern const char *kDirectoryType;
|
|
||||||
extern const char *kSymlinkType;
|
|
||||||
extern const char *kMetaMimeType;
|
|
||||||
|
|
||||||
// Error codes (to be used only by BPrivate::Storage::Mime members)
|
|
||||||
extern const status_t kMimeGuessFailureError;
|
|
||||||
|
|
||||||
std::string type_to_filename(const char *type);
|
|
||||||
|
|
||||||
status_t open_type(const char *type, BNode *result);
|
|
||||||
status_t open_or_create_type(const char *type, BNode *result, bool *didCreate);
|
|
||||||
|
|
||||||
ssize_t read_mime_attr(const char *type, const char *attr, void *data,
|
|
||||||
size_t len, type_code datatype);
|
|
||||||
status_t read_mime_attr_message(const char *type, const char *attr, BMessage *msg);
|
|
||||||
status_t read_mime_attr_string(const char *type, const char *attr, BString *str);
|
|
||||||
status_t write_mime_attr(const char *type, const char *attr, const void *data,
|
|
||||||
size_t len, type_code datatype, bool *didCreate);
|
|
||||||
status_t write_mime_attr_message(const char *type, const char *attr,
|
|
||||||
const BMessage *msg, bool *didCreate);
|
|
||||||
|
|
||||||
status_t delete_attribute(const char *type, const char *attr);
|
|
||||||
|
|
||||||
} // namespace Mime
|
|
||||||
} // namespace Storage
|
|
||||||
} // namespace BPrivate
|
|
||||||
|
|
||||||
#endif // _MIME_DATABASE_SUPPORT_H
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/CharStream.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/DisjList.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/Err.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/Parser.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/Pattern.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/PatternList.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/RPattern.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/RPatternList.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/Range.h>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../../../private/storage/sniffer/Rule.h>
|
||||||
@@ -2,6 +2,7 @@ SubDir HAIKU_TOP src build ;
|
|||||||
|
|
||||||
SubInclude HAIKU_TOP src build libbe ;
|
SubInclude HAIKU_TOP src build libbe ;
|
||||||
SubInclude HAIKU_TOP src build libhaikucompat ;
|
SubInclude HAIKU_TOP src build libhaikucompat ;
|
||||||
|
SubInclude HAIKU_TOP src build libicon ;
|
||||||
SubInclude HAIKU_TOP src build libpackage ;
|
SubInclude HAIKU_TOP src build libpackage ;
|
||||||
SubInclude HAIKU_TOP src build libroot ;
|
SubInclude HAIKU_TOP src build libroot ;
|
||||||
SubInclude HAIKU_TOP src build libshared ;
|
SubInclude HAIKU_TOP src build libshared ;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ BuildPlatformSharedLibrary libbe_build.so :
|
|||||||
# no sources here
|
# no sources here
|
||||||
:
|
:
|
||||||
<libbe_build>app_kit.o
|
<libbe_build>app_kit.o
|
||||||
|
<libbe_build>icon_kit.o
|
||||||
<libbe_build>interface_kit.o
|
<libbe_build>interface_kit.o
|
||||||
<libbe_build>storage_kit.o
|
<libbe_build>storage_kit.o
|
||||||
<libbe_build>support_kit.o
|
<libbe_build>support_kit.o
|
||||||
@@ -17,6 +18,7 @@ BuildPlatformSharedLibrary libbe_build.so :
|
|||||||
;
|
;
|
||||||
|
|
||||||
SubInclude HAIKU_TOP src build libbe app ;
|
SubInclude HAIKU_TOP src build libbe app ;
|
||||||
|
SubInclude HAIKU_TOP src build libbe icon ;
|
||||||
SubInclude HAIKU_TOP src build libbe interface ;
|
SubInclude HAIKU_TOP src build libbe interface ;
|
||||||
SubInclude HAIKU_TOP src build libbe storage ;
|
SubInclude HAIKU_TOP src build libbe storage ;
|
||||||
SubInclude HAIKU_TOP src build libbe support ;
|
SubInclude HAIKU_TOP src build libbe support ;
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
SubDir HAIKU_TOP src build libbe icon ;
|
||||||
|
|
||||||
|
# source directories
|
||||||
|
local sourceDirs =
|
||||||
|
$(DOT)
|
||||||
|
flat_icon
|
||||||
|
message
|
||||||
|
shape
|
||||||
|
style
|
||||||
|
transformable
|
||||||
|
transformer
|
||||||
|
;
|
||||||
|
|
||||||
|
local sourceDir ;
|
||||||
|
for sourceDir in $(sourceDirs) {
|
||||||
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs icon $(sourceDir) ] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs agg src ] ;
|
||||||
|
|
||||||
|
# system headers
|
||||||
|
UseLibraryHeaders agg icon ;
|
||||||
|
|
||||||
|
UsePrivateBuildHeaders shared ;
|
||||||
|
|
||||||
|
USES_BE_API on <libbe_build>icon_kit.o = true ;
|
||||||
|
|
||||||
|
BuildPlatformMergeObjectPIC <libbe_build>icon_kit.o :
|
||||||
|
# flat_icon
|
||||||
|
FlatIconFormat.cpp
|
||||||
|
FlatIconImporter.cpp
|
||||||
|
LittleEndianBuffer.cpp
|
||||||
|
PathCommandQueue.cpp
|
||||||
|
|
||||||
|
# message
|
||||||
|
Defines.cpp
|
||||||
|
MessageImporter.cpp
|
||||||
|
|
||||||
|
# shape
|
||||||
|
PathContainer.cpp
|
||||||
|
Shape.cpp
|
||||||
|
ShapeContainer.cpp
|
||||||
|
VectorPath.cpp
|
||||||
|
|
||||||
|
# style
|
||||||
|
GradientTransformable.cpp
|
||||||
|
Style.cpp
|
||||||
|
StyleContainer.cpp
|
||||||
|
|
||||||
|
# transformable
|
||||||
|
Transformable.cpp
|
||||||
|
|
||||||
|
# transformer
|
||||||
|
AffineTransformer.cpp
|
||||||
|
ContourTransformer.cpp
|
||||||
|
PathSource.cpp
|
||||||
|
PerspectiveTransformer.cpp
|
||||||
|
StrokeTransformer.cpp
|
||||||
|
Transformer.cpp
|
||||||
|
TransformerFactory.cpp
|
||||||
|
|
||||||
|
Icon.cpp
|
||||||
|
IconRenderer.cpp
|
||||||
|
IconUtils.cpp
|
||||||
|
|
||||||
|
# agg
|
||||||
|
agg_arc.cpp
|
||||||
|
agg_arrowhead.cpp
|
||||||
|
agg_bezier_arc.cpp
|
||||||
|
agg_bspline.cpp
|
||||||
|
agg_curves.cpp
|
||||||
|
agg_embedded_raster_fonts.cpp
|
||||||
|
agg_gsv_text.cpp
|
||||||
|
agg_image_filters.cpp
|
||||||
|
agg_line_aa_basics.cpp
|
||||||
|
agg_line_profile_aa.cpp
|
||||||
|
agg_rounded_rect.cpp
|
||||||
|
agg_sqrt_tables.cpp
|
||||||
|
agg_trans_affine.cpp
|
||||||
|
agg_trans_double_path.cpp
|
||||||
|
agg_trans_single_path.cpp
|
||||||
|
agg_trans_warp_magnifier.cpp
|
||||||
|
agg_vcgen_bspline.cpp
|
||||||
|
agg_vcgen_contour.cpp
|
||||||
|
agg_vcgen_dash.cpp
|
||||||
|
agg_vcgen_markers_term.cpp
|
||||||
|
agg_vcgen_smooth_poly1.cpp
|
||||||
|
agg_vcgen_stroke.cpp
|
||||||
|
agg_vpgen_clip_polygon.cpp
|
||||||
|
agg_vpgen_clip_polyline.cpp
|
||||||
|
agg_vpgen_segmentator.cpp
|
||||||
|
;
|
||||||
@@ -8,9 +8,11 @@ USES_BE_API on <libbe_build>interface_kit.o = true ;
|
|||||||
|
|
||||||
BuildPlatformMergeObjectPIC <libbe_build>interface_kit.o :
|
BuildPlatformMergeObjectPIC <libbe_build>interface_kit.o :
|
||||||
Bitmap.cpp
|
Bitmap.cpp
|
||||||
|
Gradient.cpp
|
||||||
GraphicsDefs.cpp
|
GraphicsDefs.cpp
|
||||||
Point.cpp
|
Point.cpp
|
||||||
Rect.cpp
|
Rect.cpp
|
||||||
Region.cpp
|
Region.cpp
|
||||||
RegionSupport.cpp
|
RegionSupport.cpp
|
||||||
|
SystemPalette.cpp
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2001-2006, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* DarkWyrm <[email protected]>
|
||||||
|
* Stefano Ceccherini ([email protected])
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! Methods to initialize and get the system color_map.
|
||||||
|
|
||||||
|
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
|
#include <Palette.h>
|
||||||
|
|
||||||
|
// TODO: BWindowScreen has a method to set the palette.
|
||||||
|
// maybe we should have a lock to protect this variable.
|
||||||
|
static color_map sColorMap;
|
||||||
|
|
||||||
|
|
||||||
|
// color_distance
|
||||||
|
/*! \brief Returns the "distance" between two RGB colors.
|
||||||
|
|
||||||
|
This functions defines an metric on the RGB color space. The distance
|
||||||
|
between two colors is 0, if and only if the colors are equal.
|
||||||
|
|
||||||
|
\param red1 Red component of the first color.
|
||||||
|
\param green1 Green component of the first color.
|
||||||
|
\param blue1 Blue component of the first color.
|
||||||
|
\param red2 Red component of the second color.
|
||||||
|
\param green2 Green component of the second color.
|
||||||
|
\param blue2 Blue component of the second color.
|
||||||
|
\return The distance between the given colors.
|
||||||
|
*/
|
||||||
|
static inline uint32
|
||||||
|
color_distance(uint8 red1, uint8 green1, uint8 blue1,
|
||||||
|
uint8 red2, uint8 green2, uint8 blue2)
|
||||||
|
{
|
||||||
|
int rd = (int)red1 - (int)red2;
|
||||||
|
int gd = (int)green1 - (int)green2;
|
||||||
|
int bd = (int)blue1 - (int)blue2;
|
||||||
|
|
||||||
|
// distance according to psycho-visual tests
|
||||||
|
// algorithm taken from here:
|
||||||
|
// http://www.stud.uni-hannover.de/~michaelt/juggle/Algorithms.pdf
|
||||||
|
int rmean = ((int)red1 + (int)red2) / 2;
|
||||||
|
return (((512 + rmean) * rd * rd) >> 8)
|
||||||
|
+ 4 * gd * gd
|
||||||
|
+ (((767 - rmean) * bd * bd) >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline uint8
|
||||||
|
FindClosestColor(const rgb_color &color, const rgb_color *palette)
|
||||||
|
{
|
||||||
|
uint8 closestIndex = 0;
|
||||||
|
unsigned closestDistance = UINT_MAX;
|
||||||
|
for (int32 i = 0; i < 256; i++) {
|
||||||
|
const rgb_color &c = palette[i];
|
||||||
|
unsigned distance = color_distance(color.red, color.green, color.blue,
|
||||||
|
c.red, c.green, c.blue);
|
||||||
|
if (distance < closestDistance) {
|
||||||
|
closestIndex = (uint8)i;
|
||||||
|
closestDistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return closestIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline rgb_color
|
||||||
|
InvertColor(const rgb_color &color)
|
||||||
|
{
|
||||||
|
// For some reason, Inverting (255, 255, 255) on beos
|
||||||
|
// results in the same color.
|
||||||
|
if (color.red == 255 && color.green == 255
|
||||||
|
&& color.blue == 255)
|
||||||
|
return color;
|
||||||
|
|
||||||
|
rgb_color inverted;
|
||||||
|
inverted.red = 255 - color.red;
|
||||||
|
inverted.green = 255 - color.green;
|
||||||
|
inverted.blue = 255 - color.blue;
|
||||||
|
inverted.alpha = 255;
|
||||||
|
|
||||||
|
return inverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
FillColorMap(const rgb_color *palette, color_map *map)
|
||||||
|
{
|
||||||
|
memcpy(map->color_list, palette, sizeof(map->color_list));
|
||||||
|
|
||||||
|
// init index map
|
||||||
|
for (int32 color = 0; color < 32768; color++) {
|
||||||
|
// get components
|
||||||
|
rgb_color rgbColor;
|
||||||
|
rgbColor.red = (color & 0x7c00) >> 7;
|
||||||
|
rgbColor.green = (color & 0x3e0) >> 2;
|
||||||
|
rgbColor.blue = (color & 0x1f) << 3;
|
||||||
|
|
||||||
|
map->index_map[color] = FindClosestColor(rgbColor, palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
// init inversion map
|
||||||
|
for (int32 index = 0; index < 256; index++) {
|
||||||
|
rgb_color inverted = InvertColor(map->color_list[index]);
|
||||||
|
map->inversion_map[index] = FindClosestColor(inverted, palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const color_map *
|
||||||
|
system_colors()
|
||||||
|
{
|
||||||
|
static bool sInitialized = false;
|
||||||
|
if (!sInitialized) {
|
||||||
|
FillColorMap(kSystemPalette, &sColorMap);
|
||||||
|
sInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &sColorMap;
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the Haiku distribution and is covered
|
* Copyright 2002-2007, Haiku Inc.
|
||||||
// by the MIT license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*
|
||||||
/*!
|
* Authors:
|
||||||
\file AppFileInfo.cpp
|
* Ingo Weinhold, [email protected]
|
||||||
BAppFileInfo and related structures' implementation.
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -16,7 +16,9 @@
|
|||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
|
#include <IconUtils.h>
|
||||||
#include <MimeType.h>
|
#include <MimeType.h>
|
||||||
|
#include <RegistrarDefs.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@@ -24,15 +26,17 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
static const char *kTypeAttribute = "BEOS:TYPE";
|
static const char* kTypeAttribute = "BEOS:TYPE";
|
||||||
static const char *kSignatureAttribute = "BEOS:APP_SIG";
|
static const char* kSignatureAttribute = "BEOS:APP_SIG";
|
||||||
static const char *kAppFlagsAttribute = "BEOS:APP_FLAGS";
|
static const char* kAppFlagsAttribute = "BEOS:APP_FLAGS";
|
||||||
static const char *kSupportedTypesAttribute = "BEOS:FILE_TYPES";
|
static const char* kSupportedTypesAttribute = "BEOS:FILE_TYPES";
|
||||||
static const char *kVersionInfoAttribute = "BEOS:APP_VERSION";
|
static const char* kVersionInfoAttribute = "BEOS:APP_VERSION";
|
||||||
static const char *kMiniIconAttribute = "BEOS:M:";
|
static const char* kMiniIconAttribute = "BEOS:M:";
|
||||||
static const char *kLargeIconAttribute = "BEOS:L:";
|
static const char* kLargeIconAttribute = "BEOS:L:";
|
||||||
static const char *kStandardIconType = "STD_ICON";
|
static const char* kIconAttribute = "BEOS:";
|
||||||
static const char *kCatalogEntryAttribute = "SYS:NAME";
|
static const char* kStandardIconType = "STD_ICON";
|
||||||
|
static const char* kIconType = "ICON";
|
||||||
|
static const char* kCatalogEntryAttribute = "SYS:NAME";
|
||||||
|
|
||||||
// resource IDs
|
// resource IDs
|
||||||
static const int32 kTypeResourceID = 2;
|
static const int32 kTypeResourceID = 2;
|
||||||
@@ -41,9 +45,11 @@ static const int32 kAppFlagsResourceID = 1;
|
|||||||
static const int32 kSupportedTypesResourceID = 1;
|
static const int32 kSupportedTypesResourceID = 1;
|
||||||
static const int32 kMiniIconResourceID = 101;
|
static const int32 kMiniIconResourceID = 101;
|
||||||
static const int32 kLargeIconResourceID = 101;
|
static const int32 kLargeIconResourceID = 101;
|
||||||
|
static const int32 kIconResourceID = 101;
|
||||||
static const int32 kVersionInfoResourceID = 1;
|
static const int32 kVersionInfoResourceID = 1;
|
||||||
static const int32 kMiniIconForTypeResourceID = 0;
|
static const int32 kMiniIconForTypeResourceID = 0;
|
||||||
static const int32 kLargeIconForTypeResourceID = 0;
|
static const int32 kLargeIconForTypeResourceID = 0;
|
||||||
|
static const int32 kIconForTypeResourceID = 0;
|
||||||
static const int32 kCatalogEntryResourceID = 1;
|
static const int32 kCatalogEntryResourceID = 1;
|
||||||
|
|
||||||
// type codes
|
// type codes
|
||||||
@@ -53,7 +59,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// R5 also exports these (Tracker is using them):
|
// R5 also exports these (Tracker is using them):
|
||||||
// (maybe we better want to drop them silently and declare
|
// (maybe we better want to drop them silently and declare
|
||||||
// the above in a public Haiku header - and use that one in
|
// the above in a public Haiku header - and use that one in
|
||||||
// Tracker when compiled for Haiku)
|
// Tracker when compiled for Haiku)
|
||||||
extern const uint32 MINI_ICON_TYPE, LARGE_ICON_TYPE;
|
extern const uint32 MINI_ICON_TYPE, LARGE_ICON_TYPE;
|
||||||
@@ -69,11 +75,13 @@ const uint32 LARGE_ICON_TYPE = 'ICON';
|
|||||||
/*! \brief Creates an uninitialized BAppFileInfo object.
|
/*! \brief Creates an uninitialized BAppFileInfo object.
|
||||||
*/
|
*/
|
||||||
BAppFileInfo::BAppFileInfo()
|
BAppFileInfo::BAppFileInfo()
|
||||||
: fResources(NULL),
|
:
|
||||||
fWhere(B_USE_BOTH_LOCATIONS)
|
fResources(NULL),
|
||||||
|
fWhere(B_USE_BOTH_LOCATIONS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
/*! \brief Creates an BAppFileInfo object and initializes it to the supplied
|
/*! \brief Creates an BAppFileInfo object and initializes it to the supplied
|
||||||
file.
|
file.
|
||||||
@@ -84,13 +92,15 @@ BAppFileInfo::BAppFileInfo()
|
|||||||
|
|
||||||
\param file The file the object shall be initialized to.
|
\param file The file the object shall be initialized to.
|
||||||
*/
|
*/
|
||||||
BAppFileInfo::BAppFileInfo(BFile *file)
|
BAppFileInfo::BAppFileInfo(BFile* file)
|
||||||
: fResources(NULL),
|
:
|
||||||
fWhere(B_USE_BOTH_LOCATIONS)
|
fResources(NULL),
|
||||||
|
fWhere(B_USE_BOTH_LOCATIONS)
|
||||||
{
|
{
|
||||||
SetTo(file);
|
SetTo(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
/*! \brief Frees all resources associated with this object.
|
/*! \brief Frees all resources associated with this object.
|
||||||
|
|
||||||
@@ -98,10 +108,10 @@ BAppFileInfo::BAppFileInfo(BFile *file)
|
|||||||
*/
|
*/
|
||||||
BAppFileInfo::~BAppFileInfo()
|
BAppFileInfo::~BAppFileInfo()
|
||||||
{
|
{
|
||||||
if (fResources)
|
delete fResources;
|
||||||
delete fResources;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetTo
|
// SetTo
|
||||||
/*! \brief Initializes the BAppFileInfo to the supplied file.
|
/*! \brief Initializes the BAppFileInfo to the supplied file.
|
||||||
|
|
||||||
@@ -124,36 +134,52 @@ BAppFileInfo::SetTo(BFile *file)
|
|||||||
delete fResources;
|
delete fResources;
|
||||||
fResources = NULL;
|
fResources = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check param
|
// check param
|
||||||
status_t error = (file && file->InitCheck() == B_OK ? B_OK : B_BAD_VALUE);
|
status_t error = (file && file->InitCheck() == B_OK ? B_OK : B_BAD_VALUE);
|
||||||
|
|
||||||
|
info_location where = B_USE_BOTH_LOCATIONS;
|
||||||
|
|
||||||
// create resources
|
// create resources
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
fResources = new(nothrow) BResources();
|
fResources = new(nothrow) BResources();
|
||||||
if (fResources)
|
if (fResources) {
|
||||||
error = fResources->SetTo(file);
|
error = fResources->SetTo(file);
|
||||||
else
|
if (error != B_OK) {
|
||||||
|
// no resources - this is no critical error, we'll just use
|
||||||
|
// attributes only, then
|
||||||
|
where = B_USE_ATTRIBUTES;
|
||||||
|
error = B_OK;
|
||||||
|
}
|
||||||
|
} else
|
||||||
error = B_NO_MEMORY;
|
error = B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set node info
|
// set node info
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = BNodeInfo::SetTo(file);
|
error = BNodeInfo::SetTo(file);
|
||||||
|
|
||||||
|
if (error != B_OK || (where & B_USE_RESOURCES) == 0) {
|
||||||
|
delete fResources;
|
||||||
|
fResources = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// clean up on error
|
// clean up on error
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
if (fResources) {
|
|
||||||
delete fResources;
|
|
||||||
fResources = NULL;
|
|
||||||
}
|
|
||||||
if (InitCheck() == B_OK)
|
if (InitCheck() == B_OK)
|
||||||
BNodeInfo::SetTo(NULL);
|
BNodeInfo::SetTo(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set data location
|
// set data location
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
SetInfoLocation(B_USE_BOTH_LOCATIONS);
|
SetInfoLocation(where);
|
||||||
|
|
||||||
// set error
|
// set error
|
||||||
fCStatus = error;
|
fCStatus = error;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetType
|
// GetType
|
||||||
/*! \brief Gets the file's MIME type.
|
/*! \brief Gets the file's MIME type.
|
||||||
|
|
||||||
@@ -193,6 +219,7 @@ BAppFileInfo::GetType(char *type) const
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetType
|
// SetType
|
||||||
/*! \brief Sets the file's MIME type.
|
/*! \brief Sets the file's MIME type.
|
||||||
|
|
||||||
@@ -208,7 +235,7 @@ BAppFileInfo::GetType(char *type) const
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetType(const char *type)
|
BAppFileInfo::SetType(const char* type)
|
||||||
{
|
{
|
||||||
// check initialization
|
// check initialization
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@@ -231,6 +258,7 @@ BAppFileInfo::SetType(const char *type)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetSignature
|
// GetSignature
|
||||||
/*! \brief Gets the file's application signature.
|
/*! \brief Gets the file's application signature.
|
||||||
|
|
||||||
@@ -248,7 +276,7 @@ BAppFileInfo::SetType(const char *type)
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::GetSignature(char *signature) const
|
BAppFileInfo::GetSignature(char* signature) const
|
||||||
{
|
{
|
||||||
// check param and initialization
|
// check param and initialization
|
||||||
status_t error = (signature ? B_OK : B_BAD_VALUE);
|
status_t error = (signature ? B_OK : B_BAD_VALUE);
|
||||||
@@ -258,8 +286,8 @@ BAppFileInfo::GetSignature(char *signature) const
|
|||||||
size_t read = 0;
|
size_t read = 0;
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
error = _ReadData(kSignatureAttribute, kSignatureResourceID,
|
error = _ReadData(kSignatureAttribute, kSignatureResourceID,
|
||||||
B_MIME_STRING_TYPE, signature, B_MIME_TYPE_LENGTH,
|
B_MIME_STRING_TYPE, signature,
|
||||||
read);
|
B_MIME_TYPE_LENGTH, read);
|
||||||
}
|
}
|
||||||
// check the read data -- null terminate the string
|
// check the read data -- null terminate the string
|
||||||
if (error == B_OK && signature[read - 1] != '\0') {
|
if (error == B_OK && signature[read - 1] != '\0') {
|
||||||
@@ -271,6 +299,7 @@ BAppFileInfo::GetSignature(char *signature) const
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetSignature
|
// SetSignature
|
||||||
/*! \brief Sets the file's application signature.
|
/*! \brief Sets the file's application signature.
|
||||||
|
|
||||||
@@ -286,7 +315,7 @@ BAppFileInfo::GetSignature(char *signature) const
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetSignature(const char *signature)
|
BAppFileInfo::SetSignature(const char* signature)
|
||||||
{
|
{
|
||||||
// check initialization
|
// check initialization
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@@ -368,7 +397,7 @@ BAppFileInfo::GetCatalogEntry(char *catalogEntry) const
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetCatalogEntry(const char *catalogEntry)
|
BAppFileInfo::SetCatalogEntry(const char* catalogEntry)
|
||||||
{
|
{
|
||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
@@ -400,7 +429,7 @@ BAppFileInfo::SetCatalogEntry(const char *catalogEntry)
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::GetAppFlags(uint32 *flags) const
|
BAppFileInfo::GetAppFlags(uint32* flags) const
|
||||||
{
|
{
|
||||||
// check param and initialization
|
// check param and initialization
|
||||||
status_t error = (flags ? B_OK : B_BAD_VALUE);
|
status_t error = (flags ? B_OK : B_BAD_VALUE);
|
||||||
@@ -419,6 +448,7 @@ BAppFileInfo::GetAppFlags(uint32 *flags) const
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetAppFlags
|
// SetAppFlags
|
||||||
/*! \brief Sets the file's application flags.
|
/*! \brief Sets the file's application flags.
|
||||||
\param flags The application flags to be assigned to the file.
|
\param flags The application flags to be assigned to the file.
|
||||||
@@ -436,14 +466,35 @@ BAppFileInfo::SetAppFlags(uint32 flags)
|
|||||||
error = B_NO_INIT;
|
error = B_NO_INIT;
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
// write the data
|
// write the data
|
||||||
if (error == B_OK) {
|
error = _WriteData(kAppFlagsAttribute, kAppFlagsResourceID,
|
||||||
error = _WriteData(kAppFlagsAttribute, kAppFlagsResourceID,
|
B_APP_FLAGS_TYPE, &flags, sizeof(uint32));
|
||||||
B_APP_FLAGS_TYPE, &flags, sizeof(uint32));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// RemoveAppFlags
|
||||||
|
/*! \brief Removes the file's application flags.
|
||||||
|
\return
|
||||||
|
- \c B_OK: Everything went fine.
|
||||||
|
- \c B_NO_INIT: The object is not properly initialized.
|
||||||
|
- other error codes
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BAppFileInfo::RemoveAppFlags()
|
||||||
|
{
|
||||||
|
// check initialization
|
||||||
|
status_t error = B_OK;
|
||||||
|
if (error == B_OK && InitCheck() != B_OK)
|
||||||
|
error = B_NO_INIT;
|
||||||
|
if (error == B_OK) {
|
||||||
|
// remove the data
|
||||||
|
error = _RemoveData(kAppFlagsAttribute, B_APP_FLAGS_TYPE);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetSupportedTypes
|
// GetSupportedTypes
|
||||||
/*! \brief Gets the MIME types supported by the application.
|
/*! \brief Gets the MIME types supported by the application.
|
||||||
|
|
||||||
@@ -462,7 +513,7 @@ BAppFileInfo::SetAppFlags(uint32 flags)
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::GetSupportedTypes(BMessage *types) const
|
BAppFileInfo::GetSupportedTypes(BMessage* types) const
|
||||||
{
|
{
|
||||||
// check param and initialization
|
// check param and initialization
|
||||||
status_t error = (types ? B_OK : B_BAD_VALUE);
|
status_t error = (types ? B_OK : B_BAD_VALUE);
|
||||||
@@ -479,11 +530,11 @@ BAppFileInfo::GetSupportedTypes(BMessage *types) const
|
|||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = types->Unflatten((const char*)buffer);
|
error = types->Unflatten((const char*)buffer);
|
||||||
// clean up
|
// clean up
|
||||||
if (buffer)
|
free(buffer);
|
||||||
free(buffer);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetSupportedTypes
|
// SetSupportedTypes
|
||||||
/*! \brief Sets the MIME types supported by the application.
|
/*! \brief Sets the MIME types supported by the application.
|
||||||
|
|
||||||
@@ -511,7 +562,7 @@ BAppFileInfo::GetSupportedTypes(BMessage *types) const
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetSupportedTypes(const BMessage *types, bool syncAll)
|
BAppFileInfo::SetSupportedTypes(const BMessage* types, bool syncAll)
|
||||||
{
|
{
|
||||||
// check initialization
|
// check initialization
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@@ -524,7 +575,7 @@ BAppFileInfo::SetSupportedTypes(const BMessage *types, bool syncAll)
|
|||||||
error = B_OK;
|
error = B_OK;
|
||||||
if (types) {
|
if (types) {
|
||||||
// check param -- supported types must be valid
|
// check param -- supported types must be valid
|
||||||
const char *type;
|
const char* type;
|
||||||
for (int32 i = 0;
|
for (int32 i = 0;
|
||||||
error == B_OK && types->FindString("types", i, &type) == B_OK;
|
error == B_OK && types->FindString("types", i, &type) == B_OK;
|
||||||
i++) {
|
i++) {
|
||||||
@@ -539,7 +590,7 @@ BAppFileInfo::SetSupportedTypes(const BMessage *types, bool syncAll)
|
|||||||
error = size;
|
error = size;
|
||||||
}
|
}
|
||||||
// allocate a buffer for the flattened data
|
// allocate a buffer for the flattened data
|
||||||
char *buffer = NULL;
|
char* buffer = NULL;
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
buffer = new(nothrow) char[size];
|
buffer = new(nothrow) char[size];
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
@@ -555,17 +606,17 @@ BAppFileInfo::SetSupportedTypes(const BMessage *types, bool syncAll)
|
|||||||
buffer, size);
|
buffer, size);
|
||||||
}
|
}
|
||||||
// clean up
|
// clean up
|
||||||
if (buffer)
|
delete[] buffer;
|
||||||
delete[] buffer;
|
|
||||||
} else
|
} else
|
||||||
error = _RemoveData(kSupportedTypesAttribute, B_MESSAGE_TYPE);
|
error = _RemoveData(kSupportedTypesAttribute, B_MESSAGE_TYPE);
|
||||||
// update the MIME database, if the app signature is installed
|
// update the MIME database, if the app signature is installed
|
||||||
// if (error == B_OK && mimeType.IsInstalled())
|
// if (error == B_OK && mimeType.IsInstalled())
|
||||||
// error = mimeType.SetSupportedTypes(types, syncAll);
|
// error = mimeType.SetSupportedTypes(types, syncAll);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetSupportedTypes
|
// SetSupportedTypes
|
||||||
/*! \brief Sets the MIME types supported by the application.
|
/*! \brief Sets the MIME types supported by the application.
|
||||||
|
|
||||||
@@ -580,11 +631,12 @@ BAppFileInfo::SetSupportedTypes(const BMessage *types, bool syncAll)
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetSupportedTypes(const BMessage *types)
|
BAppFileInfo::SetSupportedTypes(const BMessage* types)
|
||||||
{
|
{
|
||||||
return SetSupportedTypes(types, false);
|
return SetSupportedTypes(types, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IsSupportedType
|
// IsSupportedType
|
||||||
/*! \brief Returns whether the application supports the supplied MIME type.
|
/*! \brief Returns whether the application supports the supplied MIME type.
|
||||||
|
|
||||||
@@ -596,7 +648,7 @@ BAppFileInfo::SetSupportedTypes(const BMessage *types)
|
|||||||
the application, \c false otherwise.
|
the application, \c false otherwise.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
BAppFileInfo::IsSupportedType(const char *type) const
|
BAppFileInfo::IsSupportedType(const char* type) const
|
||||||
{
|
{
|
||||||
status_t error = (type ? B_OK : B_BAD_VALUE);
|
status_t error = (type ? B_OK : B_BAD_VALUE);
|
||||||
// get the supported types
|
// get the supported types
|
||||||
@@ -610,7 +662,7 @@ BAppFileInfo::IsSupportedType(const char *type) const
|
|||||||
// iterate through the supported types
|
// iterate through the supported types
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
const char *supportedType;
|
const char* supportedType;
|
||||||
for (int32 i = 0;
|
for (int32 i = 0;
|
||||||
!found && types.FindString("types", i, &supportedType) == B_OK;
|
!found && types.FindString("types", i, &supportedType) == B_OK;
|
||||||
i++) {
|
i++) {
|
||||||
@@ -621,6 +673,7 @@ BAppFileInfo::IsSupportedType(const char *type) const
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Supports
|
// Supports
|
||||||
/*! \brief Returns whether the application supports the supplied MIME type
|
/*! \brief Returns whether the application supports the supplied MIME type
|
||||||
explicitly.
|
explicitly.
|
||||||
@@ -634,7 +687,7 @@ BAppFileInfo::IsSupportedType(const char *type) const
|
|||||||
supported by the application, \c false otherwise.
|
supported by the application, \c false otherwise.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
BAppFileInfo::Supports(BMimeType *type) const
|
BAppFileInfo::Supports(BMimeType* type) const
|
||||||
{
|
{
|
||||||
status_t error = (type && type->InitCheck() == B_OK ? B_OK : B_BAD_VALUE);
|
status_t error = (type && type->InitCheck() == B_OK ? B_OK : B_BAD_VALUE);
|
||||||
// get the supported types
|
// get the supported types
|
||||||
@@ -644,7 +697,7 @@ BAppFileInfo::Supports(BMimeType *type) const
|
|||||||
// iterate through the supported types
|
// iterate through the supported types
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
const char *supportedType;
|
const char* supportedType;
|
||||||
for (int32 i = 0;
|
for (int32 i = 0;
|
||||||
!found && types.FindString("types", i, &supportedType) == B_OK;
|
!found && types.FindString("types", i, &supportedType) == B_OK;
|
||||||
i++) {
|
i++) {
|
||||||
@@ -654,6 +707,7 @@ BAppFileInfo::Supports(BMimeType *type) const
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetIcon
|
// GetIcon
|
||||||
/*! \brief Gets the file's icon.
|
/*! \brief Gets the file's icon.
|
||||||
\param icon A pointer to a pre-allocated BBitmap of the correct dimension
|
\param icon A pointer to a pre-allocated BBitmap of the correct dimension
|
||||||
@@ -669,11 +723,29 @@ BAppFileInfo::Supports(BMimeType *type) const
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::GetIcon(BBitmap *icon, icon_size which) const
|
BAppFileInfo::GetIcon(BBitmap* icon, icon_size which) const
|
||||||
{
|
{
|
||||||
return GetIconForType(NULL, icon, which);
|
return GetIconForType(NULL, icon, which);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GetIcon
|
||||||
|
/*! \brief Gets the file's icon.
|
||||||
|
\param data The pointer in which the flat icon data will be returned.
|
||||||
|
\param size The pointer in which the size of the data found will be returned.
|
||||||
|
\return
|
||||||
|
- \c B_OK: Everything went fine.
|
||||||
|
- \c B_NO_INIT: The object is not properly initialized.
|
||||||
|
- \c B_BAD_VALUE: \c NULL \a data or \c NULL size.
|
||||||
|
- other error codes
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BAppFileInfo::GetIcon(uint8** data, size_t* size) const
|
||||||
|
{
|
||||||
|
return GetIconForType(NULL, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetIcon
|
// SetIcon
|
||||||
/*! \brief Sets the file's icon.
|
/*! \brief Sets the file's icon.
|
||||||
|
|
||||||
@@ -691,11 +763,33 @@ BAppFileInfo::GetIcon(BBitmap *icon, icon_size which) const
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetIcon(const BBitmap *icon, icon_size which)
|
BAppFileInfo::SetIcon(const BBitmap* icon, icon_size which)
|
||||||
{
|
{
|
||||||
return SetIconForType(NULL, icon, which);
|
return SetIconForType(NULL, icon, which);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SetIcon
|
||||||
|
/*! \brief Sets the file's icon.
|
||||||
|
|
||||||
|
If \a icon is \c NULL the file's icon is unset.
|
||||||
|
|
||||||
|
\param data A pointer to the data buffer containing the vector icon
|
||||||
|
to be set. May be \c NULL.
|
||||||
|
\param size Specifies the size of buffer pointed to by \a data.
|
||||||
|
\return
|
||||||
|
- \c B_OK: Everything went fine.
|
||||||
|
- \c B_NO_INIT: The object is not properly initialized.
|
||||||
|
- \c B_BAD_VALUE: \c NULL data.
|
||||||
|
- other error codes
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BAppFileInfo::SetIcon(const uint8* data, size_t size)
|
||||||
|
{
|
||||||
|
return SetIconForType(NULL, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetVersionInfo
|
// GetVersionInfo
|
||||||
/*! \brief Gets the file's version info.
|
/*! \brief Gets the file's version info.
|
||||||
\param info A pointer to a pre-allocated version_info structure into which
|
\param info A pointer to a pre-allocated version_info structure into which
|
||||||
@@ -711,7 +805,7 @@ BAppFileInfo::SetIcon(const BBitmap *icon, icon_size which)
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::GetVersionInfo(version_info *info, version_kind kind) const
|
BAppFileInfo::GetVersionInfo(version_info* info, version_kind kind) const
|
||||||
{
|
{
|
||||||
// check params and initialization
|
// check params and initialization
|
||||||
if (!info)
|
if (!info)
|
||||||
@@ -752,10 +846,11 @@ BAppFileInfo::GetVersionInfo(version_info *info, version_kind kind) const
|
|||||||
} else
|
} else
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetVersionInfo
|
// SetVersionInfo
|
||||||
/*! \brief Sets the file's version info.
|
/*! \brief Sets the file's version info.
|
||||||
|
|
||||||
@@ -772,7 +867,7 @@ BAppFileInfo::GetVersionInfo(version_info *info, version_kind kind) const
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetVersionInfo(const version_info *info, version_kind kind)
|
BAppFileInfo::SetVersionInfo(const version_info* info, version_kind kind)
|
||||||
{
|
{
|
||||||
// check initialization
|
// check initialization
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@@ -824,6 +919,7 @@ BAppFileInfo::SetVersionInfo(const version_info *info, version_kind kind)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetIconForType
|
// GetIconForType
|
||||||
/*! \brief Gets the icon the application provides for a given MIME type.
|
/*! \brief Gets the icon the application provides for a given MIME type.
|
||||||
|
|
||||||
@@ -844,16 +940,61 @@ BAppFileInfo::SetVersionInfo(const version_info *info, version_kind kind)
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::GetIconForType(const char *type, BBitmap *icon,
|
BAppFileInfo::GetIconForType(const char* type, BBitmap* icon,
|
||||||
icon_size which) const
|
icon_size size) const
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
if (InitCheck() != B_OK)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
if (!icon || icon->InitCheck() != B_OK)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
// TODO: for consistency with attribute based icon reading, we
|
||||||
|
// could also prefer B_CMAP8 icons here if the provided bitmap
|
||||||
|
// is in that format. Right now, an existing B_CMAP8 icon resource
|
||||||
|
// would be ignored as soon as a vector icon is present. On the other
|
||||||
|
// hand, maybe this still results in a more consistent user interface,
|
||||||
|
// since Tracker/Deskbar would surely show the vector icon.
|
||||||
|
|
||||||
|
// try vector icon first
|
||||||
|
BString vectorAttributeName(kIconAttribute);
|
||||||
|
|
||||||
|
// check type param
|
||||||
|
if (type) {
|
||||||
|
if (BMimeType::IsValid(type))
|
||||||
|
vectorAttributeName += type;
|
||||||
|
else
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
} else {
|
||||||
|
vectorAttributeName += kIconType;
|
||||||
|
}
|
||||||
|
const char* attribute = vectorAttributeName.String();
|
||||||
|
|
||||||
|
size_t bytesRead;
|
||||||
|
void* allocatedBuffer;
|
||||||
|
status_t error = _ReadData(attribute, -1, B_VECTOR_ICON_TYPE, NULL, 0,
|
||||||
|
bytesRead, &allocatedBuffer);
|
||||||
|
if (error == B_OK) {
|
||||||
|
error = BIconUtils::GetVectorIcon((uint8*)allocatedBuffer,
|
||||||
|
bytesRead, icon);
|
||||||
|
free(allocatedBuffer);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no vector icon if we got this far,
|
||||||
|
// align size argument just in case
|
||||||
|
if (size < B_LARGE_ICON)
|
||||||
|
size = B_MINI_ICON;
|
||||||
|
else
|
||||||
|
size = B_LARGE_ICON;
|
||||||
|
|
||||||
|
error = B_OK;
|
||||||
// set some icon size related variables
|
// set some icon size related variables
|
||||||
BString attributeString;
|
BString attributeString;
|
||||||
BRect bounds;
|
BRect bounds;
|
||||||
uint32 attrType = 0;
|
uint32 attrType = 0;
|
||||||
size_t attrSize = 0;
|
size_t attrSize = 0;
|
||||||
switch (which) {
|
switch (size) {
|
||||||
case B_MINI_ICON:
|
case B_MINI_ICON:
|
||||||
attributeString = kMiniIconAttribute;
|
attributeString = kMiniIconAttribute;
|
||||||
bounds.Set(0, 0, 15, 15);
|
bounds.Set(0, 0, 15, 15);
|
||||||
@@ -867,39 +1008,36 @@ BAppFileInfo::GetIconForType(const char *type, BBitmap *icon,
|
|||||||
attrSize = 32 * 32;
|
attrSize = 32 * 32;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error = B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
// check type param
|
// check type param
|
||||||
if (error == B_OK) {
|
if (type) {
|
||||||
if (type) {
|
if (BMimeType::IsValid(type))
|
||||||
if (BMimeType::IsValid(type))
|
attributeString += type;
|
||||||
attributeString += type;
|
else
|
||||||
else
|
return B_BAD_VALUE;
|
||||||
error = B_BAD_VALUE;
|
} else
|
||||||
} else
|
attributeString += kStandardIconType;
|
||||||
attributeString += kStandardIconType;
|
|
||||||
}
|
attribute = attributeString.String();
|
||||||
const char *attribute = attributeString.String();
|
|
||||||
|
// check parameters
|
||||||
|
// currently, scaling B_CMAP8 icons is not supported
|
||||||
|
if (icon->ColorSpace() == B_CMAP8 && icon->Bounds() != bounds)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// check parameter and initialization
|
|
||||||
if (error == B_OK
|
|
||||||
&& (!icon || icon->InitCheck() != B_OK || icon->Bounds() != bounds)) {
|
|
||||||
error = B_BAD_VALUE;
|
|
||||||
}
|
|
||||||
if (error == B_OK && InitCheck() != B_OK)
|
|
||||||
error = B_NO_INIT;
|
|
||||||
// read the data
|
// read the data
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
bool otherColorSpace = (icon->ColorSpace() != B_CMAP8);
|
bool tempBuffer = (icon->ColorSpace() != B_CMAP8
|
||||||
char *buffer = NULL;
|
|| icon->Bounds() != bounds);
|
||||||
|
uint8* buffer = NULL;
|
||||||
size_t read;
|
size_t read;
|
||||||
if (otherColorSpace) {
|
if (tempBuffer) {
|
||||||
// other color space than stored in attribute
|
// other color space or bitmap size than stored in attribute
|
||||||
buffer = new(nothrow) char[attrSize];
|
buffer = new(nothrow) uint8[attrSize];
|
||||||
if (!buffer)
|
if (!buffer) {
|
||||||
error = B_NO_MEMORY;
|
error = B_NO_MEMORY;
|
||||||
if (error == B_OK) {
|
} else {
|
||||||
error = _ReadData(attribute, -1, attrType, buffer, attrSize,
|
error = _ReadData(attribute, -1, attrType, buffer, attrSize,
|
||||||
read);
|
read);
|
||||||
}
|
}
|
||||||
@@ -909,11 +1047,14 @@ BAppFileInfo::GetIconForType(const char *type, BBitmap *icon,
|
|||||||
}
|
}
|
||||||
if (error == B_OK && read != attrSize)
|
if (error == B_OK && read != attrSize)
|
||||||
error = B_ERROR;
|
error = B_ERROR;
|
||||||
if (otherColorSpace) {
|
if (tempBuffer) {
|
||||||
// other color space than stored in attribute
|
// other color space than stored in attribute
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
error = icon->ImportBits(buffer, attrSize, B_ANY_BYTES_PER_ROW,
|
error = BIconUtils::ConvertFromCMAP8(buffer,
|
||||||
0, B_CMAP8);
|
(uint32)size,
|
||||||
|
(uint32)size,
|
||||||
|
(uint32)size,
|
||||||
|
icon);
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
@@ -921,6 +1062,58 @@ BAppFileInfo::GetIconForType(const char *type, BBitmap *icon,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GetIconForType
|
||||||
|
/*! \brief Gets the icon the application provides for a given MIME type.
|
||||||
|
|
||||||
|
If \a type is \c NULL, the application's icon is retrieved.
|
||||||
|
|
||||||
|
\param type The MIME type in question. May be \c NULL.
|
||||||
|
\param data A pointer in which the icon data will be returned. When you
|
||||||
|
are done with the data, you should use free() to deallocate it.
|
||||||
|
\param size A pointer in which the size of the retrieved data is returned.
|
||||||
|
\return
|
||||||
|
- \c B_OK: Everything went fine.
|
||||||
|
- \c B_NO_INIT: The object is not properly initialized.
|
||||||
|
- \c B_BAD_VALUE: \c NULL \a data and/or \a size. Or the supplied
|
||||||
|
\a type is not a valid MIME type.
|
||||||
|
- other error codes
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BAppFileInfo::GetIconForType(const char* type, uint8** data,
|
||||||
|
size_t* size) const
|
||||||
|
{
|
||||||
|
if (InitCheck() != B_OK)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
if (!data || !size)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
// get vector icon
|
||||||
|
BString attributeName(kIconAttribute);
|
||||||
|
|
||||||
|
// check type param
|
||||||
|
if (type) {
|
||||||
|
if (BMimeType::IsValid(type))
|
||||||
|
attributeName += type;
|
||||||
|
else
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
} else {
|
||||||
|
attributeName += kIconType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* allocatedBuffer = NULL;
|
||||||
|
status_t ret = _ReadData(attributeName.String(), -1,
|
||||||
|
B_VECTOR_ICON_TYPE, NULL, 0, *size, &allocatedBuffer);
|
||||||
|
|
||||||
|
if (ret < B_OK)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
*data = (uint8*)allocatedBuffer;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetIconForType
|
// SetIconForType
|
||||||
/*! \brief Sets the icon the application provides for a given MIME type.
|
/*! \brief Sets the icon the application provides for a given MIME type.
|
||||||
|
|
||||||
@@ -939,12 +1132,13 @@ BAppFileInfo::GetIconForType(const char *type, BBitmap *icon,
|
|||||||
\return
|
\return
|
||||||
- \c B_OK: Everything went fine.
|
- \c B_OK: Everything went fine.
|
||||||
- \c B_NO_INIT: The object is not properly initialized.
|
- \c B_NO_INIT: The object is not properly initialized.
|
||||||
- \c B_BAD_VALUE: Unknown icon size \a which or bitmap dimensions (\a icon)
|
- \c B_BAD_VALUE: Either the icon size \a which is unkown, bitmap dimensions (\a icon)
|
||||||
and icon size (\a which) do not match.
|
and icon size (\a which) do not match, or the provided \a type is
|
||||||
|
not a valid MIME type.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::SetIconForType(const char *type, const BBitmap *icon,
|
BAppFileInfo::SetIconForType(const char* type, const BBitmap* icon,
|
||||||
icon_size which)
|
icon_size which)
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@@ -985,7 +1179,7 @@ BAppFileInfo::SetIconForType(const char *type, const BBitmap *icon,
|
|||||||
} else
|
} else
|
||||||
attributeString += kStandardIconType;
|
attributeString += kStandardIconType;
|
||||||
}
|
}
|
||||||
const char *attribute = attributeString.String();
|
const char* attribute = attributeString.String();
|
||||||
// check parameter and initialization
|
// check parameter and initialization
|
||||||
if (error == B_OK && icon
|
if (error == B_OK && icon
|
||||||
&& (icon->InitCheck() != B_OK || icon->Bounds() != bounds)) {
|
&& (icon->InitCheck() != B_OK || icon->Bounds() != bounds)) {
|
||||||
@@ -1014,16 +1208,79 @@ BAppFileInfo::SetIconForType(const char *type, const BBitmap *icon,
|
|||||||
error = _RemoveData(attribute, attrType);
|
error = _RemoveData(attribute, attrType);
|
||||||
}
|
}
|
||||||
// set the attribute on the MIME type, if the file has a signature
|
// set the attribute on the MIME type, if the file has a signature
|
||||||
BMimeType mimeType;
|
// BMimeType mimeType;
|
||||||
if (error == B_OK && GetMetaMime(&mimeType) == B_OK) {
|
// if (error == B_OK && GetMetaMime(&mimeType) == B_OK) {
|
||||||
// if (!mimeType.IsInstalled())
|
// if (!mimeType.IsInstalled())
|
||||||
// error = mimeType.Install();
|
// error = mimeType.Install();
|
||||||
// if (error == B_OK)
|
// if (error == B_OK)
|
||||||
// error = mimeType.SetIconForType(type, icon, which);
|
// error = mimeType.SetIconForType(type, icon, which);
|
||||||
}
|
// }
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SetIconForType
|
||||||
|
/*! \brief Sets the icon the application provides for a given MIME type.
|
||||||
|
|
||||||
|
If \a type is \c NULL, the application's icon is set.
|
||||||
|
If \a data is \c NULL the icon is unset.
|
||||||
|
|
||||||
|
If the file has a signature, then the icon is also set on the MIME type.
|
||||||
|
If the type for the signature has not been installed yet, it is installed
|
||||||
|
before.
|
||||||
|
|
||||||
|
\param type The MIME type in question. May be \c NULL.
|
||||||
|
\param data A pointer to the data containing the icon to be set.
|
||||||
|
May be \c NULL.
|
||||||
|
\param size Specifies the size of buffer provided in \a data.
|
||||||
|
\return
|
||||||
|
- \c B_OK: Everything went fine.
|
||||||
|
- \c B_NO_INIT: The object is not properly initialized.
|
||||||
|
- \c B_BAD_VALUE: The provided \a type is not a valid MIME type.
|
||||||
|
- other error codes
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BAppFileInfo::SetIconForType(const char* type, const uint8* data,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
if (InitCheck() != B_OK)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
// set some icon related variables
|
||||||
|
BString attributeString = kIconAttribute;
|
||||||
|
int32 resourceID = type ? kIconForTypeResourceID : kIconResourceID;
|
||||||
|
uint32 attrType = B_VECTOR_ICON_TYPE;
|
||||||
|
|
||||||
|
// check type param
|
||||||
|
if (type) {
|
||||||
|
if (BMimeType::IsValid(type))
|
||||||
|
attributeString += type;
|
||||||
|
else
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
} else
|
||||||
|
attributeString += kIconType;
|
||||||
|
|
||||||
|
const char* attribute = attributeString.String();
|
||||||
|
|
||||||
|
status_t error;
|
||||||
|
// write/remove the attribute
|
||||||
|
if (data)
|
||||||
|
error = _WriteData(attribute, resourceID, attrType, data, size, true);
|
||||||
|
else // no icon given => remove
|
||||||
|
error = _RemoveData(attribute, attrType);
|
||||||
|
|
||||||
|
// set the attribute on the MIME type, if the file has a signature
|
||||||
|
// BMimeType mimeType;
|
||||||
|
// if (error == B_OK && GetMetaMime(&mimeType) == B_OK) {
|
||||||
|
// if (!mimeType.IsInstalled())
|
||||||
|
// error = mimeType.Install();
|
||||||
|
// if (error == B_OK)
|
||||||
|
// error = mimeType.SetIconForType(type, data, size);
|
||||||
|
// }
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetInfoLocation
|
// SetInfoLocation
|
||||||
/*! \brief Specifies the location where the meta data shall be stored.
|
/*! \brief Specifies the location where the meta data shall be stored.
|
||||||
|
|
||||||
@@ -1037,6 +1294,10 @@ BAppFileInfo::SetIconForType(const char *type, const BBitmap *icon,
|
|||||||
void
|
void
|
||||||
BAppFileInfo::SetInfoLocation(info_location location)
|
BAppFileInfo::SetInfoLocation(info_location location)
|
||||||
{
|
{
|
||||||
|
// if the resources failed to initialize, we must not use them
|
||||||
|
if (fResources == NULL)
|
||||||
|
location = info_location(location & ~B_USE_RESOURCES);
|
||||||
|
|
||||||
fWhere = location;
|
fWhere = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1049,9 +1310,10 @@ BAppFileInfo::SetInfoLocation(info_location location)
|
|||||||
bool
|
bool
|
||||||
BAppFileInfo::IsUsingAttributes() const
|
BAppFileInfo::IsUsingAttributes() const
|
||||||
{
|
{
|
||||||
return (fWhere & B_USE_ATTRIBUTES);
|
return (fWhere & B_USE_ATTRIBUTES) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IsUsingResources
|
// IsUsingResources
|
||||||
/*! \brief Returns whether the object stores the meta data (also) in the
|
/*! \brief Returns whether the object stores the meta data (also) in the
|
||||||
file's resources.
|
file's resources.
|
||||||
@@ -1061,14 +1323,16 @@ BAppFileInfo::IsUsingAttributes() const
|
|||||||
bool
|
bool
|
||||||
BAppFileInfo::IsUsingResources() const
|
BAppFileInfo::IsUsingResources() const
|
||||||
{
|
{
|
||||||
return (fWhere & B_USE_RESOURCES);
|
return (fWhere & B_USE_RESOURCES) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FBC
|
// FBC
|
||||||
void BAppFileInfo::_ReservedAppFileInfo1() {}
|
void BAppFileInfo::_ReservedAppFileInfo1() {}
|
||||||
void BAppFileInfo::_ReservedAppFileInfo2() {}
|
void BAppFileInfo::_ReservedAppFileInfo2() {}
|
||||||
void BAppFileInfo::_ReservedAppFileInfo3() {}
|
void BAppFileInfo::_ReservedAppFileInfo3() {}
|
||||||
|
|
||||||
|
|
||||||
// =
|
// =
|
||||||
/*! \brief Privatized assignment operator to prevent usage.
|
/*! \brief Privatized assignment operator to prevent usage.
|
||||||
*/
|
*/
|
||||||
@@ -1078,6 +1342,7 @@ BAppFileInfo::operator=(const BAppFileInfo &)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// copy constructor
|
// copy constructor
|
||||||
/*! \brief Privatized copy constructor to prevent usage.
|
/*! \brief Privatized copy constructor to prevent usage.
|
||||||
*/
|
*/
|
||||||
@@ -1085,6 +1350,7 @@ BAppFileInfo::BAppFileInfo(const BAppFileInfo &)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetMetaMime
|
// GetMetaMime
|
||||||
/*! \brief Initializes a BMimeType to the file's signature.
|
/*! \brief Initializes a BMimeType to the file's signature.
|
||||||
|
|
||||||
@@ -1101,7 +1367,7 @@ BAppFileInfo::BAppFileInfo(const BAppFileInfo &)
|
|||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::GetMetaMime(BMimeType *meta) const
|
BAppFileInfo::GetMetaMime(BMimeType* meta) const
|
||||||
{
|
{
|
||||||
char signature[B_MIME_TYPE_LENGTH];
|
char signature[B_MIME_TYPE_LENGTH];
|
||||||
status_t error = GetSignature(signature);
|
status_t error = GetSignature(signature);
|
||||||
@@ -1114,6 +1380,7 @@ BAppFileInfo::GetMetaMime(BMimeType *meta) const
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _ReadData
|
// _ReadData
|
||||||
/*! \brief Reads data from an attribute or resource.
|
/*! \brief Reads data from an attribute or resource.
|
||||||
|
|
||||||
@@ -1137,12 +1404,12 @@ BAppFileInfo::GetMetaMime(BMimeType *meta) const
|
|||||||
- error code
|
- error code
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::_ReadData(const char *name, int32 id, type_code type,
|
BAppFileInfo::_ReadData(const char* name, int32 id, type_code type,
|
||||||
void *buffer, size_t bufferSize,
|
void* buffer, size_t bufferSize,
|
||||||
size_t &bytesRead, void **allocatedBuffer) const
|
size_t &bytesRead, void** allocatedBuffer) const
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
|
||||||
if (allocatedBuffer)
|
if (allocatedBuffer)
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
|
|
||||||
@@ -1209,7 +1476,7 @@ BAppFileInfo::_ReadData(const char *name, int32 id, type_code type,
|
|||||||
error = B_BAD_VALUE;
|
error = B_BAD_VALUE;
|
||||||
|
|
||||||
// load resource
|
// load resource
|
||||||
const void *resourceData = NULL;
|
const void* resourceData = NULL;
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
resourceData = fResources->LoadResource(type, name, &bytesRead);
|
resourceData = fResources->LoadResource(type, name, &bytesRead);
|
||||||
if (resourceData && sizeFound == bytesRead)
|
if (resourceData && sizeFound == bytesRead)
|
||||||
@@ -1217,7 +1484,6 @@ BAppFileInfo::_ReadData(const char *name, int32 id, type_code type,
|
|||||||
else
|
else
|
||||||
error = B_ERROR;
|
error = B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!foundData)
|
} else if (!foundData)
|
||||||
error = B_BAD_VALUE;
|
error = B_BAD_VALUE;
|
||||||
|
|
||||||
@@ -1232,6 +1498,7 @@ BAppFileInfo::_ReadData(const char *name, int32 id, type_code type,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _WriteData
|
// _WriteData
|
||||||
/*! \brief Writes data to an attribute or resource.
|
/*! \brief Writes data to an attribute or resource.
|
||||||
|
|
||||||
@@ -1253,12 +1520,16 @@ BAppFileInfo::_ReadData(const char *name, int32 id, type_code type,
|
|||||||
- error code
|
- error code
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::_WriteData(const char *name, int32 id, type_code type,
|
BAppFileInfo::_WriteData(const char* name, int32 id, type_code type,
|
||||||
const void *buffer, size_t bufferSize, bool findID)
|
const void* buffer, size_t bufferSize, bool findID)
|
||||||
{
|
{
|
||||||
|
if (!IsUsingAttributes() && !IsUsingResources())
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
|
||||||
// write to attribute
|
// write to attribute
|
||||||
if (IsUsingAttributes() && error == B_OK) {
|
if (IsUsingAttributes()) {
|
||||||
ssize_t written = fNode->WriteAttr(name, type, 0, buffer, bufferSize);
|
ssize_t written = fNode->WriteAttr(name, type, 0, buffer, bufferSize);
|
||||||
if (written < 0)
|
if (written < 0)
|
||||||
error = written;
|
error = written;
|
||||||
@@ -1298,11 +1569,15 @@ BAppFileInfo::_WriteData(const char *name, int32 id, type_code type,
|
|||||||
- error code
|
- error code
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BAppFileInfo::_RemoveData(const char *name, type_code type)
|
BAppFileInfo::_RemoveData(const char* name, type_code type)
|
||||||
{
|
{
|
||||||
|
if (!IsUsingAttributes() && !IsUsingResources())
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
|
||||||
// remove the attribute
|
// remove the attribute
|
||||||
if (IsUsingAttributes() && error == B_OK) {
|
if (IsUsingAttributes()) {
|
||||||
error = fNode->RemoveAttr(name);
|
error = fNode->RemoveAttr(name);
|
||||||
// It's no error, if there has been no attribute.
|
// It's no error, if there has been no attribute.
|
||||||
if (error == B_ENTRY_NOT_FOUND)
|
if (error == B_ENTRY_NOT_FOUND)
|
||||||
|
|||||||
@@ -352,6 +352,16 @@ BEntry::Exists() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
BEntry::Name() const
|
||||||
|
{
|
||||||
|
if (fCStatus != B_OK)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills in a stat structure for the entry. The information is copied into
|
/*! \brief Fills in a stat structure for the entry. The information is copied into
|
||||||
the \c stat structure pointed to by \a result.
|
the \c stat structure pointed to by \a result.
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) mime ] ;
|
|||||||
|
|
||||||
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits storage ] ;
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits storage ] ;
|
||||||
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits storage mime ] ;
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits storage mime ] ;
|
||||||
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits storage sniffer ] ;
|
||||||
|
|
||||||
USES_BE_API on <libbe_build>storage_kit.o = true ;
|
USES_BE_API on <libbe_build>storage_kit.o = true ;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ BuildPlatformMergeObjectPIC <libbe_build>storage_kit.o :
|
|||||||
File.cpp
|
File.cpp
|
||||||
FileIO.cpp
|
FileIO.cpp
|
||||||
FindDirectory.cpp
|
FindDirectory.cpp
|
||||||
|
MergedDirectory.cpp
|
||||||
Mime.cpp
|
Mime.cpp
|
||||||
MimeType.cpp
|
MimeType.cpp
|
||||||
Node.cpp
|
Node.cpp
|
||||||
@@ -33,7 +35,31 @@ BuildPlatformMergeObjectPIC <libbe_build>storage_kit.o :
|
|||||||
Volume.cpp
|
Volume.cpp
|
||||||
storage_support.cpp
|
storage_support.cpp
|
||||||
|
|
||||||
|
# mime
|
||||||
|
AppMetaMimeCreator.cpp
|
||||||
|
AssociatedTypes.cpp
|
||||||
|
Database.cpp
|
||||||
|
DatabaseDirectory.cpp
|
||||||
|
DatabaseLocation.cpp
|
||||||
database_support.cpp
|
database_support.cpp
|
||||||
|
InstalledTypes.cpp
|
||||||
|
MimeSniffer.cpp
|
||||||
|
SnifferRules.cpp
|
||||||
|
Supertype.cpp
|
||||||
|
SupportingApps.cpp
|
||||||
|
|
||||||
MimeUpdateThread.cpp
|
MimeUpdateThread.cpp
|
||||||
UpdateMimeInfoThread.cpp
|
UpdateMimeInfoThread.cpp
|
||||||
|
|
||||||
|
# sniffer
|
||||||
|
CharStream.cpp
|
||||||
|
Err.cpp
|
||||||
|
DisjList.cpp
|
||||||
|
Pattern.cpp
|
||||||
|
PatternList.cpp
|
||||||
|
Parser.cpp
|
||||||
|
Range.cpp
|
||||||
|
RPattern.cpp
|
||||||
|
RPatternList.cpp
|
||||||
|
Rule.cpp
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -0,0 +1,240 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Ingo Weinhold <[email protected]>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <MergedDirectory.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <Directory.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
|
#include "storage_support.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct BMergedDirectory::EntryNameSet : std::set<std::string> {
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
BMergedDirectory::BMergedDirectory(BPolicy policy)
|
||||||
|
:
|
||||||
|
BEntryList(),
|
||||||
|
fDirectories(10, true),
|
||||||
|
fPolicy(policy),
|
||||||
|
fDirectoryIndex(0),
|
||||||
|
fVisitedEntries(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMergedDirectory::~BMergedDirectory()
|
||||||
|
{
|
||||||
|
delete fVisitedEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMergedDirectory::Init()
|
||||||
|
{
|
||||||
|
delete fVisitedEntries;
|
||||||
|
fDirectories.MakeEmpty(true);
|
||||||
|
|
||||||
|
fVisitedEntries = new(std::nothrow) EntryNameSet;
|
||||||
|
return fVisitedEntries != NULL ? B_OK : B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMergedDirectory::BPolicy
|
||||||
|
BMergedDirectory::Policy() const
|
||||||
|
{
|
||||||
|
return fPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMergedDirectory::SetPolicy(BPolicy policy)
|
||||||
|
{
|
||||||
|
fPolicy = policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMergedDirectory::AddDirectory(BDirectory* directory)
|
||||||
|
{
|
||||||
|
return fDirectories.AddItem(directory) ? B_OK : B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMergedDirectory::AddDirectory(const char* path)
|
||||||
|
{
|
||||||
|
BDirectory* directory = new(std::nothrow) BDirectory(path);
|
||||||
|
if (directory == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
ObjectDeleter<BDirectory> directoryDeleter(directory);
|
||||||
|
|
||||||
|
if (directory->InitCheck() != B_OK)
|
||||||
|
return directory->InitCheck();
|
||||||
|
|
||||||
|
status_t error = AddDirectory(directory);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
directoryDeleter.Detach();
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMergedDirectory::GetNextEntry(BEntry* entry, bool traverse)
|
||||||
|
{
|
||||||
|
entry_ref ref;
|
||||||
|
status_t error = GetNextRef(&ref);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return entry->SetTo(&ref, traverse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMergedDirectory::GetNextRef(entry_ref* ref)
|
||||||
|
{
|
||||||
|
BPrivate::Storage::LongDirEntry dirEntry;
|
||||||
|
int32 result = GetNextDirents(&dirEntry, sizeof(dirEntry), 1);
|
||||||
|
if (result < 0)
|
||||||
|
return result;
|
||||||
|
if (result == 0)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
BEntry entry;
|
||||||
|
status_t error
|
||||||
|
= entry.SetTo(fDirectories.ItemAt(fDirectoryIndex), dirEntry.d_name);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return entry.GetRef(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
BMergedDirectory::GetNextDirents(struct dirent* direntBuffer, size_t bufferSize,
|
||||||
|
int32 maxEntries)
|
||||||
|
{
|
||||||
|
if (maxEntries <= 0)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
while (fDirectoryIndex < fDirectories.CountItems()) {
|
||||||
|
int32 count = fDirectories.ItemAt(fDirectoryIndex)->GetNextDirents(
|
||||||
|
direntBuffer, bufferSize, 1);
|
||||||
|
if (count < 0)
|
||||||
|
return count;
|
||||||
|
if (count == 0) {
|
||||||
|
fDirectoryIndex++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(direntBuffer->d_name, ".") == 0
|
||||||
|
|| strcmp(direntBuffer->d_name, "..") == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (fPolicy) {
|
||||||
|
case B_ALLOW_DUPLICATES:
|
||||||
|
return count;
|
||||||
|
|
||||||
|
case B_ALWAYS_FIRST:
|
||||||
|
case B_COMPARE:
|
||||||
|
if (fVisitedEntries != NULL
|
||||||
|
&& fVisitedEntries->find(direntBuffer->d_name)
|
||||||
|
!= fVisitedEntries->end()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fVisitedEntries != NULL) {
|
||||||
|
try {
|
||||||
|
fVisitedEntries->insert(direntBuffer->d_name);
|
||||||
|
} catch (std::bad_alloc&) {
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPolicy == B_ALWAYS_FIRST
|
||||||
|
|| _IsBestEntry(direntBuffer->d_name)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fVisitedEntries->erase(direntBuffer->d_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMergedDirectory::Rewind()
|
||||||
|
{
|
||||||
|
for (int32 i = 0; BDirectory* directory = fDirectories.ItemAt(i); i++)
|
||||||
|
directory->Rewind();
|
||||||
|
|
||||||
|
if (fVisitedEntries != NULL)
|
||||||
|
fVisitedEntries->clear();
|
||||||
|
|
||||||
|
fDirectoryIndex = 0;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
BMergedDirectory::CountEntries()
|
||||||
|
{
|
||||||
|
int32 count = 0;
|
||||||
|
char buffer[sizeof(dirent) + B_FILE_NAME_LENGTH];
|
||||||
|
while (GetNextDirents((dirent*)&buffer, sizeof(buffer), 1) == 1)
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BMergedDirectory::ShallPreferFirstEntry(const entry_ref& entry1, int32 index1,
|
||||||
|
const entry_ref& entry2, int32 index2)
|
||||||
|
{
|
||||||
|
// That's basically B_ALWAYS_FIRST semantics. A derived class will implement
|
||||||
|
// the desired semantics.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BMergedDirectory::_IsBestEntry(const char* name)
|
||||||
|
{
|
||||||
|
entry_ref bestEntry;
|
||||||
|
if (BEntry(fDirectories.ItemAt(fDirectoryIndex), name).GetRef(&bestEntry)
|
||||||
|
!= B_OK) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 directoryCount = fDirectories.CountItems();
|
||||||
|
for (int32 i = fDirectoryIndex + 1; i < directoryCount; i++) {
|
||||||
|
BEntry entry(fDirectories.ItemAt(i), name);
|
||||||
|
entry_ref ref;
|
||||||
|
if (entry.Exists() && entry.GetRef(&ref) == B_OK
|
||||||
|
&& !ShallPreferFirstEntry(bestEntry, fDirectoryIndex, ref, i)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -12,7 +12,8 @@
|
|||||||
Mime type C functions implementation.
|
Mime type C functions implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mime/database_access.h>
|
#include <Mime.h>
|
||||||
|
|
||||||
#include <mime/UpdateMimeInfoThread.h>
|
#include <mime/UpdateMimeInfoThread.h>
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|||||||
@@ -1,378 +0,0 @@
|
|||||||
//----------------------------------------------------------------------
|
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
|
||||||
// by the OpenBeOS license.
|
|
||||||
//---------------------------------------------------------------------
|
|
||||||
/*!
|
|
||||||
\file database_support.cpp
|
|
||||||
Private mime database functions and constants
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <AppMisc.h>
|
|
||||||
#include <DataIO.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Node.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <storage_support.h>
|
|
||||||
#include <TypeConstants.h>
|
|
||||||
|
|
||||||
#include <fs_attr.h> // For struct attr_info
|
|
||||||
#include <new> // For new(nothrow)
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "mime/database_support.h"
|
|
||||||
|
|
||||||
//#define DBG(x) x
|
|
||||||
#define DBG(x)
|
|
||||||
#define OUT printf
|
|
||||||
|
|
||||||
namespace BPrivate {
|
|
||||||
namespace Storage {
|
|
||||||
namespace Mime {
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
static const char *get_user_settings_dir(BPath &path);
|
|
||||||
|
|
||||||
static BPath sSettingsDirPath;
|
|
||||||
static const std::string sSettingsDir = get_user_settings_dir(sSettingsDirPath);
|
|
||||||
|
|
||||||
static const char *sHaikuDBDirName = "beos_mime";
|
|
||||||
// when running natively under Haiku
|
|
||||||
static const char *sBeOSDBDirName = "obos_mime";
|
|
||||||
// when running under BeOS
|
|
||||||
const std::string kDatabaseDir = sSettingsDir + "/"
|
|
||||||
+ (is_running_on_haiku() ? sHaikuDBDirName : sBeOSDBDirName);
|
|
||||||
const std::string kApplicationDatabaseDir = kDatabaseDir + "/application";
|
|
||||||
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
#define ATTR_PREFIX "META:"
|
|
||||||
#define MINI_ICON_ATTR_PREFIX ATTR_PREFIX "M:"
|
|
||||||
#define LARGE_ICON_ATTR_PREFIX ATTR_PREFIX "L:"
|
|
||||||
|
|
||||||
const char *kMiniIconAttrPrefix = MINI_ICON_ATTR_PREFIX;
|
|
||||||
const char *kLargeIconAttrPrefix = LARGE_ICON_ATTR_PREFIX;
|
|
||||||
|
|
||||||
// attribute names
|
|
||||||
const char *kFileTypeAttr = "BEOS:TYPE";
|
|
||||||
const char *kTypeAttr = ATTR_PREFIX "TYPE";
|
|
||||||
const char *kAppHintAttr = ATTR_PREFIX "PPATH";
|
|
||||||
const char *kAttrInfoAttr = ATTR_PREFIX "ATTR_INFO";
|
|
||||||
const char *kShortDescriptionAttr = ATTR_PREFIX "S:DESC";
|
|
||||||
const char *kLongDescriptionAttr = ATTR_PREFIX "L:DESC";
|
|
||||||
const char *kFileExtensionsAttr = ATTR_PREFIX "EXTENS";
|
|
||||||
const char *kMiniIconAttr = MINI_ICON_ATTR_PREFIX "STD_ICON";
|
|
||||||
const char *kLargeIconAttr = LARGE_ICON_ATTR_PREFIX "STD_ICON";
|
|
||||||
const char *kPreferredAppAttr = ATTR_PREFIX "PREF_APP";
|
|
||||||
const char *kSnifferRuleAttr = ATTR_PREFIX "SNIFF_RULE";
|
|
||||||
const char *kSupportedTypesAttr = ATTR_PREFIX "FILE_TYPES";
|
|
||||||
|
|
||||||
// attribute data types (as used in the R5 database)
|
|
||||||
const int32 kFileTypeType = 'MIMS'; // B_MIME_STRING_TYPE
|
|
||||||
const int32 kTypeType = B_STRING_TYPE;
|
|
||||||
const int32 kAppHintType = 'MPTH';
|
|
||||||
const int32 kAttrInfoType = B_MESSAGE_TYPE;
|
|
||||||
const int32 kShortDescriptionType = 'MSDC';
|
|
||||||
const int32 kLongDescriptionType = 'MLDC';
|
|
||||||
const int32 kFileExtensionsType = B_MESSAGE_TYPE;
|
|
||||||
const int32 kMiniIconType = B_MINI_ICON_TYPE;
|
|
||||||
const int32 kLargeIconType = B_LARGE_ICON_TYPE;
|
|
||||||
const int32 kPreferredAppType = 'MSIG';
|
|
||||||
const int32 kSnifferRuleType = B_STRING_TYPE;
|
|
||||||
const int32 kSupportedTypesType = B_MESSAGE_TYPE;
|
|
||||||
|
|
||||||
// Message fields
|
|
||||||
const char *kApplicationsField = "applications";
|
|
||||||
const char *kExtensionsField = "extensions";
|
|
||||||
const char *kSupertypesField = "super_types";
|
|
||||||
const char *kSupportingAppsSubCountField = "be:sub";
|
|
||||||
const char *kSupportingAppsSuperCountField = "be:super";
|
|
||||||
const char *kTypesField = "types";
|
|
||||||
|
|
||||||
// Mime types
|
|
||||||
const char *kGenericFileType = "application/octet-stream";
|
|
||||||
const char *kDirectoryType = "application/x-vnd.Be-directory";
|
|
||||||
const char *kSymlinkType = "application/x-vnd.Be-symlink";
|
|
||||||
const char *kMetaMimeType = "application/x-vnd.Be-meta-mime";
|
|
||||||
|
|
||||||
// Error codes
|
|
||||||
const status_t kMimeGuessFailureError = B_ERRORS_END+1;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
// get_settings_dir
|
|
||||||
/*! \brief Sets the supplied BPath to the user settings directory and returns
|
|
||||||
it as C string.
|
|
||||||
\param path BPath to be set to the user settings path.
|
|
||||||
\return the user settings path as C string (\code path.Path() \endcode).
|
|
||||||
*/
|
|
||||||
static
|
|
||||||
const char*
|
|
||||||
get_user_settings_dir(BPath &path)
|
|
||||||
{
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
|
||||||
path.SetTo("/boot/home/config/settings");
|
|
||||||
return path.Path();
|
|
||||||
}
|
|
||||||
|
|
||||||
// type_to_filename
|
|
||||||
//! Converts the given MIME type to an absolute path in the MIME database.
|
|
||||||
std::string
|
|
||||||
type_to_filename(const char *type)
|
|
||||||
{
|
|
||||||
return kDatabaseDir + "/" + BPrivate::Storage::to_lower(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
// open_type
|
|
||||||
/*! \brief Opens a BNode on the given type, failing if the type has no
|
|
||||||
corresponding file in the database.
|
|
||||||
\param type The MIME type to open
|
|
||||||
\param result Pointer to a pre-allocated BNode into which
|
|
||||||
is opened on the given MIME type
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
open_type(const char *type, BNode *result)
|
|
||||||
{
|
|
||||||
status_t err = (type && result ? B_OK : B_BAD_VALUE);
|
|
||||||
if (!err)
|
|
||||||
err = result->SetTo(type_to_filename(type).c_str());
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// open_or_create_type
|
|
||||||
/*! \brief Opens a BNode on the given type, creating a node of the
|
|
||||||
appropriate flavor if necessary.
|
|
||||||
|
|
||||||
All MIME types are converted to lowercase for use in the filesystem.
|
|
||||||
\param type The MIME type to open
|
|
||||||
\param result Pointer to a pre-allocated BNode into which
|
|
||||||
is opened on the given MIME type
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
open_or_create_type(const char *type, BNode *result, bool *didCreate)
|
|
||||||
{
|
|
||||||
if (didCreate)
|
|
||||||
*didCreate = false;
|
|
||||||
std::string filename;
|
|
||||||
std::string typeLower = BPrivate::Storage::to_lower(type);
|
|
||||||
status_t err = (type && result ? B_OK : B_BAD_VALUE);
|
|
||||||
if (!err) {
|
|
||||||
filename = type_to_filename(type);
|
|
||||||
err = result->SetTo(filename.c_str());
|
|
||||||
}
|
|
||||||
if (err == B_ENTRY_NOT_FOUND) {
|
|
||||||
// Figure out what type of node we need to create
|
|
||||||
// + Supertype == directory
|
|
||||||
// + Non-supertype == file
|
|
||||||
uint32 pos = typeLower.find_first_of('/');
|
|
||||||
if (pos == std::string::npos) {
|
|
||||||
// Supertype == directory
|
|
||||||
BDirectory parent(kDatabaseDir.c_str());
|
|
||||||
err = parent.InitCheck();
|
|
||||||
if (!err)
|
|
||||||
err = parent.CreateDirectory(typeLower.c_str(), NULL);
|
|
||||||
} else {
|
|
||||||
// Non-supertype == file
|
|
||||||
std::string super(typeLower, 0, pos);
|
|
||||||
std::string sub(typeLower, pos+1);
|
|
||||||
BDirectory parent((kDatabaseDir + "/" + super).c_str());
|
|
||||||
err = parent.InitCheck();
|
|
||||||
if (!err)
|
|
||||||
err = parent.CreateFile(sub.c_str(), NULL);
|
|
||||||
}
|
|
||||||
// Now try opening again
|
|
||||||
err = result->SetTo(filename.c_str());
|
|
||||||
if (!err && didCreate)
|
|
||||||
*didCreate = true;
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read_mime_attr
|
|
||||||
/*! \brief Reads up to \c len bytes of the given data from the given attribute
|
|
||||||
for the given MIME type.
|
|
||||||
|
|
||||||
If no entry for the given type exists in the database, the function fails,
|
|
||||||
and the contents of \c data are undefined.
|
|
||||||
|
|
||||||
\param type The MIME type
|
|
||||||
\param attr The attribute name
|
|
||||||
\param data Pointer to a memory buffer into which the data should be copied
|
|
||||||
\param len The maximum number of bytes to read
|
|
||||||
\param datatype The expected data type
|
|
||||||
\return If successful, the number of bytes read is returned, otherwise, an
|
|
||||||
error code is returned.
|
|
||||||
*/
|
|
||||||
ssize_t
|
|
||||||
read_mime_attr(const char *type, const char *attr, void *data,
|
|
||||||
size_t len, type_code datatype)
|
|
||||||
{
|
|
||||||
BNode node;
|
|
||||||
ssize_t err = (type && attr && data ? B_OK : B_BAD_VALUE);
|
|
||||||
if (!err)
|
|
||||||
err = open_type(type, &node);
|
|
||||||
if (!err)
|
|
||||||
err = node.ReadAttr(attr, datatype, 0, data, len);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read_mime_attr_message
|
|
||||||
/*! \brief Reads a flattened BMessage from the given attribute of the given
|
|
||||||
MIME type.
|
|
||||||
|
|
||||||
If no entry for the given type exists in the database, or if the data
|
|
||||||
stored in the attribute is not a flattened BMessage, the function fails
|
|
||||||
and the contents of \c msg are undefined.
|
|
||||||
|
|
||||||
\param type The MIME type
|
|
||||||
\param attr The attribute name
|
|
||||||
\param data Pointer to a pre-allocated BMessage into which the attribute
|
|
||||||
data is unflattened.
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
read_mime_attr_message(const char *type, const char *attr, BMessage *msg)
|
|
||||||
{
|
|
||||||
BNode node;
|
|
||||||
attr_info info;
|
|
||||||
char *buffer = NULL;
|
|
||||||
ssize_t err = (type && attr && msg ? B_OK : B_BAD_VALUE);
|
|
||||||
if (!err)
|
|
||||||
err = open_type(type, &node);
|
|
||||||
if (!err)
|
|
||||||
err = node.GetAttrInfo(attr, &info);
|
|
||||||
if (!err)
|
|
||||||
err = info.type == B_MESSAGE_TYPE ? B_OK : B_BAD_VALUE;
|
|
||||||
if (!err) {
|
|
||||||
buffer = new(std::nothrow) char[info.size];
|
|
||||||
if (!buffer)
|
|
||||||
err = B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
if (!err)
|
|
||||||
err = node.ReadAttr(attr, B_MESSAGE_TYPE, 0, buffer, info.size);
|
|
||||||
if (err >= 0)
|
|
||||||
err = err == info.size ? (status_t)B_OK : (status_t)B_FILE_ERROR;
|
|
||||||
if (!err)
|
|
||||||
err = msg->Unflatten(buffer);
|
|
||||||
delete [] buffer;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read_mime_attr_string
|
|
||||||
/*! \brief Reads a BString from the given attribute of the given
|
|
||||||
MIME type.
|
|
||||||
|
|
||||||
If no entry for the given type exists in the database, the function fails
|
|
||||||
and the contents of \c str are undefined.
|
|
||||||
|
|
||||||
\param type The MIME type
|
|
||||||
\param attr The attribute name
|
|
||||||
\param str Pointer to a pre-allocated BString into which the attribute
|
|
||||||
data stored.
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
read_mime_attr_string(const char *type, const char *attr, BString *str)
|
|
||||||
{
|
|
||||||
BNode node;
|
|
||||||
status_t err = (type && attr && str ? B_OK : B_BAD_VALUE);
|
|
||||||
if (!err)
|
|
||||||
err = open_type(type, &node);
|
|
||||||
if (!err)
|
|
||||||
err = node.ReadAttrString(attr, str);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// write_mime_attr
|
|
||||||
/*! \brief Writes \c len bytes of the given data to the given attribute
|
|
||||||
for the given MIME type.
|
|
||||||
|
|
||||||
If no entry for the given type exists in the database, it is created.
|
|
||||||
|
|
||||||
\param type The MIME type
|
|
||||||
\param attr The attribute name
|
|
||||||
\param data Pointer to the data to write
|
|
||||||
\param len The number of bytes to write
|
|
||||||
\param datatype The data type of the given data
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
write_mime_attr(const char *type, const char *attr, const void *data,
|
|
||||||
size_t len, type_code datatype, bool *didCreate)
|
|
||||||
{
|
|
||||||
BNode node;
|
|
||||||
status_t err = (type && attr && data ? B_OK : B_BAD_VALUE);
|
|
||||||
if (!err)
|
|
||||||
err = open_or_create_type(type, &node, didCreate);
|
|
||||||
if (!err) {
|
|
||||||
ssize_t bytes = node.WriteAttr(attr, datatype, 0, data, len);
|
|
||||||
if (bytes < B_OK)
|
|
||||||
err = bytes;
|
|
||||||
else
|
|
||||||
err = (bytes != (ssize_t)len ? (status_t)B_FILE_ERROR : (status_t)B_OK);
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// write_mime_attr_message
|
|
||||||
/*! \brief Flattens the given \c BMessage and writes it to the given attribute
|
|
||||||
of the given MIME type.
|
|
||||||
|
|
||||||
If no entry for the given type exists in the database, it is created.
|
|
||||||
|
|
||||||
\param type The MIME type
|
|
||||||
\param attr The attribute name
|
|
||||||
\param msg The BMessage to flatten and write
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
write_mime_attr_message(const char *type, const char *attr, const BMessage *msg, bool *didCreate)
|
|
||||||
{
|
|
||||||
BNode node;
|
|
||||||
BMallocIO data;
|
|
||||||
ssize_t bytes;
|
|
||||||
ssize_t err = (type && attr && msg ? B_OK : B_BAD_VALUE);
|
|
||||||
if (!err)
|
|
||||||
err = data.SetSize(msg->FlattenedSize());
|
|
||||||
if (!err)
|
|
||||||
err = msg->Flatten(&data, &bytes);
|
|
||||||
if (!err)
|
|
||||||
err = bytes == msg->FlattenedSize() ? B_OK : B_ERROR;
|
|
||||||
if (!err)
|
|
||||||
err = open_or_create_type(type, &node, didCreate);
|
|
||||||
if (!err)
|
|
||||||
err = node.WriteAttr(attr, B_MESSAGE_TYPE, 0, data.Buffer(), data.BufferLength());
|
|
||||||
if (err >= 0)
|
|
||||||
err = err == (ssize_t)data.BufferLength() ? (ssize_t)B_OK : (ssize_t)B_FILE_ERROR;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete_attribute
|
|
||||||
//! Deletes the given attribute for the given type
|
|
||||||
/*!
|
|
||||||
\param type The mime type
|
|
||||||
\param attr The attribute name
|
|
||||||
\return
|
|
||||||
- B_OK: success
|
|
||||||
- B_ENTRY_NOT_FOUND: no such type or attribute
|
|
||||||
- "error code": failure
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
delete_attribute(const char *type, const char *attr)
|
|
||||||
{
|
|
||||||
status_t err = type ? B_OK : B_BAD_VALUE;
|
|
||||||
BNode node;
|
|
||||||
if (!err)
|
|
||||||
err = open_type(type, &node);
|
|
||||||
if (!err)
|
|
||||||
err = node.RemoveAttr(attr);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Mime
|
|
||||||
} // namespace Storage
|
|
||||||
} // namespace BPrivate
|
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
SubDir HAIKU_TOP src build libicon ;
|
||||||
|
|
||||||
|
# source directories
|
||||||
|
local sourceDirs =
|
||||||
|
$(DOT)
|
||||||
|
flat_icon
|
||||||
|
message
|
||||||
|
shape
|
||||||
|
style
|
||||||
|
transformable
|
||||||
|
transformer
|
||||||
|
;
|
||||||
|
|
||||||
|
local sourceDir ;
|
||||||
|
for sourceDir in $(sourceDirs) {
|
||||||
|
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs icon $(sourceDir) ] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# system headers
|
||||||
|
UseLibraryHeaders agg icon ;
|
||||||
|
|
||||||
|
UsePrivateBuildHeaders shared ;
|
||||||
|
|
||||||
|
USES_BE_API on libicon_build.a = true ;
|
||||||
|
|
||||||
|
BuildPlatformStaticLibrary libicon_build.a :
|
||||||
|
# flat_icon
|
||||||
|
FlatIconFormat.cpp
|
||||||
|
FlatIconImporter.cpp
|
||||||
|
LittleEndianBuffer.cpp
|
||||||
|
PathCommandQueue.cpp
|
||||||
|
|
||||||
|
# message
|
||||||
|
Defines.cpp
|
||||||
|
MessageImporter.cpp
|
||||||
|
|
||||||
|
# shape
|
||||||
|
PathContainer.cpp
|
||||||
|
Shape.cpp
|
||||||
|
ShapeContainer.cpp
|
||||||
|
VectorPath.cpp
|
||||||
|
|
||||||
|
# style
|
||||||
|
GradientTransformable.cpp
|
||||||
|
Style.cpp
|
||||||
|
StyleContainer.cpp
|
||||||
|
|
||||||
|
# transformable
|
||||||
|
Transformable.cpp
|
||||||
|
|
||||||
|
# transformer
|
||||||
|
AffineTransformer.cpp
|
||||||
|
ContourTransformer.cpp
|
||||||
|
PathSource.cpp
|
||||||
|
PerspectiveTransformer.cpp
|
||||||
|
StrokeTransformer.cpp
|
||||||
|
Transformer.cpp
|
||||||
|
TransformerFactory.cpp
|
||||||
|
|
||||||
|
Icon.cpp
|
||||||
|
IconRenderer.cpp
|
||||||
|
IconUtils.cpp
|
||||||
|
;
|
||||||
+3
-4
@@ -61,10 +61,9 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
|
|||||||
|
|
||||||
local mimesetSources =
|
local mimesetSources =
|
||||||
mimeset.cpp
|
mimeset.cpp
|
||||||
Mime.cpp
|
# Mime.cpp
|
||||||
database_support.cpp
|
# UpdateMimeInfoThread.cpp
|
||||||
UpdateMimeInfoThread.cpp
|
# MimeUpdateThread.cpp
|
||||||
MimeUpdateThread.cpp
|
|
||||||
;
|
;
|
||||||
|
|
||||||
if $(HOST_PLATFORM) = haiku_host {
|
if $(HOST_PLATFORM) = haiku_host {
|
||||||
|
|||||||
Reference in New Issue
Block a user