hrev44418 adds 3 changesets to branch 'master' old head: 8fe9f8b2d0e3c8f88406f5720a1d2027638c43b6 new head: 96a1e39a63f093e57d351cf79b0e7ee51b80145a ---------------------------------------------------------------------------- b05aa8b: Style changes in Tracker, no functional change. Manual whitespace cleanup Change instances of const char * to const char* Convert /* */ C style comments to // C++ style comments caaec01: A for loop with just an end condition is better as a while loop. 96a1e39: An error while emptying trash is not that dramatic. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 135 files changed, 6821 insertions(+), 6314 deletions(-) src/kits/tracker/AttributeStream.cpp | 248 +++-- src/kits/tracker/AttributeStream.h | 234 ++--- src/kits/tracker/Attributes.h | 218 ++--- src/kits/tracker/AutoMounterSettings.cpp | 1 + src/kits/tracker/AutoMounterSettings.h | 5 +- src/kits/tracker/Background.h | 2 +- src/kits/tracker/BackgroundImage.cpp | 74 +- src/kits/tracker/BackgroundImage.h | 46 +- src/kits/tracker/Bitmaps.cpp | 41 +- src/kits/tracker/Bitmaps.h | 36 +- src/kits/tracker/Commands.h | 2 +- src/kits/tracker/ContainerWindow.cpp | 392 ++++---- src/kits/tracker/ContainerWindow.h | 216 ++--- src/kits/tracker/CountView.cpp | 12 +- src/kits/tracker/CountView.h | 17 +- src/kits/tracker/Cursors.h | 1 + src/kits/tracker/DeskWindow.cpp | 34 +- src/kits/tracker/DeskWindow.h | 26 +- src/kits/tracker/DesktopPoseView.cpp | 38 +- src/kits/tracker/DesktopPoseView.h | 32 +- src/kits/tracker/DialogPane.cpp | 107 +- src/kits/tracker/DialogPane.h | 8 +- src/kits/tracker/DirMenu.cpp | 29 +- src/kits/tracker/DirMenu.h | 18 +- src/kits/tracker/EntryIterator.cpp | 53 +- src/kits/tracker/EntryIterator.h | 75 +- src/kits/tracker/FBCPadding.cpp | 16 +- src/kits/tracker/FSClipboard.cpp | 166 ++-- src/kits/tracker/FSClipboard.h | 27 +- src/kits/tracker/FSUndoRedo.cpp | 68 +- src/kits/tracker/FSUndoRedo.h | 24 +- src/kits/tracker/FSUtils.cpp | 433 ++++----- src/kits/tracker/FSUtils.h | 141 +-- src/kits/tracker/FavoritesMenu.cpp | 26 +- src/kits/tracker/FavoritesMenu.h | 37 +- src/kits/tracker/FilePanel.cpp | 93 +- src/kits/tracker/FilePanelPriv.cpp | 167 ++-- src/kits/tracker/FilePanelPriv.h | 178 ++-- src/kits/tracker/FilePermissionsView.cpp | 12 +- src/kits/tracker/FilePermissionsView.h | 45 +- src/kits/tracker/FindPanel.cpp | 467 ++++----- src/kits/tracker/FindPanel.h | 137 ++- src/kits/tracker/FunctionObject.h | 122 ++- src/kits/tracker/GroupedMenu.cpp | 56 +- src/kits/tracker/GroupedMenu.h | 38 +- src/kits/tracker/IconCache.cpp | 384 ++++---- src/kits/tracker/IconCache.h | 300 +++--- src/kits/tracker/IconMenuItem.cpp | 32 +- src/kits/tracker/IconMenuItem.h | 38 +- src/kits/tracker/InfoWindow.cpp | 145 ++- src/kits/tracker/InfoWindow.h | 34 +- src/kits/tracker/LockingList.h | 18 +- src/kits/tracker/MimeTypeList.cpp | 34 +- src/kits/tracker/MimeTypeList.h | 28 +- src/kits/tracker/MimeTypes.h | 34 +- src/kits/tracker/MiniMenuField.cpp | 51 +- src/kits/tracker/MiniMenuField.h | 12 +- src/kits/tracker/Model.cpp | 94 +- src/kits/tracker/Model.h | 115 ++- src/kits/tracker/MountMenu.cpp | 26 +- src/kits/tracker/MountMenu.h | 7 +- src/kits/tracker/NavMenu.cpp | 41 +- src/kits/tracker/Navigator.cpp | 115 ++- src/kits/tracker/Navigator.h | 43 +- src/kits/tracker/NodePreloader.cpp | 90 +- src/kits/tracker/NodePreloader.h | 16 +- src/kits/tracker/NodeWalker.cpp | 59 +- src/kits/tracker/NodeWalker.h | 71 +- src/kits/tracker/OpenWithWindow.cpp | 259 +++-- src/kits/tracker/OpenWithWindow.h | 176 ++-- src/kits/tracker/OverrideAlert.cpp | 31 +- src/kits/tracker/OverrideAlert.h | 25 +- src/kits/tracker/PendingNodeMonitorCache.cpp | 30 +- src/kits/tracker/PendingNodeMonitorCache.h | 21 +- src/kits/tracker/Pose.cpp | 193 ++-- src/kits/tracker/Pose.h | 97 +- src/kits/tracker/PoseList.cpp | 31 +- src/kits/tracker/PoseList.h | 67 +- src/kits/tracker/PoseView.cpp | 1129 +++++++++++----------- src/kits/tracker/PoseView.h | 538 +++++------ src/kits/tracker/PoseViewScripting.cpp | 248 ++--- src/kits/tracker/PublicCommands.h | 5 +- src/kits/tracker/QueryContainerWindow.cpp | 30 +- src/kits/tracker/QueryContainerWindow.h | 27 +- src/kits/tracker/QueryPoseView.cpp | 172 ++-- src/kits/tracker/QueryPoseView.h | 87 +- src/kits/tracker/RecentItems.cpp | 138 +-- src/kits/tracker/RecentItems.h | 125 ++- src/kits/tracker/RegExp.cpp | 184 ++-- src/kits/tracker/RegExp.h | 98 +- src/kits/tracker/SelectionWindow.cpp | 10 +- src/kits/tracker/SelectionWindow.h | 29 +- src/kits/tracker/Settings.cpp | 146 +-- src/kits/tracker/Settings.h | 67 +- src/kits/tracker/SettingsHandler.cpp | 125 ++- src/kits/tracker/SettingsHandler.h | 77 +- src/kits/tracker/SettingsViews.cpp | 32 +- src/kits/tracker/SettingsViews.h | 46 +- src/kits/tracker/SlowContextPopup.cpp | 84 +- [ *** stats truncated: 36 lines dropped *** ] ############################################################################ Commit: b05aa8b5b16e5b4f420a35c37805c6387df98737 URL: http://cgit.haiku-os.org/haiku/commit/?id=b05aa8b Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 27 23:07:09 2012 UTC Style changes in Tracker, no functional change. Manual whitespace cleanup Change instances of const char * to const char* Convert /* */ C style comments to // C++ style comments ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/AttributeStream.cpp b/src/kits/tracker/AttributeStream.cpp index 8c429e1..47a8ce0 100644 --- a/src/kits/tracker/AttributeStream.cpp +++ b/src/kits/tracker/AttributeStream.cpp @@ -32,11 +32,13 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "AttributeStream.h" #include <Debug.h> #include <Node.h> + // ToDo: // lazy Rewind from Drive, only if data is available // BMessage node @@ -49,14 +51,15 @@ AttributeInfo::AttributeInfo(const AttributeInfo &cloneThis) { } -AttributeInfo::AttributeInfo(const char *name, attr_info info) + +AttributeInfo::AttributeInfo(const char* name, attr_info info) : fName(name), fInfo(info) { } -AttributeInfo::AttributeInfo(const char *name, uint32 type, off_t size) +AttributeInfo::AttributeInfo(const char* name, uint32 type, off_t size) : fName(name) { fInfo.size = size; @@ -64,7 +67,7 @@ AttributeInfo::AttributeInfo(const char *name, uint32 type, off_t size) } -const char * +const char* AttributeInfo::Name() const { return fName.String(); @@ -91,14 +94,14 @@ AttributeInfo::SetTo(const AttributeInfo &attr) } void -AttributeInfo::SetTo(const char *name, attr_info info) +AttributeInfo::SetTo(const char* name, attr_info info) { fName = name; fInfo = info; } void -AttributeInfo::SetTo(const char *name, uint32 type, off_t size) +AttributeInfo::SetTo(const char* name, uint32 type, off_t size) { fName = name; fInfo.type = type; @@ -118,7 +121,7 @@ AttributeStreamNode::~AttributeStreamNode() Detach(); } -AttributeStreamNode & +AttributeStreamNode& AttributeStreamNode::operator<<(AttributeStreamNode &source) { fReadFrom = &source; @@ -143,7 +146,7 @@ AttributeStreamFileNode::MakeEmpty() } off_t -AttributeStreamNode::Contains(const char *name, uint32 type) +AttributeStreamNode::Contains(const char* name, uint32 type) { if (!fReadFrom) return 0; @@ -153,8 +156,8 @@ AttributeStreamNode::Contains(const char *name, uint32 type) off_t -AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type, - off_t size, void *buffer, void (*swapFunc)(void *)) +AttributeStreamNode::Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*)) { if (!fReadFrom) return 0; @@ -162,9 +165,10 @@ AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc); } + off_t -AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 type, - off_t size, const void *buffer) +AttributeStreamNode::Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer) { if (!fWriteTo) return 0; @@ -172,6 +176,7 @@ AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 typ return fWriteTo->Write(name, foreignName, type, size, buffer); } + bool AttributeStreamNode::Drive() { @@ -183,7 +188,8 @@ AttributeStreamNode::Drive() return true; } -const AttributeInfo * + +const AttributeInfo* AttributeStreamNode::Next() { if (fReadFrom) @@ -192,7 +198,8 @@ AttributeStreamNode::Next() return NULL; } -const char * + +const char* AttributeStreamNode::Get() { ASSERT(fReadFrom); @@ -202,13 +209,15 @@ AttributeStreamNode::Get() return fReadFrom->Get(); } + bool -AttributeStreamNode::Fill(char *buffer) const +AttributeStreamNode::Fill(char* buffer) const { ASSERT(fReadFrom); return fReadFrom->Fill(buffer); } + bool AttributeStreamNode::Start() { @@ -219,11 +228,12 @@ AttributeStreamNode::Start() return fWriteTo->Start(); } + void AttributeStreamNode::Detach() { - AttributeStreamNode *tmpFrom = fReadFrom; - AttributeStreamNode *tmpTo = fWriteTo; + AttributeStreamNode* tmpFrom = fReadFrom; + AttributeStreamNode* tmpTo = fWriteTo; fReadFrom = NULL; fWriteTo = NULL; @@ -240,12 +250,13 @@ AttributeStreamFileNode::AttributeStreamFileNode() } -AttributeStreamFileNode::AttributeStreamFileNode(BNode *node) +AttributeStreamFileNode::AttributeStreamFileNode(BNode* node) : fNode(node) { ASSERT(fNode); } + void AttributeStreamFileNode::Rewind() { @@ -253,15 +264,16 @@ AttributeStreamFileNode::Rewind() fNode->RewindAttrs(); } + void -AttributeStreamFileNode::SetTo(BNode *node) +AttributeStreamFileNode::SetTo(BNode* node) { fNode = node; } off_t -AttributeStreamFileNode::Contains(const char *name, uint32 type) +AttributeStreamFileNode::Contains(const char* name, uint32 type) { ASSERT(fNode); attr_info info; @@ -274,9 +286,10 @@ AttributeStreamFileNode::Contains(const char *name, uint32 type) return info.size; } + off_t -AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 type, - off_t size, void *buffer, void (*swapFunc)(void *)) +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; @@ -291,12 +304,13 @@ AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 return 0; } + off_t -AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 type, - off_t size, const void *buffer) +AttributeStreamFileNode::Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer) { ASSERT(fNode); - ASSERT(dynamic_cast<BNode *>(fNode)); + ASSERT(dynamic_cast<BNode*>(fNode)); off_t result = fNode->WriteAttr(name, type, 0, buffer, (size_t)size); if (result == size && foreignName) // the write operation worked fine, remove the foreign attribute @@ -306,6 +320,7 @@ AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 return result; } + bool AttributeStreamFileNode::Drive() { @@ -313,9 +328,9 @@ AttributeStreamFileNode::Drive() if (!_inherited::Drive()) return false; - const AttributeInfo *attr; + const AttributeInfo* attr; while ((attr = fReadFrom->Next()) != 0) { - const char *data = fReadFrom->Get(); + const char* data = fReadFrom->Get(); off_t result = fNode->WriteAttr(attr->Name(), attr->Type(), 0, data, (size_t)attr->Size()); if (result < attr->Size()) @@ -324,7 +339,8 @@ AttributeStreamFileNode::Drive() return true; } -const char * + +const char* AttributeStreamFileNode::Get() { ASSERT(fNode); @@ -332,15 +348,17 @@ AttributeStreamFileNode::Get() return NULL; } + bool -AttributeStreamFileNode::Fill(char *buffer) const +AttributeStreamFileNode::Fill(char* buffer) const { ASSERT(fNode); return fNode->ReadAttr(fCurrentAttr.Name(), fCurrentAttr.Type(), 0, buffer, (size_t)fCurrentAttr.Size()) == (ssize_t)fCurrentAttr.Size(); } -const AttributeInfo * + +const AttributeInfo* AttributeStreamFileNode::Next() { ASSERT(fNode); @@ -364,12 +382,14 @@ AttributeStreamMemoryNode::AttributeStreamMemoryNode() { } + void AttributeStreamMemoryNode::MakeEmpty() { fAttributes.MakeEmpty(); } + void AttributeStreamMemoryNode::Rewind() { @@ -377,8 +397,9 @@ AttributeStreamMemoryNode::Rewind() fCurrentIndex = -1; } + int32 -AttributeStreamMemoryNode::Find(const char *name, uint32 type) const +AttributeStreamMemoryNode::Find(const char* name, uint32 type) const { int32 count = fAttributes.CountItems(); for (int32 index = 0; index < count; index++) @@ -389,8 +410,9 @@ AttributeStreamMemoryNode::Find(const char *name, uint32 type) const return -1; } + off_t -AttributeStreamMemoryNode::Contains(const char *name, uint32 type) +AttributeStreamMemoryNode::Contains(const char* name, uint32 type) { int32 index = Find(name, type); if (index < 0) @@ -400,13 +422,13 @@ AttributeStreamMemoryNode::Contains(const char *name, uint32 type) off_t -AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreignName), - uint32 type, off_t bufferSize, void *buffer, void (*DEBUG_ONLY(swapFunc))(void *)) +AttributeStreamMemoryNode::Read(const char* name, const char* DEBUG_ONLY(foreignName), + uint32 type, off_t bufferSize, void* buffer, void (*DEBUG_ONLY(swapFunc))(void*)) { ASSERT(!foreignName); ASSERT(!swapFunc); - AttrNode *attrNode = NULL; + AttrNode* attrNode = NULL; int32 index = Find(name, type); if (index < 0) { @@ -429,18 +451,20 @@ AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreign return attrNode->fAttr.Size(); } + off_t -AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type, - off_t size, const void *buffer) +AttributeStreamMemoryNode::Write(const char* name, const char*, uint32 type, + off_t size, const void* buffer) { - char *newBuffer = new char[size]; + char* newBuffer = new char[size]; memcpy(newBuffer, buffer, (size_t)size); - AttrNode *attrNode = new AttrNode(name, type, size, newBuffer); + AttrNode* attrNode = new AttrNode(name, type, size, newBuffer); fAttributes.AddItem(attrNode); return size; } + bool AttributeStreamMemoryNode::Drive() { @@ -453,35 +477,37 @@ AttributeStreamMemoryNode::Drive() return true; } -AttributeStreamMemoryNode::AttrNode * -AttributeStreamMemoryNode::BufferingGet(const char *name, uint32 type, off_t size) + +AttributeStreamMemoryNode::AttrNode* +AttributeStreamMemoryNode::BufferingGet(const char* name, uint32 type, off_t size) { - char *newBuffer = new char[size]; + char* newBuffer = new char[size]; if (!fReadFrom->Fill(newBuffer)) { delete[] newBuffer; return NULL; } - AttrNode *attrNode = new AttrNode(name, type, size, newBuffer); + AttrNode* attrNode = new AttrNode(name, type, size, newBuffer); fAttributes.AddItem(attrNode); return fAttributes.LastItem(); } -AttributeStreamMemoryNode::AttrNode * +AttributeStreamMemoryNode::AttrNode* AttributeStreamMemoryNode::BufferingGet() { if (!fReadFrom) return NULL; - const AttributeInfo *attr = fReadFrom->Next(); + const AttributeInfo* attr = fReadFrom->Next(); if (!attr) return NULL; return BufferingGet(attr->Name(), attr->Type(), attr->Size()); } -const AttributeInfo * + +const AttributeInfo* AttributeStreamMemoryNode::Next() { if (fReadFrom) @@ -495,15 +521,17 @@ AttributeStreamMemoryNode::Next() return &fAttributes.ItemAt(++fCurrentIndex)->fAttr; } -const char * + +const char* AttributeStreamMemoryNode::Get() { ASSERT(fCurrentIndex < fAttributes.CountItems()); return fAttributes.ItemAt(fCurrentIndex)->fData; } + bool -AttributeStreamMemoryNode::Fill(char *buffer) const +AttributeStreamMemoryNode::Fill(char* buffer) const { ASSERT(fCurrentIndex < fAttributes.CountItems()); memcpy(buffer, fAttributes.ItemAt(fCurrentIndex)->fData, @@ -513,16 +541,17 @@ AttributeStreamMemoryNode::Fill(char *buffer) const } -AttributeStreamTemplateNode::AttributeStreamTemplateNode(const AttributeTemplate * - attrTemplates, int32 count) +AttributeStreamTemplateNode::AttributeStreamTemplateNode( + const AttributeTemplate* attrTemplates, int32 count) : fAttributes(attrTemplates), fCurrentIndex(-1), fCount(count) { } + off_t -AttributeStreamTemplateNode::Contains(const char *name, uint32 type) +AttributeStreamTemplateNode::Contains(const char* name, uint32 type) { int32 index = Find(name, type); if (index < 0) @@ -531,13 +560,15 @@ AttributeStreamTemplateNode::Contains(const char *name, uint32 type) return fAttributes[index].fSize; } + void AttributeStreamTemplateNode::Rewind() { fCurrentIndex = -1; } -const AttributeInfo * + +const AttributeInfo* AttributeStreamTemplateNode::Next() { if (fCurrentIndex + 1 >= fCount) @@ -546,53 +577,62 @@ AttributeStreamTemplateNode::Next() ++fCurrentIndex; fCurrentAttr.SetTo(fAttributes[fCurrentIndex].fAttributeName, - fAttributes[fCurrentIndex].fAttributeType, fAttributes[fCurrentIndex].fSize); + fAttributes[fCurrentIndex].fAttributeType, + fAttributes[fCurrentIndex].fSize); return &fCurrentAttr; } -const char * + +const char* AttributeStreamTemplateNode::Get() { ASSERT(fCurrentIndex < fCount); return fAttributes[fCurrentIndex].fBits; } + bool -AttributeStreamTemplateNode::Fill(char *buffer) const +AttributeStreamTemplateNode::Fill(char* buffer) const { ASSERT(fCurrentIndex < fCount); - memcpy(buffer, fAttributes[fCurrentIndex].fBits, (size_t)fAttributes[fCurrentIndex].fSize); + memcpy(buffer, fAttributes[fCurrentIndex].fBits, + (size_t)fAttributes[fCurrentIndex].fSize); return true; } + int32 -AttributeStreamTemplateNode::Find(const char *name, uint32 type) const +AttributeStreamTemplateNode::Find(const char* name, uint32 type) const { - for (int32 index = 0; index < fCount; index++) + for (int32 index = 0; index < fCount; index++) { if (fAttributes[index].fAttributeType == type && - strcmp(name, fAttributes[index].fAttributeName) == 0) + strcmp(name, fAttributes[index].fAttributeName) == 0) { return index; + } + } return -1; } + bool -AttributeStreamFilterNode::Reject(const char *, uint32 , off_t ) +AttributeStreamFilterNode::Reject(const char*, uint32, off_t) { // simple pass everything filter return false; } -const AttributeInfo * + +const AttributeInfo* AttributeStreamFilterNode::Next() { if (!fReadFrom) return NULL; for (;;) { - const AttributeInfo *attr = fReadFrom->Next(); + const AttributeInfo* attr = fReadFrom->Next(); if (!attr) break; @@ -602,8 +642,9 @@ AttributeStreamFilterNode::Next() return NULL; } + off_t -AttributeStreamFilterNode::Contains(const char *name, uint32 type) +AttributeStreamFilterNode::Contains(const char* name, uint32 type) { if (!fReadFrom) return 0; @@ -616,9 +657,10 @@ AttributeStreamFilterNode::Contains(const char *name, uint32 type) return 0; } + off_t -AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint32 type, - off_t size, void *buffer, void (*swapFunc)(void *)) +AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*)) { if (!fReadFrom) return 0; @@ -629,9 +671,10 @@ AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint3 return 0; } + off_t -AttributeStreamFilterNode::Write(const char *name, const char *foreignName, uint32 type, - off_t size, const void *buffer) +AttributeStreamFilterNode::Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer) { if (!fWriteTo) return 0; @@ -643,30 +686,34 @@ AttributeStreamFilterNode::Write(const char *name, const char *foreignName, uint } -NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char **nameList) +NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char** nameList) : fNameList(nameList) { } + bool -NamesToAcceptAttrFilter::Reject(const char *name, uint32 , off_t ) +NamesToAcceptAttrFilter::Reject(const char* name, uint32 , off_t ) { for (int32 index = 0; ;index++) { if (!fNameList[index]) break; if (strcmp(name, fNameList[index]) == 0) { -// PRINT(("filter passing through %s\n", name)); + //PRINT(("filter passing through %s\n", name)); return false; } } -// PRINT(("filter rejecting %s\n", name)); + + //PRINT(("filter rejecting %s\n", name)); return true; } -SelectiveAttributeTransformer::SelectiveAttributeTransformer(const char *attributeName, - bool (*transformFunc)(const char * , uint32 , off_t, void *, void *), void *params) +SelectiveAttributeTransformer::SelectiveAttributeTransformer( + const char* attributeName, + bool (*transformFunc)(const char* , uint32 , off_t, void*, void*), + void* params) : fAttributeNameToTransform(attributeName), fTransformFunc(transformFunc), fTransformParams(params), @@ -677,54 +724,62 @@ SelectiveAttributeTransformer::SelectiveAttributeTransformer(const char *attribu SelectiveAttributeTransformer::~SelectiveAttributeTransformer() { - for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--) + for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; + index--) { delete [] fTransformedBuffers.ItemAt(index); + } } + void SelectiveAttributeTransformer::Rewind() { - for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--) + for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; + index--) { delete [] fTransformedBuffers.ItemAt(index); + } fTransformedBuffers.MakeEmpty(); } off_t -SelectiveAttributeTransformer::Read(const char *name, const char *foreignName, - uint32 type, off_t size, void *buffer, void (*swapFunc)(void *)) +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); + off_t result = fReadFrom->Read(name, foreignName, type, size, buffer, + swapFunc); - if (WillTransform(name, type, size, (const char *)buffer)) - ApplyTransformer(name, type, size, (char *)buffer); + if (WillTransform(name, type, size, (const char*)buffer)) + ApplyTransformer(name, type, size, (char*)buffer); return result; } + bool -SelectiveAttributeTransformer::WillTransform(const char *name, uint32 , off_t , - const char *) const +SelectiveAttributeTransformer::WillTransform(const char* name, uint32, off_t, + const char*) const { return strcmp(name, fAttributeNameToTransform) == 0; } + bool -SelectiveAttributeTransformer::ApplyTransformer(const char *name, uint32 type, off_t size, - char *data) +SelectiveAttributeTransformer::ApplyTransformer(const char* name, uint32 type, + off_t size, char* data) { return (fTransformFunc)(name, type, size, data, fTransformParams); } -char * -SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 type, - off_t size, const char *data) +char* +SelectiveAttributeTransformer::CopyAndApplyTransformer(const char* name, + uint32 type, off_t size, const char* data) { - char *result = NULL; + char* result = NULL; if (data) { result = new char[size]; memcpy(result, data, (size_t)size); @@ -734,13 +789,15 @@ SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 delete [] result; return NULL; } + return result; } -const AttributeInfo * + +const AttributeInfo* SelectiveAttributeTransformer::Next() { - const AttributeInfo *result = fReadFrom->Next(); + const AttributeInfo* result = fReadFrom->Next(); if (!result) return NULL; @@ -748,19 +805,22 @@ SelectiveAttributeTransformer::Next() return result; } -const char * + +const char* SelectiveAttributeTransformer::Get() { if (!fReadFrom) return NULL; - const char *result = fReadFrom->Get(); + const char* result = fReadFrom->Get(); - if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), fCurrentAttr.Size(), result)) + if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), + fCurrentAttr.Size(), result)) { return result; + } - char *transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), fCurrentAttr.Type(), - fCurrentAttr.Size(), result); + char* transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), + fCurrentAttr.Type(), fCurrentAttr.Size(), result); // enlist for proper disposal when our job is done if (transformedData) { diff --git a/src/kits/tracker/AttributeStream.h b/src/kits/tracker/AttributeStream.h index 1c31a85..0102ba8 100644 --- a/src/kits/tracker/AttributeStream.h +++ b/src/kits/tracker/AttributeStream.h @@ -46,11 +46,10 @@ All rights reserved. // // In addition to the whacky (but usefull) << syntax, calls like Read, Write are also // available - - #ifndef __ATTRIBUTE_STREAM__ #define __ATTRIBUTE_STREAM__ + #include <Node.h> #include <Rect.h> #include <String.h> @@ -60,14 +59,15 @@ All rights reserved. #include "ObjectList.h" + namespace BPrivate { struct AttributeTemplate { // used for read-only attribute source - const char *fAttributeName; + const char* fAttributeName; uint32 fAttributeType; off_t fSize; - const char *fBits; + const char* fBits; }; @@ -77,26 +77,27 @@ public: AttributeInfo() {} AttributeInfo(const AttributeInfo &); - AttributeInfo(const char *, attr_info); - AttributeInfo(const char *, uint32, off_t); + AttributeInfo(const char*, attr_info); + AttributeInfo(const char*, uint32, off_t); void SetTo(const AttributeInfo &); - void SetTo(const char *, attr_info); - void SetTo(const char *, uint32, off_t); - const char *Name() const; + void SetTo(const char*, attr_info); + void SetTo(const char*, uint32, off_t); + const char* Name() const; uint32 Type() const; off_t Size() const; private: BString fName; attr_info fInfo; -}; - +}; + + class AttributeStreamNode { public: AttributeStreamNode(); virtual ~AttributeStreamNode(); - + AttributeStreamNode &operator<<(AttributeStreamNode &source); // workhorse call // to the outside makes this node a part of the stream, passing on @@ -104,35 +105,34 @@ public: // // under the hood sets up streaming into the next node; hooking // up source and destination, forces the stream head to start streaming - + virtual void Rewind(); // get ready to start all over again virtual void MakeEmpty() {} // remove any attributes the node may have - - virtual off_t Contains(const char *, uint32); + + virtual off_t Contains(const char*, uint32); // returns size of attribute if found - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); // read from this node - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, + const void* buffer); // write to this node - // work calls virtual bool Drive(); // node at the head of the stream makes the entire stream // feed it - virtual const AttributeInfo *Next(); + virtual const AttributeInfo* Next(); // give me the next attribute in the stream - virtual const char *Get(); + virtual const char* Get(); // give me the data of the attribute in the stream that was just returned // by Next // assumes there is a buffering node somewhere on the way to // the source, from which the resulting buffer is borrowed - virtual bool Fill(char *buffer) const; + virtual bool Fill(char* buffer) const; // fill the buffer with data of the attribute in the stream that was just returned // by next // <buffer> is big enough to hold the entire attribute data @@ -148,47 +148,49 @@ private: void Detach(); protected: - AttributeStreamNode *fReadFrom; - AttributeStreamNode *fWriteTo; + AttributeStreamNode* fReadFrom; + AttributeStreamNode* fWriteTo; }; + class AttributeStreamFileNode : public AttributeStreamNode { // handles reading and writing attributes to and from the // stream public: AttributeStreamFileNode(); - AttributeStreamFileNode(BNode *); - + AttributeStreamFileNode(BNode*); + virtual void MakeEmpty(); virtual void Rewind(); - virtual off_t Contains(const char *name, uint32 type); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); + virtual off_t Contains(const char* name, uint32 type); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer); - void SetTo(BNode *); + void SetTo(BNode*); - BNode *Node() + BNode* Node() { return fNode; } - + protected: virtual bool CanFeed() const { return true; } virtual bool Drive(); // give me all the attributes, I'll write them into myself - virtual const AttributeInfo *Next(); + virtual const AttributeInfo* Next(); // return the info for the next attribute I can read for you - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const char* Get(); + virtual bool Fill(char* buffer) const; private: AttributeInfo fCurrentAttr; - BNode *fNode; + BNode* fNode; typedef AttributeStreamNode _inherited; }; + class AttributeStreamMemoryNode : public AttributeStreamNode { // in memory attribute buffer; can be both target of writing and source // of reading at the same time @@ -196,24 +198,23 @@ public: AttributeStreamMemoryNode(); virtual void MakeEmpty(); - virtual off_t Contains(const char *name, uint32 type); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); - -protected: + virtual off_t Contains(const char* name, uint32 type); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, + const void* buffer); +protected: virtual bool CanFeed() const { return true; } virtual void Rewind(); virtual bool Drive(); - virtual const AttributeInfo *Next(); - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const AttributeInfo* Next(); + virtual const char* Get(); + virtual bool Fill(char* buffer) const; class AttrNode { public: - AttrNode(const char *name, uint32 type, off_t size, char *data) + AttrNode(const char* name, uint32 type, off_t size, char* data) : fAttr(name, type, size), fData(data) { @@ -225,129 +226,132 @@ protected: } AttributeInfo fAttr; - char *fData; + char* fData; }; - + // utility calls - virtual AttrNode *BufferingGet(); - virtual AttrNode *BufferingGet(const char *name, uint32 type, off_t size); - int32 Find(const char *name, uint32 type) const; + virtual AttrNode* BufferingGet(); + virtual AttrNode* BufferingGet(const char* name, uint32 type, off_t size); + int32 Find(const char* name, uint32 type) const; private: - BObjectList<AttrNode> fAttributes; int32 fCurrentIndex; typedef AttributeStreamNode _inherited; }; + class AttributeStreamTemplateNode : public AttributeStreamNode { // in read-only memory attribute source // can only be used as a source for Next and Get public: - AttributeStreamTemplateNode(const AttributeTemplate *, int32 count); + AttributeStreamTemplateNode(const AttributeTemplate*, int32 count); - virtual off_t Contains(const char *name, uint32 type); - -protected: + virtual off_t Contains(const char* name, uint32 type); +protected: virtual bool CanFeed() const { return true; } virtual void Rewind(); - virtual const AttributeInfo *Next(); - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const AttributeInfo* Next(); + virtual const char* Get(); + virtual bool Fill(char* buffer) const; - int32 Find(const char *name, uint32 type) const; + int32 Find(const char* name, uint32 type) const; private: AttributeInfo fCurrentAttr; - const AttributeTemplate *fAttributes; + const AttributeTemplate* fAttributes; int32 fCurrentIndex; int32 fCount; typedef AttributeStreamNode _inherited; }; + class AttributeStreamFilterNode : public AttributeStreamNode { // filter node may not pass thru specified attributes public: AttributeStreamFilterNode() {} - virtual off_t Contains(const char *name, uint32 type); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); + virtual off_t Contains(const char* name, uint32 type); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, + const void* buffer); protected: - virtual bool Reject(const char *name, uint32 type, off_t size); + virtual bool Reject(const char* name, uint32 type, off_t size); // override to implement filtering - virtual const AttributeInfo *Next(); - + virtual const AttributeInfo* Next(); + private: typedef AttributeStreamNode _inherited; }; + class NamesToAcceptAttrFilter : public AttributeStreamFilterNode { // filter node that only passes thru attributes that match // a list of names public: - NamesToAcceptAttrFilter(const char **); + NamesToAcceptAttrFilter(const char**); protected: - virtual bool Reject(const char *name, uint32 type, off_t size); + virtual bool Reject(const char* name, uint32 type, off_t size); private: - const char **fNameList; + const char** fNameList; }; + class SelectiveAttributeTransformer : public AttributeStreamNode { // node applies a transformation on specified attributes public: - SelectiveAttributeTransformer(const char *attributeName, bool (*)(const char *, - uint32 , off_t , void *, void *), void *params); + SelectiveAttributeTransformer(const char* attributeName, bool (*)(const char*, + uint32 , off_t , void*, void*), void* params); virtual ~SelectiveAttributeTransformer(); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); virtual void Rewind(); protected: - virtual bool WillTransform(const char *name, uint32 type, off_t size, const char *data) const; + virtual bool WillTransform(const char* name, uint32 type, off_t size, const char* data) const; // override to implement filtering; should only return true if transformation will // occur - virtual char *CopyAndApplyTransformer(const char *name, uint32 type, off_t size, const char *data); + virtual char* CopyAndApplyTransformer(const char* name, uint32 type, off_t size, const char* data); // makes a copy of data - virtual bool ApplyTransformer(const char *name, uint32 type, off_t size, char *data); + virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, char* data); // transforms in place - virtual const AttributeInfo *Next(); - virtual const char *Get(); - + virtual const AttributeInfo* Next(); + virtual const char* Get(); + private: AttributeInfo fCurrentAttr; - const char *fAttributeNameToTransform; - bool (*fTransformFunc)(const char *, uint32 , off_t , void *, void *); - void *fTransformParams; + const char* fAttributeNameToTransform; + bool (*fTransformFunc)(const char*, uint32 , off_t , void*, void*); + void* fTransformParams; BObjectList<char> fTransformedBuffers; typedef AttributeStreamNode _inherited; }; + template <class Type> class AttributeStreamConstValue : public AttributeStreamNode { public: - AttributeStreamConstValue(const char *name, uint32 attributeType, Type value); -protected: + AttributeStreamConstValue(const char* name, uint32 attributeType, Type value); +protected: virtual bool CanFeed() const { return true; } virtual void Rewind() { fRewound = true; } - virtual const AttributeInfo *Next(); - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const AttributeInfo* Next(); + virtual const char* Get(); + virtual bool Fill(char* buffer) const; - int32 Find(const char *name, uint32 type) const; + int32 Find(const char* name, uint32 type) const; private: AttributeInfo fAttr; @@ -357,8 +361,9 @@ private: typedef AttributeStreamNode _inherited; }; + template<class Type> -AttributeStreamConstValue<Type>::AttributeStreamConstValue(const char *name, +AttributeStreamConstValue<Type>::AttributeStreamConstValue(const char* name, uint32 attributeType, Type value) : fAttr(name, attributeType, sizeof(Type)), fValue(value), @@ -366,35 +371,39 @@ AttributeStreamConstValue<Type>::AttributeStreamConstValue(const char *name, { } + template<class Type> -const AttributeInfo * +const AttributeInfo* AttributeStreamConstValue<Type>::Next() { if (!fRewound) return NULL; - + fRewound = false; return &fAttr; } + template<class Type> -const char * +const char* AttributeStreamConstValue<Type>::Get() { - return (const char *)&fValue; + return (const char*)&fValue; } + template<class Type> -bool -AttributeStreamConstValue<Type>::Fill(char *buffer) const +bool +AttributeStreamConstValue<Type>::Fill(char* buffer) const { memcpy(buffer, &fValue, sizeof(Type)); return true; } + template<class Type> -int32 -AttributeStreamConstValue<Type>::Find(const char *name, uint32 type) const +int32 +AttributeStreamConstValue<Type>::Find(const char* name, uint32 type) const { if (strcmp(fAttr.Name(), name) == 0 && type == fAttr.Type()) return 0; @@ -402,42 +411,47 @@ AttributeStreamConstValue<Type>::Find(const char *name, uint32 type) const return -1; } + class AttributeStreamBoolValue : public AttributeStreamConstValue<bool> { public: - AttributeStreamBoolValue(const char *name, bool value) + AttributeStreamBoolValue(const char* name, bool value) : AttributeStreamConstValue<bool>(name, B_BOOL_TYPE, value) {} }; + class AttributeStreamInt32Value : public AttributeStreamConstValue<int32> { public: - AttributeStreamInt32Value(const char *name, int32 value) + AttributeStreamInt32Value(const char* name, int32 value) : AttributeStreamConstValue<int32>(name, B_INT32_TYPE, value) {} }; + class AttributeStreamInt64Value : public AttributeStreamConstValue<int64> { public: - AttributeStreamInt64Value(const char *name, int64 value) + AttributeStreamInt64Value(const char* name, int64 value) : AttributeStreamConstValue<int64>(name, B_INT64_TYPE, value) {} }; + class AttributeStreamRectValue : public AttributeStreamConstValue<BRect> { public: - AttributeStreamRectValue(const char *name, BRect value) + AttributeStreamRectValue(const char* name, BRect value) : AttributeStreamConstValue<BRect>(name, B_RECT_TYPE, value) {} }; + class AttributeStreamFloatValue : public AttributeStreamConstValue<float> { public: - AttributeStreamFloatValue(const char *name, float value) + AttributeStreamFloatValue(const char* name, float value) : AttributeStreamConstValue<float>(name, B_FLOAT_TYPE, value) {} }; -} +} // namespace BPrivate using namespace BPrivate; diff --git a/src/kits/tracker/Attributes.h b/src/kits/tracker/Attributes.h index 2a513a3..b79f2eb 100644 --- a/src/kits/tracker/Attributes.h +++ b/src/kits/tracker/Attributes.h @@ -31,157 +31,157 @@ 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. */ - #ifndef _ATTRIBUTES_H #define _ATTRIBUTES_H + namespace BPrivate { // viewable attributes -#define kAttrStatName "_stat/name" -#define kAttrRealName "_stat/realname" -#define kAttrStatSize "_stat/size" -#define kAttrStatModified "_stat/modified" -#define kAttrStatCreated "_stat/created" -#define kAttrStatMode "_stat/mode" -#define kAttrStatOwner "_stat/owner" -#define kAttrStatGroup "_stat/group" -#define kAttrPath "_trk/path" -#define kAttrOriginalPath "_trk/original_path" -#define kAttrAppVersion "_trk/app_version" -#define kAttrSystemVersion "_trk/system_version" -#define kAttrOpenWithRelation "_trk/open_with_relation" +#define kAttrStatName "_stat/name" +#define kAttrRealName "_stat/realname" +#define kAttrStatSize "_stat/size" +#define kAttrStatModified "_stat/modified" +#define kAttrStatCreated "_stat/created" +#define kAttrStatMode "_stat/mode" +#define kAttrStatOwner "_stat/owner" +#define kAttrStatGroup "_stat/group" +#define kAttrPath "_trk/path" +#define kAttrOriginalPath "_trk/original_path" +#define kAttrAppVersion "_trk/app_version" +#define kAttrSystemVersion "_trk/system_version" +#define kAttrOpenWithRelation "_trk/open_with_relation" // private attributes -#define kAttrWindowFrame "_trk/windframe" -#define kAttrWindowWorkspace "_trk/windwkspc" -#define kAttrWindowDecor "_trk/winddecor" +#define kAttrWindowFrame "_trk/windframe" +#define kAttrWindowWorkspace "_trk/windwkspc" +#define kAttrWindowDecor "_trk/winddecor" -#define kAttrQueryString "_trk/qrystr" -#define kAttrQueryVolume "_trk/qryvol1" +#define kAttrQueryString "_trk/qrystr" +#define kAttrQueryVolume "_trk/qryvol1" -#define kAttrMIMEType "BEOS:TYPE" -#define kAttrAppSignature "BEOS:APP_SIG" -#define kAttrPreferredApp "BEOS:PREF_APP" -#define kAttrLargeIcon "BEOS:L:STD_ICON" -#define kAttrMiniIcon "BEOS:M:STD_ICON" -#define kAttrIcon "BEOS:ICON" +#define kAttrMIMEType "BEOS:TYPE" +#define kAttrAppSignature "BEOS:APP_SIG" +#define kAttrPreferredApp "BEOS:PREF_APP" +#define kAttrLargeIcon "BEOS:L:STD_ICON" +#define kAttrMiniIcon "BEOS:M:STD_ICON" +#define kAttrIcon "BEOS:ICON" -#define kAttrDisksFrame "_trk/d_windframe" -#define kAttrDisksWorkspace "_trk/d_windwkspc" +#define kAttrDisksFrame "_trk/d_windframe" +#define kAttrDisksWorkspace "_trk/d_windwkspc" -#define kAttrOpenWindows "_trk/_windows_to_open_" +#define kAttrOpenWindows "_trk/_windows_to_open_" -#define kAttrClippingFile "_trk/_clipping_file_" +#define kAttrClippingFile "_trk/_clipping_file_" -#define kAttrQueryInitialMode "_trk/qryinitmode" -#define kAttrQueryInitialString "_trk/qryinitstr" -#define kAttrQueryInitialNumAttrs "_trk/qryinitnumattrs" -#define kAttrQueryInitialAttrs "_trk/qryinitattrs" -#define kAttrQueryInitialMime "_trk/qryinitmime" -#define kAttrQueryLastChange "_trk/qrylastchange" +#define kAttrQueryInitialMode "_trk/qryinitmode" +#define kAttrQueryInitialString "_trk/qryinitstr" +#define kAttrQueryInitialNumAttrs "_trk/qryinitnumattrs" +#define kAttrQueryInitialAttrs "_trk/qryinitattrs" +#define kAttrQueryInitialMime "_trk/qryinitmime" +#define kAttrQueryLastChange "_trk/qrylastchange" -#define kAttrQueryMoreOptions_le "_trk/qrymoreoptions_le" -#define kAttrQueryMoreOptions_be "_trk/qrymoreoptions" +#define kAttrQueryMoreOptions_le "_trk/qrymoreoptions_le" +#define kAttrQueryMoreOptions_be "_trk/qrymoreoptions" -#define kAttrQueryTemplate "_trk/queryTemplate" -#define kAttrQueryTemplateName "_trk/queryTemplateName" -#define kAttrDynamicDateQuery "_trk/queryDynamicDate" +#define kAttrQueryTemplate "_trk/queryTemplate" +#define kAttrQueryTemplateName "_trk/queryTemplateName" +#define kAttrDynamicDateQuery "_trk/queryDynamicDate" // attributes that need endian swapping (stored as raw) -#define kAttrPoseInfo_be "_trk/pinfo" -#define kAttrPoseInfo_le "_trk/pinfo_le" -#define kAttrDisksPoseInfo_be "_trk/d_pinfo" -#define kAttrDisksPoseInfo_le "_trk/d_pinfo_le" -#define kAttrTrashPoseInfo_be "_trk/t_pinfo" -#define kAttrTrashPoseInfo_le "_trk/t_pinfo_le" -#define kAttrColumns_be "_trk/columns" -#define kAttrColumns_le "_trk/columns_le" -#define kAttrViewState_be "_trk/viewstate" -#define kAttrViewState_le "_trk/viewstate_le" -#define kAttrDisksViewState_be "_trk/d_viewstate" -#define kAttrDisksViewState_le "_trk/d_viewstate_le" -#define kAttrDesktopViewState_be "_trk/desk_viewstate" -#define kAttrDesktopViewState_le "_trk/desk_viewstate_le" -#define kAttrDisksColumns_be "_trk/d_columns" -#define kAttrDisksColumns_le "_trk/d_columns_le" - -#define kAttrExtendedPoseInfo_be "_trk/xtpinfo" -#define kAttrExtendedPoseInfo_le "_trk/xtpinfo_le" -#define kAttrExtendedDisksPoseInfo_be "_trk/xt_d_pinfo" -#define kAttrExtendedDisksPoseInfo_le "_trk/xt_d_pinfo_le" +#define kAttrPoseInfo_be "_trk/pinfo" +#define kAttrPoseInfo_le "_trk/pinfo_le" +#define kAttrDisksPoseInfo_be "_trk/d_pinfo" +#define kAttrDisksPoseInfo_le "_trk/d_pinfo_le" +#define kAttrTrashPoseInfo_be "_trk/t_pinfo" +#define kAttrTrashPoseInfo_le "_trk/t_pinfo_le" +#define kAttrColumns_be "_trk/columns" +#define kAttrColumns_le "_trk/columns_le" +#define kAttrViewState_be "_trk/viewstate" +#define kAttrViewState_le "_trk/viewstate_le" +#define kAttrDisksViewState_be "_trk/d_viewstate" +#define kAttrDisksViewState_le "_trk/d_viewstate_le" +#define kAttrDesktopViewState_be "_trk/desk_viewstate" +#define kAttrDesktopViewState_le "_trk/desk_viewstate_le" +#define kAttrDisksColumns_be "_trk/d_columns" +#define kAttrDisksColumns_le "_trk/d_columns_le" + +#define kAttrExtendedPoseInfo_be "_trk/xtpinfo" +#define kAttrExtendedPoseInfo_le "_trk/xtpinfo_le" +#define kAttrExtendedDisksPoseInfo_be "_trk/xt_d_pinfo" +#define kAttrExtendedDisksPoseInfo_le "_trk/xt_d_pinfo_le" #if B_HOST_IS_LENDIAN -#define kEndianSuffix "_le" -#define kForeignEndianSuffix "" +#define kEndianSuffix "_le" +#define kForeignEndianSuffix "" -#define kAttrDisksPoseInfo kAttrDisksPoseInfo_le -#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_be +#define kAttrDisksPoseInfo kAttrDisksPoseInfo_le +#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_be -#define kAttrTrashPoseInfo kAttrTrashPoseInfo_le -#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_be +#define kAttrTrashPoseInfo kAttrTrashPoseInfo_le +#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_be -#define kAttrPoseInfo kAttrPoseInfo_le -#define kAttrPoseInfoForeign kAttrPoseInfo_be +#define kAttrPoseInfo kAttrPoseInfo_le +#define kAttrPoseInfoForeign kAttrPoseInfo_be -#define kAttrColumns kAttrColumns_le -#define kAttrColumnsForeign kAttrColumns_be +#define kAttrColumns kAttrColumns_le +#define kAttrColumnsForeign kAttrColumns_be -#define kAttrViewState kAttrViewState_le -#define kAttrViewStateForeign kAttrViewState_be +#define kAttrViewState kAttrViewState_le +#define kAttrViewStateForeign kAttrViewState_be -#define kAttrDisksViewState kAttrDisksViewState_le -#define kAttrDisksViewStateForeign kAttrDisksViewState_be +#define kAttrDisksViewState kAttrDisksViewState_le +#define kAttrDisksViewStateForeign kAttrDisksViewState_be -#define kAttrDisksColumns kAttrDisksColumns_le -#define kAttrDisksColumnsForeign kAttrDisksColumns_be +#define kAttrDisksColumns kAttrDisksColumns_le +#define kAttrDisksColumnsForeign kAttrDisksColumns_be -#define kAttrDesktopViewState kAttrDesktopViewState_le -#define kAttrDesktopViewStateForeign kAttrDesktopViewState_be +#define kAttrDesktopViewState kAttrDesktopViewState_le +#define kAttrDesktopViewStateForeign kAttrDesktopViewState_be -#define kAttrQueryMoreOptions kAttrQueryMoreOptions_le -#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_be -#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_le -#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_be -#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_le -#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_be +#define kAttrQueryMoreOptions kAttrQueryMoreOptions_le +#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_be +#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_le +#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_be +#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_le +#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_be #else -#define kEndianSuffix "" -#define kForeignEndianSuffix "_le" +#define kEndianSuffix "" +#define kForeignEndianSuffix "_le" -#define kAttrDisksPoseInfo kAttrDisksPoseInfo_be -#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_le +#define kAttrDisksPoseInfo kAttrDisksPoseInfo_be +#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_le -#define kAttrTrashPoseInfo kAttrTrashPoseInfo_be -#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_le +#define kAttrTrashPoseInfo kAttrTrashPoseInfo_be +#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_le -#define kAttrPoseInfo kAttrPoseInfo_be -#define kAttrPoseInfoForeign kAttrPoseInfo_le +#define kAttrPoseInfo kAttrPoseInfo_be +#define kAttrPoseInfoForeign kAttrPoseInfo_le -#define kAttrColumns kAttrColumns_be -#define kAttrColumnsForeign kAttrColumns_le +#define kAttrColumns kAttrColumns_be +#define kAttrColumnsForeign kAttrColumns_le -#define kAttrViewState kAttrViewState_be -#define kAttrViewStateForeign kAttrViewState_le +#define kAttrViewState kAttrViewState_be +#define kAttrViewStateForeign kAttrViewState_le -#define kAttrDisksViewState kAttrDisksViewState_be -#define kAttrDisksViewStateForeign kAttrDisksViewState_le +#define kAttrDisksViewState kAttrDisksViewState_be +#define kAttrDisksViewStateForeign kAttrDisksViewState_le -#define kAttrDisksColumns kAttrDisksColumns_be -#define kAttrDisksColumnsForeign kAttrDisksColumns_le +#define kAttrDisksColumns kAttrDisksColumns_be +#define kAttrDisksColumnsForeign kAttrDisksColumns_le -#define kAttrDesktopViewState kAttrViewState_be -#define kAttrDesktopViewStateForeign kAttrViewState_le +#define kAttrDesktopViewState kAttrViewState_be +#define kAttrDesktopViewStateForeign kAttrViewState_le -#define kAttrQueryMoreOptions kAttrQueryMoreOptions_be -#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_le -#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_be -#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_le -#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_be -#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_le +#define kAttrQueryMoreOptions kAttrQueryMoreOptions_be +#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_le +#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_be +#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_le +#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_be +#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_le #endif diff --git a/src/kits/tracker/AutoMounterSettings.cpp b/src/kits/tracker/AutoMounterSettings.cpp index 795870f..33730b3 100644 --- a/src/kits/tracker/AutoMounterSettings.cpp +++ b/src/kits/tracker/AutoMounterSettings.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "AutoMounterSettings.h" #include <Alert.h> diff --git a/src/kits/tracker/AutoMounterSettings.h b/src/kits/tracker/AutoMounterSettings.h index 88fa68d..75cfbb9 100644 --- a/src/kits/tracker/AutoMounterSettings.h +++ b/src/kits/tracker/AutoMounterSettings.h @@ -31,7 +31,6 @@ 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. */ - #ifndef AUTOMOUNTER_SETTINGS_H #define AUTOMOUNTER_SETTINGS_H @@ -43,13 +42,13 @@ namespace BPrivate { class AutomountSettingsDialog : public BWindow { public: - AutomountSettingsDialog(BMessage *settings, const BMessenger &target); + AutomountSettingsDialog(BMessage* settings, const BMessenger &target); virtual ~AutomountSettingsDialog(); static void RunAutomountSettings(const BMessenger &target); private: - static AutomountSettingsDialog *sOneCopyOnly; + static AutomountSettingsDialog* sOneCopyOnly; }; } // namespace BPrivate diff --git a/src/kits/tracker/Background.h b/src/kits/tracker/Background.h index cf8afcc..b850313 100644 --- a/src/kits/tracker/Background.h +++ b/src/kits/tracker/Background.h @@ -68,4 +68,4 @@ enum { const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to // use a new background image -#endif /* _TRACKER_BACKGROUND_H */ +#endif // _TRACKER_BACKGROUND_H diff --git a/src/kits/tracker/BackgroundImage.cpp b/src/kits/tracker/BackgroundImage.cpp index 565ee90..f12d110 100644 --- a/src/kits/tracker/BackgroundImage.cpp +++ b/src/kits/tracker/BackgroundImage.cpp @@ -33,7 +33,7 @@ All rights reserved. */ // Classes used for setting up and managing background images -// + #include <Bitmap.h> #include <ControlLook.h> @@ -50,26 +50,28 @@ All rights reserved. #include "Commands.h" #include "PoseView.h" + namespace BPrivate { -const char *kBackgroundImageInfo = B_BACKGROUND_INFO; -const char *kBackgroundImageInfoOffset = B_BACKGROUND_ORIGIN; -const char *kBackgroundImageInfoTextOutline = B_BACKGROUND_TEXT_OUTLINE; -const char *kBackgroundImageInfoMode = B_BACKGROUND_MODE; -const char *kBackgroundImageInfoWorkspaces = B_BACKGROUND_WORKSPACES; -const char *kBackgroundImageInfoPath = B_BACKGROUND_IMAGE; +const char* kBackgroundImageInfo = B_BACKGROUND_INFO; +const char* kBackgroundImageInfoOffset = B_BACKGROUND_ORIGIN; +const char* kBackgroundImageInfoTextOutline = B_BACKGROUND_TEXT_OUTLINE; +const char* kBackgroundImageInfoMode = B_BACKGROUND_MODE; +const char* kBackgroundImageInfoWorkspaces = B_BACKGROUND_WORKSPACES; +const char* kBackgroundImageInfoPath = B_BACKGROUND_IMAGE; + +} // namespace BPrivate -} -BackgroundImage * -BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) +BackgroundImage* +BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop) { attr_info info; if (node->GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) return NULL; BMessage container; - char *buffer = new char [info.size]; + char* buffer = new char [info.size]; status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size); if (error == info.size) @@ -80,14 +82,14 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) if (error != B_OK) return NULL; - BackgroundImage *result = NULL; + BackgroundImage* result = NULL; for (int32 index = 0; ; index++) { - const char *path; + const char* path; uint32 workspaces = B_ALL_WORKSPACES; Mode mode = kTiled; bool textWidgetLabelOutline = false; BPoint offset; - BBitmap *bitmap = NULL; + BBitmap* bitmap = NULL; if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) { bitmap = BTranslationUtils::GetBitmap(path); @@ -102,12 +104,12 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) be_control_look->SetBackgroundInfo(container); } - container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces); - container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode); + container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32*)&workspaces); + container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode); container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline); container.FindPoint(kBackgroundImageInfoOffset, index, &offset); - BackgroundImage::BackgroundImageInfo *imageInfo = new + BackgroundImage::BackgroundImageInfo* imageInfo = new BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset, textWidgetLabelOutline); @@ -121,7 +123,7 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) BackgroundImage::BackgroundImageInfo::BackgroundImageInfo(uint32 workspaces, - BBitmap *bitmap, Mode mode, BPoint offset, bool textWidgetOutline) + BBitmap* bitmap, Mode mode, BPoint offset, bool textWidgetOutline) : fWorkspace(workspaces), fBitmap(bitmap), fMode(mode), @@ -137,7 +139,7 @@ BackgroundImage::BackgroundImageInfo::~BackgroundImageInfo() } -BackgroundImage::BackgroundImage(const BNode *node, bool desktop) +BackgroundImage::BackgroundImage(const BNode* node, bool desktop) : fIsDesktop(desktop), fDefinedByNode(*node), fView(NULL), @@ -153,20 +155,20 @@ BackgroundImage::~BackgroundImage() void -BackgroundImage::Add(BackgroundImageInfo *info) +BackgroundImage::Add(BackgroundImageInfo* info) { fBitmapForWorkspaceList.AddItem(info); } void -BackgroundImage::Show(BView *view, int32 workspace) +BackgroundImage::Show(BView* view, int32 workspace) { fView = view; - BackgroundImageInfo *info = ImageInfoForWorkspace(workspace); + BackgroundImageInfo* info = ImageInfoForWorkspace(workspace); if (info) { - BPoseView *poseView = dynamic_cast<BPoseView *>(fView); + BPoseView* poseView = dynamic_cast<BPoseView*>(fView); if (poseView) poseView->SetWidgetTextOutline(info->fTextWidgetOutline); Show(info, fView); @@ -174,9 +176,9 @@ BackgroundImage::Show(BView *view, int32 workspace) } void -BackgroundImage::Show(BackgroundImageInfo *info, BView *view) +BackgroundImage::Show(BackgroundImageInfo* info, BView* view) { - BPoseView *poseView = dynamic_cast<BPoseView *>(view); + BPoseView* poseView = dynamic_cast<BPoseView*>(view); if (poseView) poseView->SetWidgetTextOutline(info->fTextWidgetOutline); @@ -271,7 +273,7 @@ BackgroundImage::Remove() if (fShowingBitmap) { fView->ClearViewBitmap(); fView->Invalidate(); - BPoseView *poseView = dynamic_cast<BPoseView *>(fView); + BPoseView* poseView = dynamic_cast<BPoseView*>(fView); // make sure text widgets draw the default way, erasing their background if (poseView) poseView->SetWidgetTextOutline(true); @@ -279,7 +281,7 @@ BackgroundImage::Remove() fShowingBitmap = NULL; } -BackgroundImage::BackgroundImageInfo * +BackgroundImage::BackgroundImageInfo* BackgroundImage::ImageInfoForWorkspace(int32 workspace) const { uint32 workspaceMask = 1; @@ -292,9 +294,9 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const // do a simple lookup for the most likely candidate bitmap - // pick the imageInfo that is only defined for this workspace over one // that supports multiple workspaces - BackgroundImageInfo *result = NULL; + BackgroundImageInfo* result = NULL; for (int32 index = 0; index < count; index++) { - BackgroundImageInfo *info = fBitmapForWorkspaceList.ItemAt(index); + BackgroundImageInfo* info = fBitmapForWorkspaceList.ItemAt(index); if (info->fWorkspace == workspaceMask) return info; if (info->fWorkspace & workspaceMask) @@ -305,7 +307,7 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const } void -BackgroundImage::WorkspaceActivated(BView *view, int32 workspace, bool state) +BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state) { if (!fIsDesktop) // we only care for desktop bitmaps @@ -315,13 +317,13 @@ BackgroundImage::WorkspaceActivated(BView *view, int32 workspace, bool state) // we only care comming into a new workspace, not leaving one return; - BackgroundImageInfo *info = ImageInfoForWorkspace(workspace); + BackgroundImageInfo* info = ImageInfoForWorkspace(workspace); if (info != fShowingBitmap) { if (info) Show(info, view); else { - if (BPoseView *poseView = dynamic_cast<BPoseView *>(view)) + if (BPoseView* poseView = dynamic_cast<BPoseView*>(view)) poseView->SetWidgetTextOutline(true); view->ClearViewBitmap(); view->Invalidate(); @@ -350,16 +352,16 @@ BackgroundImage::ScreenChanged(BRect, color_space) } } -BackgroundImage * -BackgroundImage::Refresh(BackgroundImage *oldBackgroundImage, - const BNode *fromNode, bool desktop, BPoseView *poseView) +BackgroundImage* +BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage, + const BNode* fromNode, bool desktop, BPoseView* poseView) { if (oldBackgroundImage) { oldBackgroundImage->Remove(); delete oldBackgroundImage; } - BackgroundImage *result = GetBackgroundImage(fromNode, desktop); + BackgroundImage* result = GetBackgroundImage(fromNode, desktop); if (result && poseView->ViewMode() != kListMode) result->Show(poseView, current_workspace()); diff --git a/src/kits/tracker/BackgroundImage.h b/src/kits/tracker/BackgroundImage.h index cba8f75..d5857ca 100644 --- a/src/kits/tracker/BackgroundImage.h +++ b/src/kits/tracker/BackgroundImage.h @@ -31,16 +31,17 @@ 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. */ +#ifndef __BACKGROUND_IMAGE__ +#define __BACKGROUND_IMAGE__ + // Classes used for setting up and managing background images -// -#ifndef __BACKGROUND_IMAGE__ -#define __BACKGROUND_IMAGE__ #include <String.h> #include "ObjectList.h" + class BNode; class BView; class BBitmap; @@ -50,12 +51,12 @@ namespace BPrivate { class BackgroundImage; class BPoseView; -extern const char *kBackgroundImageInfo; -extern const char *kBackgroundImageInfoOffset; -extern const char *kBackgroundImageInfoTextOutline; -extern const char *kBackgroundImageInfoMode; -extern const char *kBackgroundImageInfoWorkspaces; -extern const char *kBackgroundImageInfoPath; +extern const char* kBackgroundImageInfo; +extern const char* kBackgroundImageInfoOffset; +extern const char* kBackgroundImageInfoTextOutline; +extern const char* kBackgroundImageInfoMode; +extern const char* kBackgroundImageInfoWorkspaces; +extern const char* kBackgroundImageInfoPath; const uint32 kRestoreBackgroundImage = 'Tbgr'; @@ -76,44 +77,44 @@ public: class BackgroundImageInfo { // element of the per-workspace list public: - BackgroundImageInfo(uint32 workspace, BBitmap *bitmap, Mode mode, BPoint offset, + BackgroundImageInfo(uint32 workspace, BBitmap* bitmap, Mode mode, BPoint offset, bool textWidgetOutline); ~BackgroundImageInfo(); uint32 fWorkspace; - BBitmap *fBitmap; + BBitmap* fBitmap; Mode fMode; BPoint fOffset; bool fTextWidgetOutline; }; - static BackgroundImage *GetBackgroundImage(const BNode *node, + static BackgroundImage* GetBackgroundImage(const BNode* node, bool isDesktop); // create a BackgroundImage object by reading it from a node virtual ~BackgroundImage(); - void Show(BView *view, int32 workspace); + void Show(BView* view, int32 workspace); // display the right background for a given workspace void Remove(); // remove the background from it's current view - void WorkspaceActivated(BView *view, int32 workspace, bool state); + void WorkspaceActivated(BView* view, int32 workspace, bool state); // respond to a workspace change void ScreenChanged(BRect rect, color_space space); // respond to a screen size change - static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage, - const BNode *fromNode, bool desktop, BPoseView *poseView); + static BackgroundImage* Refresh(BackgroundImage* oldBackgroundImage, + const BNode* fromNode, bool desktop, BPoseView* poseView); // respond to a background image setting change private: - BackgroundImageInfo *ImageInfoForWorkspace(int32) const; - void Show(BackgroundImageInfo *, BView *view); + BackgroundImageInfo* ImageInfoForWorkspace(int32) const; + void Show(BackgroundImageInfo*, BView* view); - BackgroundImage(const BNode *, bool); + BackgroundImage(const BNode*, bool); // no public constructor, GetBackgroundImage factory function is // used instead - void Add(BackgroundImageInfo *); + void Add(BackgroundImageInfo*); float BRectRatio(BRect rect); float BRectHorizontalOverlap(BRect hostRect, BRect resizedRect); @@ -121,13 +122,12 @@ private: bool fIsDesktop; BNode fDefinedByNode; - BView *fView; - BackgroundImageInfo *fShowingBitmap; + BView* fView; + BackgroundImageInfo* fShowingBitmap; BObjectList<BackgroundImageInfo> fBitmapForWorkspaceList; }; - } // namespace BPrivate using namespace BPrivate; diff --git a/src/kits/tracker/Bitmaps.cpp b/src/kits/tracker/Bitmaps.cpp index ed22d54..2f4f68c 100644 --- a/src/kits/tracker/Bitmaps.cpp +++ b/src/kits/tracker/Bitmaps.cpp @@ -48,7 +48,7 @@ All rights reserved. #endif -BImageResources::BImageResources(void *memAddr) +BImageResources::BImageResources(void* memAddr) { image_id image = find_image(memAddr); image_info info; @@ -71,7 +71,7 @@ BImageResources::~BImageResources() } -const BResources * +const BResources* BImageResources::ViewResources() const { if (fLock.Lock() != B_OK) @@ -81,7 +81,7 @@ BImageResources::ViewResources() const } -BResources * +BResources* BImageResources::ViewResources() { if (fLock.Lock() != B_OK) @@ -92,7 +92,7 @@ BImageResources::ViewResources() status_t -BImageResources::FinishResources(BResources *res) const +BImageResources::FinishResources(BResources* res) const { ASSERT(res == &fResources); if (res != &fResources) @@ -103,8 +103,8 @@ BImageResources::FinishResources(BResources *res) const } -const void * -BImageResources::LoadResource(type_code type, int32 id, size_t *out_size) 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 @@ -116,12 +116,12 @@ BImageResources::LoadResource(type_code type, int32 id, size_t *out_size) const // Return the resource. Because we never change the BResources // object, the returned data will not change until TTracker is // destroyed. - return const_cast<BResources *>(&fResources)->LoadResource(type, id, out_size); + return const_cast<BResources*>(&fResources)->LoadResource(type, id, out_size); } -const void * -BImageResources::LoadResource(type_code type, const char *name, size_t *out_size) const +const void* +BImageResources::LoadResource(type_code type, const char* name, size_t* out_size) const { // Serialize execution. BAutolock lock(fLock); @@ -131,15 +131,15 @@ BImageResources::LoadResource(type_code type, const char *name, size_t *out_size // Return the resource. Because we never change the BResources // object, the returned data will not change until TTracker is // destroyed. - return const_cast<BResources *>(&fResources)->LoadResource(type, name, out_size); + return const_cast<BResources*>(&fResources)->LoadResource(type, name, out_size); } status_t -BImageResources::GetIconResource(int32 id, icon_size size, BBitmap *dest) const +BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const { size_t length = 0; - const void *data; + const void* data; #ifdef __HAIKU__ // try to load vector icon @@ -194,27 +194,30 @@ BImageResources::GetIconResource(int32 id, const uint8** iconData, image_id -BImageResources::find_image(void *memAddr) const +BImageResources::find_image(void* memAddr) const { 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)) + if ((info.text <= memAddr + && (((uint8*)info.text)+info.text_size) > memAddr) + || (info.data <= memAddr + && (((uint8*)info.data)+info.data_size) > memAddr)) { // Found the image. return info.id; + } return -1; } status_t -BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap **out) const +BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap** out) const { *out = NULL; size_t len = 0; - const void *data = LoadResource(type, id, &len); + const void* data = LoadResource(type, id, &len); if (data == NULL) { TRESPASS(); @@ -245,7 +248,7 @@ BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap **out) cons static BLocker resLock; -static BImageResources *resources = NULL; +static BImageResources* resources = NULL; // This class is used as a static instance to delete the resources // global object when the image is getting unloaded. @@ -265,7 +268,7 @@ namespace BPrivate { static _TTrackerCleanupResources CleanupResources; -BImageResources *GetTrackerResources() +BImageResources* GetTrackerResources() { if (!resources) { BAutolock lock(&resLock); diff --git a/src/kits/tracker/Bitmaps.h b/src/kits/tracker/Bitmaps.h index 3f3ced9..c04331f 100644 --- a/src/kits/tracker/Bitmaps.h +++ b/src/kits/tracker/Bitmaps.h @@ -31,7 +31,6 @@ 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. */ - #ifndef __BITS__ #define __BITS__ @@ -43,31 +42,32 @@ All rights reserved. #include "TrackerIcons.h" + class BBitmap; namespace BPrivate { class BImageResources { - // convenience class for accessing + // convenience class for accessing public: - BImageResources(void *memAddr); + BImageResources(void* memAddr); ~BImageResources(); - - BResources *ViewResources(); - const BResources *ViewResources() const; - - status_t FinishResources(BResources *) const; - - const void *LoadResource(type_code type, int32 id, - size_t *outSize) const; - const void *LoadResource(type_code type, const char *name, - size_t *outSize) const; + + BResources* ViewResources(); + const BResources* ViewResources() const; + + status_t FinishResources(BResources*) const; + + const void* LoadResource(type_code type, int32 id, + size_t* outSize) const; + const void* LoadResource(type_code type, const char* name, + size_t* outSize) const; // load a resource from the Tracker executable, just like the // corresponding functions in BResources. These methods are // thread-safe. - - status_t GetIconResource(int32 id, icon_size size, BBitmap *dest) const; + + status_t GetIconResource(int32 id, icon_size size, BBitmap* dest) const; // this is a wrapper around LoadResource(), for retrieving // B_LARGE_ICON and B_MINI_ICON ('ICON' and 'MICN' respectively) // resources. this does sanity checking on the found data, @@ -78,7 +78,7 @@ public: // this is a wrapper around LoadResource(), for retrieving // the vector icon data - status_t GetBitmapResource(type_code type, int32 id, BBitmap **out) const; + status_t GetBitmapResource(type_code type, int32 id, BBitmap** out) const; // this is a wrapper around LoadResource(), for retrieving // arbitrary bitmaps. the resource with the given type and // id is looked up, and a BBitmap created from it and returned @@ -86,13 +86,12 @@ public: // that is an archived bitmap object. private: - image_id find_image(void *memAddr) const; + image_id find_image(void* memAddr) const; mutable BLocker fLock; BResources fResources; }; - extern #ifdef _IMPEXP_TRACKER @@ -100,6 +99,7 @@ _IMPEXP_TRACKER #endif BImageResources* GetTrackerResources(); + } // namespace BPrivate using namespace BPrivate; diff --git a/src/kits/tracker/Commands.h b/src/kits/tracker/Commands.h index c2e19d3..208cbb6 100644 --- a/src/kits/tracker/Commands.h +++ b/src/kits/tracker/Commands.h @@ -31,10 +31,10 @@ 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. */ - #ifndef _COMMANDS_H #define _COMMANDS_H + #include "PublicCommands.h" #include <MountServer.h> diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index fc9649e..34d9b28 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -110,12 +110,12 @@ namespace BPrivate { class DraggableContainerIcon : public BView { public: - DraggableContainerIcon(BRect rect, const char *name, uint32 resizeMask); + DraggableContainerIcon(BRect rect, const char* name, uint32 resizeMask); virtual void AttachedToWindow(); virtual void MouseDown(BPoint where); virtual void MouseUp(BPoint where); - virtual void MouseMoved(BPoint point, uint32 /*transit*/, const BMessage *message); + virtual void MouseMoved(BPoint point, uint32 /*transit*/, const BMessage* message); virtual void FrameMoved(BPoint newLocation); virtual void Draw(BRect updateRect); @@ -128,8 +128,8 @@ class DraggableContainerIcon : public BView { } // namespace BPrivate struct AddOneAddonParams { - BObjectList<BMenuItem> *primaryList; - BObjectList<BMenuItem> *secondaryList; + BObjectList<BMenuItem>* primaryList; + BObjectList<BMenuItem>* secondaryList; }; struct StaggerOneParams { @@ -147,9 +147,9 @@ BRect BContainerWindow::sNewWindRect(85, 50, 548, 280); namespace BPrivate { filter_result -ActivateWindowFilter(BMessage *, BHandler **target, BMessageFilter *) +ActivateWindowFilter(BMessage*, BHandler** target, BMessageFilter*) { - BView *view = dynamic_cast<BView*>(*target); + BView* view = dynamic_cast<BView*>(*target); // activate the window if no PoseView or DraggableContainerIcon had been pressed // (those will activate the window themselves, if necessary) @@ -164,7 +164,7 @@ ActivateWindowFilter(BMessage *, BHandler **target, BMessageFilter *) static void -StripShortcut(const Model *model, char *result, uint32 &shortcut) +StripShortcut(const Model* model, char* result, uint32 &shortcut) { // model name (possibly localized) for the menu item label strlcpy(result, model->Name(), B_FILE_NAME_LENGTH); @@ -189,14 +189,14 @@ StripShortcut(const Model *model, char *result, uint32 &shortcut) } -static const Model * -MatchOne(const Model *model, void *castToName) +static const Model* +MatchOne(const Model* model, void* castToName) { char buffer[B_FILE_NAME_LENGTH]; uint32 dummy; StripShortcut(model, buffer, dummy); - if (strcmp(buffer, (const char *)castToName) == 0) { + if (strcmp(buffer, (const char*)castToName) == 0) { // found match, bail out return model; } @@ -206,7 +206,7 @@ MatchOne(const Model *model, void *castToName) int -CompareLabels(const BMenuItem *item1, const BMenuItem *item2) +CompareLabels(const BMenuItem* item1, const BMenuItem* item2) { return strcasecmp(item1->Label(), item2->Label()); } @@ -215,14 +215,14 @@ CompareLabels(const BMenuItem *item1, const BMenuItem *item2) static bool -AddOneAddon(const Model *model, const char *name, uint32 shortcut, bool primary, void *context) +AddOneAddon(const Model* model, const char* name, uint32 shortcut, bool primary, void* context) { - AddOneAddonParams *params = (AddOneAddonParams *)context; + AddOneAddonParams* params = (AddOneAddonParams*)context; - BMessage *message = new BMessage(kLoadAddOn); + BMessage* message = new BMessage(kLoadAddOn); message->AddRef("refs", model->EntryRef()); - ModelMenuItem *item = new ModelMenuItem(model, name, message, + ModelMenuItem* item = new ModelMenuItem(model, name, message, (char)shortcut, B_OPTION_KEY); if (primary) @@ -235,7 +235,7 @@ AddOneAddon(const Model *model, const char *name, uint32 shortcut, bool primary, static int32 -AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) +AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef) { std::auto_ptr<BMessage> refsMessagePtr(refsMessage); @@ -248,15 +248,15 @@ AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) if (result == B_OK) { image_id addonImage = load_add_on(path.Path()); if (addonImage >= 0) { - void (*processRefs)(entry_ref, BMessage *, void *); - result = get_image_symbol(addonImage, "process_refs", 2, (void **)&processRefs); + void (*processRefs)(entry_ref, BMessage*, void*); + result = get_image_symbol(addonImage, "process_refs", 2, (void**)&processRefs); #ifndef __INTEL__ if (result < 0) { PRINT(("trying old legacy ppc signature\n")); // try old-style addon signature result = get_image_symbol(addonImage, - "process_refs__F9entry_refP8BMessagePv", 2, (void **)&processRefs); + "process_refs__F9entry_refP8BMessagePv", 2, (void**)&processRefs); } #endif @@ -289,7 +289,7 @@ AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) static bool -NodeHasSavedState(const BNode *node) +NodeHasSavedState(const BNode* node) { attr_info info; return node->GetAttrInfo(kAttrWindowFrame, &info) == B_OK; @@ -297,11 +297,11 @@ NodeHasSavedState(const BNode *node) static bool -OffsetFrameOne(const char *DEBUG_ONLY(name), uint32, off_t, void *castToRect, - void *castToParams) +OffsetFrameOne(const char* DEBUG_ONLY(name), uint32, off_t, void* castToRect, + void* castToParams) { ASSERT(strcmp(name, kAttrWindowFrame) == 0); - StaggerOneParams *params = (StaggerOneParams *)castToParams; + StaggerOneParams* params = (StaggerOneParams*)castToParams; if (!params->rectFromParent) return false; @@ -309,20 +309,20 @@ OffsetFrameOne(const char *DEBUG_ONLY(name), uint32, off_t, void *castToRect, if (!castToRect) return false; - ((BRect *)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy); + ((BRect*)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy); return true; } static void -AddMimeTypeString(BObjectList<BString> &list, Model *model) +AddMimeTypeString(BObjectList<BString> &list, Model* model) { - BString *mimeType = new BString(model->MimeType()); - + BString* mimeType = new BString(model->MimeType()); + if (mimeType->Length()) { // only add the type if it's not already there for (int32 i = list.CountItems(); i-- > 0;) { - BString *string = list.ItemAt(i); + BString* string = list.ItemAt(i); if (string != NULL && !string->ICompare(*mimeType)) { delete mimeType; return; @@ -336,7 +336,7 @@ AddMimeTypeString(BObjectList<BString> &list, Model *model) // #pragma mark - -DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char *name, +DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char* name, uint32 resizeMask) : BView(rect, name, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS), fDragButton(0), @@ -358,7 +358,7 @@ void DraggableContainerIcon::MouseDown(BPoint point) { // we only like container windows - BContainerWindow *window = dynamic_cast<BContainerWindow *>(Window()); + BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window()); if (window == NULL) return; @@ -367,7 +367,7 @@ DraggableContainerIcon::MouseDown(BPoint point) return; uint32 buttons; - window->CurrentMessage()->FindInt32("buttons", (int32 *)&buttons); + window->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); if (IconCache::sIconCache->IconHitTest(point, window->TargetModel(), kNormalIcon, B_MINI_ICON)) { @@ -396,16 +396,16 @@ DraggableContainerIcon::MouseUp(BPoint /*point*/) void DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, - const BMessage */*message*/) + const BMessage* /*message*/) { if (fDragButton == 0 || fDragStarted || (abs((int32)(point.x - fClickPoint.x)) <= kDragSlop && abs((int32)(point.y - fClickPoint.y)) <= kDragSlop)) return; - BContainerWindow *window = static_cast<BContainerWindow *>(Window()); + BContainerWindow* window = static_cast<BContainerWindow*>(Window()); // we can only get here in a BContainerWindow - Model *model = window->TargetModel(); + Model* model = window->TargetModel(); // Find the required height BFont font; @@ -417,10 +417,10 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, + Bounds().Height() + 8; BRect rect(0, 0, max_c(Bounds().Width(), font.StringWidth(model->Name()) + 4), height); - BBitmap *dragBitmap = new BBitmap(rect, B_RGBA32, true); + BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); dragBitmap->Lock(); - BView *view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); + BView* view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); dragBitmap->AddChild(view); view->SetOrigin(0, 0); BRect clipRect(view->Bounds()); @@ -480,7 +480,7 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, void DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/) { - BMenuBar* bar = dynamic_cast<BMenuBar *>(Parent()); + BMenuBar* bar = dynamic_cast<BMenuBar*>(Parent()); if (bar == NULL) return; @@ -493,11 +493,10 @@ DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/) bar->GetPreferredSize(&width, &height); bar->SetResizingMode(resizingMode); -/* - BMenuItem* item = bar->ItemAt(bar->CountItems() - 1); - if (item == NULL) - return; -*/ + //BMenuItem* item = bar->ItemAt(bar->CountItems() - 1); + //if (item == NULL) + // return; + // BeOS shifts the coordinates for hidden views, so we cannot // use them to decide if we should be visible or not... @@ -513,7 +512,7 @@ DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/) void DraggableContainerIcon::Draw(BRect updateRect) { - BContainerWindow *window = dynamic_cast<BContainerWindow *>(Window()); + BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window()); if (window == NULL) return; @@ -540,7 +539,7 @@ DraggableContainerIcon::Draw(BRect updateRect) // #pragma mark - -BContainerWindow::BContainerWindow(LockingList<BWindow> *list, +BContainerWindow::BContainerWindow(LockingList<BWindow>* list, uint32 containerWindowFlags, window_look look, window_feel feel, uint32 flags, uint32 workspace) : BWindow(InitialWindowRect(feel), "TrackerWindow", look, feel, flags, @@ -590,7 +589,7 @@ BContainerWindow::BContainerWindow(LockingList<BWindow> *list, Run(); // Watch out for settings changes: - if (TTracker *app = dynamic_cast<TTracker*>(be_app)) { + if (TTracker* app = dynamic_cast<TTracker*>(be_app)) { app->Lock(); app->StartWatching(this, kWindowsShowFullPathChanged); app->StartWatching(this, kSingleWindowBrowseChanged); @@ -611,7 +610,7 @@ BContainerWindow::~BContainerWindow() ASSERT(IsLocked()); // stop the watchers - if (TTracker *app = dynamic_cast<TTracker*>(be_app)) { + if (TTracker* app = dynamic_cast<TTracker*>(be_app)) { app->Lock(); app->StopWatching(this, kWindowsShowFullPathChanged); app->StopWatching(this, kSingleWindowBrowseChanged); @@ -676,7 +675,7 @@ BContainerWindow::Quit() { // get rid of context menus if (fNavigationItem) { - BMenu *menu = fNavigationItem->Menu(); + BMenu* menu = fNavigationItem->Menu(); if (menu) menu->RemoveItem(fNavigationItem); delete fNavigationItem; @@ -741,15 +740,15 @@ BContainerWindow::Quit() } -BPoseView * -BContainerWindow::NewPoseView(Model *model, BRect rect, uint32 viewMode) +BPoseView* +BContainerWindow::NewPoseView(Model* model, BRect rect, uint32 viewMode) { return new BPoseView(model, rect, viewMode); } void -BContainerWindow::UpdateIfTrash(Model *model) +BContainerWindow::UpdateIfTrash(Model* model) { BEntry entry(model->EntryRef()); @@ -762,7 +761,7 @@ BContainerWindow::UpdateIfTrash(Model *model) void -BContainerWindow::CreatePoseView(Model *model) +BContainerWindow::CreatePoseView(Model* model) { UpdateIfTrash(model); BRect rect(Bounds()); @@ -843,10 +842,10 @@ BContainerWindow::RepopulateMenus() } if (fNavigationItem) { - BMenu *menu = fNavigationItem->Menu(); + BMenu* menu = fNavigationItem->Menu(); if (menu) { menu->RemoveItem(fNavigationItem); - BMenuItem *item = menu->RemoveItem((int32)0); + BMenuItem* item = menu->RemoveItem((int32)0); ASSERT(item != fNavigationItem); delete item; } @@ -894,7 +893,7 @@ BContainerWindow::RepopulateMenus() void -BContainerWindow::Init(const BMessage *message) +BContainerWindow::Init(const BMessage* message) { float y_delta; BEntry entry; [ *** diff truncated: 33994 lines dropped *** ] ############################################################################ Commit: caaec0198e99172abb5b06af3bfb229712e687da URL: http://cgit.haiku-os.org/haiku/commit/?id=caaec01 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jul 28 00:40:58 2012 UTC A for loop with just an end condition is better as a while loop. ---------------------------------------------------------------------------- ############################################################################ Revision: hrev44418 Commit: 96a1e39a63f093e57d351cf79b0e7ee51b80145a URL: http://cgit.haiku-os.org/haiku/commit/?id=96a1e39 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jul 28 00:41:38 2012 UTC An error while emptying trash is not that dramatic. ----------------------------------------------------------------------------