2013-02-01 05:47:06 +04:00
|
|
|
/*
|
2014-06-19 03:10:45 +04:00
|
|
|
* Copyright 2013-2014 Haiku, Inc. All rights reserved.
|
2013-02-01 05:47:06 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Authors:
|
2013-02-01 05:47:06 +04:00
|
|
|
* Ingo Weinhold, bonefish@users.sf.net
|
|
|
|
* John Scipione, jscipione@gmail.com
|
|
|
|
*
|
|
|
|
* Corresponds to:
|
2014-06-19 03:10:45 +04:00
|
|
|
* headers/os/storage/Mime.h hrev47402
|
|
|
|
* src/kits/storage/Mime.cpp hrev47402
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\file Mime.h
|
|
|
|
\ingroup storage
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup libbe
|
2013-02-01 05:47:06 +04:00
|
|
|
\brief Provides C and Haiku-only C++ MIME-type handling functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum icon_size
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup storage
|
2013-02-01 05:47:06 +04:00
|
|
|
\brief Legacy BeOS icon size constants.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\var icon_size B_LARGE_ICON
|
|
|
|
|
|
|
|
32x32 "Large" icon.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\var icon_size B_MINI_ICON
|
|
|
|
|
|
|
|
16x16 "Mini" icon.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\var B_UPDATE_MIME_INFO_NO_FORCE
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Files that already have a \c BEOS:TYPE attribute won't be updated.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since Haiku R1
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\var B_UPDATE_MIME_INFO_FORCE_KEEP_TYPE
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Files that already have a \c BEOS:TYPE attribute will be updated
|
|
|
|
too, but \c BEOS:TYPE itself will remain untouched.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since Haiku R1
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\var B_UPDATE_MIME_INFO_FORCE_UPDATE_ALL
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Similar to \c B_UPDATE_MIME_INFO_FORCE_KEEP_TYPE, but the
|
|
|
|
\c BEOS:TYPE attribute will be updated too.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since Haiku R1
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn int update_mime_info(const char* path, int recursive, int synchronous,
|
2013-02-01 05:47:06 +04:00
|
|
|
int force)
|
|
|
|
\brief Updates the MIME information (i.e MIME type) for one or more files.
|
|
|
|
|
|
|
|
If \a path points to a file, the MIME information for this file are
|
|
|
|
updated only. If it points to a directory and \a recursive is non-null,
|
|
|
|
the information for all the files in the given directory tree are updated.
|
|
|
|
If path is \c NULL all files are considered; \a recursive is ignored in
|
|
|
|
this case.
|
|
|
|
|
|
|
|
\param path The path to a file or directory, or \c NULL.
|
|
|
|
\param recursive Triggers recursive behavior if not \c NULL.
|
|
|
|
\param synchronous If not \c NULL update_mime_info() waits until the
|
2014-06-19 03:10:45 +04:00
|
|
|
operation is finished, otherwise it returns immediately and the
|
|
|
|
update is done asynchronously.
|
2013-02-01 05:47:06 +04:00
|
|
|
\param force Specifies how to handle files that already have MIME
|
2014-06-19 03:10:45 +04:00
|
|
|
information. See enum definitions for more information:
|
|
|
|
- \c B_UPDATE_MIME_INFO_NO_FORCE
|
|
|
|
- \c B_UPDATE_MIME_INFO_FORCE_KEEP_TYPE
|
|
|
|
- \c B_UPDATE_MIME_INFO_FORCE_UPDATE_ALL
|
|
|
|
|
|
|
|
\return A status code, \c B_OK if everything went fine, an error code
|
|
|
|
otherwise.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t create_app_meta_mime(const char* path, int recursive,
|
2013-02-01 05:47:06 +04:00
|
|
|
int synchronous, int force)
|
|
|
|
\brief Creates a MIME database entry for one or more applications.
|
|
|
|
|
|
|
|
If \a path points to an application file, a MIME DB entry is create for
|
|
|
|
the application. If it points to a directory and \a recursive is not
|
|
|
|
\c NULL then entries are created for all application files in the given
|
|
|
|
directory tree. If path is \c NULL then all files are considered and
|
|
|
|
\a recursive is ignored.
|
|
|
|
|
|
|
|
\param path The path to an application file, a directory, or \c NULL.
|
|
|
|
\param recursive Trigger recursive behavior if not \c NULL.
|
|
|
|
\param synchronous Waits until the operation is finished if not \c NULL,
|
2014-06-19 03:10:45 +04:00
|
|
|
otherwise it returns immediately and the operation is done
|
|
|
|
asynchronously.
|
2013-02-01 05:47:06 +04:00
|
|
|
\param force Entries are created even if they do already exist if not
|
2014-06-19 03:10:45 +04:00
|
|
|
\c NULL.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return A status code, \c B_OK if everything went fine, an error code
|
|
|
|
otherwise.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t get_device_icon(const char* device, void* icon, int32 size)
|
2013-02-01 05:47:06 +04:00
|
|
|
\brief Retrieves an icon associated with a given device.
|
|
|
|
|
|
|
|
\param device The path to the device.
|
|
|
|
\param icon A pointer to a buffer the icon data shall be written to.
|
|
|
|
\param size The size of the icon to retrieve. Currently 16
|
2014-06-19 03:10:45 +04:00
|
|
|
(\c B_MINI_ICON) and 32 (\c B_LARGE_ICON) are supported.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return A status code, \c B_OK if everything went fine, an error code
|
|
|
|
otherwise.
|
|
|
|
\retval B_OK Retrieved the icon successfully.
|
2013-02-01 05:47:06 +04:00
|
|
|
\retval B_BAD_VALUE \a device or \a icon was \c NULL.
|
|
|
|
\retval B_NO_MEMORY Ran out of memory allocating bitmap.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t get_device_icon(const char* device, BBitmap* icon,
|
2013-02-01 05:47:06 +04:00
|
|
|
icon_size which)
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Retrieves an icon associated with a given device into a BBitmap,
|
|
|
|
C++ only.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
|
|
|
\param device The path to the device.
|
|
|
|
\param icon A pointer to a pre-allocated BBitmap of the correct dimension
|
2014-06-19 03:10:45 +04:00
|
|
|
to store the requested icon (16x16 for the mini and 32x32 for the
|
|
|
|
large icon).
|
2013-02-01 05:47:06 +04:00
|
|
|
\param which The size of the icon to retrieve. Currently 16
|
2014-06-19 03:10:45 +04:00
|
|
|
(\c B_MINI_ICON) and 32 (\c B_LARGE_ICON) are supported.
|
|
|
|
|
|
|
|
\return A status code, \c B_OK if everything went fine, an error code
|
|
|
|
otherwise.
|
|
|
|
\retval B_OK Retrieved the icon successfully.
|
|
|
|
\retval B_BAD_VALUE \a device or \a icon was \c NULL.
|
2013-02-01 05:47:06 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since Haiku R1
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t get_device_icon(const char* device, uint8** _data,
|
|
|
|
size_t* _size, type_code* _type);
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Try to get the icon by name first, if that fails try to get the
|
|
|
|
vector icon, C++ only.
|
|
|
|
|
|
|
|
\param device The path to the device.
|
|
|
|
\param _data A pointer to a pointer to an array of uint8 pixel data to
|
|
|
|
fill out.
|
|
|
|
\param _size The size of the icon to fill out. If vector, it is filled in
|
|
|
|
with the width in pixels, if bitmap, one of the following constants:
|
|
|
|
- \c B_MINI_ICON
|
|
|
|
- \c B_LARGE_ICON
|
|
|
|
\param _type The icon type code to fill out, one of the following:
|
|
|
|
- \c B_MINI_ICON_TYPE
|
|
|
|
- \c B_LARGE_ICON_TYPE
|
|
|
|
- \c B_VECTOR_ICON_TYPE
|
|
|
|
|
|
|
|
\return A status code, \c B_OK if everything went fine, an error code
|
|
|
|
otherwise.
|
|
|
|
\retval B_OK Retrieved the icon successfully.
|
|
|
|
\retval B_BAD_VALUE \a device, \a _data, \a _size, or _type was \c NULL.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t get_named_icon(const char* name, BBitmap* icon,
|
|
|
|
icon_size which);
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Get the icon by name, C++ only.
|
|
|
|
|
|
|
|
\param name The name of the icon to get.
|
|
|
|
\param icon A pointer to a pre-allocated BBitmap of the correct dimension
|
|
|
|
to store the requested icon (16x16 for the mini and 32x32 for the
|
|
|
|
large icon).
|
|
|
|
\param which The size of the icon to retrieve. Currently 16
|
|
|
|
(\c B_MINI_ICON) and 32 (\c B_LARGE_ICON) are supported.
|
|
|
|
|
|
|
|
\return A status code, \c B_OK if everything went fine, an error code
|
|
|
|
otherwise.
|
|
|
|
\retval B_OK Retrieved the icon successfully.
|
|
|
|
\retval B_BAD_VALUE \a name or \a icon was \c NULL.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t get_named_icon(const char* name, uint8** _data,
|
2013-02-01 05:47:06 +04:00
|
|
|
size_t* _size, type_code* _type);
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Get the icon by name, C++ only.
|
|
|
|
|
|
|
|
\param name The name of the icon to get.
|
|
|
|
\param _data A pointer to a pointer to an array of uint8 pixel data to
|
|
|
|
fill out.
|
|
|
|
\param _size The size of the icon to fill out. If vector, it is filled in
|
|
|
|
with the width in pixels, if bitmap, one of the following constants:
|
|
|
|
- \c B_MINI_ICON
|
|
|
|
- \c B_LARGE_ICON
|
|
|
|
\param _type The icon type code to fill out, one of the following:
|
|
|
|
- \c B_MINI_ICON_TYPE
|
|
|
|
- \c B_LARGE_ICON_TYPE
|
|
|
|
- \c B_VECTOR_ICON_TYPE
|
|
|
|
|
|
|
|
\return A status code, \c B_OK if everything went fine, an error code
|
|
|
|
otherwise.
|
|
|
|
\retval B_OK Retrieved the icon successfully.
|
|
|
|
\retval B_BAD_VALUE \a name, \a _data, \a _size, or \c _type was \c NULL.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2013-02-01 05:47:06 +04:00
|
|
|
*/
|