All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Public Member Functions | List of all members
BNodeInfo Class Reference

Provides access to file type meta data on a node. More...

Inherited by BAppFileInfo.

Public Member Functions

 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.
 
Constructor helper methods
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.
 
MIME-type methods
virtual status_t GetType (char *type) const
 Writes the MIME-type of the node into type.
 
virtual status_t SetType (const char *type)
 Sets the MIME-type of the node. If type is NULL the BEOS:TYPE attribute is removed instead.
 
Preferred Application
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.
 
Application Hint
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.
 

Icon

virtual status_t GetIcon (BBitmap *icon, icon_size which=B_LARGE_ICON) const
 Gets the icon of the node.
 
virtual status_t SetIcon (const BBitmap *icon, icon_size which=B_LARGE_ICON)
 Sets the icon of the node. If icon is NULL, the 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.
 
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.
 

Detailed Description

Provides access to file type meta data on a node.

BNodeInfo provides a nice wrapper to all sorts of useful meta data such as the MIME-type, the file's icon and the application that will open the file.

Since
BeOS R3

Constructor & Destructor Documentation

◆ BNodeInfo() [1/2]

BNodeInfo::BNodeInfo ( )

Creates an uninitialized BNodeInfo object.

After created a BNodeInfo with this, you should call SetTo().

See also
SetTo(BNode* node)
Since
BeOS R3

◆ BNodeInfo() [2/2]

BNodeInfo::BNodeInfo ( BNode node)

Creates a BNodeInfo object and initializes it to the supplied node.

Parameters
nodeThe node to initialize to and gather information.
Since
BeOS R3

◆ ~BNodeInfo()

BNodeInfo::~BNodeInfo ( )
virtual

Frees the object and associated resources.

The internal BNode object is not deleted.

Since
BeOS R3

Member Function Documentation

◆ GetAppHint()

status_t BNodeInfo::GetAppHint ( entry_ref ref) const

Fills out ref with a pointer to a hint about the application that will open this node.

The path contained in the BEOS:PPATH attribute of the node is converted into an entry_ref and returned. ref should be pre-allocated before being passed into this method.

Parameters
refA pointer to a pre-allocated entry_ref into which the app hint is written.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_DATAAttribute size greater than B_PATH_NAME_LENGTH.
B_BAD_TYPEThe stored type string attribute has the wrong type.
B_BAD_VALUEThe ref object passed in was NULL.
B_ERRORUnable to read BEOS:PPATH attribute.
B_NO_INITThe object was not properly initialized.

◆ GetIcon() [1/2]

status_t BNodeInfo::GetIcon ( BBitmap icon,
icon_size  which = B_LARGE_ICON 
) const
virtual

Gets the icon of the node.

The icon stored in the BEOS:L:STD_ICON attribute (large) or BEOS:M:STD_ICON attribute (mini) is retrieved.

Parameters
iconA pointer to a pre-allocated BBitmap object of the correct dimension to store the requested icon: 16x16 for the mini or 32x32 for the large icon.
whichThe size of the icon to be retrieved: B_MINI_ICON for a 16x16 icon and B_LARGE_ICON for a 32x32 icon.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object was not properly initialized.
B_BAD_VALUENULL icon, unsupported icon size k or bitmap dimensions (icon) and icon size (k) do not match.
Since
BeOS R3

Reimplemented in BAppFileInfo.

◆ GetIcon() [2/2]

status_t BNodeInfo::GetIcon ( uint8 **  data,
size_t *  size,
type_code type 
) const

Gets the icon of the node.

The icon stored in the BEOS:ICON attribute of the node is retrieved. The caller is responsible to delete[] the data if the icon was retrieved.

Parameters
dataA pointer in which a pointer to the icon data will be filled in.
sizeA pointer in which the size of the found icon data will be filled in.
typeA pointer in which the type of the found icon data will be filled in.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object was not properly initialized.
B_BAD_VALUENULL data, NULL size or NULL type.
B_NO_MEMORYNo memory to allocate the data buffer.
Since
Haiku R1

◆ GetPreferredApp()

status_t BNodeInfo::GetPreferredApp ( char *  signature,
app_verb  verb = B_OPEN 
) const

Gets the preferred application of the node.

Writes the contents of the BEOS:PREF_APP attribute into the signature buffer. The preferred application can be identified by its signature. signature should be at least B_MIME_TYPE_LENGTH or longer and pre-allocated before it is passed into this method.

Parameters
signatureA pointer to a pre-allocated character buffer of size B_MIME_TYPE_LENGTH or larger into which the MIME-type of the preferred application is written.
verbThe type of access the preferred application is requested. Currently B_OPEN is the only meaningful option.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object was not properly initialized.
B_BAD_VALUENULL signature or bad app_verb.

◆ GetTrackerIcon() [1/2]

status_t BNodeInfo::GetTrackerIcon ( BBitmap icon,
icon_size  which = B_LARGE_ICON 
) const

Gets the icon displayed by Tracker for the icon.

This method tries really hard to find an icon for the node:

  • If the node has no type this method returns the icon for B_FILE_MIME_TYPE if it's a regular file or B_DIRECTORY_MIME_TYPE if it's a directory, even if the node has its own icon!
  • Next it will ask GetIcon() for an icon.
  • If this fails it will get the preferred application and ask the MIME database if the application has an icon for the file type of the node.
  • Next it will ask the MIME database whether there is an icon for the file type of the node.
  • Then it will ask the MIME database for the preferred application for the file type of the node and whether this application has a special icon for the type.
  • Finally it will return a generic icon for whatever type of file type (file/dir/etc.) the node is from the MIME database.

The first action that provides an icon is used. In the case that none of them yield an icon this method fails, this is very unlikely though.

Remarks
You can set which to get a scaled icon instead of using a predefined icon_size constant, pass in an integer casted to icon_size. For example to get a 64x64 icon pass in:
icon_size
Definition: Mime.h:16
Parameters
iconA 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).
whichThe size of the icon to be retrieved: B_MINI_ICON for a 16x16 icon or B_LARGE_ICON for a 32x32 icon.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object was not properly initialized.
B_BAD_VALUENULL icon, unsupported icon size which or bitmap dimensions (icon) and icon size (which) do not match.
Since
BeOS R3

◆ GetTrackerIcon() [2/2]

status_t BNodeInfo::GetTrackerIcon ( const entry_ref ref,
BBitmap icon,
icon_size  which = B_LARGE_ICON 
)
static

Gets the icon displayed by Tracker for the node referred to by ref.

This methods works similarly to the non-static version but ref identifies the node. icon must be pre-allocated to the size requested using which before being passed to this method.

Parameters
refAn entry_ref referring to the node for which the icon is retrieved.
iconA pointer to a pre-allocated BBitmap object of the correct dimension to store the requested icon (16x16 for the mini and 32x32 for the large icon).
whichThe size of the icon to be retrieved: B_MINI_ICON for a 16x16 icon or B_LARGE_ICON for a 32x32 icon.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object is not properly initialized.
B_BAD_VALUENULL ref or icon, unsupported icon size which or bitmap dimensions (icon) and icon size (which) do not match.
Since
BeOS R3

◆ GetType()

status_t BNodeInfo::GetType ( char *  type) const
virtual

Writes the MIME-type of the node into type.

The source of the type information is the BEOS:TYPE attribute of the node. The type buffer should be pre-allocated before it is passed into GetType(), it should be at least B_MIME_TYPE_LENGTH in length.

Parameters
typeA pointer to a pre-allocated char buffer of at least B_MIME_TYPE_LENGTH length into which the MIME-type of the node is written.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object is not properly initialized.
B_BAD_VALUENULL type or the type string stored in the attribute is longer than B_MIME_TYPE_LENGTH.
B_BAD_TYPEThe stored type string attribute has the wrong type.
B_ENTRY_NOT_FOUNDNo type is set on the node.
Since
BeOS R3

Reimplemented in BAppFileInfo.

◆ InitCheck()

status_t BNodeInfo::InitCheck ( ) const

Checks whether or not the object has been properly initialized.

Returns
A status code.
Return values
B_OKThe object was properly initialized.
B_BAD_VALUEThe object was not properly initialized.
Since
BeOS R3

◆ SetAppHint()

status_t BNodeInfo::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.

ref is converted into a path and stored in the BEOS:PPATH attribute of the node. If ref is NULL BEOS:PPATH is removed instead.

Parameters
refA pointer to an entry_ref referring to the application. May be NULL.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_VALUEThe ref object passed in was NULL.
B_ENTRY_NOT_FOUNDBEOS:PPATH attribute not found.
B_ERRORUnable to write BEOS:PPATH attribute.
B_NO_INITThe object was not properly initialized.

◆ SetIcon() [1/2]

status_t BNodeInfo::SetIcon ( const BBitmap icon,
icon_size  which = B_LARGE_ICON 
)
virtual

Sets the icon of the node. If icon is NULL, the attribute is removed instead.

The icon is stored in the BEOS:L:STD_ICON attribute (large) or BEOS:M:STD_ICON attribute (mini). If icon is NULL the respective attribute is removed instead.

Parameters
iconA pointer to a BBitmap object containing the icon to be set. May be NULL.
whichThe size of the icon to be set: B_MINI_ICON for the mini or B_LARGE_ICON for the large icon.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object is not properly initialized.
B_BAD_VALUEUnknown icon size k or bitmap dimensions (icon) and icon size (k) do not match.
Since
BeOS R3

Reimplemented in BAppFileInfo.

◆ SetIcon() [2/2]

status_t BNodeInfo::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.

The icon is stored in the BEOS:ICON attribute of the node.

Parameters
dataA pointer to valid icon data. May be NULL.
sizeThe size of the provided data buffer. May be 0.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object was not properly initialized.
Since
Haiku R1

◆ SetPreferredApp()

status_t BNodeInfo::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.

The supplied string is written into the BEOS:PREF_APP attribute of the node. If signature is NULL, the respective attribute is removed instead. signature must not be longer than B_MIME_TYPE_LENGTH (including the terminating NUL).

Parameters
signatureThe signature of the preferred application to be set. May be NULL.
verbThe type of access set to the preferred application. Currently only B_OPEN is meaningful.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object is not properly initialized.
B_BAD_VALUENULL signature, signature is longer than B_MIME_TYPE_LENGTH or bad app_verb.

◆ SetTo()

status_t BNodeInfo::SetTo ( BNode node)

Initializes the BNodeInfo to the supplied node.

The BNodeInfo object does not copy the supplied node object, it uses it directly instead. You must not delete the supply node while the BNodeInfo object exists. The BNodeInfo does not take over ownership of the node and it doesn't delete it on destruction either.

Parameters
nodeThe node to gather information on.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_VALUEThe node was not properly initialized.
Since
BeOS R3

◆ SetType()

status_t BNodeInfo::SetType ( const char *  type)
virtual

Sets the MIME-type of the node. If type is NULL the BEOS:TYPE attribute is removed instead.

The type string is written into the BEOS:TYPE attribute of the node. If type is NULL, the BEOS:TYPE attribute is removed instead. The type parameter may not by longer than B_MIME_TYPE_LENGTH in length including the terminating \0 character.

Parameters
typeThe MIME-type to be assigned to the node. Must not be longer than B_MIME_TYPE_LENGTH (including the terminating NUL). May be NULL to remove the attribute.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITThe object was not properly initialized.
B_BAD_VALUEtype is longer than B_MIME_TYPE_LENGTH.
Since
BeOS R3

Reimplemented in BAppFileInfo.