예제 #1
0
파일: NavMenu.cpp 프로젝트: RAZVOR/haiku
void
SpringLoadedFolderAddUniqueTypeToList(entry_ref* ref,
	BObjectList<BString>* typeslist)
{
	if (!ref || !typeslist)
		return;

	//	get the mime type for the current ref
	BNodeInfo nodeinfo;
	BNode node(ref);
	if (node.InitCheck() != B_OK)
		return;

	nodeinfo.SetTo(&node);

	char mimestr[B_MIME_TYPE_LENGTH];
	//	add it to the list
	if (nodeinfo.GetType(mimestr) == B_OK && strlen(mimestr) > 0) {
		//	if this is a symlink, add symlink to the list (below)
		//	resolve the symlink, add the resolved type
		//	to the list
		if (strcmp(B_LINK_MIMETYPE, mimestr) == 0) {
			BEntry entry(ref, true);
			if (entry.InitCheck() == B_OK) {
				entry_ref resolvedRef;
				if (entry.GetRef(&resolvedRef) == B_OK)
					SpringLoadedFolderAddUniqueTypeToList(&resolvedRef, typeslist);
			}
		}
		//	scan the current list, don't add dups
		bool unique = true;
		int32 count = typeslist->CountItems();
		for (int32 index = 0 ; index < count ; index++) {
			if (typeslist->ItemAt(index)->Compare(mimestr) == 0) {
				unique = false;
				break;
			}
		}

		if (unique)
			typeslist->AddItem(new BString(mimestr));
	}
}
예제 #2
0
파일: NavMenu.cpp 프로젝트: Ithamar/cosmoe
void
SpringLoadedFolderCacheDragData(const BMessage *incoming, BMessage **message, BObjectList<BString> **typeslist)
{
	if (!incoming)
		return;
		
	delete *message;
	delete *typeslist;
	
	BMessage *localMessage = new BMessage(*incoming);
	BObjectList<BString> *localTypesList = new BObjectList<BString>(10, true);

	for (int32 index=0; incoming->HasRef("refs", index); index++) {
		entry_ref ref;
		if (incoming->FindRef("refs", index, &ref) != B_OK)
			continue;

		SpringLoadedFolderAddUniqueTypeToList(&ref, localTypesList);
	}
	
	*message = localMessage;
	*typeslist = localTypesList;
}