Provides access to the metadata associated with executables, libraries and add-ons. More...
Inherits BNodeInfo.
Public Member Functions | |
BAppFileInfo () | |
Creates an uninitialized BAppFileInfo object. | |
BAppFileInfo (BFile *file) | |
Creates an BAppFileInfo object and initializes it to the supplied file. | |
virtual | ~BAppFileInfo () |
Frees all resources associated with this object. | |
status_t | SetTo (BFile *file) |
Initializes the BAppFileInfo to the supplied file. | |
MIME Type | |
virtual status_t | GetType (char *type) const |
Gets the MIME type of the associated file. | |
virtual status_t | SetType (const char *type) |
Sets the MIME type of the associated file. | |
Signature | |
status_t | GetSignature (char *signature) const |
Gets the application signature of the associated file. | |
status_t | SetSignature (const char *signature) |
Sets the application signature of the associated file. | |
Catalog Entry | |
status_t | GetCatalogEntry (char *catalogEntry) const |
Gets the catalog entry of the associated file used for localization. | |
status_t | SetCatalogEntry (const char *catalogEntry) |
Sets the catalog entry of the associated file used for localization. | |
Application Flags | |
status_t | GetAppFlags (uint32 *flags) const |
Gets the application flags of the associated file. | |
status_t | SetAppFlags (uint32 flags) |
Sets the application flags of the associated file. | |
status_t | RemoveAppFlags () |
Removes the application flags from the associated file. | |
Supported MIME Types | |
status_t | GetSupportedTypes (BMessage *types) const |
Gets the MIME types supported by the application. | |
status_t | SetSupportedTypes (const BMessage *types, bool updateMimeDB, bool syncAll) |
Sets the MIME types that are supported by the application and allows you to specify whether or not the supported types in the MIME DB shall be updated as well. | |
status_t | SetSupportedTypes (const BMessage *types, bool syncAll) |
Sets the MIME types that are supported by the application and allows you to specify whether or not the no longer supported types shall be updated as well. | |
status_t | SetSupportedTypes (const BMessage *types) |
Sets the MIME types supported by the application. | |
bool | IsSupportedType (const char *type) const |
Returns whether the application supports the supplied MIME type. | |
bool | Supports (BMimeType *type) const |
Returns whether the application supports the supplied MIME type explicitly. | |
Application Icon | |
virtual status_t | GetIcon (BBitmap *icon, icon_size which) const |
Gets the icon of the associated file and puts it into a pre-allocated BBitmap. | |
status_t | SetIcon (const BBitmap *icon, icon_size which, bool updateMimeDB) |
Sets the icon of the associated file from a BBitmap. | |
virtual status_t | SetIcon (const BBitmap *icon, icon_size which) |
Sets the icon of the associated file from a BBitmap. | |
status_t | GetIcon (uint8 **data, size_t *size) const |
Gets the icon of the associated file and puts it into a buffer. | |
status_t | SetIcon (const uint8 *data, size_t size, bool updateMimeDB) |
Sets the icon of the associated file from a buffer. | |
status_t | SetIcon (const uint8 *data, size_t size) |
Sets the icon of the associated file from a buffer. | |
status_t | GetIconForType (const char *type, BBitmap *icon, icon_size which) const |
Gets the icon the application provides for a given MIME type and puts it into a BBitmap. | |
status_t | GetIconForType (const char *type, uint8 **data, size_t *size) const |
Gets the icon the application provides for a given MIME type and puts it into a buffer. | |
status_t | SetIconForType (const char *type, const BBitmap *icon, icon_size which, bool updateMimeDB) |
Sets the icon the application provides for a given MIME type from a BBitmap. | |
status_t | SetIconForType (const char *type, const BBitmap *icon, icon_size which) |
Sets the icon the application provides for a given MIME type from a BBitmap. | |
status_t | SetIconForType (const char *type, const uint8 *data, size_t size, bool updateMimeDB) |
Sets the icon the application provides for a given MIME type from a buffer. | |
status_t | SetIconForType (const char *type, const uint8 *data, size_t size) |
Sets the icon the application provides for a given MIME type from a buffer. | |
Version Info | |
status_t | GetVersionInfo (version_info *info, version_kind kind) const |
Gets the version info of the associated file. | |
status_t | SetVersionInfo (const version_info *info, version_kind kind) |
Sets the version info of the associated file. | |
Attributes/Resources | |
void | SetInfoLocation (info_location location) |
Specifies the location where the metadata shall be stored. | |
bool | IsUsingAttributes () const |
Returns whether the object (also) stores the metadata in the attributes of the associated file. | |
bool | IsUsingResources () const |
Returns whether the object (also) stores the metadata in the resources of the associated file. | |
Public Member Functions inherited from BNodeInfo | |
BNodeInfo () | |
Creates an uninitialized BNodeInfo object. | |
BNodeInfo (BNode *node) | |
Creates a BNodeInfo object and initializes it to the supplied node. | |
virtual | ~BNodeInfo () |
Frees the object and associated resources. | |
status_t | SetTo (BNode *node) |
Initializes the BNodeInfo to the supplied node. | |
status_t | InitCheck () const |
Checks whether or not the object has been properly initialized. | |
status_t | GetPreferredApp (char *signature, app_verb verb=B_OPEN) const |
Gets the preferred application of the node. | |
status_t | SetPreferredApp (const char *signature, app_verb verb=B_OPEN) |
Sets the preferred application of the node. If signature is NULL , the BEOS:PREF_APP attribute is removed instead. | |
status_t | GetAppHint (entry_ref *ref) const |
Fills out ref with a pointer to a hint about the application that will open this node. | |
status_t | SetAppHint (const entry_ref *ref) |
Sets the application that will open the file type of the node. If ref is NULL , the BEOS:PPATH attribute is removed instead. | |
status_t | GetIcon (uint8 **data, size_t *size, type_code *type) const |
Gets the icon of the node. | |
status_t | SetIcon (const uint8 *data, size_t size) |
Sets the node icon of the node. If data is NULL or size is 0, the BEOS:ICON attribute is removed instead. | |
status_t | GetTrackerIcon (BBitmap *icon, icon_size which=B_LARGE_ICON) const |
Gets the icon displayed by Tracker for the icon. | |
Additional Inherited Members | |
Static Public Member Functions inherited from BNodeInfo | |
static status_t | GetTrackerIcon (const entry_ref *ref, BBitmap *icon, icon_size which=B_LARGE_ICON) |
Gets the icon displayed by Tracker for the node referred to by ref. | |
Provides access to the metadata associated with executables, libraries and add-ons.
The BAppFileInfo class allows for information about an executable or add-on to be accessed or set. Information about an executable that can be accessed include the signature, catalog entry, supported MIME types, application flags, icon(s), and version info.
You should initialize the BAppFileInfo with a BFile object that represents the executable or add-on that you want to access. If you only want to read metadata from the file you do not have to open it for reading. However, if you also want to write metadata then you should open the BFile for writing.
To associate a BFile with a BAppFileInfo object you can either pass the BFile object into the constructor or you can use the empty constructor and then use the SetTo() method to set the BFile to the BAppFileInfo object.
When accessing information from a BFileInfo object it will first look in the attributes of the BFile. If the information is not found then the BFileInfo object will next look at the resource of the BFile. You can tell the BFileInfo object to look only in the attributes or resources with the SetInfoLocation() method.
BAppFileInfo::BAppFileInfo | ( | ) |
Creates an uninitialized BAppFileInfo object.
BAppFileInfo::BAppFileInfo | ( | BFile * | file | ) |
Creates an BAppFileInfo object and initializes it to the supplied file.
The caller retains ownership of the supplied BFile object. It must not be deleted during the life time of the BAppFileInfo. It is not deleted when the BAppFileInfo is destroyed.
file | The BFile object that the BAppFileInfo object shall be initialized to. |
|
virtual |
Frees all resources associated with this object.
The supplied BFile object is not deleted if one is specified.
Gets the application flags of the associated file.
flags | A pointer to a pre-allocated uint32 into which the application flags of the file are written. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL flags. |
B_BAD_TYPE | The attribute/resources the flags are stored in have the wrong type. |
B_ENTRY_NOT_FOUND | No application flags are set on the file. |
status_t BAppFileInfo::GetCatalogEntry | ( | char * | catalogEntry | ) | const |
Gets the catalog entry of the associated file used for localization.
catalogEntry | A pointer to a pre-allocated character buffer of size B_MIME_TYPE_LENGTH * 3 or larger into which the catalog entry of the file will be written. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL catalogEntry or the entry stored in the attribute/resources is longer than B_MIME_TYPE_LENGTH * 3. |
B_BAD_TYPE | The attribute/resources the entry is stored in have the wrong type. |
B_ENTRY_NOT_FOUND | No catalog entry is set on the file. |
Gets the icon of the associated file and puts it into a pre-allocated BBitmap.
icon | A pointer to a pre-allocated BBitmap of the correct dimension to store the requested icon (16x16 for the B_MINI_ICON and 32x32 for the B_LARGE_ICON ). |
which | Specifies the size of the icon to be retrieved: B_MINI_ICON for the mini and B_LARGE_ICON for the large icon. For HVIF icons this parameter has no effect. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL icon, unsupported icon size which or bitmap dimensions (icon) and icon size (which) do not match. |
Reimplemented from BNodeInfo.
Gets the icon of the associated file and puts it into a buffer.
data | The pointer in which the flat icon data will be returned. |
size | The pointer in which the size of the data found will be returned. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL data or NULL size. |
Gets the icon the application provides for a given MIME type and puts it into a BBitmap.
NULL
, the application's icon is retrieved.type | The MIME type in question. May be NULL . |
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). |
size | Specifies the size of the icon to be retrieved: B_MINI_ICON for the mini and B_LARGE_ICON for the large icon. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL icon, unsupported icon size which or bitmap dimensions (icon) and icon size (which) do not match. |
Gets the icon the application provides for a given MIME type and puts it into a buffer.
NULL
the the application's icon is retrieved.type | The MIME type in question. May be NULL . |
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. |
size | A pointer in which the size of the retrieved data is returned. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL data and/or size. Or the supplied type is not a valid MIME type. |
status_t BAppFileInfo::GetSignature | ( | char * | signature | ) | const |
Gets the application signature of the associated file.
signature | A pointer to a pre-allocated character buffer of size B_MIME_TYPE_LENGTH or larger into which the application signature of the file will be written. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL signature or the signature stored in the attribute/resources is longer than B_MIME_TYPE_LENGTH . |
B_BAD_TYPE | The attribute/resources the signature is stored in have the wrong type. |
B_ENTRY_NOT_FOUND | No signature is set on the file. |
Gets the MIME types supported by the application.
The supported MIME types are added to a field "types" of type B_STRING_TYPE
in types.
types | A pointer to a pre-allocated BMessage into which the MIME types supported by the application will be written. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL types. |
B_BAD_TYPE | The attribute/resources that the supported types are stored in have the wrong type. |
B_ENTRY_NOT_FOUND | No supported types are set on the file. |
|
virtual |
Gets the MIME type of the associated file.
type | A pointer to a pre-allocated character buffer of size B_MIME_TYPE_LENGTH or larger into which the MIME type of the file will be written. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL type or the type string stored in the attribute/resources is longer than B_MIME_TYPE_LENGTH . |
B_BAD_TYPE | The attribute/resources the type string is stored in has the wrong type. |
B_ENTRY_NOT_FOUND | No type is set on the file. |
Reimplemented from BNodeInfo.
status_t BAppFileInfo::GetVersionInfo | ( | version_info * | info, |
version_kind | kind | ||
) | const |
Gets the version info of the associated file.
info | A pointer to a pre-allocated version_info structure into which the version info should be written. |
kind | Specifies the kind of the version info to be retrieved:
|
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL info. |
bool BAppFileInfo::IsSupportedType | ( | const char * | type | ) | const |
Returns whether the application supports the supplied MIME type.
If the application supports the wildcard type "application/octet-stream" then this method returns true
for any MIME type.
type | The MIME type in question. |
true
if type is a valid MIME type and it is supported by the application, false
otherwise.bool BAppFileInfo::IsUsingAttributes | ( | ) | const |
Returns whether the object (also) stores the metadata in the attributes of the associated file.
true
if the metadata are (also) stored in the file's attributes, false
otherwise.bool BAppFileInfo::IsUsingResources | ( | ) | const |
Returns whether the object (also) stores the metadata in the resources of the associated file.
true
if the metadata are (also) stored in the file's resources, false
otherwise.status_t BAppFileInfo::RemoveAppFlags | ( | ) |
Removes the application flags from the associated file.
B_OK | Everything went fine. |
B_NO_INIT | The object was not properly initialized. |
Sets the application flags of the associated file.
flags | The application flags to be assigned to the file. |
B_OK | Everything went fine. |
B_NO_INIT | The object was not properly initialized. |
status_t BAppFileInfo::SetCatalogEntry | ( | const char * | catalogEntry | ) |
Sets the catalog entry of the associated file used for localization.
If catalogEntry is NULL
the file's catalog entry is unset.
catalogEntry | The catalog entry to be assigned to the file. Of the form "x-vnd.Haiku-app:context:name". Must not be longer than B_MIME_TYPE_LENGTH * 3 (including the terminating \0). The catalogEntry may be NULL . |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | catalogEntry is longer than B_MIME_TYPE_LENGTH * 3. |
Sets the icon of the associated file from a BBitmap.
If icon is NULL
then the icon of the file is unset.
Also sets the application's icon in the MIME DB, if the file has a valid application signature.
icon | A pointer to the BBitmap containing the icon to be set. May be NULL to specify no icon. |
which | Specifies the size of the icon to be set: B_MINI_ICON for 16x16 mini icon and B_LARGE_ICON for the 32x32 large icon. For HVIF icons this parameter has no effect. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | Unknown icon size which or bitmap dimensions (icon) and icon size (which) do not match. |
Reimplemented from BNodeInfo.
Sets the icon of the associated file from a BBitmap.
If icon is NULL
then the icon of the file is unset.
icon | A pointer to the BBitmap containing the icon to be set. May be NULL to specify no icon. |
which | Specifies the size of the icon to be set: B_MINI_ICON for 16x16 mini icon and B_LARGE_ICON for the 32x32 large icon. For HVIF icons this parameter has no effect. |
updateMimeDB | true to also set the icon for the application in the MIME DB. false otherwise. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | Unknown icon size which or bitmap dimensions (icon) and icon size (which) do not match. |
Sets the icon of the associated file from a buffer.
If data is NULL
then the icon of the file is unset.
Also sets the application's icon in the MIME DB, if the file has a valid application signature.
data | A pointer to the data buffer containing the vector icon to be set. May be NULL . |
size | Specifies the size of buffer pointed to by data. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL data. |
Sets the icon of the associated file from a buffer.
If data is NULL
then the icon of the file is unset.
data | A pointer to the data buffer containing the vector icon to be set. May be NULL . |
size | Specifies the size of buffer pointed to by data. |
updateMimeDB | true to also set the icon for the application in the MIME DB. false otherwise. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | NULL data. |
Sets the icon the application provides for a given MIME type from a BBitmap.
NULL
then the icon is set. NULL
then 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.
type | The MIME type in question. May be NULL . |
icon | A pointer to the BBitmap containing the icon to be set. May be NULL . |
which | Specifies the size of the icon to be set: B_MINI_ICON for the mini and B_LARGE_ICON for the large icon. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | Either the icon size which is unknown, the bitmap dimensions (icon) and icon size (which) do not match, or the provided type is not a valid MIME type. |
status_t BAppFileInfo::SetIconForType | ( | const char * | type, |
const BBitmap * | icon, | ||
icon_size | which, | ||
bool | updateMimeDB | ||
) |
Sets the icon the application provides for a given MIME type from a BBitmap.
NULL
then the icon is set. NULL
then the icon is unset.If updateMimeDB is true
and 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.
type | The MIME type in question. May be NULL . |
icon | A pointer to the BBitmap containing the icon to be set. May be NULL . |
which | Specifies the size of the icon to be set: B_MINI_ICON for the mini and B_LARGE_ICON for the large icon. |
updateMimeDB | true to also set the icon for the type in the MIME DB. false otherwise. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | Either the icon size which is unknown, the bitmap dimensions (icon) and icon size (which) do not match, or the provided type is not a valid MIME type. |
Sets the icon the application provides for a given MIME type from a buffer.
NULL
then the icon is set. NULL
then 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.
type | The MIME type in question. May be NULL . |
data | A pointer to the data containing the icon to be set. May be NULL . |
size | Specifies the size of buffer provided in data. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | The provided type is not a valid MIME type. |
status_t BAppFileInfo::SetIconForType | ( | const char * | type, |
const uint8 * | data, | ||
size_t | size, | ||
bool | updateMimeDB | ||
) |
Sets the icon the application provides for a given MIME type from a buffer.
NULL
then the icon is set. NULL
then the icon is unset.If updateMimeDB is true
and 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.
type | The MIME type in question. May be NULL . |
data | A pointer to the data containing the icon to be set. May be NULL . |
size | Specifies the size of buffer provided in data. |
updateMimeDB | true to also set the icon for the type in the MIME DB. false otherwise. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | The provided type is not a valid MIME type. |
void BAppFileInfo::SetInfoLocation | ( | info_location | location | ) |
Specifies the location where the metadata shall be stored.
The options for location are:
B_USE_ATTRIBUTES:
Store the data in the attributes.B_USE_RESOURCES:
Store the data in the resources.B_USE_BOTH_LOCATIONS:
Store the data in attributes and resources.location | The location where the metadata shall be stored. |
status_t BAppFileInfo::SetSignature | ( | const char * | signature | ) |
Sets the application signature of the associated file.
If signature is NULL
the file's application signature is unset.
signature | The application signature to be assigned to the file. Must not be longer than B_MIME_TYPE_LENGTH (including the terminating \0). The signature may be NULL . |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | signature is longer than B_MIME_TYPE_LENGTH . |
Sets the MIME types supported by the application.
This method is a short-hand for SetSupportedTypes(types, false).
types | The supported types to be assigned to the file. May be NULL . |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
Sets the MIME types that are supported by the application and allows you to specify whether or not the no longer supported types shall be updated as well.
If types is NULL
then the application's supported types are unset.
The supported MIME types must be stored in a field "types" of type B_STRING_TYPE
in types.
The method informs the registrar about this news. For each supported type the result of BMimeType::GetSupportingApps() will afterwards include the signature of this application. That is, the application file needs to have a signature set.
syncAll specifies whether the no longer supported types shall be updated as well, i.e. whether or not this application shall be removed from the list of supporting applications.
types | The supported types to be assigned to the file. May be NULL . |
syncAll | true to also synchronize the no-longer supported types, false otherwise. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
status_t BAppFileInfo::SetSupportedTypes | ( | const BMessage * | types, |
bool | updateMimeDB, | ||
bool | syncAll | ||
) |
Sets the MIME types that are supported by the application and allows you to specify whether or not the supported types in the MIME DB shall be updated as well.
If types is NULL
then the application's supported types are unset.
The supported MIME types must be stored in a field "types" of type B_STRING_TYPE
in types.
If updateMimeDB is true
, the method will inform the registrar about this news. In this case for each supported type the result of BMimeType::GetSupportingApps() will afterward include the signature of this application. That is, the application file needs to have a signature set.
syncAll specifies whether the no longer supported types shall be updated as well, i.e. whether or not this application shall be removed from the list of supporting applications. Only relevant when updateMimeDB is true
.
types | The supported types to be assigned to the file. May be NULL . |
updateMimeDB | true to update the supported types in the MIME DB, false otherwise. |
syncAll | true to also synchronize the no-longer supported types, false otherwise. |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
Initializes the BAppFileInfo to the supplied file.
The caller retains ownership of the supplied BFile object. It must not be deleted during the life time of the BAppFileInfo. The BFile object is not deleted when the BAppFileInfo is destroyed.
file | The BFile object that the BAppFileInfo object shall be initialized to. |
B_OK | Everything went fine. |
B_BAD_VALUE | NULL file or file is not properly initialized. |
|
virtual |
Sets the MIME type of the associated file.
If type is NULL
if the file's MIME type is unset.
type | The MIME type to be assigned to the file. It must not be longer than B_MIME_TYPE_LENGTH (including the terminating \0). The MIME type may be NULL . |
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
B_BAD_VALUE | type is longer than B_MIME_TYPE_LENGTH . |
Reimplemented from BNodeInfo.
status_t BAppFileInfo::SetVersionInfo | ( | const version_info * | info, |
version_kind | kind | ||
) |
Sets the version info of the associated file.
NULL
then the file's version info is unset.info | The version info to be set. May be NULL . |
kind | Specifies kind of version info to be set:
|
B_OK | Everything went fine. |
B_NO_INIT | The object is not properly initialized. |
bool BAppFileInfo::Supports | ( | BMimeType * | type | ) | const |
Returns whether the application supports the supplied MIME type explicitly.
Unlike IsSupportedType(), this method returns true
, only if the type is explicitly supported, regardless of whether it supports "application/octet-stream".
type | The MIME type in question. |
true
if type is a valid MIME type and it is explicitly supported by the application, false
otherwise.