From 8c34572babbee53bbeab71d0291c0b967f91790d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 15 Nov 2006 17:37:26 +0000 Subject: [PATCH] Somehow the vector icon version of GetIconForType() was missing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19295 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/storage/MimeType.h | 34 +++++++++------------------ src/kits/storage/MimeType.cpp | 43 ++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/headers/os/storage/MimeType.h b/headers/os/storage/MimeType.h index af38f611f9..3124035144 100644 --- a/headers/os/storage/MimeType.h +++ b/headers/os/storage/MimeType.h @@ -70,20 +70,6 @@ enum { B_META_MIME_DELETED = 'MMDL', }; -/* ------------------------------------------------------------- */ - -//! File typing functionality. -/*! The BMimeType class provides access to the file typing system, which - provides the following functionality: - - Basic MIME string manipulation - - Access to file type information in the MIME database - - Ways to receive notifications when parts of the MIME database are updated - - Methods to determine/help determine the types of untyped files - - \author Tyler Dauwalder - \author Ingo Weinhold - \version 0.0.0 -*/ class BMimeType { public: BMimeType(); @@ -109,8 +95,8 @@ class BMimeType { status_t Install(); status_t Delete(); bool IsInstalled() const; - status_t GetIcon(BBitmap *icon, icon_size size) const; - status_t GetIcon(uint8** data, size_t* size) const; + status_t GetIcon(BBitmap* icon, icon_size size) const; + status_t GetIcon(uint8** _data, size_t* _size) const; status_t GetPreferredApp(char *signature, app_verb verb = B_OPEN) const; status_t GetAttrInfo(BMessage *info) const; status_t GetFileExtensions(BMessage *extensions) const; @@ -137,9 +123,11 @@ class BMimeType { status_t SetAppHint(const entry_ref *ref); /* for application signatures only. */ - status_t GetIconForType(const char *type, BBitmap *icon, + status_t GetIconForType(const char* type, BBitmap* icon, icon_size which) const; - status_t SetIconForType(const char *type, const BBitmap *icon, + status_t GetIconForType(const char* type, uint8** _data, + size_t* _size) const; + status_t SetIconForType(const char* type, const BBitmap* icon, icon_size which); status_t SetIconForType(const char* type, const uint8* data, size_t size); @@ -163,7 +151,7 @@ class BMimeType { status_t SetType(const char *mimeType); private: - BMimeType(const char *mimeType, const char *mimePath); + BMimeType(const char* mimeType, const char* mimePath); // if mimePath is NULL, defaults to "/boot/home/config/settings/beos_mime/" friend class MimeTypeTest; @@ -176,13 +164,13 @@ class BMimeType { virtual void _ReservedMimeType2(); virtual void _ReservedMimeType3(); - BMimeType &operator=(const BMimeType &); - BMimeType(const BMimeType &); + BMimeType& operator=(const BMimeType& source); + BMimeType(const BMimeType& source); status_t GetSupportedTypes(BMessage* types); status_t SetSupportedTypes(const BMessage* types, bool fullSync = true); - - static status_t GetAssociatedTypes(const char *extension, BMessage *types); + + static status_t GetAssociatedTypes(const char* extension, BMessage* types); private: char* fType; diff --git a/src/kits/storage/MimeType.cpp b/src/kits/storage/MimeType.cpp index 7b6db18549..f8e35d604c 100644 --- a/src/kits/storage/MimeType.cpp +++ b/src/kits/storage/MimeType.cpp @@ -444,10 +444,9 @@ BMimeType::GetIcon(BBitmap *icon, icon_size size) const } -// GetIcon -//! Fetches the vector icon associated with the MIME type -/*! The icon data is returned in \c data. - +/*! \brief Fetches the vector icon associated with the MIME type + The icon data is returned in \c data. + \param data Pointer in which the allocated icon data is returned. You need to delete the buffer when you are done with it. \param size Pointer in which the size of the allocated icon data is returned. @@ -1247,7 +1246,7 @@ BMimeType::SetAppHint(const entry_ref *ref) return err; } -// GetIconForType + /*! \brief Fetches the large or mini icon used by an application of this type for files of the given type. @@ -1291,7 +1290,39 @@ BMimeType::GetIconForType(const char *type, BBitmap *icon, icon_size which) cons return err; } -// SetIconForType + +/*! \brief Fetches the vector icon used by an application of this type for files of + the given type. + + The icon data is returned in \c data. + See the other GetIconForType() for more information. + + \param type Pointer to a pre-allocated string containing the MIME type whose + custom icon you wish to fetch. + \param data Pointer in which the allocated icon data is returned. You need to + delete the buffer when you are done with it. + \param size Pointer in which the size of the allocated icon data is returned. + \return + - \c B_OK: Success + - \c B_ENTRY_NOT_FOUND: No icon of the given size exists for the given type + - other error code: Failure + +*/ +status_t +BMimeType::GetIconForType(const char *type, uint8** _data, size_t* _size) const +{ + // If type is NULL, this function works just like GetIcon(), otherwise, + // we need to make sure the give type is valid. + if (type == NULL) + return GetIcon(_data, _size); + + if (!BMimeType::IsValid(type)) + return B_BAD_VALUE; + + return get_icon_for_type(Type(), type, _data, _size); +} + + /*! \brief Sets the large or mini icon used by an application of this type for files of the given type.