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


C++ BMimeType::GetSupertype方法代码示例

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


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

示例1: preferredApp

status_t
icon_for_type(const BMimeType& type, uint8** _data, size_t* _size,
	icon_source* _source)
{
	if (_data == NULL || _size == NULL)
		return B_BAD_VALUE;

	icon_source source = kNoIcon;
	uint8* data;
	size_t size;

	if (type.GetIcon(&data, &size) == B_OK)
		source = kOwnIcon;

	if (source == kNoIcon) {
		// check for icon from preferred app

		char preferred[B_MIME_TYPE_LENGTH];
		if (type.GetPreferredApp(preferred) == B_OK) {
			BMimeType preferredApp(preferred);

			if (preferredApp.GetIconForType(type.Type(), &data, &size) == B_OK)
				source = kApplicationIcon;
		}
	}

	if (source == kNoIcon) {
		// check super type for an icon

		BMimeType superType;
		if (type.GetSupertype(&superType) == B_OK) {
			if (superType.GetIcon(&data, &size) == B_OK)
				source = kSupertypeIcon;
			else {
				// check the super type's preferred app
				char preferred[B_MIME_TYPE_LENGTH];
				if (superType.GetPreferredApp(preferred) == B_OK) {
					BMimeType preferredApp(preferred);

					if (preferredApp.GetIconForType(superType.Type(),
							&data, &size) == B_OK)
						source = kSupertypeIcon;
				}
			}
		}
	}

	if (source != kNoIcon) {
		*_data = data;
		*_size = size;
	} // NOTE: else there is no data, so nothing is leaked.
	if (_source)
		*_source = source;

	return source != kNoIcon ? B_OK : B_ERROR;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:56,代码来源:IconView.cpp

示例2: type

static status_t 
GetTrackerIcon(BMimeType &type, BBitmap *icon, icon_size iconSize)
{
	// set some icon size related variables
	status_t error = B_OK;
	BRect bounds;
	switch (iconSize) {
		case B_MINI_ICON:
			bounds.Set(0, 0, 15, 15);
			break;
		case B_LARGE_ICON:
			bounds.Set(0, 0, 31, 31);
			break;
		default:
			error = B_BAD_VALUE;
			break;
	}
	// check parameters and initialization
	if (error == B_OK
		&& (!icon || icon->InitCheck() != B_OK || icon->Bounds() != bounds))
		return B_BAD_VALUE;

	bool success = false;

	// Ask the MIME database for the preferred application for the file type
	// and whether this application has a special icon for the type.
	char signature[B_MIME_TYPE_LENGTH];
	if (type.GetPreferredApp(signature) == B_OK) {
		BMimeType type(signature);
		success = (type.GetIconForType(type.Type(), icon, iconSize) == B_OK);
	}

	// Ask the MIME database whether there is an icon for the node's file type.
	if (error == B_OK && !success)
		success = (type.GetIcon(icon, iconSize) == B_OK);

	// Ask the MIME database for the super type and start all over
	if (error == B_OK && !success) {
		BMimeType super;
		if (type.GetSupertype(&super) == B_OK)
			return GetTrackerIcon(super, icon, iconSize);
	}

	// Return the icon for "application/octet-stream" from the MIME database.
	if (error == B_OK && !success) {
		// get the "application/octet-stream" icon
		BMimeType type("application/octet-stream");
		error = type.GetIcon(icon, iconSize);
	}

	return error;
}
开发者ID:mmanley,项目名称:Antares,代码行数:52,代码来源:Enclosures.cpp

示例3: node

bool
FileIterator::_ExamineFile(BEntry& entry, char* buffer, bool textFilesOnly)
{
	BPath path;
	if (entry.GetPath(&path) != B_OK)
		return false;

	strcpy(buffer, path.Path());

	if (!textFilesOnly)
		return true;

	BMimeType mimeType;
	BNode node(&entry);
	BNodeInfo nodeInfo(&node);
	char mimeTypeString[B_MIME_TYPE_LENGTH];

	if (nodeInfo.GetType(mimeTypeString) != B_OK) {
		// try to get a MIME type before failing
		if (BMimeType::GuessMimeType(path.Path(), &mimeType) != B_OK)
			return false;

		nodeInfo.SetType(mimeType.Type());
	} else
		mimeType.SetTo(mimeTypeString);

	BMimeType superType;
	if (mimeType.GetSupertype(&superType) == B_OK) {
		if (strcmp("text", superType.Type()) == 0
			|| strcmp("message", superType.Type()) == 0) {
			return true;
		}
	}

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


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