* Added "sortInodes" parameter to CachedEntryIteratorList constructor.
* Moved static CompareInode() to CachedEntryIterator::_CompareInodes(). * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27869 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -43,23 +43,28 @@ All rights reserved.
|
||||
#include "NodeWalker.h"
|
||||
#include "ObjectList.h"
|
||||
|
||||
|
||||
TWalkerWrapper::TWalkerWrapper(WALKER_NS::TWalker *walker)
|
||||
: fWalker(walker),
|
||||
fStatus(B_OK)
|
||||
:
|
||||
fWalker(walker),
|
||||
fStatus(B_OK)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TWalkerWrapper::~TWalkerWrapper()
|
||||
{
|
||||
delete fWalker;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TWalkerWrapper::InitCheck() const
|
||||
{
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TWalkerWrapper::GetNextEntry(BEntry *entry, bool traverse)
|
||||
{
|
||||
@@ -67,6 +72,7 @@ TWalkerWrapper::GetNextEntry(BEntry *entry, bool traverse)
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TWalkerWrapper::GetNextRef(entry_ref *ref)
|
||||
{
|
||||
@@ -74,55 +80,70 @@ TWalkerWrapper::GetNextRef(entry_ref *ref)
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TWalkerWrapper::GetNextDirents(struct dirent *buffer, size_t length, int32 count)
|
||||
TWalkerWrapper::GetNextDirents(struct dirent *buffer, size_t length,
|
||||
int32 count)
|
||||
{
|
||||
int32 result = fWalker->GetNextDirents(buffer, length, count);
|
||||
fStatus = result < 0 ? result : (result ? B_OK : B_ENTRY_NOT_FOUND);
|
||||
fStatus = result < B_OK ? result : (result ? B_OK : B_ENTRY_NOT_FOUND);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TWalkerWrapper::Rewind()
|
||||
{
|
||||
return fWalker->Rewind();
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TWalkerWrapper::CountEntries()
|
||||
{
|
||||
return fWalker->CountEntries();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
EntryListBase::EntryListBase()
|
||||
: fStatus(B_OK)
|
||||
{
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
EntryListBase::InitCheck() const
|
||||
{
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
dirent *
|
||||
EntryListBase::Next(dirent *ent)
|
||||
{
|
||||
return (dirent *)((char *)ent + ent->d_reclen + sizeof(dirent));
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
CachedEntryIterator::CachedEntryIterator(BEntryList *iterator, int32 numEntries,
|
||||
bool sortInodes)
|
||||
: fIterator(iterator),
|
||||
fEntryRefBuffer(NULL),
|
||||
fCacheSize(numEntries),
|
||||
fNumEntries(0),
|
||||
fIndex(0),
|
||||
fDirentBuffer(NULL),
|
||||
fCurrentDirent(NULL),
|
||||
fSortInodes(sortInodes),
|
||||
fSortedList(NULL),
|
||||
fEntryBuffer(NULL)
|
||||
bool sortInodes)
|
||||
:
|
||||
fIterator(iterator),
|
||||
fEntryRefBuffer(NULL),
|
||||
fCacheSize(numEntries),
|
||||
fNumEntries(0),
|
||||
fIndex(0),
|
||||
fDirentBuffer(NULL),
|
||||
fCurrentDirent(NULL),
|
||||
fSortInodes(sortInodes),
|
||||
fSortedList(NULL),
|
||||
fEntryBuffer(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -135,7 +156,8 @@ CachedEntryIterator::~CachedEntryIterator()
|
||||
delete [] fEntryBuffer;
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
CachedEntryIterator::GetNextEntry(BEntry *result, bool traverse)
|
||||
{
|
||||
ASSERT(!fDirentBuffer);
|
||||
@@ -158,15 +180,17 @@ CachedEntryIterator::GetNextEntry(BEntry *result, bool traverse)
|
||||
fIndex = 0;
|
||||
}
|
||||
*result = fEntryBuffer[fIndex++];
|
||||
if (fIndex > fNumEntries)
|
||||
if (fIndex > fNumEntries) {
|
||||
// we are at the end of the cache we loaded up, time to return
|
||||
// an error, if we had one
|
||||
return fStatus;
|
||||
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
CachedEntryIterator::GetNextRef(entry_ref *ref)
|
||||
{
|
||||
ASSERT(!fDirentBuffer);
|
||||
@@ -193,23 +217,24 @@ CachedEntryIterator::GetNextRef(entry_ref *ref)
|
||||
// we are at the end of the cache we loaded up, time to return
|
||||
// an error, if we had one
|
||||
return fStatus;
|
||||
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
CompareInode(const dirent *ent1, const dirent *ent2)
|
||||
/*static*/ int
|
||||
CachedEntryIterator::_CompareInodes(const dirent *ent1, const dirent *ent2)
|
||||
{
|
||||
if (ent1->d_ino < ent2->d_ino)
|
||||
return -1;
|
||||
else if (ent1->d_ino == ent2->d_ino)
|
||||
if (ent1->d_ino == ent2->d_ino)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32
|
||||
|
||||
int32
|
||||
CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size,
|
||||
int32 count)
|
||||
{
|
||||
@@ -219,7 +244,7 @@ CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size,
|
||||
ASSERT(fIndex == 0 && fNumEntries == 0);
|
||||
ASSERT(size > sizeof(dirent) + B_FILE_NAME_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
|
||||
@@ -236,14 +261,17 @@ CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size,
|
||||
|
||||
fNumEntries += count;
|
||||
|
||||
int32 currentDirentSize = fCurrentDirent->d_reclen + (ssize_t)sizeof(dirent);
|
||||
int32 currentDirentSize = fCurrentDirent->d_reclen
|
||||
+ (ssize_t)sizeof(dirent);
|
||||
bufferRemain -= currentDirentSize;
|
||||
if (bufferRemain < (sizeof(dirent) + B_FILE_NAME_LENGTH))
|
||||
if (bufferRemain < (sizeof(dirent) + B_FILE_NAME_LENGTH)) {
|
||||
// cant fit a big entryRef in the buffer, just bail
|
||||
// and start from scratch
|
||||
break;
|
||||
|
||||
fCurrentDirent = (dirent *)((char *)fCurrentDirent + currentDirentSize);
|
||||
}
|
||||
|
||||
fCurrentDirent
|
||||
= (dirent *)((char *)fCurrentDirent + currentDirentSize);
|
||||
}
|
||||
fCurrentDirent = fDirentBuffer;
|
||||
if (fSortInodes) {
|
||||
@@ -256,16 +284,17 @@ CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size,
|
||||
fSortedList->AddItem(fCurrentDirent, 0);
|
||||
fCurrentDirent = Next(fCurrentDirent);
|
||||
}
|
||||
fSortedList->SortItems(CompareInode);
|
||||
fSortedList->SortItems(&_CompareInodes);
|
||||
fCurrentDirent = fDirentBuffer;
|
||||
}
|
||||
fIndex = 0;
|
||||
}
|
||||
if (fIndex >= fNumEntries)
|
||||
if (fIndex >= fNumEntries) {
|
||||
// we are done, no more dirents left
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fSortInodes)
|
||||
if (fSortInodes)
|
||||
fCurrentDirent = fSortedList->ItemAt(fIndex);
|
||||
|
||||
fIndex++;
|
||||
@@ -276,13 +305,14 @@ CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size,
|
||||
|
||||
memcpy(ent, fCurrentDirent, currentDirentSize);
|
||||
|
||||
if (!fSortInodes)
|
||||
if (!fSortInodes)
|
||||
fCurrentDirent = (dirent *)((char *)fCurrentDirent + currentDirentSize);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
CachedEntryIterator::Rewind()
|
||||
{
|
||||
fIndex = 0;
|
||||
@@ -296,12 +326,14 @@ CachedEntryIterator::Rewind()
|
||||
return fIterator->Rewind();
|
||||
}
|
||||
|
||||
int32
|
||||
|
||||
int32
|
||||
CachedEntryIterator::CountEntries()
|
||||
{
|
||||
return fIterator->CountEntries();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CachedEntryIterator::SetTo(BEntryList *iterator)
|
||||
{
|
||||
@@ -311,40 +343,52 @@ CachedEntryIterator::SetTo(BEntryList *iterator)
|
||||
fIterator = iterator;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
CachedDirectoryEntryList::CachedDirectoryEntryList(const BDirectory &dir)
|
||||
: CachedEntryIterator(0, 40, true),
|
||||
fDir(dir)
|
||||
: CachedEntryIterator(0, 40, true),
|
||||
fDir(dir)
|
||||
{
|
||||
fStatus = fDir.InitCheck();
|
||||
SetTo(&fDir);
|
||||
}
|
||||
|
||||
|
||||
CachedDirectoryEntryList::~CachedDirectoryEntryList()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
DirectoryEntryList::DirectoryEntryList(const BDirectory &dir)
|
||||
: fDir(dir)
|
||||
:
|
||||
fDir(dir)
|
||||
{
|
||||
fStatus = fDir.InitCheck();
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
DirectoryEntryList::GetNextEntry(BEntry *entry, bool traverse)
|
||||
{
|
||||
fStatus = fDir.GetNextEntry(entry, traverse);
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
DirectoryEntryList::GetNextRef(entry_ref *ref)
|
||||
{
|
||||
fStatus = fDir.GetNextRef(ref);
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
int32
|
||||
|
||||
int32
|
||||
DirectoryEntryList::GetNextDirents(struct dirent *buffer, size_t length,
|
||||
int32 count)
|
||||
{
|
||||
@@ -352,26 +396,33 @@ DirectoryEntryList::GetNextDirents(struct dirent *buffer, size_t length,
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
DirectoryEntryList::Rewind()
|
||||
{
|
||||
fStatus = fDir.Rewind();
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
int32
|
||||
|
||||
int32
|
||||
DirectoryEntryList::CountEntries()
|
||||
{
|
||||
return fDir.CountEntries();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
EntryIteratorList::EntryIteratorList()
|
||||
: fList(5, true),
|
||||
fCurrentIndex(0)
|
||||
:
|
||||
fList(5, true),
|
||||
fCurrentIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EntryIteratorList::~EntryIteratorList()
|
||||
{
|
||||
int32 count = fList.CountItems();
|
||||
@@ -388,70 +439,76 @@ EntryIteratorList::~EntryIteratorList()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
EntryIteratorList::AddItem(BEntryList *walker)
|
||||
{
|
||||
fList.AddItem(walker);
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
EntryIteratorList::GetNextEntry(BEntry *entry, bool traverse)
|
||||
{
|
||||
for (;;) {
|
||||
while (true) {
|
||||
if (fCurrentIndex >= fList.CountItems()) {
|
||||
fStatus = B_ENTRY_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
fStatus = fList.ItemAt(fCurrentIndex)->GetNextEntry(entry, traverse);
|
||||
if (fStatus != B_ENTRY_NOT_FOUND)
|
||||
break;
|
||||
|
||||
|
||||
fCurrentIndex++;
|
||||
}
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
EntryIteratorList::GetNextRef(entry_ref *ref)
|
||||
{
|
||||
for (;;) {
|
||||
while (true) {
|
||||
if (fCurrentIndex >= fList.CountItems()) {
|
||||
fStatus = B_ENTRY_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
fStatus = fList.ItemAt(fCurrentIndex)->GetNextRef(ref);
|
||||
if (fStatus != B_ENTRY_NOT_FOUND)
|
||||
break;
|
||||
|
||||
|
||||
fCurrentIndex++;
|
||||
}
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
int32
|
||||
EntryIteratorList::GetNextDirents(struct dirent *buffer, size_t length, int32 count)
|
||||
|
||||
int32
|
||||
EntryIteratorList::GetNextDirents(struct dirent *buffer, size_t length,
|
||||
int32 count)
|
||||
{
|
||||
int32 result = 0;
|
||||
for (;;) {
|
||||
while (true) {
|
||||
if (fCurrentIndex >= fList.CountItems()) {
|
||||
fStatus = B_ENTRY_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
result = fList.ItemAt(fCurrentIndex)->GetNextDirents(buffer, length, count);
|
||||
|
||||
result = fList.ItemAt(fCurrentIndex)->GetNextDirents(buffer, length,
|
||||
count);
|
||||
if (result > 0) {
|
||||
fStatus = B_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
fCurrentIndex++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t
|
||||
|
||||
status_t
|
||||
EntryIteratorList::Rewind()
|
||||
{
|
||||
fCurrentIndex = 0;
|
||||
@@ -462,7 +519,8 @@ EntryIteratorList::Rewind()
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
int32
|
||||
|
||||
int32
|
||||
EntryIteratorList::CountEntries()
|
||||
{
|
||||
int32 result = 0;
|
||||
@@ -475,14 +533,18 @@ EntryIteratorList::CountEntries()
|
||||
}
|
||||
|
||||
|
||||
CachedEntryIteratorList::CachedEntryIteratorList()
|
||||
: CachedEntryIterator(0, 10, true)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
CachedEntryIteratorList::CachedEntryIteratorList(bool sortInodes)
|
||||
: CachedEntryIterator(NULL, 10, sortInodes)
|
||||
{
|
||||
fStatus = B_OK;
|
||||
SetTo(&fIteratorList);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
void
|
||||
CachedEntryIteratorList::AddItem(BEntryList *walker)
|
||||
{
|
||||
fIteratorList.AddItem(walker);
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
// sorted by their i-node number -- this turns out to give quite a bit
|
||||
// better performance over just using the order in which they show up using
|
||||
// the default BEntryList iterator subclass
|
||||
|
||||
|
||||
CachedEntryIterator(BEntryList *iterator, int32 numEntries,
|
||||
bool sortInodes = false);
|
||||
// CachedEntryIterator does not get to own the <iterator>
|
||||
@@ -112,22 +112,24 @@ public:
|
||||
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
|
||||
|
||||
virtual void SetTo(BEntryList *iterator);
|
||||
// CachedEntryIterator does not get to own the <iterator>
|
||||
|
||||
|
||||
private:
|
||||
static int _CompareInodes(const dirent *ent1, const dirent *ent2);
|
||||
|
||||
BEntryList *fIterator;
|
||||
entry_ref *fEntryRefBuffer;
|
||||
int32 fCacheSize;
|
||||
int32 fNumEntries;
|
||||
int32 fIndex;
|
||||
|
||||
|
||||
dirent *fDirentBuffer;
|
||||
dirent *fCurrentDirent;
|
||||
bool fSortInodes;
|
||||
BObjectList<dirent> *fSortedList;
|
||||
|
||||
|
||||
BEntry *fEntryBuffer;
|
||||
};
|
||||
|
||||
@@ -185,8 +187,8 @@ protected:
|
||||
|
||||
class CachedEntryIteratorList : public CachedEntryIterator {
|
||||
public:
|
||||
CachedEntryIteratorList();
|
||||
void AddItem(BEntryList *);
|
||||
CachedEntryIteratorList(bool sortInodes = true);
|
||||
void AddItem(BEntryList *list);
|
||||
|
||||
protected:
|
||||
EntryIteratorList fIteratorList;
|
||||
|
||||
@@ -198,7 +198,7 @@ FindOne(const BString *element, void *castToString)
|
||||
{
|
||||
if (strcasecmp(element->String(), (const char *)castToString) == 0)
|
||||
return element;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -207,10 +207,10 @@ static const entry_ref *
|
||||
AddOneUniqueDocumentType(const entry_ref *ref, void *castToList)
|
||||
{
|
||||
BObjectList<BString> *list = (BObjectList<BString> *)castToList;
|
||||
|
||||
|
||||
BEntry entry(ref, true);
|
||||
// traverse symlinks
|
||||
|
||||
|
||||
// get this documents type
|
||||
char type[B_MIME_TYPE_LENGTH];
|
||||
BFile file(&entry, O_RDONLY);
|
||||
@@ -286,9 +286,9 @@ OpenWithContainerWindow::MakeDefaultAndOpen()
|
||||
if (!selectedAppPose)
|
||||
return;
|
||||
|
||||
// collect all the types of all the opened documents into a list
|
||||
// collect all the types of all the opened documents into a list
|
||||
BObjectList<BString> openedFileTypes(10, true);
|
||||
EachEntryRef(EntryList(), AddOneUniqueDocumentType, &openedFileTypes, 100);
|
||||
EachEntryRef(EntryList(), AddOneUniqueDocumentType, &openedFileTypes, 100);
|
||||
|
||||
// set the default application to be the selected pose for all the
|
||||
// mime types in the list
|
||||
@@ -445,10 +445,10 @@ OpenWithContainerWindow::RestoreWindowState(AttributeStreamNode *node)
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
const char *rectAttributeName = kAttrWindowFrame;
|
||||
const char *rectAttributeName = kAttrWindowFrame;
|
||||
BRect frame(Frame());
|
||||
if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame)
|
||||
== sizeof(BRect)) {
|
||||
== sizeof(BRect)) {
|
||||
MoveTo(frame.LeftTop());
|
||||
ResizeTo(frame.Width(), frame.Height());
|
||||
}
|
||||
@@ -566,8 +566,7 @@ AddSupportingAppForTypeToQuery(SearchForSignatureEntryList *queryIterator,
|
||||
static const entry_ref *
|
||||
AddOneRefSignatures(const entry_ref *ref, void *castToIterator)
|
||||
{
|
||||
// ToDo:
|
||||
// resolve cases where each entry has a different type and
|
||||
// TODO: resolve cases where each entry has a different type and
|
||||
// their supporting apps are disjoint sets
|
||||
|
||||
SearchForSignatureEntryList *queryIterator =
|
||||
@@ -579,7 +578,7 @@ AddOneRefSignatures(const entry_ref *ref, void *castToIterator)
|
||||
|
||||
BString mimeType(model.MimeType());
|
||||
|
||||
if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0)
|
||||
if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0)
|
||||
// if model is of unknown type, try mimeseting it first
|
||||
model.Mimeset(true);
|
||||
|
||||
@@ -683,8 +682,7 @@ OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
|
||||
// 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");
|
||||
@@ -696,7 +694,7 @@ OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
|
||||
|
||||
if (fSelectionHandler)
|
||||
fSelectionHandler->PostMessage(&message);
|
||||
|
||||
|
||||
window->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
|
||||
@@ -737,12 +735,12 @@ OpenWithPoseView::Pulse()
|
||||
}
|
||||
|
||||
ASSERT(fSelectionList->CountItems() == 1);
|
||||
|
||||
|
||||
// enable the Open and make default if selected application different
|
||||
// from preferred app ref
|
||||
window->SetCanSetAppAsDefault((*fSelectionList->FirstItem()->
|
||||
TargetModel()->EntryRef()) != fPreferredRef);
|
||||
|
||||
|
||||
_inherited::Pulse();
|
||||
}
|
||||
|
||||
@@ -786,23 +784,26 @@ OpenWithPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 cou
|
||||
// overridden to try to select the preferred handling app
|
||||
_inherited::CreatePoses(models, poseInfoArray, count, resultingPoses, insertionSort,
|
||||
lastPoseIndexPtr, boundsPtr, forceDraw);
|
||||
|
||||
if (resultingPoses)
|
||||
for (int32 index = 0; index < count; index++)
|
||||
|
||||
if (resultingPoses) {
|
||||
for (int32 index = 0; index < count; index++) {
|
||||
if (resultingPoses[index] && fHaveCommonPreferredApp
|
||||
&& *(models[index]->EntryRef()) == fPreferredRef)
|
||||
&& *(models[index]->EntryRef()) == fPreferredRef) {
|
||||
// this is our preferred app, select it's pose
|
||||
SelectPose(resultingPoses[index], IndexOfPose(resultingPoses[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OpenWithPoseView::KeyDown(const char *bytes, int32 count)
|
||||
{
|
||||
if (bytes[0] == B_TAB)
|
||||
if (bytes[0] == B_TAB) {
|
||||
// just shift the focus, don't tab to the next pose
|
||||
BView::KeyDown(bytes, count);
|
||||
else
|
||||
} else
|
||||
_inherited::KeyDown(bytes, count);
|
||||
}
|
||||
|
||||
@@ -950,7 +951,7 @@ int32
|
||||
RelationCachingModelProxy::Relation(SearchForSignatureEntryList *iterator,
|
||||
BMessage *entries) const
|
||||
{
|
||||
if (fRelation == kUnknownRelation)
|
||||
if (fRelation == kUnknownRelation)
|
||||
fRelation = iterator->Relation(entries, fModel);
|
||||
|
||||
return fRelation;
|
||||
@@ -1061,7 +1062,7 @@ OpenWithMenu::AddNextItem()
|
||||
// Tracker, filter out version that don't list the correct types,
|
||||
// etc.
|
||||
delete model;
|
||||
} else
|
||||
} else
|
||||
fSupportingAppList->AddItem(new RelationCachingModelProxy(model));
|
||||
|
||||
return true;
|
||||
@@ -1128,7 +1129,7 @@ OpenWithMenu::DoneBuildingItemList()
|
||||
// divide different relations of opening with a separator
|
||||
int32 relation = modelProxy->Relation(fIterator, &fEntriesToOpen);
|
||||
if (lastRelation != -1 && relation != lastRelation)
|
||||
AddSeparatorItem();
|
||||
AddSeparatorItem();
|
||||
lastRelation = relation;
|
||||
|
||||
ModelMenuItem *item = new ModelMenuItem(model, result.String(), message);
|
||||
@@ -1186,7 +1187,7 @@ SearchForSignatureEntryList::~SearchForSignatureEntryList()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
SearchForSignatureEntryList::PushUniqueSignature(const char *str)
|
||||
{
|
||||
// do a unique add
|
||||
@@ -1197,21 +1198,21 @@ SearchForSignatureEntryList::PushUniqueSignature(const char *str)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
status_t
|
||||
SearchForSignatureEntryList::GetNextEntry(BEntry *entry, bool)
|
||||
{
|
||||
return fIteratorList->GetNextEntry(entry);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
status_t
|
||||
SearchForSignatureEntryList::GetNextRef(entry_ref *ref)
|
||||
{
|
||||
return fIteratorList->GetNextRef(ref);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
int32
|
||||
SearchForSignatureEntryList::GetNextDirents(struct dirent *buffer,
|
||||
size_t length, int32 count)
|
||||
{
|
||||
@@ -1238,7 +1239,7 @@ AddOnePredicateTerm(const BString *item, void *castToParams)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
status_t
|
||||
SearchForSignatureEntryList::Rewind()
|
||||
{
|
||||
if (fIteratorList)
|
||||
@@ -1253,7 +1254,7 @@ SearchForSignatureEntryList::Rewind()
|
||||
// build the predicate string by oring queries for the individual
|
||||
// signatures
|
||||
BString predicateString;
|
||||
|
||||
|
||||
AddOneTermParams params;
|
||||
params.result = &predicateString;
|
||||
params.first = true;
|
||||
@@ -1265,24 +1266,24 @@ SearchForSignatureEntryList::Rewind()
|
||||
fIteratorList->AddItem(new TWalkerWrapper(
|
||||
new WALKER_NS::TQueryWalker(predicateString.String())));
|
||||
fIteratorList->AddItem(new ConditionalAllAppsIterator(this));
|
||||
|
||||
|
||||
return fIteratorList->Rewind();
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
int32
|
||||
SearchForSignatureEntryList::CountEntries()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
bool
|
||||
SearchForSignatureEntryList::GetPreferredApp(entry_ref *ref) const
|
||||
{
|
||||
if (fPreferredAppCount == 1)
|
||||
*ref = fPreferredRef;
|
||||
|
||||
|
||||
return fPreferredAppCount == 1;
|
||||
}
|
||||
|
||||
@@ -1299,7 +1300,7 @@ SearchForSignatureEntryList::TrySettingPreferredApp(const entry_ref *ref)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
SearchForSignatureEntryList::TrySettingPreferredAppForFile(const entry_ref *ref)
|
||||
{
|
||||
if (!fPreferredAppForFileCount) {
|
||||
@@ -1312,28 +1313,28 @@ SearchForSignatureEntryList::TrySettingPreferredAppForFile(const entry_ref *ref)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
SearchForSignatureEntryList::NonGenericFileFound()
|
||||
{
|
||||
fGenericFilesOnly = false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
bool
|
||||
SearchForSignatureEntryList::GenericFilesOnly() const
|
||||
{
|
||||
return fGenericFilesOnly;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
bool
|
||||
SearchForSignatureEntryList::ShowAllApplications() const
|
||||
{
|
||||
return fCanAddAllApps && !fFoundOneNonSuperHandler;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
int32
|
||||
SearchForSignatureEntryList::Relation(const Model *nodeModel,
|
||||
const Model *applicationModel)
|
||||
{
|
||||
@@ -1356,7 +1357,7 @@ SearchForSignatureEntryList::Relation(const Model *nodeModel,
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
int32
|
||||
SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen,
|
||||
const Model *model) const
|
||||
{
|
||||
@@ -1366,7 +1367,7 @@ SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen,
|
||||
const Model *model, BString *description) const
|
||||
{
|
||||
@@ -1376,7 +1377,7 @@ SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen,
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
int32
|
||||
SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen,
|
||||
const Model *applicationModel, const entry_ref *preferredApp,
|
||||
const entry_ref *preferredAppForFile)
|
||||
@@ -1392,7 +1393,7 @@ SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen,
|
||||
Model model(&ref, true, true);
|
||||
if (model.InitCheck())
|
||||
continue;
|
||||
|
||||
|
||||
int32 result = Relation(&model, applicationModel);
|
||||
if (result != kNoRelation) {
|
||||
if (preferredAppForFile
|
||||
@@ -1400,19 +1401,19 @@ SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen,
|
||||
return kPreferredForFile;
|
||||
|
||||
if (result == kSupportsType && preferredApp
|
||||
&& *applicationModel->EntryRef() == *preferredApp)
|
||||
&& *applicationModel->EntryRef() == *preferredApp)
|
||||
// application matches cached preferred app, we are done
|
||||
return kPreferredForType;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return kNoRelation;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen,
|
||||
const Model *applicationModel, BString *description, const entry_ref *preferredApp,
|
||||
const entry_ref *preferredAppForFile)
|
||||
@@ -1426,11 +1427,11 @@ SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen,
|
||||
*description = "Preferred for file";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Model model(&ref, true, true);
|
||||
if (model.InitCheck())
|
||||
continue;
|
||||
|
||||
|
||||
BMimeType mimeType;
|
||||
int32 result = Relation(&model, applicationModel);
|
||||
switch (result) {
|
||||
@@ -1442,43 +1443,43 @@ SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen,
|
||||
return;
|
||||
|
||||
case kSupportsSupertype:
|
||||
{
|
||||
mimeType.SetTo(model.MimeType());
|
||||
// status_t result = mimeType.GetSupertype(&mimeType);
|
||||
|
||||
char *type = (char *)mimeType.Type();
|
||||
char *tmp = strchr(type, '/');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
|
||||
//PRINT(("getting supertype for %s, result %s, got %s\n",
|
||||
// model.MimeType(), strerror(result), mimeType.Type()));
|
||||
*description = "Handles any ";
|
||||
// *description += mimeType.Type();
|
||||
*description += type;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
mimeType.SetTo(model.MimeType());
|
||||
// status_t result = mimeType.GetSupertype(&mimeType);
|
||||
|
||||
char *type = (char *)mimeType.Type();
|
||||
char *tmp = strchr(type, '/');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
|
||||
//PRINT(("getting supertype for %s, result %s, got %s\n",
|
||||
// model.MimeType(), strerror(result), mimeType.Type()));
|
||||
*description = "Handles any ";
|
||||
// *description += mimeType.Type();
|
||||
*description += type;
|
||||
return;
|
||||
}
|
||||
|
||||
case kSupportsType:
|
||||
{
|
||||
mimeType.SetTo(model.MimeType());
|
||||
|
||||
if (preferredApp && *applicationModel->EntryRef() == *preferredApp)
|
||||
// application matches cached preferred app, we are done
|
||||
*description = "Preferred for ";
|
||||
else
|
||||
*description = "Handles ";
|
||||
|
||||
char shortDescription[256];
|
||||
if (mimeType.GetShortDescription(shortDescription) == B_OK)
|
||||
*description += shortDescription;
|
||||
else
|
||||
*description += mimeType.Type();
|
||||
return;
|
||||
}
|
||||
{
|
||||
mimeType.SetTo(model.MimeType());
|
||||
|
||||
if (preferredApp && *applicationModel->EntryRef() == *preferredApp)
|
||||
// application matches cached preferred app, we are done
|
||||
*description = "Preferred for ";
|
||||
else
|
||||
*description = "Handles ";
|
||||
|
||||
char shortDescription[256];
|
||||
if (mimeType.GetShortDescription(shortDescription) == B_OK)
|
||||
*description += shortDescription;
|
||||
else
|
||||
*description += mimeType.Type();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*description = "Does not handle file";
|
||||
}
|
||||
|
||||
@@ -1520,7 +1521,7 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel,
|
||||
BPath path, path2;
|
||||
BEntry entry(appModel->EntryRef());
|
||||
entry.GetPath(&path);
|
||||
|
||||
|
||||
BEntry entry2(&trackerInfo.ref);
|
||||
entry2.GetPath(&path2);
|
||||
|
||||
@@ -1531,7 +1532,7 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (FSInTrashDir(appModel->EntryRef()))
|
||||
return false;
|
||||
|
||||
@@ -1542,10 +1543,10 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel,
|
||||
BAppFileInfo appFileInfo(dynamic_cast<BFile *>(appModel->Node()));
|
||||
if (appFileInfo.GetAppFlags(&flags) != B_OK)
|
||||
return false;
|
||||
|
||||
|
||||
if ((flags & B_BACKGROUND_APP) || (flags & B_ARGV_ONLY))
|
||||
return false;
|
||||
|
||||
|
||||
if (!signature[0])
|
||||
// weed out apps with empty signatures
|
||||
return false;
|
||||
@@ -1557,7 +1558,7 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel,
|
||||
BPath path;
|
||||
BEntry entry(appModel->EntryRef());
|
||||
entry.GetPath(&path);
|
||||
|
||||
|
||||
PRINT(("filtering out %s, does not handle any of opened files\n",
|
||||
path.Path()));
|
||||
#endif
|
||||
@@ -1628,7 +1629,8 @@ ConditionalAllAppsIterator::GetNextRef(entry_ref *ref)
|
||||
|
||||
|
||||
int32
|
||||
ConditionalAllAppsIterator::GetNextDirents(struct dirent *buffer, size_t length, int32 count)
|
||||
ConditionalAllAppsIterator::GetNextDirents(struct dirent *buffer, size_t length,
|
||||
int32 count)
|
||||
{
|
||||
if (!Iterate())
|
||||
return 0;
|
||||
|
||||
@@ -116,7 +116,7 @@ class SearchForSignatureEntryList : public EntryListBase {
|
||||
// returns the reason why an application is shown in Open With window
|
||||
|
||||
CachedEntryIteratorList *fIteratorList;
|
||||
BObjectList<BString> fSignatures;
|
||||
BObjectList<BString> fSignatures;
|
||||
|
||||
entry_ref fPreferredRef;
|
||||
int32 fPreferredAppCount;
|
||||
@@ -132,7 +132,7 @@ class OpenWithContainerWindow : public BContainerWindow {
|
||||
OpenWithContainerWindow(BMessage *entriesToOpen,
|
||||
LockingList<BWindow> *windowList,
|
||||
window_look look = B_DOCUMENT_WINDOW_LOOK,
|
||||
window_feel feel = B_NORMAL_WINDOW_FEEL,
|
||||
window_feel feel = B_NORMAL_WINDOW_FEEL,
|
||||
uint32 flags = 0, uint32 workspace = B_CURRENT_WORKSPACE);
|
||||
// <entriesToOpen> eventually get opened by the selected app
|
||||
virtual ~OpenWithContainerWindow();
|
||||
@@ -273,13 +273,13 @@ class OpenWithMenu : public BSlowMenu {
|
||||
|
||||
virtual bool StartBuildingItemList();
|
||||
virtual bool AddNextItem();
|
||||
virtual void DoneBuildingItemList();
|
||||
virtual void DoneBuildingItemList();
|
||||
virtual void ClearMenuBuildingState();
|
||||
|
||||
BMessage fEntriesToOpen;
|
||||
BHandler *target;
|
||||
BMessenger fMessenger;
|
||||
|
||||
|
||||
// menu building state
|
||||
SearchForSignatureEntryList *fIterator;
|
||||
entry_ref fPreferredRef;
|
||||
@@ -305,7 +305,7 @@ class ConditionalAllAppsIterator : public EntryListBase {
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
bool Iterate() const;
|
||||
void Instantiate();
|
||||
|
||||
@@ -313,7 +313,7 @@ class ConditionalAllAppsIterator : public EntryListBase {
|
||||
SearchForSignatureEntryList *fParent;
|
||||
WALKER_NS::TWalker *fWalker;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
Reference in New Issue
Block a user