To create a BBitmap
you must have a be_app
object ; the object needn't be running.
| Derived From: | BNodeInfo |
| Mix-in Classes: | None |
| Declared In: | be/storage/AppFileInfo.h |
| Library: | libbe.so |
| Allocation: | – |
| Class Overview | |
BAppFileInfo();
BAppFileInfo(BFile* file);
The default constructor creates a new, uninitialized BAppFileInfo object.
To initialize you have to follow this construction with a call to
SetTo().
The BFile
version intializes the BAppFileInfo by passing the argument to
SetTo().
~BAppFileInfo();
Destroys the object. The BFile
that was used to initialize this object isn't touched.
status_t GetAppFlags(uint32* flags) const;status_t SetAppFlags(uint32 flags);
These functions get and set the executable's "app flags." These are the
constants that determine whether an executable can only be launched once,
whether it runs in the background, and so on. The app flag constants are
defined in
be/app/Roster.h;
the flags must include one of the following…
B_SINGLE_LAUNCH
B_MULTIPLE_LAUNCH
B_EXCLUSIVE_LAUNCH
…plus either of these two:
B_BACKGROUND_APP
B_ARGV_ONLY
See the BApplication
class for details on the meanings of these constants.
RETURN CODES
B_OKEverything went fine.
B_NO_INITThe object is not properly initialized.
B_BAD_VALUE
NULL flags.
B_BAD_TYPEThe attribute/resources the flags are stored in have the wrong type.
B_ENTRY_NOT_FOUNDNo application flags are set on the file.
status_t GetIcon(BBitmap* icon,
icon_size which) const;status_t SetIcon(BBitmap* icon,
icon_size which);status_t GetIconForType(const char* file_type,
BBitmap* icon,
icon_size which) const;status_t SetIconForType(const char* file_type,
BBitmap* icon,
icon_size which);
GetIcon() and SetIcon()
get and set the icons that are represent the
executable. GetIconForType() and SetIconForType() get and set the icons
that the executable uses when it writes (or otherwise "takes possession
of") a file of the given type, identified by file_type. You specify which
icon you want (large or small) by passing B_LARGE_ICON or B_MINI_ICON as
the which argument.
The icon is passed in or returned through the icon argument. The bitmap
must be the proper size: 32x32 for the large icon, 16x16 for the small
one. In BRect lingo, that's
BRect(0, 0, 31, 31) and BRect(0, 0, 15, 15).
The bitmap's color space must be B_CMAP8. For example:
BBitmap*bitmap= newBBitmap(BRect(0,0,31,31),B_CMAP8);appFileInfo.GetIcon(bitmap,B_LARGE_ICON);
You can remove an icon by passing NULL as the icon
argument to SetIcon().
RETURN CODES
B_OK.Success
B_BAD_VALUE.
(Get…()) NULL
BBitmap, or invalid file_type.
B_BAD_VALUE.
(Set…()) The bitmap data isn't the proper size.
B_NO_INIT.The object is not properly initialized.
An application's preferred app must be itself; an add-on is more flexible. For syntax, see
BNodeInfo::SetPreferredApp().
status_t GetSignature(char* signature) const;status_t SetSignature(const char* signature);
These functions get and set the executable's MIME type signature. The
signature buffer you pass to GetSignature() should be at least
B_MIME_TYPE_LENGTH characters long; the
SetSignature() buffer must be no
longer than that.
When you set an executable's signature, the signature is installed in the File Type database if it's not there already. The old signature isn't removed from the database.
RETURN CODES
B_OK.Success.
B_ENTRY_NOT_FOUND.
(Get…())
The executable doesn't have a signature.
B_BAD_VALUE.
(Set…())
signature is too long.
status_t GetSupportedTypes(BMessage* types) const;status_t SetSupportedTypes(const BMessage* types);
status_t SetSupportedTypes(const BMessage* types,
bool sync_all);
These functions get and set the MIME file types that this executable can
read and/or write. The types
BMessage that you pass in looks like this:
| Field | Type | Meaning |
|---|---|---|
types (array) | B_STRING_TYPE | An array of MIME strings. |
GetSupportedTypes() copies the types
into the types field;
SetSupportedTypes() reads them from the field. The message's command
constants (its what value) is ignored.
Here we print an executable's supported types:
BMessagemsg; uint32i=0; char*ptr; if (appFileInfo.GetSupportedTypes(&msg) !=B_OK) /* Handle the error. */ while (msg.FindString("types",i++, &ptr) ==B_OK)printf("> Supported Type: %sn",ptr);
If SetSupportedTypes() names a type that doesn't already appear in the
File Type database, the new type is added to the database and its
preferred handler is set to the executable that this BAppFileInfo object
represents.
SetSupportedTypes() clobbers an executable's existing set of supported
types. If you want to augment an executable's supported types, you should
retrieve the existing set, add the new ones, and then call
SetSupportedTypes().
RETURN CODES
B_OK.Success.
B_NO_MEMORY.Insufficient memory to copy the types.
See Also:
Supports()
Implementation detail; see "Functions Inherited From BNodeInfo". An
executable's default file type (for both applications and add-ons) is
B_APP_MIME_TYPE. This value mustn't be changed. For syntax, see
BNodeInfo::SetType().
status_t GetVersionInfo(version_info* info,
version_kind kind) const;status_t SetVersionInfo(const version_info* info,
version_kind kind);The functions get and set the application's "version info." The information is recorded in the version_info structure:
struct version_info { uint32major; uint32middle; uint32minor; uint32variety; uint32internal; charshort_info[64]; charlong_info[256]; }
The field names (and types) provide suggestions for the type of info they want to store.
There are two kinds of version info, as specified by the kind argument:
B_APP_VERSION_KINDProvides information about this specific app.
B_SYSTEM_VERSION_KINDProvides information about the "suite," or other grouping of apps, that this app belongs to.
Again, the uses of the two kinds is up to the app developer—currently, nothing in the BeOS depends on any information being stored in either version_info structure.
RETURN CODES
B_OK.The version_info was found or set.
B_ENTRY_NOT_FOUND.
(Get…())
the app doesn't have the requested version info.
status_t InitCheck() const;Returns the status of the most recent initialization.
RETURN CODES
B_OK.The object was successfully initialized.
B_BAD_VALUE.The object is uninitialized.
bool IsSupportedType(const char* type) const;bool Supports(BMimeType* type) const;
Returns true if the app supports the given MIME type and false if it
doesn't. IsSupportedType() always returns true if the application
supports "application/octet-stream", while Supports() returns true only
if type is explicitly supported.
See Also:
GetSupportedTypes(),
SetSupportedTypes()
void SetInfoLocation(info_location loc);bool IsUsingAttributes() const;bool IsUsingResources() const;
SetInfoLocation() sets the location where
the BAppFileInfo object stores
its information. It can store them as either attributes, resources, or
both. loc takes the following values:
B_USE_ATTRIBUTES
B_USE_RESOURCES
B_USE_BOTH
IsUsingAttributes() and IsUsingResources()
return true if the
BAppFileInfo object is storing information in the designated location and
false otherwise.
status_t SetTo(BFile* file);
Initializes the BAppFileInfo object by pointing it
to file, which must be a valid (initialized)
BFile object, and
must not be locked. The BFile is
not copied, or re-opened by BAppFileInfo. In particular, the BAppFileInfo
uses file's file descriptor, and doesn't destroy the BFile object when it
(the BAppFileInfo) is destroyed or reinitialized.
The BAppFileInfo object doesn't check to make sure that the file that
you pass in really is an executable. Passing in a non-executable (a plain
file, a directory, etc.) could corrupt the file.
RETURN CODES
B_OK.The object was successfully initialized.
B_BAD_VALUE.
file is invalid (uninitialized).