Exemplo n.º 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;
}
Exemplo n.º 2
0
int32
OpenWithPoseView::OpenWithRelation(const Model* model) const
{
	OpenWithContainerWindow* window = ContainerWindow();

	return SearchForSignatureEntryList::Relation(window->EntryList(),
		model, fHaveCommonPreferredApp ? &fPreferredRef : 0, 0);
}
Exemplo n.º 3
0
void
OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
{
	OpenWithContainerWindow *window = ContainerWindow();

	int32 count = fSelectionList->CountItems();
	if (!count)
		return;

	if (!pose)
		pose = fSelectionList->FirstItem();

	ASSERT(pose);

	BEntry entry(pose->TargetModel()->EntryRef());
	if (entry.InitCheck() != B_OK) {
		BString errorString;
		errorString << "Could not find application \""
			<< pose->TargetModel()->Name() << "\"";

		(new BAlert("", errorString.String(), "OK", 0, 0, B_WIDTH_AS_USUAL,
			B_WARNING_ALERT))->Go();
		return;
	}

	if (OpenWithRelation(pose->TargetModel()) == kNoRelation) {
		if (!fIterator->GenericFilesOnly()) {
			BString warning;
			warning << "The application \"" << pose->TargetModel()->Name()
				<< "\" does not support the type of document you are "
				"about to open. Are you sure you want to proceed? If you know that "
				"the application supports the document type, you should contact the "
				"publisher of the application and ask them to update their application "
				"to list the type of your document as supported.";

			if ((new BAlert("", warning.String(), "Cancel", "Open", 0,
				B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 0)
				return;
		}
		// else - once we have an extensible sniffer, tell users to ask
		// publishers to fix up sniffers
	}
		
		
	BMessage message(*window->EntryList());
		// make a clone to send
	message.RemoveName("launchUsingSelector");
		// make sure the old selector is not in the message
	message.AddRef("handler", pose->TargetModel()->EntryRef());
		// add ref of the selected handler

	ASSERT(fSelectionHandler);

	if (fSelectionHandler)
		fSelectionHandler->PostMessage(&message);
		
	window->PostMessage(B_QUIT_REQUESTED);
}
Exemplo n.º 4
0
void
OpenWithPoseView::OpenWithRelationDescription(const Model* model,
	BString* description) const
{
	OpenWithContainerWindow* window = ContainerWindow();

	SearchForSignatureEntryList::RelationDescription(window->EntryList(),
		model, description, fHaveCommonPreferredApp ? &fPreferredRef : 0, 0);
}
Exemplo n.º 5
0
bool
OpenWithPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo)
{
	OpenWithContainerWindow *window = ContainerWindow();
	// filter for add_poses
	if (!fIterator->CanOpenWithFilter(model, window->EntryList(),
		fHaveCommonPreferredApp ? &fPreferredRef : 0))
		return false;

	return _inherited::ShouldShowPose(model, poseInfo);
}
Exemplo n.º 6
0
void
OpenWithPoseView::OpenSelection(BPose* pose, int32*)
{
	OpenWithContainerWindow* window = ContainerWindow();

	int32 count = fSelectionList->CountItems();
	if (count == 0)
		return;

	if (pose == NULL)
		pose = fSelectionList->FirstItem();

	ASSERT(pose != NULL);

	BEntry entry(pose->TargetModel()->EntryRef());
	if (entry.InitCheck() != B_OK) {
		BString errorString(
			B_TRANSLATE("Could not find application \"%appname\""));
		errorString.ReplaceFirst("%appname", pose->TargetModel()->Name());

		BAlert* alert = new BAlert("", errorString.String(), B_TRANSLATE("OK"),
			0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
		return;
	}

	if (OpenWithRelation(pose->TargetModel()) == kNoRelation) {
		if (!fIterator->GenericFilesOnly()) {
			BString warning(B_TRANSLATE(
				"The application \"%appname\" does not support the type of "
				"document you are about to open.\nAre you sure you want to "
				"proceed?\n\nIf you know that the application supports the "
				"document type, you should contact the publisher of the "
				"application and ask them to update their application to list "
				"the type of your document as supported."));
			warning.ReplaceFirst("%appname", pose->TargetModel()->Name());

			BAlert* alert = new BAlert("", warning.String(),
				B_TRANSLATE("Cancel"), B_TRANSLATE("Open"),	0, B_WIDTH_AS_USUAL,
				B_WARNING_ALERT);
			alert->SetShortcut(0, B_ESCAPE);
			if (alert->Go() == 0)
				return;
		}
		// else - once we have an extensible sniffer, tell users to ask
		// publishers to fix up sniffers
	}

	BMessage message(*window->EntryList());
		// make a clone to send
	message.RemoveName("launchUsingSelector");
		// make sure the old selector is not in the message
	message.AddRef("handler", pose->TargetModel()->EntryRef());
		// add ref of the selected handler

	ASSERT(fSelectionHandler != NULL);
	if (fSelectionHandler != NULL)
		fSelectionHandler->PostMessage(&message);

	window->PostMessage(B_QUIT_REQUESTED);
}