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