From 4fba3522e02906506b6c713ef5b57d72e9458fef Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 11 Apr 2009 21:24:32 +0000 Subject: [PATCH] * Removed src/kits/tracker/OpenHashTable.h. The shared version in headers/private/shared is newer, though with small interface changes. * Removed the unnecessary Debug.h include in headers/private/shared/ObjectList.h. * Adjusted sources using these headers, mostly by adding missing includes. * Lots of automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30123 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/shared/ObjectList.h | 177 +++++---- .../intel/ExtendedPartitionAddOn.cpp | 4 +- src/apps/diskprobe/AttributeWindow.cpp | 13 +- src/apps/diskprobe/DataEditor.cpp | 44 +- src/apps/diskprobe/DataView.cpp | 3 + src/apps/diskprobe/TypeEditors.cpp | 37 +- src/apps/drivesetup/MainWindow.cpp | 3 + src/apps/drivesetup/Support.cpp | 2 + .../disk_device/DiskDeviceJobGenerator.cpp | 1 + .../disk_device/DiskDeviceJobQueue.cpp | 2 + src/kits/storage/disk_device/Partition.cpp | 1 + src/kits/tracker/AttributeStream.cpp | 142 +++---- src/kits/tracker/AutoMounter.cpp | 4 +- src/kits/tracker/Bitmaps.cpp | 16 +- src/kits/tracker/FilePermissionsView.cpp | 29 +- src/kits/tracker/IconCache.cpp | 282 ++++++------- src/kits/tracker/MountMenu.cpp | 1 + src/kits/tracker/OpenHashTable.h | 376 ------------------ src/kits/tracker/TaskLoop.cpp | 83 ++-- src/kits/tracker/Thread.h | 46 ++- src/kits/tracker/TrackerSettings.cpp | 32 +- src/kits/tracker/Utilities.h | 46 ++- .../backgrounds/BackgroundImage.cpp | 1 + .../backgrounds/BackgroundsView.cpp | 1 + src/preferences/mail/DNSQuery.cpp | 23 +- src/preferences/print/JobListView.cpp | 1 + src/servers/app/Desktop.cpp | 1 + src/servers/app/ServerApp.cpp | 1 + src/servers/app/ServerPicture.cpp | 79 ++-- src/servers/app/ServerWindow.cpp | 1 + src/servers/input/PathList.cpp | 1 + src/servers/media_addon/MediaFilePlayer.cpp | 25 +- src/servers/print/ConfigWindow.cpp | 71 ++-- 33 files changed, 609 insertions(+), 940 deletions(-) delete mode 100644 src/kits/tracker/OpenHashTable.h diff --git a/headers/private/shared/ObjectList.h b/headers/private/shared/ObjectList.h index c7a495c601..def0465790 100644 --- a/headers/private/shared/ObjectList.h +++ b/headers/private/shared/ObjectList.h @@ -65,7 +65,8 @@ All rights reserved. #include #endif -#include +#include + template class BObjectList; @@ -79,12 +80,12 @@ struct UnaryPredicate { private: static int _unary_predicate_glue(const void *item, void *context); - + friend class BObjectList; }; template -int +int UnaryPredicate::_unary_predicate_glue(const void *item, void *context) { return ((UnaryPredicate *)context)->operator()((const T *)item); @@ -96,7 +97,7 @@ public: _PointerList_(const _PointerList_ &list); _PointerList_(int32 itemsPerBlock = 20, bool owning = false); ~_PointerList_(); - + typedef void *(* GenericEachFunction)(void *, void *); typedef int (* GenericCompareFunction)(const void *, const void *); typedef int (* GenericCompareFunctionWithState)(const void *, const void *, @@ -108,7 +109,7 @@ public: void SortItems(GenericCompareFunctionWithState, void *state); void HSortItems(GenericCompareFunction); void HSortItems(GenericCompareFunctionWithState, void *state); - + void *BinarySearch(const void *, GenericCompareFunction) const; void *BinarySearch(const void *, GenericCompareFunctionWithState, void *state) const; @@ -147,7 +148,7 @@ public: // adding and removing // ToDo: - // change Add calls to return const item + // change Add calls to return const item bool AddItem(T *); bool AddItem(T *, int32); bool AddList(BObjectList *); @@ -228,14 +229,14 @@ public: private: void SetItem(int32, T *); }; - + template -Result +Result WhileEachListItem(BObjectList *list, Result (Item::*func)(Param1), Param1 p1) { - Result result = 0; + Result result = 0; int32 count = list->CountItems(); - + for (int32 index = 0; index < count; index++) if ((result = (list->ItemAt(index)->*func)(p1)) != 0) break; @@ -244,12 +245,12 @@ WhileEachListItem(BObjectList *list, Result (Item::*func)(Param1), Param1 } template -Result +Result WhileEachListItem(BObjectList *list, Result (*func)(Item *, Param1), Param1 p1) { - Result result = 0; + Result result = 0; int32 count = list->CountItems(); - + for (int32 index = 0; index < count; index++) if ((result = (*func)(list->ItemAt(index), p1)) != 0) break; @@ -258,13 +259,13 @@ WhileEachListItem(BObjectList *list, Result (*func)(Item *, Param1), Param } template -Result +Result WhileEachListItem(BObjectList *list, Result (Item::*func)(Param1, Param2), Param1 p1, Param2 p2) { - Result result = 0; + Result result = 0; int32 count = list->CountItems(); - + for (int32 index = 0; index < count; index++) if ((result = (list->ItemAt(index)->*func)(p1, p2)) != 0) break; @@ -273,13 +274,13 @@ WhileEachListItem(BObjectList *list, Result (Item::*func)(Param1, Param2), } template -Result +Result WhileEachListItem(BObjectList *list, Result (*func)(Item *, Param1, Param2), Param1 p1, Param2 p2) { - Result result = 0; + Result result = 0; int32 count = list->CountItems(); - + for (int32 index = 0; index < count; index++) if ((result = (*func)(list->ItemAt(index), p1, p2)) != 0) break; @@ -288,13 +289,13 @@ WhileEachListItem(BObjectList *list, Result (*func)(Item *, Param1, Param2 } template -Result +Result WhileEachListItem(BObjectList *list, Result (*func)(Item *, Param1, Param2, Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4) { - Result result = 0; + Result result = 0; int32 count = list->CountItems(); - + for (int32 index = 0; index < count; index++) if ((result = (*func)(list->ItemAt(index), p1, p2, p3, p4)) != 0) break; @@ -303,7 +304,7 @@ WhileEachListItem(BObjectList *list, Result (*func)(Item *, Param1, Param2 } template -void +void EachListItemIgnoreResult(BObjectList *list, Result (Item::*func)()) { int32 count = list->CountItems(); @@ -312,7 +313,7 @@ EachListItemIgnoreResult(BObjectList *list, Result (Item::*func)()) } template -void +void EachListItem(BObjectList *list, void (*func)(Item *, Param1), Param1 p1) { int32 count = list->CountItems(); @@ -321,7 +322,7 @@ EachListItem(BObjectList *list, void (*func)(Item *, Param1), Param1 p1) } template -void +void EachListItem(BObjectList *list, void (Item::*func)(Param1, Param2), Param1 p1, Param2 p2) { @@ -331,7 +332,7 @@ EachListItem(BObjectList *list, void (Item::*func)(Param1, Param2), } template -void +void EachListItem(BObjectList *list, void (*func)(Item *,Param1, Param2), Param1 p1, Param2 p2) { @@ -341,7 +342,7 @@ EachListItem(BObjectList *list, void (*func)(Item *,Param1, Param2), } template -void +void EachListItem(BObjectList *list, void (*func)(Item *,Param1, Param2, Param3), Param1 p1, Param2 p2, Param3 p3) { @@ -352,7 +353,7 @@ EachListItem(BObjectList *list, void (*func)(Item *,Param1, Param2, template -void +void EachListItem(BObjectList *list, void (*func)(Item *,Param1, Param2, Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4) { @@ -369,13 +370,13 @@ _PointerList_::Owning() const return owning; } -template +template BObjectList::BObjectList(int32 itemsPerBlock, bool owning) : _PointerList_(itemsPerBlock, owning) { } -template +template BObjectList::BObjectList(const BObjectList &list) : _PointerList_(list) { @@ -392,7 +393,7 @@ BObjectList::BObjectList(const BObjectList &list) } } -template +template BObjectList::~BObjectList() { if (Owning()) @@ -400,7 +401,7 @@ BObjectList::~BObjectList() MakeEmpty(); } -template +template BObjectList & BObjectList::operator=(const BObjectList &list) { @@ -419,56 +420,56 @@ BObjectList::operator=(const BObjectList &list) return result; } -template -bool +template +bool BObjectList::AddItem(T *item) { // need to cast to void * to make T work for const pointers return _PointerList_::AddItem((void *)item); } -template -bool +template +bool BObjectList::AddItem(T *item, int32 atIndex) { return _PointerList_::AddItem((void *)item, atIndex); } -template -bool +template +bool BObjectList::AddList(BObjectList *newItems) { return _PointerList_::AddList(newItems); } -template -bool +template +bool BObjectList::AddList(BObjectList *newItems, int32 atIndex) { return _PointerList_::AddList(newItems, atIndex); } -template -bool +template +bool BObjectList::RemoveItem(T *item, bool deleteIfOwning) { bool result = _PointerList_::RemoveItem((void *)item); - + if (result && Owning() && deleteIfOwning) delete item; return result; } -template +template T * BObjectList::RemoveItemAt(int32 index) { return (T *)_PointerList_::RemoveItem(index); } -template +template inline T * BObjectList::ItemAt(int32 index) const { @@ -476,7 +477,7 @@ BObjectList::ItemAt(int32 index) const } template -bool +bool BObjectList::ReplaceItem(int32 index, T *item) { if (owning) @@ -494,56 +495,56 @@ BObjectList::SwapWithItem(int32 index, T *newItem) } template -void +void BObjectList::SetItem(int32 index, T *newItem) { _PointerList_::ReplaceItem(index, (void *)newItem); } -template -int32 +template +int32 BObjectList::IndexOf(const T *item) const { return _PointerList_::IndexOf((void *)item); } -template +template T * BObjectList::FirstItem() const { return (T *)_PointerList_::FirstItem(); } -template +template T * BObjectList::LastItem() const { return (T *)_PointerList_::LastItem(); } -template -bool +template +bool BObjectList::HasItem(const T *item) const { return _PointerList_::HasItem((void *)item); } -template -bool +template +bool BObjectList::IsEmpty() const { return _PointerList_::IsEmpty(); } -template -int32 +template +int32 BObjectList::CountItems() const { return _PointerList_::CountItems(); } -template -void +template +void BObjectList::MakeEmpty() { if (owning) { @@ -554,21 +555,21 @@ BObjectList::MakeEmpty() _PointerList_::MakeEmpty(); } -template +template T * BObjectList::EachElement(EachFunction func, void *params) -{ - return (T *)_PointerList_::EachElement((GenericEachFunction)func, params); +{ + return (T *)_PointerList_::EachElement((GenericEachFunction)func, params); } -template +template const T * BObjectList::EachElement(ConstEachFunction func, void *params) const -{ +{ return (const T *) const_cast *>(this)->_PointerList_::EachElement( - (GenericEachFunction)func, params); + (GenericEachFunction)func, params); } template @@ -594,32 +595,32 @@ BObjectList::FindIf(const UnaryPredicate &predicate) } -template +template void BObjectList::SortItems(CompareFunction function) -{ - _PointerList_::SortItems((GenericCompareFunction)function); +{ + _PointerList_::SortItems((GenericCompareFunction)function); } template -void +void BObjectList::SortItems(CompareFunctionWithState function, void *state) { - _PointerList_::SortItems((GenericCompareFunctionWithState)function, state); -} - -template -void -BObjectList::HSortItems(CompareFunction function) -{ - _PointerList_::HSortItems((GenericCompareFunction)function); + _PointerList_::SortItems((GenericCompareFunctionWithState)function, state); } template -void +void +BObjectList::HSortItems(CompareFunction function) +{ + _PointerList_::HSortItems((GenericCompareFunction)function); +} + +template +void BObjectList::HSortItems(CompareFunctionWithState function, void *state) { - _PointerList_::HSortItems((GenericCompareFunctionWithState)function, state); + _PointerList_::HSortItems((GenericCompareFunctionWithState)function, state); } template @@ -667,7 +668,7 @@ BObjectList::BinaryInsert(T *item, CompareFunctionWithState func, void *state } template -bool +bool BObjectList::BinaryInsertUnique(T *item, CompareFunction func) { int32 index = _PointerList_::BinarySearchIndex(item, @@ -679,7 +680,7 @@ BObjectList::BinaryInsertUnique(T *item, CompareFunction func) } template -bool +bool BObjectList::BinaryInsertUnique(T *item, CompareFunctionWithState func, void *state) { int32 index = _PointerList_::BinarySearchIndex(item, @@ -702,7 +703,7 @@ BObjectList::BinaryInsertCopy(const T ©This, CompareFunction func) index++; else index = -index - 1; - + T *newItem = new T(copyThis); AddItem(newItem, index); return newItem; @@ -733,7 +734,7 @@ BObjectList::BinaryInsertCopyUnique(const T ©This, CompareFunction func) (GenericCompareFunction)func); if (index >= 0) return ItemAt(index); - + index = -index - 1; T *newItem = new T(copyThis); AddItem(newItem, index); @@ -749,7 +750,7 @@ BObjectList::BinaryInsertCopyUnique(const T ©This, CompareFunctionWithSta (GenericCompareFunctionWithState)func, state); if (index >= 0) return ItemAt(index); - + index = -index - 1; T *newItem = new T(copyThis); AddItem(newItem, index); @@ -757,19 +758,19 @@ BObjectList::BinaryInsertCopyUnique(const T ©This, CompareFunctionWithSta } template -int32 +int32 BObjectList::FindBinaryInsertionIndex(const UnaryPredicate &pred, bool *alreadyInList) const { int32 index = _PointerList_::BinarySearchIndexByPredicate(&pred, (UnaryPredicateGlue)&UnaryPredicate::_unary_predicate_glue); - + if (alreadyInList) *alreadyInList = index >= 0; - if (index < 0) + if (index < 0) index = -index - 1; - + return index; } diff --git a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp index 2d93acfe18..e33dc7214a 100644 --- a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp +++ b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp @@ -5,6 +5,8 @@ #include "ExtendedPartitionAddOn.h" +#include + #include #include @@ -17,7 +19,7 @@ using std::nothrow; -static const uint32 kDiskSystemFlags = +static const uint32 kDiskSystemFlags = 0 // | B_DISK_SYSTEM_SUPPORTS_CHECKING // | B_DISK_SYSTEM_SUPPORTS_REPAIRING diff --git a/src/apps/diskprobe/AttributeWindow.cpp b/src/apps/diskprobe/AttributeWindow.cpp index 381bf13451..0b1763916a 100644 --- a/src/apps/diskprobe/AttributeWindow.cpp +++ b/src/apps/diskprobe/AttributeWindow.cpp @@ -8,6 +8,9 @@ #include "ProbeView.h" #include "TypeEditors.h" +#include +#include + #include #include #include @@ -62,7 +65,7 @@ EditorTabView::EditorTabView(BRect frame, const char *name, button_width width, } -void +void EditorTabView::FrameResized(float width, float height) { BRect rect = Bounds(); @@ -84,7 +87,7 @@ EditorTabView::FrameResized(float width, float height) } -void +void EditorTabView::Select(int32 tab) { if (tab != fRawTab && fRawEditorView != NULL && !fRawEditorView->IsHidden(fRawEditorView)) @@ -131,7 +134,7 @@ EditorTabView::AddRawEditorTab(BView *view) } -void +void EditorTabView::SetTypeEditorTab(BView *view) { if (fTypeEditorView == view) @@ -257,7 +260,7 @@ AttributeWindow::~AttributeWindow() } -void +void AttributeWindow::MessageReceived(BMessage *message) { switch (message->what) { @@ -289,7 +292,7 @@ AttributeWindow::MessageReceived(BMessage *message) } -bool +bool AttributeWindow::QuitRequested() { if (fTypeEditorView != NULL) diff --git a/src/apps/diskprobe/DataEditor.cpp b/src/apps/diskprobe/DataEditor.cpp index 56e2be954f..2fd85a28df 100644 --- a/src/apps/diskprobe/DataEditor.cpp +++ b/src/apps/diskprobe/DataEditor.cpp @@ -8,11 +8,13 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -178,7 +180,7 @@ DataChange::~DataChange() } -bool +bool DataChange::Merge(DataChange *change) { return false; @@ -196,7 +198,7 @@ ReplaceChange::ReplaceChange(off_t offset, const uint8 *data, size_t size) fOldData = (uint8 *)malloc(size); if (fNewData != NULL && fOldData != NULL) { memcpy(fNewData, data, size); - fSize = size; + fSize = size; } else fSize = 0; } @@ -215,7 +217,7 @@ ReplaceChange::~ReplaceChange() * method. */ -void +void ReplaceChange::Normalize(off_t bufferOffset, size_t bufferSize, off_t &offset, size_t &dataOffset, size_t &size) { @@ -230,7 +232,7 @@ ReplaceChange::Normalize(off_t bufferOffset, size_t bufferSize, off_t &offset, } -void +void ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize) { // is it in our range? @@ -257,7 +259,7 @@ ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize) } -void +void ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize) { // is it in our range? @@ -283,7 +285,7 @@ ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize) } -bool +bool ReplaceChange::Merge(DataChange *_change) { ReplaceChange *change = dynamic_cast(_change); @@ -323,7 +325,7 @@ ReplaceChange::Merge(DataChange *_change) // if this fails, we can't do anything about it return false; } - + if (fOffset < change->fOffset) { memcpy(newData + fSize, change->fNewData, change->fSize); memcpy(oldData + fSize, change->fOldData, change->fSize); @@ -350,7 +352,7 @@ ReplaceChange::Merge(DataChange *_change) } -void +void ReplaceChange::GetRange(off_t /*fileSize*/, off_t &_offset, off_t &_size) { _offset = fOffset; @@ -392,7 +394,7 @@ DataEditor::~DataEditor() } -status_t +status_t DataEditor::SetTo(const char *path, const char *attribute) { BEntry entry(path); @@ -400,7 +402,7 @@ DataEditor::SetTo(const char *path, const char *attribute) } -status_t +status_t DataEditor::SetTo(entry_ref &ref, const char *attribute) { BEntry entry(&ref); @@ -408,7 +410,7 @@ DataEditor::SetTo(entry_ref &ref, const char *attribute) } -status_t +status_t DataEditor::SetTo(BEntry &entry, const char *attribute) { fSize = 0; @@ -516,7 +518,7 @@ DataEditor::SetTo(BEntry &entry, const char *attribute) } -status_t +status_t DataEditor::InitCheck() { return fFile.InitCheck(); @@ -747,7 +749,7 @@ DataEditor::RemoveRedos() } -status_t +status_t DataEditor::Undo() { BAutolock locker(this); @@ -776,7 +778,7 @@ DataEditor::Undo() } -status_t +status_t DataEditor::Redo() { BAutolock locker(this); @@ -863,7 +865,7 @@ DataEditor::SetViewOffset(off_t offset) } -status_t +status_t DataEditor::SetViewSize(size_t size, bool sendNotices) { BAutolock locker(this); @@ -979,7 +981,7 @@ DataEditor::UpdateIfNeeded(bool *_updated) } -status_t +status_t DataEditor::ForceUpdate() { BAutolock locker(this); @@ -1045,7 +1047,7 @@ DataEditor::GetViewBuffer(const uint8 **_buffer) } -off_t +off_t DataEditor::Find(off_t startPosition, const uint8 *data, size_t dataSize, bool caseInsensitive, bool cyclic, BMessenger progressMonitor, volatile bool *stop) @@ -1191,7 +1193,7 @@ DataEditor::SendNotices(DataChange *change) } -void +void DataEditor::SendNotices(uint32 what, BMessage *message) { if (fObservers.CountItems() == 0) @@ -1213,7 +1215,7 @@ DataEditor::SendNotices(uint32 what, BMessage *message) } -status_t +status_t DataEditor::StartWatching(BMessenger target) { BAutolock locker(this); @@ -1236,7 +1238,7 @@ DataEditor::StartWatching(BHandler *handler, BLooper *looper) } -void +void DataEditor::StopWatching(BMessenger target) { BAutolock locker(this); @@ -1254,7 +1256,7 @@ DataEditor::StopWatching(BMessenger target) } -void +void DataEditor::StopWatching(BHandler *handler, BLooper *looper) { StopWatching(BMessenger(handler, looper)); diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index ab0615183e..046d09736c 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -7,6 +7,9 @@ #include "DataView.h" #include "DataEditor.h" +#include +#include + #include #include #include diff --git a/src/apps/diskprobe/TypeEditors.cpp b/src/apps/diskprobe/TypeEditors.cpp index a8f7f79a14..f98b42ce57 100644 --- a/src/apps/diskprobe/TypeEditors.cpp +++ b/src/apps/diskprobe/TypeEditors.cpp @@ -11,6 +11,9 @@ # include #endif +#include +#include + #include #include #include @@ -27,8 +30,6 @@ #include #include -#include - static const uint32 kMsgValueChanged = 'vlch'; static const uint32 kMsgScaleChanged = 'scch'; @@ -254,7 +255,7 @@ StringEditor::AttachedToWindow() } -void +void StringEditor::DetachedFromWindow() { fEditor.StopWatching(this); @@ -305,7 +306,7 @@ MimeTypeEditor::_UpdateText() } -void +void MimeTypeEditor::CommitChanges() { if (fPreviousText != fTextControl->Text()) { @@ -333,7 +334,7 @@ MimeTypeEditor::AttachedToWindow() } -void +void MimeTypeEditor::DetachedFromWindow() { fEditor.StopWatching(this); @@ -379,7 +380,7 @@ NumberEditor::NumberEditor(BRect rect, DataEditor &editor) } -void +void NumberEditor::_UpdateText() { if (fEditor.Lock()) { @@ -625,7 +626,7 @@ NumberEditor::_TypeLabel() } -size_t +size_t NumberEditor::_Size() { switch (fEditor.Type()) { @@ -711,7 +712,7 @@ NumberEditor::AttachedToWindow() } -void +void NumberEditor::DetachedFromWindow() { fEditor.StopWatching(this); @@ -774,7 +775,7 @@ BooleanEditor::TypeMatches() } -void +void BooleanEditor::_UpdateMenuField() { if (fEditor.FileSize() != 1) @@ -790,14 +791,14 @@ BooleanEditor::_UpdateMenuField() } -void +void BooleanEditor::CommitChanges() { // we're commiting the changes as they happen } -void +void BooleanEditor::AttachedToWindow() { fTrueMenuItem->SetTarget(this); @@ -807,14 +808,14 @@ BooleanEditor::AttachedToWindow() } -void +void BooleanEditor::DetachedFromWindow() { fEditor.StopWatching(this); } -void +void BooleanEditor::MessageReceived(BMessage *message) { switch (message->what) { @@ -842,7 +843,7 @@ ImageView::ImageView(BRect rect, DataEditor &editor) fBitmap(NULL), fScaleSlider(NULL) { - if (editor.Type() == B_MINI_ICON_TYPE || editor.Type() == B_LARGE_ICON_TYPE + if (editor.Type() == B_MINI_ICON_TYPE || editor.Type() == B_LARGE_ICON_TYPE #ifdef HAIKU_TARGET_PLATFORM_HAIKU || editor.Type() == B_VECTOR_ICON_TYPE #endif @@ -876,7 +877,7 @@ ImageView::~ImageView() } -void +void ImageView::AttachedToWindow() { if (Parent() != NULL) @@ -892,7 +893,7 @@ ImageView::AttachedToWindow() } -void +void ImageView::DetachedFromWindow() { fEditor.StopWatching(this); @@ -1034,7 +1035,7 @@ ImageView::_UpdateImage() case B_MESSAGE_TYPE: type = "Flattened Bitmap"; break; - default: + default: break; } const char *colorSpace; @@ -1283,7 +1284,7 @@ MessageView::AttachedToWindow() } -void +void MessageView::DetachedFromWindow() { fEditor.StopWatching(this); diff --git a/src/apps/drivesetup/MainWindow.cpp b/src/apps/drivesetup/MainWindow.cpp index 40cf025cf8..41dab3d7e1 100644 --- a/src/apps/drivesetup/MainWindow.cpp +++ b/src/apps/drivesetup/MainWindow.cpp @@ -14,6 +14,9 @@ #include "PartitionList.h" #include "Support.h" +#include +#include + #include #include diff --git a/src/apps/drivesetup/Support.cpp b/src/apps/drivesetup/Support.cpp index 163af4bac9..68f6f21922 100644 --- a/src/apps/drivesetup/Support.cpp +++ b/src/apps/drivesetup/Support.cpp @@ -10,6 +10,8 @@ #include "Support.h" +#include + #include #include diff --git a/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp b/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp index 5882cd7cbb..6a72d7f560 100644 --- a/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp +++ b/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp @@ -7,6 +7,7 @@ #include +#include #include #include diff --git a/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp b/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp index 304d22a1f9..0b2ea74607 100644 --- a/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp +++ b/src/kits/storage/disk_device/DiskDeviceJobQueue.cpp @@ -5,6 +5,8 @@ #include "DiskDeviceJobQueue.h" +#include + #include #include "DiskDeviceJob.h" diff --git a/src/kits/storage/disk_device/Partition.cpp b/src/kits/storage/disk_device/Partition.cpp index 18d4f29092..6a11404152 100644 --- a/src/kits/storage/disk_device/Partition.cpp +++ b/src/kits/storage/disk_device/Partition.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/src/kits/tracker/AttributeStream.cpp b/src/kits/tracker/AttributeStream.cpp index 6b439ba65f..8c429e10ec 100644 --- a/src/kits/tracker/AttributeStream.cpp +++ b/src/kits/tracker/AttributeStream.cpp @@ -32,9 +32,11 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ -#include #include "AttributeStream.h" +#include +#include + // ToDo: // lazy Rewind from Drive, only if data is available // BMessage node @@ -43,7 +45,7 @@ All rights reserved. AttributeInfo::AttributeInfo(const AttributeInfo &cloneThis) : fName(cloneThis.fName), fInfo(cloneThis.fInfo) - + { } @@ -68,34 +70,34 @@ AttributeInfo::Name() const return fName.String(); } -uint32 +uint32 AttributeInfo::Type() const { return fInfo.type; } -off_t +off_t AttributeInfo::Size() const { return fInfo.size; } -void +void AttributeInfo::SetTo(const AttributeInfo &attr) { fName = attr.fName; fInfo = attr.fInfo; } -void +void AttributeInfo::SetTo(const char *name, attr_info info) { fName = name; fInfo = info; } -void +void AttributeInfo::SetTo(const char *name, uint32 type, off_t size) { fName = name; @@ -121,26 +123,26 @@ AttributeStreamNode::operator<<(AttributeStreamNode &source) { fReadFrom = &source; fReadFrom->fWriteTo = this; - if (fReadFrom->CanFeed()) + if (fReadFrom->CanFeed()) fReadFrom->Start(); return source; } -void +void AttributeStreamNode::Rewind() { if (fReadFrom) fReadFrom->Rewind(); } -void +void AttributeStreamFileNode::MakeEmpty() { TRESPASS(); } -off_t +off_t AttributeStreamNode::Contains(const char *name, uint32 type) { if (!fReadFrom) @@ -150,27 +152,27 @@ AttributeStreamNode::Contains(const char *name, uint32 type) } -off_t +off_t AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type, off_t size, void *buffer, void (*swapFunc)(void *)) { if (!fReadFrom) return 0; - + return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc); } -off_t +off_t AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 type, off_t size, const void *buffer) { if (!fWriteTo) return 0; - + return fWriteTo->Write(name, foreignName, type, size, buffer); } -bool +bool AttributeStreamNode::Drive() { ASSERT(CanFeed()); @@ -200,17 +202,17 @@ AttributeStreamNode::Get() return fReadFrom->Get(); } -bool +bool AttributeStreamNode::Fill(char *buffer) const { ASSERT(fReadFrom); return fReadFrom->Fill(buffer); } -bool +bool AttributeStreamNode::Start() { - if (!fWriteTo) + if (!fWriteTo) // we are at the head of the stream, start drivin' return Drive(); @@ -224,11 +226,11 @@ AttributeStreamNode::Detach() AttributeStreamNode *tmpTo = fWriteTo; fReadFrom = NULL; fWriteTo = NULL; - - if (tmpFrom) + + if (tmpFrom) tmpFrom->Detach(); if (tmpTo) - tmpTo->Detach(); + tmpTo->Detach(); } @@ -244,21 +246,21 @@ AttributeStreamFileNode::AttributeStreamFileNode(BNode *node) ASSERT(fNode); } -void +void AttributeStreamFileNode::Rewind() { _inherited::Rewind(); fNode->RewindAttrs(); } -void +void AttributeStreamFileNode::SetTo(BNode *node) { fNode = node; } -off_t +off_t AttributeStreamFileNode::Contains(const char *name, uint32 type) { ASSERT(fNode); @@ -272,13 +274,13 @@ AttributeStreamFileNode::Contains(const char *name, uint32 type) return info.size; } -off_t +off_t AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 type, off_t size, void *buffer, void (*swapFunc)(void *)) { if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size) return size; - + // didn't find the attribute under the native name, try the foreign name if (foreignName && fNode->ReadAttr(foreignName, type, 0, buffer, (size_t)size) == size) { // foreign attribute, swap the data @@ -289,7 +291,7 @@ AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 return 0; } -off_t +off_t AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 type, off_t size, const void *buffer) { @@ -300,11 +302,11 @@ AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 // the write operation worked fine, remove the foreign attribute // to not let stale data hang around fNode->RemoveAttr(foreignName); - + return result; } -bool +bool AttributeStreamFileNode::Drive() { ASSERT(fNode); @@ -330,7 +332,7 @@ AttributeStreamFileNode::Get() return NULL; } -bool +bool AttributeStreamFileNode::Fill(char *buffer) const { ASSERT(fNode); @@ -350,7 +352,7 @@ AttributeStreamFileNode::Next() attr_info info; if (fNode->GetAttrInfo(attrName, &info) != B_OK) return NULL; - + fCurrentAttr.SetTo(attrName, info); return &fCurrentAttr; } @@ -362,13 +364,13 @@ AttributeStreamMemoryNode::AttributeStreamMemoryNode() { } -void +void AttributeStreamMemoryNode::MakeEmpty() { fAttributes.MakeEmpty(); } -void +void AttributeStreamMemoryNode::Rewind() { _inherited::Rewind(); @@ -387,7 +389,7 @@ AttributeStreamMemoryNode::Find(const char *name, uint32 type) const return -1; } -off_t +off_t AttributeStreamMemoryNode::Contains(const char *name, uint32 type) { int32 index = Find(name, type); @@ -397,7 +399,7 @@ AttributeStreamMemoryNode::Contains(const char *name, uint32 type) } -off_t +off_t AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreignName), uint32 type, off_t bufferSize, void *buffer, void (*DEBUG_ONLY(swapFunc))(void *)) { @@ -413,7 +415,7 @@ AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreign off_t size = fReadFrom->Contains(name, type); if (!size) return 0; - + attrNode = BufferingGet(name, type, size); if (!attrNode) return 0; @@ -422,12 +424,12 @@ AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreign if (attrNode->fAttr.Size() > bufferSize) return 0; - + memcpy(buffer, attrNode->fData, (size_t)attrNode->fAttr.Size()); return attrNode->fAttr.Size(); } -off_t +off_t AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type, off_t size, const void *buffer) { @@ -439,15 +441,15 @@ AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type, return size; } -bool +bool AttributeStreamMemoryNode::Drive() { if (!_inherited::Drive()) return false; - + while (BufferingGet()) ; - + return true; } @@ -471,7 +473,7 @@ AttributeStreamMemoryNode::BufferingGet() { if (!fReadFrom) return NULL; - + const AttributeInfo *attr = fReadFrom->Next(); if (!attr) return NULL; @@ -500,7 +502,7 @@ AttributeStreamMemoryNode::Get() return fAttributes.ItemAt(fCurrentIndex)->fData; } -bool +bool AttributeStreamMemoryNode::Fill(char *buffer) const { ASSERT(fCurrentIndex < fAttributes.CountItems()); @@ -519,17 +521,17 @@ AttributeStreamTemplateNode::AttributeStreamTemplateNode(const AttributeTemplate { } -off_t +off_t AttributeStreamTemplateNode::Contains(const char *name, uint32 type) { int32 index = Find(name, type); if (index < 0) return 0; - + return fAttributes[index].fSize; } -void +void AttributeStreamTemplateNode::Rewind() { fCurrentIndex = -1; @@ -556,7 +558,7 @@ AttributeStreamTemplateNode::Get() return fAttributes[fCurrentIndex].fBits; } -bool +bool AttributeStreamTemplateNode::Fill(char *buffer) const { ASSERT(fCurrentIndex < fCount); @@ -565,18 +567,18 @@ AttributeStreamTemplateNode::Fill(char *buffer) const return true; } -int32 +int32 AttributeStreamTemplateNode::Find(const char *name, uint32 type) const { for (int32 index = 0; index < fCount; index++) if (fAttributes[index].fAttributeType == type && strcmp(name, fAttributes[index].fAttributeName) == 0) return index; - + return -1; } -bool +bool AttributeStreamFilterNode::Reject(const char *, uint32 , off_t ) { // simple pass everything filter @@ -600,43 +602,43 @@ AttributeStreamFilterNode::Next() return NULL; } -off_t +off_t AttributeStreamFilterNode::Contains(const char *name, uint32 type) { if (!fReadFrom) return 0; - + off_t size = fReadFrom->Contains(name, type); if (!Reject(name, type, size)) return size; - + return 0; } -off_t +off_t AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint32 type, off_t size, void *buffer, void (*swapFunc)(void *)) { if (!fReadFrom) return 0; - + if (!Reject(name, type, size)) return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc); - + return 0; } -off_t +off_t AttributeStreamFilterNode::Write(const char *name, const char *foreignName, uint32 type, off_t size, const void *buffer) { if (!fWriteTo) return 0; - + if (!Reject(name, type, size)) return fWriteTo->Write(name, foreignName, type, size, buffer); - + return size; } @@ -646,7 +648,7 @@ NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char **nameList) { } -bool +bool NamesToAcceptAttrFilter::Reject(const char *name, uint32 , off_t ) { for (int32 index = 0; ;index++) { @@ -679,7 +681,7 @@ SelectiveAttributeTransformer::~SelectiveAttributeTransformer() delete [] fTransformedBuffers.ItemAt(index); } -void +void SelectiveAttributeTransformer::Rewind() { for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--) @@ -689,13 +691,13 @@ SelectiveAttributeTransformer::Rewind() } -off_t +off_t SelectiveAttributeTransformer::Read(const char *name, const char *foreignName, uint32 type, off_t size, void *buffer, void (*swapFunc)(void *)) { if (!fReadFrom) return 0; - + off_t result = fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc); if (WillTransform(name, type, size, (const char *)buffer)) @@ -704,21 +706,21 @@ SelectiveAttributeTransformer::Read(const char *name, const char *foreignName, return result; } -bool +bool SelectiveAttributeTransformer::WillTransform(const char *name, uint32 , off_t , const char *) const { return strcmp(name, fAttributeNameToTransform) == 0; } -bool +bool SelectiveAttributeTransformer::ApplyTransformer(const char *name, uint32 type, off_t size, char *data) { return (fTransformFunc)(name, type, size, data, fTransformParams); } -char * +char * SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 type, off_t size, const char *data) { @@ -751,15 +753,15 @@ SelectiveAttributeTransformer::Get() { if (!fReadFrom) return NULL; - + const char *result = fReadFrom->Get(); - + if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), fCurrentAttr.Size(), result)) return result; char *transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), fCurrentAttr.Type(), fCurrentAttr.Size(), result); - + // enlist for proper disposal when our job is done if (transformedData) { fTransformedBuffers.AddItem(transformedData); diff --git a/src/kits/tracker/AutoMounter.cpp b/src/kits/tracker/AutoMounter.cpp index 2720930878..806228f2af 100644 --- a/src/kits/tracker/AutoMounter.cpp +++ b/src/kits/tracker/AutoMounter.cpp @@ -34,6 +34,8 @@ All rights reserved. #include "AutoMounter.h" +#include + #include "AutoLock.h" #include "AutoMounterSettings.h" #include "Commands.h" @@ -1021,7 +1023,7 @@ UnmountIfMatchingID(Partition *partition, void *castToParams) text << "To unmount " << partition->VolumeName() << " some query " "windows have to be closed. Would you like to close the query " "windows?"; - BAlert* alert = new BAlert("", text.String(), "Cancel", + BAlert* alert = new BAlert("", text.String(), "Cancel", "Close and unmount", NULL, B_WIDTH_FROM_LABEL); alert->SetShortcut(0, B_ESCAPE); if (alert->Go() == 0) diff --git a/src/kits/tracker/Bitmaps.cpp b/src/kits/tracker/Bitmaps.cpp index 6953a39b39..ed22d54217 100644 --- a/src/kits/tracker/Bitmaps.cpp +++ b/src/kits/tracker/Bitmaps.cpp @@ -60,7 +60,7 @@ BImageResources::BImageResources(void *memAddr) name += ".rsrc"; BFile file(name.String(), B_READ_ONLY); #endif - if (file.InitCheck() == B_OK) + if (file.InitCheck() == B_OK) fResources.SetTo(&file); } } @@ -105,7 +105,7 @@ BImageResources::FinishResources(BResources *res) const const void * BImageResources::LoadResource(type_code type, int32 id, size_t *out_size) const -{ +{ // Serialize execution. // Looks like BResources is not really thread safe. We should // clean that up in the future and remove the locking from here. @@ -196,14 +196,14 @@ BImageResources::GetIconResource(int32 id, const uint8** iconData, image_id BImageResources::find_image(void *memAddr) const { - image_info info; - int32 cookie = 0; - while (get_next_image_info(0, &cookie, &info) == B_OK) + image_info info; + int32 cookie = 0; + while (get_next_image_info(0, &cookie, &info) == B_OK) if ((info.text <= memAddr && (((uint8 *)info.text)+info.text_size) > memAddr) - ||(info.data <= memAddr && (((uint8 *)info.data)+info.data_size) > memAddr)) + ||(info.data <= memAddr && (((uint8 *)info.data)+info.data_size) > memAddr)) // Found the image. return info.id; - + return -1; } @@ -242,7 +242,7 @@ BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap **out) cons return err; } - + static BLocker resLock; static BImageResources *resources = NULL; diff --git a/src/kits/tracker/FilePermissionsView.cpp b/src/kits/tracker/FilePermissionsView.cpp index 5444bb29c5..ff3a94f681 100644 --- a/src/kits/tracker/FilePermissionsView.cpp +++ b/src/kits/tracker/FilePermissionsView.cpp @@ -32,12 +32,13 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ -#include - #include "FilePermissionsView.h" +#include #include +#include + const uint32 kPermissionsChanged = 'prch'; const uint32 kNewOwnerEntered = 'nwow'; @@ -181,7 +182,7 @@ FilePermissionsView::ModelChanged(Model *model) fExecuteUserCheckBox->Show(); fExecuteGroupCheckBox->Show(); fExecuteOtherCheckBox->Show(); - } + } if (node.GetPermissions(&perms) == B_OK) { fReadUserCheckBox->SetValue((int32)(perms & S_IRUSR)); @@ -205,9 +206,9 @@ FilePermissionsView::ModelChanged(Model *model) user << "root"; else user << nodeOwner; - fOwnerTextControl->SetText(user.String()); + fOwnerTextControl->SetText(user.String()); } else - fOwnerTextControl->SetText("Unknown"); + fOwnerTextControl->SetText("Unknown"); if (node.GetGroup(&nodeGroup) == B_OK) { BString group; @@ -218,9 +219,9 @@ FilePermissionsView::ModelChanged(Model *model) group << "0"; else group << nodeGroup; - fGroupTextControl->SetText(group.String()); + fGroupTextControl->SetText(group.String()); } else - fGroupTextControl->SetText("Unknown"); + fGroupTextControl->SetText("Unknown"); // Unless we're root, only allow the owner to transfer the ownership, // i.e. disable text controls if uid:s doesn't match: @@ -276,11 +277,11 @@ FilePermissionsView::MessageReceived(BMessage *message) BNode node(fModel->EntryRef()); - if (node.InitCheck() == B_OK) - node.SetPermissions(newPermissions); + if (node.InitCheck() == B_OK) + node.SetPermissions(newPermissions); else { ModelChanged(fModel); - beep(); + beep(); } } break; @@ -294,11 +295,11 @@ FilePermissionsView::MessageReceived(BMessage *message) node.SetOwner(owner); else { ModelChanged(fModel); - beep(); + beep(); } } else { ModelChanged(fModel); - beep(); + beep(); } } break; @@ -312,11 +313,11 @@ FilePermissionsView::MessageReceived(BMessage *message) node.SetGroup(group); else { ModelChanged(fModel); - beep(); + beep(); } } else { ModelChanged(fModel); - beep(); + beep(); } } break; diff --git a/src/kits/tracker/IconCache.cpp b/src/kits/tracker/IconCache.cpp index b7895f94da..e0a1af1040 100644 --- a/src/kits/tracker/IconCache.cpp +++ b/src/kits/tracker/IconCache.cpp @@ -127,7 +127,7 @@ IconCacheEntry::~IconCacheEntry() } -void +void IconCacheEntry::SetAliasFor(const SharedIconCache *sharedCache, const SharedCacheEntry *entry) { @@ -138,7 +138,7 @@ IconCacheEntry::SetAliasFor(const SharedIconCache *sharedCache, IconCacheEntry * IconCacheEntry::ResolveIfAlias(const SharedIconCache *sharedCache) -{ +{ return sharedCache->ResolveIfAlias(this); } @@ -154,7 +154,7 @@ IconCacheEntry::ResolveIfAlias(const SharedIconCache *sharedCache, } -bool +bool IconCacheEntry::CanConstructBitmap(IconDrawMode mode, icon_size) const { if (mode == kSelected) @@ -165,7 +165,7 @@ IconCacheEntry::CanConstructBitmap(IconDrawMode mode, icon_size) const } -bool +bool IconCacheEntry::HaveIconBitmap(IconDrawMode mode, icon_size size) const { ASSERT(mode == kSelected || mode == kNormalIcon); @@ -193,7 +193,7 @@ IconCacheEntry::IconForMode(IconDrawMode mode, icon_size size) const { ASSERT(mode == kSelected || mode == kNormalIcon); // for now only - + if (mode == kNormalIcon) { if (size == B_MINI_ICON) return fMiniIcon; @@ -209,7 +209,7 @@ IconCacheEntry::IconForMode(IconDrawMode mode, icon_size size) const } -bool +bool IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) const { ASSERT(where.x < size && where.y < size); @@ -249,7 +249,7 @@ IconCacheEntry::ConstructBitmap(BBitmap *constructFrom, IconDrawMode requestedMo // for now if (requestedMode == kSelected && constructFromMode == kNormalIcon) return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size, lazyBitmap); - + return NULL; } @@ -277,7 +277,7 @@ IconCacheEntry::AlternateModeForIconConstructing(IconDrawMode requestedMode, } -void +void IconCacheEntry::SetIcon(BBitmap *bitmap, IconDrawMode mode, icon_size size, bool /*create*/) { @@ -318,7 +318,7 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature, { ASSERT(fSharedCache.IsLocked()); - if (!preferredApp[0]) + if (!preferredApp[0]) return NULL; if (!entry) { @@ -329,7 +329,7 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature, PRINT(("File %s; Line %d # looking for %s, type %s, found %x\n", __FILE__, __LINE__, preferredApp, fileTypeSignature, entry)); #endif - if (entry->HaveIconBitmap(mode, size)) + if (entry->HaveIconBitmap(mode, size)) return entry; } } @@ -343,7 +343,7 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature, BString signature(fileTypeSignature); signature.ToLower(); if (preferredAppType.GetIconForType(signature.String(), lazyBitmap->Get(), - size) != B_OK) + size) != B_OK) return NULL; BBitmap *bitmap = lazyBitmap->Adopt(); @@ -377,7 +377,7 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, if (entry) { entry = entry->ResolveIfAlias(&fSharedCache, entry); // metamime defines an icon and we have it cached - if (entry->HaveIconBitmap(mode, size)) + if (entry->HaveIconBitmap(mode, size)) return entry; } @@ -389,7 +389,7 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, // try getting the icon directly from the metamime if (mime.GetIcon(lazyBitmap->Get(), size) != B_OK) { // try getting it from the preferred app of this type - char preferredAppSig[B_MIME_TYPE_LENGTH]; + char preferredAppSig[B_MIME_TYPE_LENGTH]; if (mime.GetPreferredApp(preferredAppSig) != B_OK) return NULL; @@ -399,8 +399,8 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, // look for icon defined by preferred app from metamime aliasTo = (SharedCacheEntry *)GetIconForPreferredApp(fileType, - preferredAppSig, mode, size, lazyBitmap, aliasTo); - + preferredAppSig, mode, size, lazyBitmap, aliasTo); + if (aliasTo == NULL) return NULL; @@ -422,7 +422,7 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, PRINT_ADD_ITEM(("File %s; Line %d # adding entry for type %s\n", __FILE__, __LINE__, fileType)); entry = fSharedCache.AddItem(fileType); - } + } entry->SetIcon(bitmap, kNormalIcon, size); } @@ -488,8 +488,8 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener, entry = GetIconFromMetaMime(superTypeFileType, mode, size, lazyBitmap, entry); #if DEBUG - else - PRINT(("File %s; Line %d # failed to get supertype for type %s\n", + else + PRINT(("File %s; Line %d # failed to get supertype for type %s\n", __FILE__, __LINE__, fileType)); #endif } @@ -499,16 +499,16 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener, if (nodePreferredApp[0]) { // we got a miss using GetIconForPreferredApp before, cache this // fileType/preferredApp combo with an aliased entry - + // make an aliased entry so that the next time we get a // hit and substitute a generic icon right away - + PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for preferredApp %s, type %s\n", __FILE__, __LINE__, nodePreferredApp, fileType)); IconCacheEntry *aliasedEntry = fSharedCache.AddItem((SharedCacheEntry **)&entry, fileType, nodePreferredApp); aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry *)entry); - // OK to cast here, have a runtime check + // OK to cast here, have a runtime check source = kPreferredAppForNode; // set source as preferred for node, so that next time we get a hit in // the initial find that uses GetIconForPreferredApp @@ -529,7 +529,7 @@ IconCache::GetVolumeIcon(AutoLock *nodeCacheLocker, AutoLock **resultingOpenCache, Model *model, IconSource &source, IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap) -{ +{ *resultingOpenCache = nodeCacheLocker; nodeCacheLocker->Lock(); @@ -548,7 +548,7 @@ IconCache::GetVolumeIcon(AutoLock *nodeCacheLocker, sharedCacheLocker->Lock(); } - if (entry->HaveIconBitmap(mode, size)) + if (entry->HaveIconBitmap(mode, size)) return entry; } } @@ -568,7 +568,7 @@ IconCache::GetVolumeIcon(AutoLock *nodeCacheLocker, entry = fNodeCache.AddItem(model->NodeRef()); } entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size); - } else if (volume.GetIcon(lazyBitmap->Get(), size) == B_OK) { + } else if (volume.GetIcon(lazyBitmap->Get(), size) == B_OK) { // Ask the device for an icon BBitmap *bitmap = lazyBitmap->Adopt(); ASSERT(bitmap); @@ -605,10 +605,10 @@ IconCache::GetRootIcon(AutoLock *, AutoLock **resultingOpenCache, Model *, IconSource &source, IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap) -{ +{ *resultingOpenCache = sharedCacheLocker; (*resultingOpenCache)->Lock(); - + source = kTrackerSupplied; return GetIconFromMetaMime(B_ROOT_MIMETYPE, mode, size, lazyBitmap, 0); } @@ -639,7 +639,7 @@ IconCache::GetWellKnownIcon(AutoLock *, entry = fSharedCache.FindItem(type.String()); if (entry) { entry = entry->ResolveIfAlias(&fSharedCache, entry); - if (entry->HaveIconBitmap(mode, size)) + if (entry->HaveIconBitmap(mode, size)) return entry; } @@ -732,7 +732,7 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener, Model *model, IconSource &source, IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry, bool permanent) -{ +{ *resultingOpenCache = nodeCacheLocker; (*resultingOpenCache)->Lock(); @@ -747,12 +747,12 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener, // an app if (model->IsExecutable()) file = dynamic_cast(model->Node()); - + PRINT_DISK_HITS(("File %s; Line %d # hitting disk for node %s\n", __FILE__, __LINE__, model->Name())); status_t result; - if (file) + if (file) result = GetAppIconFromAttr(file, lazyBitmap->Get(), size); else result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(), size); @@ -773,7 +773,7 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener, source = kNode; } } - + if (!entry) { (*resultingOpenCache)->Unlock(); *resultingOpenCache = NULL; @@ -794,7 +794,7 @@ IconCache::GetGenericIcon(AutoLock *sharedCacheLocker, Model *model, IconSource &source, IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry) -{ +{ *resultingOpenCache = sharedCacheLocker; (*resultingOpenCache)->Lock(); @@ -803,7 +803,7 @@ IconCache::GetGenericIcon(AutoLock *sharedCacheLocker, if (!entry) return NULL; - + // make an aliased entry so that the next time we get a // hit and substitute a generic icon right away PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", @@ -826,13 +826,13 @@ IconCache::GetFallbackIcon(AutoLock *sharedCacheLocker, AutoLock **resultingOpenCache, Model *model, IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry) -{ +{ *resultingOpenCache = sharedCacheLocker; (*resultingOpenCache)->Lock(); entry = fSharedCache.AddItem(model->MimeType(), model->PreferredAppSignature()); - + BBitmap *bitmap = lazyBitmap->Get(); GetTrackerResources()->GetIconResource(kResFileIcon, size, bitmap); entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size); @@ -867,10 +867,10 @@ IconCache::Preload(AutoLock *nodeCacheLocker, // closing it when we are done LazyBitmapAllocator lazyBitmap(size); // lazyBitmap manages bitmap allocation and freeing if needed - + IconSource source = model->IconFrom(); if (source == kUnknownSource || source == kUnknownNotFromNode) { - + // fish for special first models and handle them appropriately if (model->IsVolume()) { // volume may use specialized icon in the volume node @@ -896,26 +896,26 @@ IconCache::Preload(AutoLock *nodeCacheLocker, entry = GetNodeIcon(&modelOpener, nodeCacheLocker, &resultingOpenCache, model, source, mode, size, &lazyBitmap, entry, permanent); - - + + if (!entry) { // no node icon, look for file type based one modelOpener.OpenNode(); // use file types to get the icon resultingOpenCache = sharedCacheLocker; resultingOpenCache->Lock(); - + entry = GetIconFromFileTypes(&modelOpener, source, mode, size, &lazyBitmap, 0); if (!entry) // we don't have an icon, go with the generic entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache, model, source, mode, size, &lazyBitmap, entry); - } - } + } + } // update the icon source model->SetIconFrom(source); - + } else { // we already know where the icon should come from, // use shortcuts to get it @@ -923,7 +923,7 @@ IconCache::Preload(AutoLock *nodeCacheLocker, case kNode: resultingOpenCache = nodeCacheLocker; resultingOpenCache->Lock(); - + entry = GetNodeIcon(&modelOpener, nodeCacheLocker, &resultingOpenCache, model, source, mode, size, &lazyBitmap, entry, permanent); @@ -976,7 +976,7 @@ IconCache::Preload(AutoLock *nodeCacheLocker, &lazyBitmap, 0); ASSERT(!entry || entry->HaveIconBitmap(mode, size)); - if (!entry || !entry->HaveIconBitmap(mode, size)) + if (!entry || !entry->HaveIconBitmap(mode, size)) // we don't have an icon, go with the generic entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache, model, source, mode, size, &lazyBitmap, entry); @@ -998,7 +998,7 @@ IconCache::Preload(AutoLock *nodeCacheLocker, TRESPASS(); } } - + if (!entry || !entry->HaveIconBitmap(mode, size)) { // we don't have an icon, go with the generic PRINT(("icon cache complete miss, falling back on generic icon for %s\n", @@ -1007,7 +1007,7 @@ IconCache::Preload(AutoLock *nodeCacheLocker, model, source, mode, size, &lazyBitmap, entry); // we don't even have generic, something is really broken, - // go with hardcoded generic icon + // go with hardcoded generic icon if (!entry || !entry->HaveIconBitmap(mode, size)) { PRINT(("icon cache complete miss, falling back on generic icon for %s\n", model->Name())); @@ -1020,9 +1020,9 @@ IconCache::Preload(AutoLock *nodeCacheLocker, model->SetIconFrom(kUnknownSource); } } - + ASSERT(entry && entry->HaveIconBitmap(mode, size)); - + if (resultingCache) *resultingCache = resultingOpenCache; @@ -1040,7 +1040,7 @@ IconCache::Draw(Model *model, BView *view, BPoint where, IconDrawMode mode, AutoLock nodeCacheLocker(&fNodeCache, false); AutoLock sharedCacheLocker(&fSharedCache, false); - AutoLock *resultingCacheLocker; + AutoLock *resultingCacheLocker; IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker, &resultingCacheLocker, model, mode, size, false); // Preload finds/creates the appropriate entry, locking down the @@ -1054,21 +1054,21 @@ IconCache::Draw(Model *model, BView *view, BPoint where, IconDrawMode mode, // got the entry, now draw it resultingCacheLocker->LockedItem()->Draw(entry, view, where, mode, size, async); - + // either of the two cache lockers that got locked down by this call get // unlocked at this point } -void +void IconCache::SyncDraw(Model *model, BView *view, BPoint where, IconDrawMode mode, - icon_size size, void (*blitFunc)(BView *, BPoint, BBitmap *, void *), + icon_size size, void (*blitFunc)(BView *, BPoint, BBitmap *, void *), void *passThruState) { AutoLock nodeCacheLocker(&fNodeCache, false); AutoLock sharedCacheLocker(&fSharedCache, false); - AutoLock *resultingCacheLocker; + AutoLock *resultingCacheLocker; IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker, &resultingCacheLocker, model, mode, size, false); @@ -1082,7 +1082,7 @@ IconCache::SyncDraw(Model *model, BView *view, BPoint where, IconDrawMode mode, } -void +void IconCache::Preload(Model *model, IconDrawMode mode, icon_size size, bool permanent) { AutoLock nodeCacheLocker(&fNodeCache, false); @@ -1092,7 +1092,7 @@ IconCache::Preload(Model *model, IconDrawMode mode, icon_size size, bool permane } -status_t +status_t IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size) { AutoLock sharedCacheLocker(&fSharedCache); @@ -1106,14 +1106,14 @@ IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size) // try getting the icon from the preferred app for the signature IconCacheEntry *entry = GetIconForPreferredApp(fileType, preferredAppSig, - mode, size, &lazyBitmap, 0); + mode, size, &lazyBitmap, 0); if (entry) return B_OK; // try getting the icon directly from the metamime result = mime.GetIcon(lazyBitmap.Get(), size); - - if (result != B_OK) + + if (result != B_OK) return result; entry = fSharedCache.AddItem(fileType); @@ -1133,24 +1133,24 @@ IconCache::Deleting(const Model *model) { AutoLock lock(&fNodeCache); - if (model->IconFrom() == kNode) + if (model->IconFrom() == kNode) fNodeCache.Deleting(model->NodeRef()); - + // don't care if the node uses the shared cache } -void +void IconCache::Removing(const Model *model) { AutoLock lock(&fNodeCache); - if (model->IconFrom() == kNode) + if (model->IconFrom() == kNode) fNodeCache.Removing(model->NodeRef()); } -void +void IconCache::Deleting(const BView *view) { AutoLock lock(&fNodeCache); @@ -1158,32 +1158,32 @@ IconCache::Deleting(const BView *view) } -void +void IconCache::IconChanged(Model *model) { AutoLock lock(&fNodeCache); - if (model->IconFrom() == kNode || model->IconFrom() == kVolume) + if (model->IconFrom() == kNode || model->IconFrom() == kVolume) fNodeCache.Deleting(model->NodeRef()); model->ResetIconFrom(); } -void +void IconCache::IconChanged(const char *mimeType, const char *appSignature) { AutoLock sharedLock(&fSharedCache); SharedCacheEntry *entry = fSharedCache.FindItem(mimeType, appSignature); - if (!entry) + if (!entry) return; AutoLock nodeLock(&fNodeCache); - + entry = (SharedCacheEntry *)fSharedCache.ResolveIfAlias(entry); ASSERT(entry); int32 index = fSharedCache.EntryIndex(entry); - + fNodeCache.RemoveAliasesTo(index); fSharedCache.RemoveAliasesTo(index); @@ -1191,7 +1191,7 @@ IconCache::IconChanged(const char *mimeType, const char *appSignature) } -BBitmap * +BBitmap * IconCache::MakeSelectedIcon(const BBitmap *normal, icon_size size, LazyBitmapAllocator *lazyBitmap) { @@ -1208,17 +1208,17 @@ DumpBitmap(const BBitmap *bitmap) return; } int32 length = bitmap->BitsLength(); - + printf("data length %ld \n", length); - + int32 columns = (int32)bitmap->Bounds().Width() + 1; const unsigned char *bitPtr = (const unsigned char *)bitmap->Bits(); for (; length >= 0; length--) { - for (int32 columnIndex = 0; columnIndex < columns; + for (int32 columnIndex = 0; columnIndex < columns; columnIndex++, length--) printf("%c%c", "0123456789ABCDEF"[(*bitPtr)/0x10], "0123456789ABCDEF"[(*bitPtr++)%0x10]); - + printf("\n"); } printf("\n"); @@ -1242,7 +1242,7 @@ IconCache::InitHiliteTable() } -BBitmap * +BBitmap * IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/, int32 colorTransformTable[], LazyBitmapAllocator* lazyBitmap) { @@ -1305,14 +1305,14 @@ IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/, } -bool -IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode, +bool +IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode, icon_size size) { AutoLock nodeCacheLocker(&fNodeCache, false); AutoLock sharedCacheLocker(&fSharedCache, false); - AutoLock *resultingCacheLocker; + AutoLock *resultingCacheLocker; IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker, &resultingCacheLocker, const_cast(model), mode, size, false); // Preload finds/creates the appropriate entry, locking down the @@ -1325,7 +1325,7 @@ IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode, } -void +void IconCacheEntry::RetireIcons(BObjectList *retiredBitmapList) { if (fLargeIcon) { @@ -1344,7 +1344,7 @@ IconCacheEntry::RetireIcons(BObjectList *retiredBitmapList) retiredBitmapList->AddItem(fHilitedMiniIcon); fHilitedMiniIcon = NULL; } - + int32 count = retiredBitmapList->CountItems(); if (count > 10 * 1024) { PRINT(("nuking old icons from the retired bitmap list\n")); @@ -1378,7 +1378,7 @@ SharedIconCache::SharedIconCache() } -void +void SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, IconDrawMode mode, icon_size size, bool async) { @@ -1386,12 +1386,12 @@ SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, } -void +void SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, - IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint, + IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint, BBitmap *, void *), void *passThruState) { - ((SharedCacheEntry *)entry)->Draw(view, where, mode, size, + ((SharedCacheEntry *)entry)->Draw(view, where, mode, size, blitFunc, passThruState); } @@ -1408,14 +1408,14 @@ SharedIconCache::FindItem(const char *fileType, const char *appSignature) const if (!result) return NULL; - + for(;;) { - if (result->fFileType == fileType && result->fAppSignature == appSignature) + if (result->fFileType == fileType && result->fAppSignature == appSignature) return result; - + if (result->fNext < 0) break; - + result = const_cast(&fElementArray.At(result->fNext)); } @@ -1430,7 +1430,7 @@ SharedIconCache::AddItem(const char *fileType, const char *appSignature) if (!fileType) fileType = B_FILE_MIMETYPE; - SharedCacheEntry *result = &fHashTable.Add(SharedCacheEntry::Hash(fileType, + SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType, appSignature)); result->SetTo(fileType, appSignature); return result; @@ -1448,7 +1448,7 @@ SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileTy if (!fileType) fileType = B_FILE_MIMETYPE; - SharedCacheEntry *result = &fHashTable.Add(SharedCacheEntry::Hash(fileType, + SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType, appSignature)); result->SetTo(fileType, appSignature); *outstandingEntry = fHashTable.ElementAt(entryToken); @@ -1457,7 +1457,7 @@ SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileTy } -void +void SharedIconCache::IconChanged(SharedCacheEntry *entry) { // by now there should be no aliases to entry, just remove entry @@ -1468,7 +1468,7 @@ SharedIconCache::IconChanged(SharedCacheEntry *entry) } -void +void SharedIconCache::RemoveAliasesTo(int32 aliasIndex) { int32 count = fHashTable.VectorSize(); @@ -1480,7 +1480,7 @@ SharedIconCache::RemoveAliasesTo(int32 aliasIndex) } -void +void SharedIconCache::SetAliasFor(IconCacheEntry *alias, const SharedCacheEntry *original) const { alias->fAliasForIndex = fHashTable.ElementIndex(original); @@ -1501,7 +1501,7 @@ SharedCacheEntry::SharedCacheEntry(const char *fileType, const char *appSignatur } -void +void SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, bool async) { @@ -1518,7 +1518,7 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s } else { view->SetDrawingMode(B_OP_OVER); } - + if (async) view->DrawBitmapAsync(bitmap, where); else @@ -1528,26 +1528,26 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s } -void +void SharedCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState) { BBitmap *bitmap = IconForMode(mode, size); if (!bitmap) return; - + // if (bitmap->ColorSpace() == B_RGBA32) { // view->SetDrawingMode(B_OP_ALPHA); // view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); // } else { // view->SetDrawingMode(B_OP_OVER); // } -// +// (blitFunc)(view, where, bitmap, passThruState); } -uint32 +uint32 SharedCacheEntry::Hash(const char *fileType, const char *appSignature) { uint32 hash = HashString(fileType, 0); @@ -1558,7 +1558,7 @@ SharedCacheEntry::Hash(const char *fileType, const char *appSignature) } -uint32 +uint32 SharedCacheEntry::Hash() const { uint32 hash = HashString(fFileType.String(), 0); @@ -1569,14 +1569,14 @@ SharedCacheEntry::Hash() const } -bool +bool SharedCacheEntry::operator==(const SharedCacheEntry &entry) const { return fFileType == entry.FileType() && fAppSignature == entry.AppSignature(); } -void +void SharedCacheEntry::SetTo(const char *fileType, const char *appSignature) { fFileType = fileType; @@ -1590,10 +1590,10 @@ SharedCacheEntryArray::SharedCacheEntryArray(int32 initialSize) } -SharedCacheEntry * +SharedCacheEntry * SharedCacheEntryArray::Add() { - return &At(OpenHashElementArray::Add()); + return OpenHashElementArray::Add(); } @@ -1615,14 +1615,14 @@ NodeCacheEntry::NodeCacheEntry(const node_ref *node, bool permanent) } -void +void NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size, bool async) { BBitmap *bitmap = IconForMode(mode, size); if (!bitmap) return; - + drawing_mode oldMode = view->DrawingMode(); if (bitmap->ColorSpace() == B_RGBA32) { @@ -1633,7 +1633,7 @@ NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size siz } else { view->SetDrawingMode(B_OP_OVER); } - + if (false && async) { TRESPASS(); // need to copy the bits first in here @@ -1645,21 +1645,21 @@ NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size siz } -void +void NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState) { BBitmap *bitmap = IconForMode(mode, size); if (!bitmap) return; - + // if (bitmap->ColorSpace() == B_RGBA32) { // view->SetDrawingMode(B_OP_ALPHA); // view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); // } else { // view->SetDrawingMode(B_OP_OVER); // } - + (blitFunc)(view, where, bitmap, passThruState); } @@ -1671,42 +1671,42 @@ NodeCacheEntry::Node() const } -uint32 +uint32 NodeCacheEntry::Hash() const { return Hash(&fRef); } -uint32 +uint32 NodeCacheEntry::Hash(const node_ref *node) { return node->device ^ ((uint32 *)&node->node)[0] ^ ((uint32 *)&node->node)[1]; } -bool +bool NodeCacheEntry::operator==(const NodeCacheEntry &entry) const { return fRef == entry.fRef; } -void +void NodeCacheEntry::SetTo(const node_ref *node) { fRef = *node; } -bool +bool NodeCacheEntry::Permanent() const { return fPermanent; } -void +void NodeCacheEntry::MakePermanent() { fPermanent = true; @@ -1731,7 +1731,7 @@ NodeIconCache::NodeIconCache() } -void +void NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, IconDrawMode mode, icon_size size, bool async) { @@ -1740,12 +1740,12 @@ NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, } -void +void NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, - IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint, + IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint, BBitmap *, void *), void *passThruState) { - ((NodeCacheEntry *)entry)->Draw(view, where, mode, size, + ((NodeCacheEntry *)entry)->Draw(view, where, mode, size, blitFunc, passThruState); } @@ -1757,14 +1757,14 @@ NodeIconCache::FindItem(const node_ref *node) const if (!result) return NULL; - + for(;;) { if (*result->Node() == *node) return result; - + if (result->fNext < 0) break; - + result = const_cast(&fElementArray.At(result->fNext)); } @@ -1775,7 +1775,7 @@ NodeIconCache::FindItem(const node_ref *node) const NodeCacheEntry * NodeIconCache::AddItem(const node_ref *node, bool permanent) { - NodeCacheEntry *result = &fHashTable.Add(NodeCacheEntry::Hash(node)); + NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node)); result->SetTo(node); if (permanent) result->MakePermanent(); @@ -1789,7 +1789,7 @@ NodeIconCache::AddItem(NodeCacheEntry **outstandingEntry, const node_ref *node) { int32 entryToken = fHashTable.ElementIndex(*outstandingEntry); - NodeCacheEntry *result = &fHashTable.Add(NodeCacheEntry::Hash(node)); + NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node)); result->SetTo(node); *outstandingEntry = fHashTable.ElementAt(entryToken); @@ -1797,31 +1797,31 @@ NodeIconCache::AddItem(NodeCacheEntry **outstandingEntry, const node_ref *node) } -void +void NodeIconCache::Deleting(const node_ref *node) { NodeCacheEntry *entry = FindItem(node); ASSERT(entry); if (!entry || entry->Permanent()) return; - + fHashTable.Remove(entry); } -void +void NodeIconCache::Removing(const node_ref *node) { NodeCacheEntry *entry = FindItem(node); ASSERT(entry); if (!entry) return; - + fHashTable.Remove(entry); } -void +void NodeIconCache::Deleting(const BView *) { #ifdef NODE_CACHE_ASYNC_DRAWS @@ -1830,14 +1830,14 @@ NodeIconCache::Deleting(const BView *) } -void +void NodeIconCache::IconChanged(const Model *model) { Deleting(model->NodeRef()); } -void +void NodeIconCache::RemoveAliasesTo(int32 aliasIndex) { int32 count = fHashTable.VectorSize(); @@ -1861,7 +1861,7 @@ NodeCacheEntryArray::NodeCacheEntryArray(int32 initialSize) NodeCacheEntry * NodeCacheEntryArray::Add() { - return &At(OpenHashElementArray::Add()); + return OpenHashElementArray::Add(); } @@ -1874,8 +1874,8 @@ SimpleIconCache::SimpleIconCache(const char *name) } -void -SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode , +void +SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode , icon_size , bool ) { TRESPASS(); @@ -1883,7 +1883,7 @@ SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode , } -void +void SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode, icon_size, void(*)(BView *, BPoint, BBitmap *, void *), void *) { @@ -1892,21 +1892,21 @@ SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode, icon_size } -bool +bool SimpleIconCache::Lock() { return fLock.Lock(); } -void +void SimpleIconCache::Unlock() { fLock.Unlock(); } -bool +bool SimpleIconCache::IsLocked() const { return fLock.IsLocked(); @@ -1948,7 +1948,7 @@ LazyBitmapAllocator::Adopt() { if (!fBitmap) Get(); - + BBitmap *result = fBitmap; fBitmap = NULL; return result; diff --git a/src/kits/tracker/MountMenu.cpp b/src/kits/tracker/MountMenu.cpp index 410b612d77..5c9171ee98 100644 --- a/src/kits/tracker/MountMenu.cpp +++ b/src/kits/tracker/MountMenu.cpp @@ -34,6 +34,7 @@ All rights reserved. // MountMenu implements a context menu used for mounting/unmounting volumes +#include #include #include #include diff --git a/src/kits/tracker/OpenHashTable.h b/src/kits/tracker/OpenHashTable.h deleted file mode 100644 index 09858541f1..0000000000 --- a/src/kits/tracker/OpenHashTable.h +++ /dev/null @@ -1,376 +0,0 @@ -/* -Open Tracker License - -Terms and Conditions - -Copyright (c) 1991-2000, Be Incorporated. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice applies to all licensees -and shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Be Incorporated shall not be -used in advertising or otherwise to promote the sale, use or other dealings in -this Software without prior written authorization from Be Incorporated. - -Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks -of Be Incorporated in the United States and other countries. Other brand product -names are registered trademarks or trademarks of their respective holders. -All rights reserved. -*/ - -// Hash table with open addresssing - -#ifndef __OPEN_HASH_TABLE__ -#define __OPEN_HASH_TABLE__ - -#include -#include - -namespace BPrivate { - -template -class ElementVector { - // element vector for OpenHashTable needs to implement this - // interface - public: - Element &At(int32 index); - Element *Add(); - int32 IndexOf(const Element &) const; - void Remove(int32 index); -}; - -class OpenHashElement { - public: - uint32 Hash() const; - bool operator==(const OpenHashElement &) const; - void Adopt(OpenHashElement &); - // low overhead copy, original element is in undefined state - // after call (calls Adopt on BString members, etc.) - int32 fNext; -}; - -const uint32 kPrimes [] = { - 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, - 524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859, - 134217689, 268435399, 536870909, 1073741789, 2147483647, 0 -}; - -template > -class OpenHashTable { - public: - OpenHashTable(int32 minSize, ElementVec *elementVector = 0); - // it is up to the subclass of OpenHashTable to supply - // elementVector - ~OpenHashTable(); - - void SetElementVector(ElementVec *elementVector); - - Element *FindFirst(uint32 elementHash) const; - Element &Add(uint32 elementHash); - - void Remove(Element *); - - // when calling Add, any outstanding element pointer may become - // invalid; to deal with this, get the element index and restore - // it after the add - int32 ElementIndex(const Element *) const; - Element *ElementAt(int32 index) const; - - int32 VectorSize() const; - - protected: - static int32 OptimalSize(int32 minSize); - - int32 fArraySize; - int32 *fHashArray; - ElementVec *fElementVector; -}; - - -template -class OpenHashElementArray : public ElementVector { - // this is a straightforward implementation of an element vector - // deleting is handled by linking deleted elements into a free list - // the vector never shrinks - public: - OpenHashElementArray(int32 initialSize); - ~OpenHashElementArray(); - - Element &At(int32 index); - const Element &At(int32 index) const; - int32 Add(const Element &); - int32 Add(); - void Remove(int32 index); - int32 IndexOf(const Element &) const; - int32 Size() const; - - private: - Element *fData; - int32 fSize; - int32 fNextFree; - int32 fNextDeleted; -}; - - -//--- inline implementation -------------------------------- - - -template -OpenHashTable::OpenHashTable(int32 minSize,ElementVec *elementVector) - : - fArraySize(OptimalSize(minSize)), - fElementVector(elementVector) -{ - fHashArray = new int32[fArraySize]; - for (int32 index = 0; index < fArraySize; index++) - fHashArray[index] = -1; -} - - -template -OpenHashTable::~OpenHashTable() -{ - delete fHashArray; -} - - -template -int32 -OpenHashTable::OptimalSize(int32 minSize) -{ - for (int32 index = 0; ; index++) - if (!kPrimes[index] || kPrimes[index] >= (uint32)minSize) - return (int32)kPrimes[index]; - - return 0; -} - - -template -Element * -OpenHashTable::FindFirst(uint32 hash) const -{ - ASSERT(fElementVector); - hash %= fArraySize; - if (fHashArray[hash] < 0) - return 0; - - return &fElementVector->At(fHashArray[hash]); -} - - -template -int32 -OpenHashTable::ElementIndex(const Element *element) const -{ - return fElementVector->IndexOf(*element); -} - - -template -Element * -OpenHashTable::ElementAt(int32 index) const -{ - return &fElementVector->At(index); -} - - -template -int32 -OpenHashTable::VectorSize() const -{ - return fElementVector->Size(); -} - - -template -Element & -OpenHashTable::Add(uint32 hash) -{ - ASSERT(fElementVector); - hash %= fArraySize; - Element &result = *fElementVector->Add(); - result.fNext = fHashArray[hash]; - fHashArray[hash] = fElementVector->IndexOf(result); - return result; -} - - -template -void -OpenHashTable::Remove(Element *element) -{ - uint32 hash = element->Hash() % fArraySize; - int32 next = fHashArray[hash]; - ASSERT(next >= 0); - - if (&fElementVector->At(next) == element) { - fHashArray[hash] = element->fNext; - fElementVector->Remove(next); - return; - } - - for (int32 index = next; index >= 0; ) { - // look for an existing match in table - int32 next = fElementVector->At(index).fNext; - if (next < 0) { - TRESPASS(); - return; - } - - if (&fElementVector->At(next) == element) { - fElementVector->At(index).fNext = element->fNext; - fElementVector->Remove(next); - return; - } - index = next; - } -} - - -template -void -OpenHashTable::SetElementVector(ElementVec *elementVector) -{ - fElementVector = elementVector; -} - - -template -OpenHashElementArray::OpenHashElementArray(int32 initialSize) - : - fSize(initialSize), - fNextFree(0), - fNextDeleted(-1) -{ - fData = (Element *)calloc((size_t)initialSize , sizeof(Element)); - if (!fData) - throw std::bad_alloc(); -} - - -template -OpenHashElementArray::~OpenHashElementArray() -{ - free(fData); -} - - -template -Element & -OpenHashElementArray::At(int32 index) -{ - ASSERT(index < fSize); - return fData[index]; -} - - -template -const Element & -OpenHashElementArray::At(int32 index) const -{ - ASSERT(index < fSize); - return fData[index]; -} - - -template -int32 -OpenHashElementArray::IndexOf(const Element &element) const -{ - int32 result = &element - fData; - if (result < 0 || result > fSize) - return -1; - - return result; -} - - -template -int32 -OpenHashElementArray::Size() const -{ - return fSize; -} - - -template -int32 -OpenHashElementArray::Add(const Element &newElement) -{ - int32 index = Add(); - At(index).Adopt(newElement); - return index; -} - - -#if DEBUG -const int32 kGrowChunk = 10; -#else -const int32 kGrowChunk = 1024; -#endif - - -template -int32 -OpenHashElementArray::Add() -{ - int32 index = fNextFree; - if (fNextDeleted >= 0) { - index = fNextDeleted; - fNextDeleted = At(index).fNext; - } else if (fNextFree >= fSize - 1) { - int32 newSize = fSize + kGrowChunk; - Element *newData = (Element *)calloc((size_t)newSize , sizeof(Element)); - if (!newData) - throw std::bad_alloc(); - memcpy(newData, fData, fSize * sizeof(Element)); - free(fData); - fData = newData; - fSize = newSize; - index = fNextFree; - fNextFree++; - } else - fNextFree++; - - new (&At(index)) Element; - // call placement new to initialize the element properly - ASSERT(At(index).fNext == -1); - - return index; -} - - -template -void -OpenHashElementArray::Remove(int32 index) -{ - // delete by chaining empty elements in a single linked - // list, reusing the next field - ASSERT(index < fSize); - At(index).~Element(); - // call the destructor explicitly to destroy the element - // properly - At(index).fNext = fNextDeleted; - fNextDeleted = index; -} - -} // namespace BPrivate - -using namespace BPrivate; - -#endif diff --git a/src/kits/tracker/TaskLoop.cpp b/src/kits/tracker/TaskLoop.cpp index fe10f58ee2..08eb249eb5 100644 --- a/src/kits/tracker/TaskLoop.cpp +++ b/src/kits/tracker/TaskLoop.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#include #include #include "AutoLock.h" @@ -60,7 +61,7 @@ OneShotDelayedTask::~OneShotDelayedTask() } -bool +bool OneShotDelayedTask::RunIfNeeded(bigtime_t currentTime) { if (currentTime < fRunAfter) @@ -86,7 +87,7 @@ PeriodicDelayedTask::~PeriodicDelayedTask() } -bool +bool PeriodicDelayedTask::RunIfNeeded(bigtime_t currentTime) { if (!currentTime < fRunAfter) @@ -107,7 +108,7 @@ PeriodicDelayedTaskWithTimeout::PeriodicDelayedTaskWithTimeout( } -bool +bool PeriodicDelayedTaskWithTimeout::RunIfNeeded(bigtime_t currentTime) { if (currentTime < fRunAfter) @@ -137,7 +138,7 @@ RunWhenIdleTask::~RunWhenIdleTask() } -bool +bool RunWhenIdleTask::RunIfNeeded(bigtime_t currentTime) { if (currentTime < fRunAfter) @@ -146,7 +147,7 @@ RunWhenIdleTask::RunIfNeeded(bigtime_t currentTime) fRunAfter = currentTime + fPeriod; // PRINT(("runWhenIdle: runAfter %Ld, current time %Ld, period %Ld\n", // fRunAfter, currentTime, fPeriod)); - + if (fState == kInitialDelay) { // PRINT(("run when idle task - past intial delay\n")); ResetIdleTimer(currentTime); @@ -175,7 +176,7 @@ ActivityLevel() } -void +void RunWhenIdleTask::ResetIdleTimer(bigtime_t currentTime) { fActivityLevel = ActivityLevel(); @@ -194,14 +195,14 @@ RunWhenIdleTask::IsIdle(bigtime_t currentTime, float taskOverhead) bigtime_t currentActivityLevel = ActivityLevel(); float load = (float)(currentActivityLevel - fActivityLevel) / (float)(currentTime - fActivityLevelStart); - + fActivityLevel = currentActivityLevel; fActivityLevelStart = currentTime; load -= taskOverhead; - + bool idle = true; - + if (load > kIdleTreshold) { // PRINT(("not idle enough %f\n", load)); idle = false; @@ -230,7 +231,7 @@ RunWhenIdleTask::IdleTimerExpired(bigtime_t currentTime) } -bool +bool RunWhenIdleTask::StillIdle(bigtime_t currentTime) { return IsIdle(currentTime, kIdleTreshold); @@ -245,11 +246,11 @@ TaskLoop::TaskLoop(bigtime_t heartBeat) TaskLoop::~TaskLoop() -{ +{ } -void +void TaskLoop::RunLater(DelayedTask *task) { AddTask(task); @@ -263,7 +264,7 @@ TaskLoop::RunLater(FunctionObject *functor, bigtime_t delay) } -void +void TaskLoop::RunLater(FunctionObjectWithResult *functor, bigtime_t delay, bigtime_t period) { @@ -271,7 +272,7 @@ TaskLoop::RunLater(FunctionObjectWithResult *functor, } -void +void TaskLoop::RunLater(FunctionObjectWithResult *functor, bigtime_t delay, bigtime_t period, bigtime_t timeout) { @@ -279,7 +280,7 @@ TaskLoop::RunLater(FunctionObjectWithResult *functor, bigtime_t delay, } -void +void TaskLoop::RunWhenIdle(FunctionObjectWithResult *functor, bigtime_t initialDelay, bigtime_t idleTime, bigtime_t heartBeat) { @@ -298,20 +299,20 @@ public: maxAccumulatingTime(maxAccumulatingTime), initialTime(system_time()) {} - + bool CanAccumulate(const AccumulatingFunctionObject *accumulateThis) const { if (maxAccumulateCount && accumulateCount > maxAccumulateCount) // don't accumulate if too may accumulated already return false; - + if (maxAccumulatingTime && system_time() > initialTime + maxAccumulatingTime) // don't accumulate if too late past initial task return false; return static_cast(fFunctor)->CanAccumulate(accumulateThis); } - + virtual void Accumulate(AccumulatingFunctionObject *accumulateThis, bigtime_t delay) { fRunAfter = system_time() + delay; @@ -341,7 +342,7 @@ TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t del (fTaskList.ItemAt(index)); if (!task) continue; - + if (task->CanAccumulate(functor)) { task->Accumulate(functor, delay); return; @@ -352,7 +353,7 @@ TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t del } -bool +bool TaskLoop::Pulse() { ASSERT(fLock.IsLocked()); @@ -376,7 +377,7 @@ TaskLoop::Pulse() const bigtime_t kInfinity = B_INFINITE_TIMEOUT; -bigtime_t +bigtime_t TaskLoop::LatestRunTime() const { ASSERT(fLock.IsLocked()); @@ -409,7 +410,7 @@ TaskLoop::LatestRunTime() const } -void +void TaskLoop::RemoveTask(DelayedTask *task) { ASSERT(fLock.IsLocked()); @@ -441,35 +442,35 @@ StandAloneTaskLoop::StandAloneTaskLoop(bool keepThread, bigtime_t heartBeat) StandAloneTaskLoop::~StandAloneTaskLoop() -{ +{ fLock.Lock(); fNeedToQuit = true; bool easyOut = (fScanThread == -1); fLock.Unlock(); - + if (!easyOut) for (int32 timeout = 10000; ; timeout--) { // use a 10 sec timeout value in case the spawned // thread is stuck somewhere - + if (!timeout) { PRINT(("StandAloneTaskLoop timed out, quitting abruptly")); break; } - + bool done; - + fLock.Lock(); done = (fScanThread == -1); fLock.Unlock(); if (done) break; - + snooze(1000); } } -void +void StandAloneTaskLoop::StartPulsingIfNeeded() { ASSERT(fLock.IsLocked()); @@ -481,13 +482,13 @@ StandAloneTaskLoop::StartPulsingIfNeeded() } } -bool +bool StandAloneTaskLoop::KeepPulsingWhenEmpty() const { return fKeepThread; } -status_t +status_t StandAloneTaskLoop::RunBinder(void *castToThis) { StandAloneTaskLoop *self = (StandAloneTaskLoop *)castToThis; @@ -495,12 +496,12 @@ StandAloneTaskLoop::RunBinder(void *castToThis) return B_OK; } -void +void StandAloneTaskLoop::Run() { for(;;) { AutoLock autoLock(&fLock); - if (!autoLock) + if (!autoLock) return; if (fNeedToQuit) { @@ -523,17 +524,17 @@ StandAloneTaskLoop::Run() bigtime_t afterHeartBeatTime = now + fHeartBeat; bigtime_t snoozeTill = latestRunTime < afterHeartBeatTime ? latestRunTime : afterHeartBeatTime; - + autoLock.Unlock(); - if (snoozeTill > now) + if (snoozeTill > now) snooze_until(snoozeTill, B_SYSTEM_TIMEBASE); else snooze(1000); } } -void +void StandAloneTaskLoop::AddTask(DelayedTask *delayedTask) { _inherited::AddTask(delayedTask); @@ -544,9 +545,9 @@ StandAloneTaskLoop::AddTask(DelayedTask *delayedTask) thread_info info; get_thread_info(fScanThread, &info); if (info.state == B_THREAD_ASLEEP) { - suspend_thread(fScanThread); + suspend_thread(fScanThread); snooze(1000); // snooze because BeBook sez so - resume_thread(fScanThread); + resume_thread(fScanThread); } } @@ -562,7 +563,7 @@ PiggybackTaskLoop::~PiggybackTaskLoop() { } -void +void PiggybackTaskLoop::PulseMe() { if (!fPulseMe) @@ -577,13 +578,13 @@ PiggybackTaskLoop::PulseMe() } } -bool +bool PiggybackTaskLoop::KeepPulsingWhenEmpty() const { return false; } -void +void PiggybackTaskLoop::StartPulsingIfNeeded() { fPulseMe = true; diff --git a/src/kits/tracker/Thread.h b/src/kits/tracker/Thread.h index d7c120e00e..b71c57c176 100644 --- a/src/kits/tracker/Thread.h +++ b/src/kits/tracker/Thread.h @@ -35,7 +35,9 @@ All rights reserved. #ifndef __THREAD__ #define __THREAD__ +#include #include + #include "ObjectList.h" #include "FunctionObject.h" #include "Utilities.h" @@ -48,7 +50,7 @@ class SimpleThread { public: SimpleThread(int32 priority = B_LOW_PRIORITY, const char *name = 0); virtual ~SimpleThread(); - + void Go(); private: @@ -99,8 +101,8 @@ public: fParam1(param1) { } - - + + virtual void operator()() { (fFunction)(fParam1); } @@ -119,8 +121,8 @@ public: fOnThis(onThis) { } - - + + virtual void operator()() { (fOnThis->*fFunction)(); } @@ -141,7 +143,7 @@ public: fParam2(param2) { } - + virtual void operator()() { (function)(fParam1, fParam2); } @@ -164,7 +166,7 @@ public: fParam3(param3) { } - + virtual void operator()() { (function)(fParam1, fParam2, fParam3); } @@ -189,7 +191,7 @@ public: fParam4(param4) { } - + virtual void operator()() { (function)(fParam1, fParam2, fParam3, fParam4); } @@ -204,7 +206,7 @@ private: }; template -void +void LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1), Param1 p1) { Thread::Launch(new SingleParamFunctionObjectWorkaround(func, p1), @@ -212,7 +214,7 @@ LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1), Pa } template -void +void LaunchInNewThread(const char *name, int32 priority, status_t (T::*function)(), T *onThis) { Thread::Launch(new SimpleMemberFunctionObjectWorkaround(function, onThis), @@ -220,7 +222,7 @@ LaunchInNewThread(const char *name, int32 priority, status_t (T::*function)(), T } template -void +void LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1, Param2), Param1 p1, Param2 p2) @@ -230,7 +232,7 @@ LaunchInNewThread(const char *name, int32 priority, } template -void +void LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1, Param2, Param3), Param1 p1, Param2 p2, Param3 p3) @@ -240,7 +242,7 @@ LaunchInNewThread(const char *name, int32 priority, } template -void +void LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1, Param2, Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4) @@ -260,13 +262,13 @@ protected: void (View::*)(BPoint, uint32), bigtime_t pressingPeriod); virtual ~MouseDownThread(); - + void Go(); virtual void Track(); - + static status_t TrackBinder(void *); private: - + BMessenger fOwner; void (View::*fDonePressing)(BPoint); void (View::*fPressing)(BPoint, uint32); @@ -309,19 +311,19 @@ MouseDownThread::~MouseDownThread() template -void +void MouseDownThread::Go() { fThreadID = spawn_thread(&MouseDownThread::TrackBinder, "MouseTrackingThread", B_NORMAL_PRIORITY, this); - + if (fThreadID <= 0 || resume_thread(fThreadID) != B_OK) // didn't start, don't leak self delete this; } template -status_t +status_t MouseDownThread::TrackBinder(void *castToThis) { MouseDownThread *self = static_cast(castToThis); @@ -332,7 +334,7 @@ MouseDownThread::TrackBinder(void *castToThis) } template -void +void MouseDownThread::Track() { for (;;) { @@ -354,11 +356,11 @@ MouseDownThread::Track() } if (fPressing) (view->*fPressing)(location, buttons); - + lock.Unlock(); snooze(fPressingPeriod); } - + delete this; ASSERT(!"should not be here"); } diff --git a/src/kits/tracker/TrackerSettings.cpp b/src/kits/tracker/TrackerSettings.cpp index 830380dba4..ef428d6d39 100644 --- a/src/kits/tracker/TrackerSettings.cpp +++ b/src/kits/tracker/TrackerSettings.cpp @@ -32,9 +32,11 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#include "TrackerSettings.h" + +#include #include "Tracker.h" -#include "TrackerSettings.h" #include "WidgetAttributeText.h" @@ -107,7 +109,7 @@ rgb_color ValueToColor(int32 value) color.green = static_cast((value >> 8L) & 0xff); color.blue = static_cast(value & 0xff); - return color; + return color; } @@ -146,7 +148,7 @@ TTrackerState::~TTrackerState() } -void +void TTrackerState::SaveSettings(bool onlyIfNonDefault) { if (fSettingsLoaded) @@ -154,7 +156,7 @@ TTrackerState::SaveSettings(bool onlyIfNonDefault) } -void +void TTrackerState::LoadSettingsIfNeeded() { if (fSettingsLoaded) @@ -215,7 +217,7 @@ TrackerSettings::TrackerSettings() } -void +void TrackerSettings::SaveSettings(bool onlyIfNonDefault) { gTrackerState.SaveSettings(onlyIfNonDefault); @@ -243,7 +245,7 @@ TrackerSettings::DesktopFilePanelRoot() } -void +void TrackerSettings::SetDesktopFilePanelRoot(bool enabled) { gTrackerState.fDesktopFilePanelRoot->SetValue(enabled); @@ -257,7 +259,7 @@ TrackerSettings::MountVolumesOntoDesktop() } -void +void TrackerSettings::SetMountVolumesOntoDesktop(bool enabled) { gTrackerState.fMountVolumesOntoDesktop->SetValue(enabled); @@ -271,7 +273,7 @@ TrackerSettings::MountSharedVolumesOntoDesktop() } -void +void TrackerSettings::SetMountSharedVolumesOntoDesktop(bool enabled) { gTrackerState.fMountSharedVolumesOntoDesktop->SetValue(enabled); @@ -285,7 +287,7 @@ TrackerSettings::IntegrateNonBootBeOSDesktops() } -void +void TrackerSettings::SetIntegrateNonBootBeOSDesktops(bool enabled) { gTrackerState.fIntegrateNonBootBeOSDesktops->SetValue(enabled); @@ -305,7 +307,7 @@ TrackerSettings::EjectWhenUnmounting() } -void +void TrackerSettings::SetEjectWhenUnmounting(bool enabled) { gTrackerState.fEjectWhenUnmounting->SetValue(enabled); @@ -397,14 +399,14 @@ TrackerSettings::SetSortFolderNamesFirst(bool enabled) } -bool +bool TrackerSettings::HideDotFiles() { return gTrackerState.fHideDotFiles->Value(); } -void +void TrackerSettings::SetHideDotFiles(bool hide) { gTrackerState.fHideDotFiles->SetValue(hide); @@ -479,21 +481,21 @@ TrackerSettings::RecentCounts(int32 *applications, int32 *documents, int32 *fold } -void +void TrackerSettings::SetRecentApplicationsCount(int32 count) { gTrackerState.fRecentApplicationsCount->ValueChanged(count); } -void +void TrackerSettings::SetRecentDocumentsCount(int32 count) { gTrackerState.fRecentDocumentsCount->ValueChanged(count); } -void +void TrackerSettings::SetRecentFoldersCount(int32 count) { gTrackerState.fRecentFoldersCount->ValueChanged(count); diff --git a/src/kits/tracker/Utilities.h b/src/kits/tracker/Utilities.h index 4fb10c5bd1..8bb87f4dce 100644 --- a/src/kits/tracker/Utilities.h +++ b/src/kits/tracker/Utilities.h @@ -35,6 +35,9 @@ All rights reserved. #ifndef _UTILITIES_H #define _UTILITIES_H +#include +#include + #include #include #include @@ -52,7 +55,6 @@ All rights reserved. #include #include -#include class BMessage; class BVolume; @@ -133,7 +135,7 @@ class PoseInfo { // them in the same location. This should probably be reworked -- Tracker // could say strip the file location attributes when dropping files into // a closed folder - BPoint fLocation; + BPoint fLocation; }; @@ -165,7 +167,7 @@ class ExtendedPoseInfo { int32 fNumFrames; struct FrameLocation { - BPoint fLocation; + BPoint fLocation; BRect fFrame; uint32 fWorkspaces; }; @@ -178,19 +180,19 @@ void DisallowMetaKeys(BTextView *); void DisallowFilenameKeys(BTextView *); -inline bool -IsDigit(const char c) +inline bool +IsDigit(const char c) { - if ((c >= 48 && c <= 57) || c == 32) + if ((c >= 48 && c <= 57) || c == 32) return true; - else + else return false; } //! Compares two strings naturally, as opposed to lexicographically -inline int -NaturalCompare(const char *s1, const char *s2) +inline int +NaturalCompare(const char *s1, const char *s2) { struct Chunk { int32 type; @@ -214,18 +216,18 @@ NaturalCompare(const char *s1, const char *s2) while (true) { // determine type of next chunks in each string based on first char - if (i == len1) + if (i == len1) a.type = -1; else if (IsDigit(s1[i])) a.type = 1; - else + else a.type = 0; if (j == len2) b.type = -1; - else if (IsDigit(s2[j])) + else if (IsDigit(s2[j])) b.type = 1; - else + else b.type = 0; // check if we reached the end of either string @@ -346,12 +348,12 @@ extern void FadeRGBA32Vertical(uint32 *bits, int32 width, int32 height, int32 fr class FlickerFreeStringView : public BStringView { // Adds support for offscreen bitmap drawing for string views that update often - // this would be better implemented as an option of BStringView + // this would be better implemented as an option of BStringView public: - FlickerFreeStringView(BRect bounds, const char *name, + FlickerFreeStringView(BRect bounds, const char *name, const char *text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW); - FlickerFreeStringView(BRect bounds, const char *name, + FlickerFreeStringView(BRect bounds, const char *name, const char *text, BBitmap *existingOffscreen, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW); @@ -407,7 +409,7 @@ class PositionPassingMenuItem : public BMenuItem { protected: virtual status_t Invoke(BMessage * = 0); // appends the invoke location for NewFolder, etc. to use - + private: typedef BMenuItem _inherited; }; @@ -707,14 +709,14 @@ inline void PrintDirToStream(const BDirectory *, const char * = 0) {} #ifdef xDEBUG - extern FILE *logFile; + extern FILE *logFile; inline void PrintToLogFile(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); + va_list ap; + va_start(ap, fmt); vfprintf(logFile, fmt, ap); - va_end(ap); + va_end(ap); } #define WRITELOG(_ARGS_) \ @@ -729,7 +731,7 @@ inline void PrintDirToStream(const BDirectory *, const char * = 0) {} PrintToLogFile("\n"); \ fflush(logFile); \ } - + #else #define WRITELOG(_ARGS_) diff --git a/src/preferences/backgrounds/BackgroundImage.cpp b/src/preferences/backgrounds/BackgroundImage.cpp index c18fb4c852..fc24f8bdde 100644 --- a/src/preferences/backgrounds/BackgroundImage.cpp +++ b/src/preferences/backgrounds/BackgroundImage.cpp @@ -36,6 +36,7 @@ All rights reserved. // #include +#include #include #include #include diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp index 62057e5262..54f06df113 100644 --- a/src/preferences/backgrounds/BackgroundsView.cpp +++ b/src/preferences/backgrounds/BackgroundsView.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include diff --git a/src/preferences/mail/DNSQuery.cpp b/src/preferences/mail/DNSQuery.cpp index 52709cc1a2..a177048a69 100644 --- a/src/preferences/mail/DNSQuery.cpp +++ b/src/preferences/mail/DNSQuery.cpp @@ -5,6 +5,7 @@ #include #include +#include // #define DEBUG 1 @@ -64,7 +65,7 @@ BRawNetBuffer::AppendString(const char* string) status_t BRawNetBuffer::ReadUint16(uint16& value) { - uint16 netVal; + uint16 netVal; ssize_t sizeW = fBuffer.ReadAt(fReadPosition, &netVal, sizeof(uint16)); if (sizeW == 0) return B_ERROR; @@ -77,7 +78,7 @@ BRawNetBuffer::ReadUint16(uint16& value) status_t BRawNetBuffer::ReadUint32(uint32& value) { - uint32 netVal; + uint32 netVal; ssize_t sizeW = fBuffer.ReadAt(fReadPosition, &netVal, sizeof(uint32)); if (sizeW == 0) return B_ERROR; @@ -92,7 +93,7 @@ BRawNetBuffer::ReadString(BString& string) { char* buffer = (char*)fBuffer.Buffer(); buffer = &buffer[fReadPosition]; - + // if the string is compressed we have to follow the links to the // sub strings while (*buffer != 0) { @@ -209,7 +210,7 @@ DNSTools::ConvertToDNSName(const BString& string) dot = outString.FindFirst(".", lastDot + 1); if (dot == B_ERROR) break; - + // set a counts to the dot diff = dot - 1 - lastDot; outString[lastDot] = (char)diff; @@ -286,13 +287,13 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList* mxList, in_addr dnsAddress; if (ReadDNSServer(&dnsAddress) != B_OK) return B_ERROR; - + // create dns query package BRawNetBuffer buffer; dns_header header; _SetMXHeader(&header); _AppendQueryHeader(buffer, &header); - + BString serverNameConv = DNSTools::ConvertToDNSName(serverName); buffer.AppendString(serverNameConv.String()); buffer.AppendUint16(uint16(MX_RECORD)); @@ -308,7 +309,7 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList* mxList, if (netEndpoint.Connect(netAddress) != B_OK) return B_ERROR; PRINT("Connected\n"); - + #ifdef DEBUG int32 bytesSend = #endif @@ -319,12 +320,12 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList* mxList, BRawNetBuffer receiBuffer(512); netEndpoint.SetTimeout(timeout); #ifdef DEBUG - int32 bytesRecei = + int32 bytesRecei = #endif netEndpoint.ReceiveFrom(receiBuffer.Data(), 512, netAddress); PRINT("bytes received %i\n", int(bytesRecei)); dns_header receiHeader; - + _ReadQueryHeader(receiBuffer, &receiHeader); PRINT("Package contains :"); PRINT("%d Questions, ", receiHeader.q_count); @@ -338,7 +339,7 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList* mxList, receiBuffer.ReadString(dummyS); receiBuffer.ReadUint16(dummy); receiBuffer.ReadUint16(dummy); - + bool mxRecordFound = false; for (int i = 0; i < receiHeader.ans_count; i++) { resource_record_head rrHead; @@ -356,7 +357,7 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList* mxList, buffer.SkipReading(rrHead.dataLength); } } - + if (!mxRecordFound) return B_ERROR; diff --git a/src/preferences/print/JobListView.cpp b/src/preferences/print/JobListView.cpp index 044aeae73d..38cca75863 100644 --- a/src/preferences/print/JobListView.cpp +++ b/src/preferences/print/JobListView.cpp @@ -34,6 +34,7 @@ #include "pr_server.h" #include "SpoolFolder.h" +#include #include #include diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 74cd18e241..2b575c42fd 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 72a2c0be61..b08a08e53c 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -48,6 +48,7 @@ #include #include +#include #include #include #include diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index 3548bcf272..8550c15f3a 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -91,7 +92,7 @@ ShapePainter::IterateLineTo(int32 lineCount, BPoint *linePts) fOpStack.push(OP_LINETO | lineCount); for (int32 i = 0; i < lineCount; i++) fPtStack.push(linePts[i]); - + return B_OK; } @@ -112,7 +113,7 @@ status_t ShapePainter::IterateClose(void) { fOpStack.push(OP_CLOSE); - + return B_OK; } @@ -128,8 +129,8 @@ ShapePainter::Draw(View *view, BRect frame, bool filled) int32 i; uint32 *opList = new (std::nothrow) uint32[opCount]; if (opList == NULL) - return; - + return; + BPoint *ptList = new (std::nothrow) BPoint[ptCount]; if (ptList == NULL) { delete[] opList; @@ -163,7 +164,7 @@ get_polygon_frame(const BPoint *points, int32 numPoints, BRect *_frame) float l, t, r, b; ASSERT(numPoints > 0); - + l = r = points->x; t = b = points->y; @@ -205,7 +206,7 @@ stroke_line(View *view, BPoint start, BPoint end) BPoint penPos = end; view->ConvertToScreenForDrawing(&start); - view->ConvertToScreenForDrawing(&end); + view->ConvertToScreenForDrawing(&end); view->Window()->GetDrawingEngine()->StrokeLine(start, end); view->CurrentState()->SetPenLocation(penPos); @@ -218,7 +219,7 @@ stroke_line(View *view, BPoint start, BPoint end) static void stroke_rect(View *view, BRect rect) { - view->ConvertToScreenForDrawing(&rect); + view->ConvertToScreenForDrawing(&rect); view->Window()->GetDrawingEngine()->StrokeRect(rect); } @@ -226,7 +227,7 @@ stroke_rect(View *view, BRect rect) static void fill_rect(View *view, BRect rect) { - view->ConvertToScreenForDrawing(&rect); + view->ConvertToScreenForDrawing(&rect); view->Window()->GetDrawingEngine()->FillRect(rect); } @@ -234,7 +235,7 @@ fill_rect(View *view, BRect rect) static void stroke_round_rect(View *view, BRect rect, BPoint radii) { - view->ConvertToScreenForDrawing(&rect); + view->ConvertToScreenForDrawing(&rect); view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, false); } @@ -243,7 +244,7 @@ stroke_round_rect(View *view, BRect rect, BPoint radii) static void fill_round_rect(View *view, BRect rect, BPoint radii) { - view->ConvertToScreenForDrawing(&rect); + view->ConvertToScreenForDrawing(&rect); view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, true); } @@ -341,7 +342,7 @@ stroke_polygon(View *view, int32 numPoints, const BPoint *viewPoints, BRect polyFrame; get_polygon_frame(points, numPoints, &polyFrame); - view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, + view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, false, isClosed && numPoints > 2); free(points); } @@ -364,11 +365,11 @@ fill_polygon(View *view, int32 numPoints, const BPoint *viewPoints) BRect polyFrame; get_polygon_frame(points, numPoints, &polyFrame); - view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, + view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, true, true); } else { // avoid constructor/destructor calls by using malloc instead of new [] - BPoint *points = (BPoint *)malloc(numPoints * sizeof(BPoint)); + BPoint *points = (BPoint *)malloc(numPoints * sizeof(BPoint)); if (!points) return; @@ -377,7 +378,7 @@ fill_polygon(View *view, int32 numPoints, const BPoint *viewPoints) BRect polyFrame; get_polygon_frame(points, numPoints, &polyFrame); - view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, + view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, true, true); free(points); } @@ -431,14 +432,14 @@ draw_pixels(View *view, BRect src, BRect dest, int32 width, int32 height, { UtilityBitmap bitmap(BRect(0, 0, width - 1, height - 1), (color_space)pixelFormat, 0, bytesPerRow); - + if (!bitmap.IsValid()) return; - + memcpy(bitmap.Bits(), data, height * bytesPerRow); view->ConvertToScreenForDrawing(&dest); - + view->Window()->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest, options); } @@ -447,10 +448,10 @@ draw_pixels(View *view, BRect src, BRect dest, int32 width, int32 height, static void draw_picture(View *view, BPoint where, int32 token) { - ServerPicture *picture = view->Window()->ServerWindow()->App()->FindPicture(token); + ServerPicture *picture = view->Window()->ServerWindow()->App()->FindPicture(token); if (picture != NULL) { view->SetDrawingOrigin(where); - view->PushState(); + view->PushState(); picture->Play(view); view->PopState(); } @@ -465,7 +466,7 @@ set_clipping_rects(View *view, const BRect *rects, uint32 numRects) BRegion region; for (uint32 c = 0; c < numRects; c++) region.Include(rects[c]); - view->SetUserClipping(®ion); + view->SetUserClipping(®ion); } @@ -512,7 +513,7 @@ exit_state_change(View *view) } -static void +static void enter_font_state(View *view) { } @@ -525,7 +526,7 @@ exit_font_state(View *view) } -static void +static void set_origin(View *view, BPoint pt) { view->CurrentState()->SetOrigin(pt); @@ -600,7 +601,7 @@ set_scale(View *view, float scale) { view->CurrentState()->SetScale(scale); view->Window()->ServerWindow()->ResyncDrawState(); - + // Update the drawing engine draw state, since some stuff (for example // the pen size) needs to be recalculated. } @@ -746,7 +747,7 @@ const static void *kTableEntries[] = { (const void *)set_font_shear, (const void *)reserved, // TODO: Marc Flerackers calls this "set_font_bpp". Investigate (const void *)set_font_face, - (const void *)set_blending_mode + (const void *)set_blending_mode }; @@ -761,7 +762,7 @@ ServerPicture::ServerPicture() { fToken = gTokenSpace.NewToken(kPictureToken, this); fData = new (std::nothrow) BMallocIO(); - + PictureDataWriter::SetTo(fData); } @@ -781,13 +782,13 @@ ServerPicture::ServerPicture(const ServerPicture &picture) return; fData = mallocIO; - + const off_t size = picture.DataLength(); if (mallocIO->SetSize(size) < B_OK) return; - + picture.fData->ReadAt(0, const_cast(mallocIO->Buffer()), size); - + PictureDataWriter::SetTo(fData); } @@ -801,7 +802,7 @@ ServerPicture::ServerPicture(const char *fileName, const int32 &offset) fUsurped(NULL) { fToken = gTokenSpace.NewToken(kPictureToken, this); - + fFile = new (std::nothrow) BFile(fileName, B_READ_WRITE); if (fFile == NULL) return; @@ -824,7 +825,7 @@ ServerPicture::~ServerPicture() delete fData; delete fFile; gTokenSpace.RemoveToken(fToken); - + // We only delete the subpictures list, not the subpictures themselves, // since the ServerApp keeps them in a list and will delete them on quit. delete fPictures; @@ -859,7 +860,7 @@ ServerPicture::SyncState(View *view) view->CurrentState()->MiterLimit()); //WriteSetPattern(*view->CurrentState()->GetPattern().GetInt8()); WriteSetDrawingMode(view->CurrentState()->GetDrawingMode()); - + WriteSetHighColor(view->CurrentState()->HighColor()); WriteSetLowColor(view->CurrentState()->LowColor()); @@ -888,10 +889,10 @@ ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link) link.Read(&size); WriteSetFontSize(size); } - + if (mask & B_FONT_SHEAR) { float shear; - link.Read(&shear); + link.Read(&shear); WriteSetFontShear(shear); } @@ -969,7 +970,7 @@ ServerPicture::NestPicture(ServerPicture *picture) { if (fPictures == NULL) fPictures = new (std::nothrow) BList; - + if (fPictures == NULL || !fPictures->AddItem(picture)) return false; @@ -985,13 +986,13 @@ ServerPicture::DataLength() const return 0; off_t size; fData->GetSize(&size); - return size; + return size; } status_t ServerPicture::ImportData(BPrivate::LinkReceiver &link) -{ +{ int32 size = 0; link.Read(&size); @@ -1027,9 +1028,9 @@ ServerPicture::ExportData(BPrivate::PortLink &link) link.Attach(subPicturesCount); if (subPicturesCount > 0) { for (int32 i = 0; i < subPicturesCount; i++) { - ServerPicture *subPic = static_cast(fPictures->ItemAtFast(i)); - link.Attach(subPic->Token()); - } + ServerPicture *subPic = static_cast(fPictures->ItemAtFast(i)); + link.Attach(subPic->Token()); + } } off_t size = 0; diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 8c238a7f7e..83e11ada4e 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include #include diff --git a/src/servers/input/PathList.cpp b/src/servers/input/PathList.cpp index f71bec5120..07c8814e37 100644 --- a/src/servers/input/PathList.cpp +++ b/src/servers/input/PathList.cpp @@ -10,6 +10,7 @@ #include "PathList.h" #include +#include #include diff --git a/src/servers/media_addon/MediaFilePlayer.cpp b/src/servers/media_addon/MediaFilePlayer.cpp index 51e5a613a6..de872ea20a 100644 --- a/src/servers/media_addon/MediaFilePlayer.cpp +++ b/src/servers/media_addon/MediaFilePlayer.cpp @@ -9,6 +9,7 @@ #include "ObjectList.h" #include +#include BObjectList list; @@ -35,12 +36,12 @@ PlayMediaFile(const char *media_type, const char *media_name) player->Restart(); return; } - + list.RemoveItem(player); delete player; - player = NULL; + player = NULL; } - + if (!player) { player = new MediaFilePlayer(media_type, media_name, &ref); if (player->InitCheck() == B_OK) @@ -60,39 +61,39 @@ MediaFilePlayer::MediaFilePlayer(const char *media_type, fPlayTrack(NULL) { fName = strdup(media_name); - + fPlayFile = new BMediaFile(&fRef); if ((fInitCheck = fPlayFile->InitCheck()) CountTracks(); i++) { BMediaTrack *track = fPlayFile->TrackAt(i); if (track == NULL) continue; fPlayFormat.type = B_MEDIA_RAW_AUDIO; fPlayFormat.u.raw_audio.buffer_size = 256; - if ((track->DecodedFormat(&fPlayFormat) == B_OK) + if ((track->DecodedFormat(&fPlayFormat) == B_OK) && (fPlayFormat.type == B_MEDIA_RAW_AUDIO)) { fPlayTrack = track; break; } fPlayFile->ReleaseTrack(track); } - + if (fPlayTrack == NULL) { fInitCheck = B_BAD_VALUE; return; } - + fSoundPlayer = new BSoundPlayer(&fPlayFormat.u.raw_audio, media_name, PlayFunction, NULL, this); if ((fInitCheck = fSoundPlayer->InitCheck()) != B_OK) { return; } - + fSoundPlayer->SetVolume(1.0f); fSoundPlayer->SetHasData(true); fSoundPlayer->Start(); @@ -134,7 +135,7 @@ MediaFilePlayer::Restart() void MediaFilePlayer::Stop() { - fSoundPlayer->Stop(); + fSoundPlayer->Stop(); } @@ -144,7 +145,7 @@ MediaFilePlayer::PlayFunction(void *cookie, void * buffer, size_t size, const me MediaFilePlayer *player = (MediaFilePlayer *)cookie; int64 frames = 0; player->fPlayTrack->ReadFrames(buffer, &frames); - + if (frames <=0) { player->fSoundPlayer->SetHasData(false); } diff --git a/src/servers/print/ConfigWindow.cpp b/src/servers/print/ConfigWindow.cpp index 6a9cfa3470..2b13d3457a 100644 --- a/src/servers/print/ConfigWindow.cpp +++ b/src/servers/print/ConfigWindow.cpp @@ -21,6 +21,7 @@ // BeOS #include #include +#include #include @@ -55,7 +56,7 @@ static struct PageFormat char *label; float width; float height; -} pageFormat[] = +} pageFormat[] = { {"Letter", letter_width, letter_height }, {"Legal", legal_width, legal_height }, @@ -81,7 +82,7 @@ static void GetPageFormat(float w, float h, BString& label) label = pf.label; return; } } - + float unit = 72.0; // currently inc[h]es only label << (w / unit) << "x" << (h / unit) << " in."; } @@ -105,31 +106,31 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, if (kind == kJobSetup) SetTitle("Print Setup"); - BView* panel = new BBox(Bounds(), "top_panel", B_FOLLOW_ALL, + BView* panel = new BBox(Bounds(), "top_panel", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); AddChild(panel); - + float left = 10, top = 10; BRect r(left, top, 160, 20); // print selection popup menu BPopUpMenu* menu = new BPopUpMenu("Select a Printer"); SetupPrintersMenu(menu); - + float width = be_plain_font->StringWidth("Printer:") + 10.0; r.right = r.left + width + menu->MaxContentWidth() + 10; fPrinters = new BMenuField(r, "Printer", "Printer:", menu); fPrinters->SetDivider(width); panel->AddChild(fPrinters); top += fPrinters->Bounds().Height() + 10; - + // page format button r.OffsetTo(left, top); fPageSetup = AddPictureButton(panel, r, "Page Format", "PAGE_SETUP_ON", "PAGE_SETUP_OFF", MSG_PAGE_SETUP); - + // add description to button r.OffsetTo(left + fPageSetup->Bounds().Width() + 5, fPageSetup->Frame().top); BStringView *stringView = AddStringView(panel, r, "Paper Setup:"); @@ -139,7 +140,7 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, fPageFormatText = AddStringView(panel, r, ""); fPageFormatText->ResizeToPreferred(); top = fPageSetup->Frame().bottom + 15; - + // page selection button fJobSetup = NULL; if (kind == kJobSetup) { @@ -156,14 +157,14 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, top = fJobSetup->Frame().bottom + 15; } top += 5; - + // separator line BRect line(Bounds()); line.OffsetTo(0, top); line.bottom = line.top+1; AddChild(new BBox(line, "line", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP)); top += 10; - + // Cancel button r.OffsetTo(left, top); BButton* cancel = new BButton(r, "Cancel", "Cancel", @@ -171,7 +172,7 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, panel->AddChild(cancel); cancel->ResizeToPreferred(); left = cancel->Frame().right + 10; - + // OK button r.OffsetTo(left, top); fOk = new BButton(r, "OK", "OK", new BMessage(MSG_OK)); @@ -179,15 +180,15 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, fOk->ResizeToPreferred(); top += fOk->Bounds().Height() + 10; - // resize window + // resize window ResizeTo(fOk->Frame().right + 10, top); - + AddShortcut('i', 0, new BMessage(B_ABOUT_REQUESTED)); - + SetDefaultButton(fOk); - + fPrinters->MakeFocus(true); - + UpdateSettings(true); } @@ -244,7 +245,7 @@ void ConfigWindow::MessageReceived(BMessage* m) } -static const char* +static const char* kAbout = "Printer Server\n" "© 2001-2008 Haiku\n" @@ -293,32 +294,32 @@ BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame, { BBitmap* onBM = LoadBitmap(on); BBitmap* offBM = LoadBitmap(off); - + BPicture* onPict = BitmapToPicture(panel, onBM); BPicture* offPict = BitmapToPicture(panel, offBM); BPictureButton* button = NULL; - - if (onPict != NULL && offPict != NULL) { + + if (onPict != NULL && offPict != NULL) { button = new BPictureButton(frame, name, onPict, offPict, new BMessage(what)); button->SetViewColor(B_TRANSPARENT_COLOR); panel->AddChild(button); onBM->Lock(); button->ResizeTo(onBM->Bounds().Width(), onBM->Bounds().Height()); onBM->Unlock(); - + BPicture* disabled = BitmapToGrayedPicture(panel, offBM); button->SetDisabledOn(disabled); delete disabled; - + disabled = BitmapToGrayedPicture(panel, onBM); button->SetDisabledOff(disabled); delete disabled; - } - - delete onPict; delete offPict; + } + + delete onPict; delete offPict; delete onBM; delete offBM; - + return button; } @@ -430,21 +431,21 @@ void ConfigWindow::UpdateUI() fOk->SetEnabled(false); fPageFormatText->SetText("Undefined paper format"); fPageFormatText->ResizeToPreferred(); - } else { + } else { fPageSetup->SetEnabled(true); - + if (fJobSetup) fJobSetup->SetEnabled(fKind == kJobSetup && !fPageSettings.IsEmpty()); fOk->SetEnabled(fKind == kJobSetup && !fJobSettings.IsEmpty() || fKind == kPageSetup && !fPageSettings.IsEmpty()); - - // display information about page format + + // display information about page format BRect paperRect; BString pageFormat; if (fPageSettings.FindRect(PSRV_FIELD_PAPER_RECT, &paperRect) == B_OK) { GetPageFormat(paperRect.Width(), paperRect.Height(), pageFormat); - + int32 orientation = 0; fPageSettings.FindInt32(PSRV_FIELD_ORIENTATION, &orientation); if (orientation == 0) @@ -463,7 +464,7 @@ void ConfigWindow::UpdateUI() int32 first, last; if (fJobSettings.FindInt32(PSRV_FIELD_FIRST_PAGE, &first) == B_OK && fJobSettings.FindInt32(PSRV_FIELD_LAST_PAGE, &last) == B_OK) { - if (first >= 1 && first <= last && last != INT_MAX) { + if (first >= 1 && first <= last && last != INT_MAX) { job << "From page " << first << " to " << last; } else { job << "All pages"; @@ -496,17 +497,17 @@ void ConfigWindow::Setup(config_setup_kind kind) if (fCurrentPrinter) { Hide(); if (kind == kPageSetup) { - BMessage settings = fPageSettings; + BMessage settings = fPageSettings; if (fCurrentPrinter->ConfigurePage(settings) == B_OK) { fPageSettings = settings; if (!fJobSettings.IsEmpty()) AddFields(&fJobSettings, &fPageSettings); } } else { - BMessage settings; + BMessage settings; if (fJobSettings.IsEmpty()) settings = fPageSettings; else settings = fJobSettings; - + if (fCurrentPrinter->ConfigureJob(settings) == B_OK) fJobSettings = settings; }