Example #1
0
EntryListBase*
OpenWithPoseView::InitDirentIterator(const entry_ref*)
{
	OpenWithContainerWindow* window = ContainerWindow();

	const BMessage* entryList = window->EntryList();

	fIterator = new SearchForSignatureEntryList(true);

	// push all the supporting apps from all the entries into the
	// search for signature iterator
	EachEntryRef(entryList, AddOneRefSignatures, fIterator, 100);

	// push superhandlers
	AddSupportingAppForTypeToQuery(fIterator, B_FILE_MIMETYPE);
	fHaveCommonPreferredApp = fIterator->GetPreferredApp(&fPreferredRef);

	if (fIterator->Rewind() != B_OK) {
		delete fIterator;
		fIterator = NULL;
		HideBarberPole();
		return NULL;
	}
	SetRefFilter(new OpenWithRefFilter(fIterator, entryList,
		(fHaveCommonPreferredApp ? &fPreferredRef : 0)));

	return fIterator;
}
static const entry_ref *
AddOneRefSignatures(const entry_ref *ref, void *castToIterator)
{
	// ToDo:
	// resolve cases where each entry has a different type and
	// their supporting apps are disjoint sets

	SearchForSignatureEntryList *queryIterator =
		(SearchForSignatureEntryList *)castToIterator;

	Model model(ref, true, true);
	if (model.InitCheck() != B_OK)
		return NULL;

	BString mimeType(model.MimeType());

	if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0) 
		// if model is of unknown type, try mimeseting it first
		model.Mimeset(true);

	bool preferredAppFromNode = false;
	entry_ref preferredRef;

	// add preferred app for file, if any
	if (model.PreferredAppSignature()[0]) {
		queryIterator->PushUniqueSignature(model.PreferredAppSignature());

		// got one, mark it as preferred for this node
		if (be_roster->FindApp(model.PreferredAppSignature(), &preferredRef) == B_OK) {
			preferredAppFromNode = true;
			queryIterator->TrySettingPreferredAppForFile(&preferredRef);
		}
	}

	mimeType = model.MimeType();
	mimeType.ToLower();

	if (mimeType.Length() && !mimeType.ICompare(B_FILE_MIMETYPE) == 0)
		queryIterator->NonGenericFileFound();

	// get supporting apps for type
	AddSupportingAppForTypeToQuery(queryIterator, mimeType.String());

	// find the preferred app for this type
	if (be_roster->FindApp(mimeType.String(), &preferredRef) == B_OK)
		queryIterator->TrySettingPreferredApp(&preferredRef);

	return NULL;
}
Example #3
0
bool
OpenWithMenu::StartBuildingItemList()
{
	fIterator = new SearchForSignatureEntryList(false);
	// push all the supporting apps from all the entries into the
	// search for signature iterator
	EachEntryRef(&fEntriesToOpen, AddOneRefSignatures, fIterator, 100);
	// add superhandlers
	AddSupportingAppForTypeToQuery(fIterator, B_FILE_MIMETYPE);

	fHaveCommonPreferredApp = fIterator->GetPreferredApp(&fPreferredRef);
	status_t error = fIterator->Rewind();
	if (error != B_OK) {
		PRINT(("failed to initialize iterator %s\n", strerror(error)));
		return false;
	}

	fSupportingAppList = new BObjectList<RelationCachingModelProxy>(20, true);

	//queryRetrieval = new BStopWatch("get next entry on BQuery");
	return true;
}