当前位置: 首页>>代码示例>>C++>>正文


C++ BMimeType类代码示例

本文整理汇总了C++中BMimeType的典型用法代码示例。如果您正苦于以下问题:C++ BMimeType类的具体用法?C++ BMimeType怎么用?C++ BMimeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BMimeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LOG

nsresult nsOSHelperAppService::LoadUriInternal(nsIURI * aURL)
{
	LOG(("-- nsOSHelperAppService::LoadUrl\n"));
	nsresult rv = NS_OK;

	if (aURL) {
		// Get the Protocol
		nsCAutoString scheme;
		aURL->GetScheme(scheme);
		BString protoStr(scheme.get());
		protoStr.Prepend("application/x-vnd.Be.URL.");
		// Get the Spec
		nsCAutoString spec;
		aURL->GetSpec(spec);
		const char* args[] = { spec.get() };
		
		//Launch the app		
		BMimeType protocol;
		bool isInstalled = false;
		if (protocol.SetTo(protoStr.String()) == B_OK)
		{
			if(protocol.IsInstalled())
			{
				isInstalled = true;	
				be_roster->Launch(protoStr.String(), NS_ARRAY_LENGTH(args), (char **)args);
			}
		}
		if ((!isInstalled) && (!strcmp("mailto", scheme.get())))
			be_roster->Launch("text/x-email", NS_ARRAY_LENGTH(args), (char **)args);
	}
	return rv;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:32,代码来源:nsOSHelperAppService.cpp

示例2:

void
DockItem::GetGenericIcon( void )
{
	if ( IsFolder() ) {
		BMimeType type;
		type.SetType( "application/x-vnd.Be-directory" );
		type.GetIcon( mLargeIcon, B_LARGE_ICON );
		type.GetIcon( mSmallIcon, B_MINI_ICON );
	} else {
		app_info appInfo;
		BFile appFile;
		BAppFileInfo appFileInfo;
		be_app->GetAppInfo( &appInfo );
		appFile.SetTo( &appInfo.ref, B_READ_WRITE );
		appFileInfo.SetTo( &appFile );
		appFileInfo.GetIconForType( "application/x-be-executable", mLargeIcon, B_LARGE_ICON );
		appFileInfo.GetIconForType( "application/x-be-executable", mSmallIcon, B_MINI_ICON );
		/*
		BMimeType appType;
		appType.SetType( "application/x-vnd.HK-LaunchPad" );
		appType.GetIcon( mLargeIcon, B_LARGE_ICON );
		appType.GetIcon( mSmallIcon, B_MINI_ICON );
		*/
	}
}
开发者ID:HaikuArchives,项目名称:LaunchPad,代码行数:25,代码来源:DockItem.cpp

示例3: read

/*!
	Determines if the data in \a inSource is of the UTF8 plain

	\param data buffer containing data already read (must be at
		least DATA_BUFFER_SIZE bytes large)
	\param nread number of bytes that have already been read from the stream
	\param header the STXT stream header read in by Identify() or Translate()
	\param inSource the stream with the STXT data
	\param outInfo information about the type of data from inSource is stored here
	\param outType the desired output type for the data in inSource
*/
status_t
identify_text(uint8* data, int32 bytesRead, BPositionIO* source,
              translator_info* outInfo, uint32 outType, const char*& encoding)
{
    ssize_t readLater = source->Read(data + bytesRead, DATA_BUFFER_SIZE - bytesRead);
    if (readLater < B_OK)
        return B_NO_TRANSLATOR;

    bytesRead += readLater;

    // TODO: identify encoding as possible!
    BMimeType type;
    if (!file_ascmagic((const unsigned char*)data, bytesRead, &type, encoding))
        return B_NO_TRANSLATOR;

    float capability = TEXT_IN_CAPABILITY;
    if (bytesRead < 20)
        capability = .1f;

    // return information about the data in the stream
    outInfo->type = B_TRANSLATOR_TEXT;
    outInfo->group = B_TRANSLATOR_TEXT;
    outInfo->quality = TEXT_IN_QUALITY;
    outInfo->capability = capability;

    char description[B_MIME_TYPE_LENGTH];
    if (type.GetLongDescription(description) == B_OK)
        strlcpy(outInfo->name, description, sizeof(outInfo->name));
    else
        strlcpy(outInfo->name, "Plain text file", sizeof(outInfo->name));

    //strlcpy(outInfo->MIME, type.Type(), sizeof(outInfo->MIME));
    strcpy(outInfo->MIME, "text/plain");
    return B_OK;
}
开发者ID:mmanley,项目名称:Antares,代码行数:46,代码来源:STXTTranslator.cpp

示例4:

/*! \brief Returns a list of all currently installed types of the given
	supertype in the pre-allocated \c BMessage pointed to by \c types.

	See \c BMimeType::GetInstalledTypes(const char*, BMessage*) for more
	information.
*/
status_t
InstalledTypes::GetInstalledTypes(const char *supertype, BMessage *types)
{
	if (supertype == NULL || types == NULL)
		return B_BAD_VALUE;

	// Verify the supertype is valid *and* is a supertype

	BMimeType mime;
	BMimeType super;
	// Make sure the supertype is valid
	status_t err = mime.SetTo(supertype);
	// Make sure it's really a supertype
	if (!err && !mime.IsSupertypeOnly())
		err = B_BAD_VALUE;
	// See if we need to do our initial build still
	if (!err && !fHaveDoneFullBuild)
		err = _BuildInstalledTypesList();

	// Ask the appropriate supertype for its list
	if (!err) {
		std::map<std::string, Supertype>::iterator i = fSupertypes.find(supertype);
		if (i != fSupertypes.end())
			err = i->second.GetInstalledSubtypes(types);
		else
			err = B_NAME_NOT_FOUND;
	}
	return err;
}
开发者ID:mariuz,项目名称:haiku,代码行数:35,代码来源:InstalledTypes.cpp

示例5: GetSupportedTypes

/*!	\brief Returns whether the application supports the supplied MIME type.

	If the application supports the wildcard type "application/octet-stream"
	any this method returns \c true for any MIME type.

	\param type The MIME type in question.
	\return \c true, if \a type is a valid MIME type and it is supported by
			the application, \c false otherwise.
*/
bool
BAppFileInfo::IsSupportedType(const char *type) const
{
	status_t error = (type ? B_OK : B_BAD_VALUE);
	// get the supported types
	BMessage types;
	if (error == B_OK)
		error = GetSupportedTypes(&types);
	// turn type into a BMimeType
	BMimeType mimeType;
	if (error == B_OK)
		error = mimeType.SetTo(type);
	// iterate through the supported types
	bool found = false;
	if (error == B_OK) {
		const char *supportedType;
		for (int32 i = 0;
			 !found && types.FindString("types", i, &supportedType) == B_OK;
			 i++) {
			found = !strcmp(supportedType, "application/octet-stream")
					|| BMimeType(supportedType).Contains(&mimeType);
		}
	}
	return found;
}
开发者ID:mmanley,项目名称:Antares,代码行数:34,代码来源:AppFileInfo.cpp

示例6:

void
ExtensionListView::SetType(BMimeType* type)
{
	if (type != NULL)
		fType.SetTo(type->Type());
	else
		fType.Unset();
}
开发者ID:mmanley,项目名称:Antares,代码行数:8,代码来源:FileTypesWindow.cpp

示例7:

// Returns whether this and the supplied MIME type are equal
bool
BMimeType::operator==(const char* type) const
{
	BMimeType mime;
	if (type)
		mime.SetTo(type);

	return (*this) == mime;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:10,代码来源:MimeType.cpp

示例8: IconSize

void
TBarApp::FetchAppIcon(BarTeamInfo* barInfo)
{
	int32 width = IconSize();
	int32 index = (width - kMinimumIconSize) / kIconSizeInterval;

	// first look in the icon cache
	barInfo->icon = barInfo->iconCache[index];
	if (barInfo->icon != NULL)
		return;

	// icon wasn't in cache, get it from be_roster and cache it
	app_info appInfo;
	icon_size size = width >= 31 ? B_LARGE_ICON : B_MINI_ICON;
	BBitmap* icon = new BBitmap(IconRect(), kIconColorSpace);
	if (be_roster->GetAppInfo(barInfo->sig, &appInfo) == B_OK) {
		// fetch the app icon
		BFile file(&appInfo.ref, B_READ_ONLY);
		BAppFileInfo appMime(&file);
		if (appMime.GetIcon(icon, size) == B_OK) {
			delete barInfo->iconCache[index];
			barInfo->iconCache[index] = barInfo->icon = icon;
			return;
		}
	}

	// couldn't find the app icon
	// fetch the generic 3 boxes icon and cache it
	BMimeType defaultAppMime;
	defaultAppMime.SetTo(B_APP_MIME_TYPE);
	if (defaultAppMime.GetIcon(icon, size) == B_OK) {
		delete barInfo->iconCache[index];
		barInfo->iconCache[index] = barInfo->icon = icon;
		return;
	}

	// couldn't find generic 3 boxes icon
	// fill with transparent
	uint8* iconBits = (uint8*)icon->Bits();
	if (icon->ColorSpace() == B_RGBA32) {
		int32 i = 0;
		while (i < icon->BitsLength()) {
			iconBits[i++] = B_TRANSPARENT_32_BIT.red;
			iconBits[i++] = B_TRANSPARENT_32_BIT.green;
			iconBits[i++] = B_TRANSPARENT_32_BIT.blue;
			iconBits[i++] = B_TRANSPARENT_32_BIT.alpha;
		}
	} else {
		// Assume B_CMAP8
		for (int32 i = 0; i < icon->BitsLength(); i++)
			iconBits[i] = B_TRANSPARENT_MAGIC_CMAP8;
	}

	delete barInfo->iconCache[index];
	barInfo->iconCache[index] = barInfo->icon = icon;
}
开发者ID:kbjava,项目名称:haiku,代码行数:56,代码来源:BarApp.cpp

示例9: if

// Returns whether this and the supplied MIME type are equal
bool
BMimeType::operator==(const BMimeType &type) const
{
	if (InitCheck() == B_NO_INIT && type.InitCheck() == B_NO_INIT)
		return true;
	else if (InitCheck() == B_OK && type.InitCheck() == B_OK)
		return strcasecmp(Type(), type.Type()) == 0;

	return false;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:11,代码来源:MimeType.cpp

示例10: GetMetaMime

/*!	\brief Sets the MIME types supported by the application.

	If \a types is \c NULL the application's supported types are unset.

	The supported MIME types must be stored in a field "types" of type
	\c B_STRING_TYPE in \a 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.

	\a syncAll specifies whether the not longer supported types shall be
	updated as well, i.e. whether this application shall be remove from the
	lists of supporting applications.

	\param types The supported types to be assigned to the file.
		   May be \c NULL.
	\param syncAll \c true to also synchronize the not longer supported
		   types, \c false otherwise.
	\return
	- \c B_OK: Everything went fine.
	- \c B_NO_INIT: The object is not properly initialized.
	- other error codes
*/
status_t
BAppFileInfo::SetSupportedTypes(const BMessage *types, bool syncAll)
{
	// check initialization
	status_t error = B_OK;
	if (error == B_OK && InitCheck() != B_OK)
		error = B_NO_INIT;
	BMimeType mimeType;
	if (error == B_OK)
		error = GetMetaMime(&mimeType);
	if (error == B_OK || error == B_ENTRY_NOT_FOUND) {
		error = B_OK;
		if (types) {
			// check param -- supported types must be valid
			const char *type;
			for (int32 i = 0;
				 error == B_OK && types->FindString("types", i, &type) == B_OK;
				 i++) {
				if (!BMimeType::IsValid(type))
					error = B_BAD_VALUE;
			}
			// get flattened size
			ssize_t size = 0;
			if (error == B_OK) {
				size = types->FlattenedSize();
				if (size < 0)
					error = size;
			}
			// allocate a buffer for the flattened data
			char *buffer = NULL;
			if (error == B_OK) {
				buffer = new(nothrow) char[size];
				if (!buffer)
					error = B_NO_MEMORY;
			}
			// flatten the message
			if (error == B_OK)
				error = types->Flatten(buffer, size);
			// write the data
			if (error == B_OK) {
				error = _WriteData(kSupportedTypesAttribute,
								   kSupportedTypesResourceID, B_MESSAGE_TYPE,
								   buffer, size);
			}
			// clean up
			delete[] buffer;
		} else
			error = _RemoveData(kSupportedTypesAttribute, B_MESSAGE_TYPE);
		// update the MIME database, if the app signature is installed
		if (error == B_OK && mimeType.IsInstalled())
			error = mimeType.SetSupportedTypes(types, syncAll);
	}
	return error;
}
开发者ID:mariuz,项目名称:haiku,代码行数:79,代码来源:AppFileInfo.cpp

示例11:

status_t
Icon::CopyTo(BMimeType& type, bool force) const
{
	status_t status = B_OK;

	if (fLarge != NULL || force)
		status = type.SetIcon(fLarge, B_LARGE_ICON);
	if (fMini != NULL || force)
		status = type.SetIcon(fMini, B_MINI_ICON);
	if (fData != NULL || force)
		status = type.SetIcon(fData, fSize);
	return status;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:13,代码来源:IconView.cpp

示例12: MimeType

void TorrentObject::MimeType(BMimeType& mime)
{
	mime.SetTo(B_DIRECTORY_MIME_TYPE);
	
	if( !IsFolder() && !IsMagnet() )
		BMimeType::GuessMimeType(Info()->files[0].name, &mime);
}
开发者ID:bsdn321321,项目名称:Torrentor,代码行数:7,代码来源:TorrentObject.cpp

示例13: msg

void
PieView::_Launch(FileInfo* info, const entry_ref* appRef)
{
	BMessage msg(B_REFS_RECEIVED);
	msg.AddRef("refs", &info->ref);

	if (appRef == NULL) {
		// Let the registrar pick an app based on the file's MIME type.
		BMimeType* type = info->Type();
		be_roster->Launch(type->Type(), &msg);
		delete type;
	} else {
		// Launch a designated app to handle this file.
		be_roster->Launch(appRef, &msg);
	}
}
开发者ID:ysei,项目名称:haiku,代码行数:16,代码来源:PieView.cpp

示例14: file

/*static*/ BString
Playlist::_MIMEString(const entry_ref* ref)
{
	BFile file(ref, B_READ_ONLY);
	BNodeInfo nodeInfo(&file);
	char mimeString[B_MIME_TYPE_LENGTH];
	if (nodeInfo.GetType(mimeString) != B_OK) {
		BMimeType type;
		if (BMimeType::GuessMimeType(ref, &type) != B_OK)
			return BString();

		strlcpy(mimeString, type.Type(), B_MIME_TYPE_LENGTH);
		nodeInfo.SetType(type.Type());
	}
	return BString(mimeString);
}
开发者ID:michael-manley,项目名称:haiku,代码行数:16,代码来源:Playlist.cpp

示例15: if

void
KindAttributeText::ReadValue(BString *result)
{
	BMimeType mime;
	char desc[B_MIME_TYPE_LENGTH];

	// get the mime type
	if (mime.SetType(fModel->MimeType()) != B_OK)
		*result = "Unknown";
	// get the short mime type description
	else if (mime.GetShortDescription(desc) == B_OK)
		*result = desc;
	else
		*result = fModel->MimeType();
	fValueDirty = false;
}
开发者ID:mmanley,项目名称:Antares,代码行数:16,代码来源:WidgetAttributeText.cpp


注:本文中的BMimeType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。