From c22cb42c69cdec8f3c0e4871f00e66995bd19568 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 14 Jul 2012 10:37:25 -0400 Subject: [PATCH 01/46] Clean up dead code. CID 611306. --- .../user_interface/gui/inspector_window/InspectorWindow.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp index c3612e6576..224cb0a88f 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp +++ b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp @@ -251,9 +251,6 @@ InspectorWindow::MessageReceived(BMessage* msg) } break; } - { - break; - } default: { BWindow::MessageReceived(msg); From 2a8e9bb83d29cb06a5846ddc42fa1606d831a597 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 14 Jul 2012 10:40:44 -0400 Subject: [PATCH 02/46] Fix missing break statement. CID 611232. --- src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index f8d7f772cf..61636f8531 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -238,6 +238,7 @@ TeamWindow::MessageReceived(BMessage* message) { _SaveInspectorSettings(CurrentMessage()); fInspectorWindow = NULL; + break; } case B_REFS_RECEIVED: From c163f973e6a96a2c37d70cc1992f2bb027f9ab81 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 14 Jul 2012 11:24:22 -0400 Subject: [PATCH 03/46] Fix resource leak in error cases. CID 611238. --- src/apps/debugger/value/value_nodes/BMessageValueNode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp index 8316d6e8dc..b805a35332 100644 --- a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp @@ -281,6 +281,9 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, uint8* messageBuffer = new(std::nothrow) uint8[totalSize]; if (messageBuffer == NULL) return B_NO_MEMORY; + + ArrayDeleter deleter(messageBuffer); + memset(messageBuffer, 0, totalSize); memcpy(messageBuffer, fHeader, sizeof(BMessage::message_header)); uint8* tempBuffer = messageBuffer + sizeof(BMessage::message_header); @@ -313,7 +316,6 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, } error = fMessage.Unflatten((const char*)messageBuffer); - delete[] messageBuffer; if (error != B_OK) return error; From 6faa3c97662c81aaea1bfa5b6803bb33d733f6af Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 14 Jul 2012 12:09:11 -0400 Subject: [PATCH 04/46] Fix #8729. - If we're asked to generate an entry for a tag we don't recognize, return an error so don't then attempt to add a null/invalid entry into the compilation unit's entry list and later crash dereferencing it. --- src/apps/debugger/dwarf/DebugInfoEntries.cpp | 1 + src/apps/debugger/dwarf/DwarfFile.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/dwarf/DebugInfoEntries.cpp b/src/apps/debugger/dwarf/DebugInfoEntries.cpp index 976684090c..9c2ecf47a9 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntries.cpp +++ b/src/apps/debugger/dwarf/DebugInfoEntries.cpp @@ -2697,6 +2697,7 @@ DebugInfoEntryFactory::CreateDebugInfoEntry(uint16 tag, DebugInfoEntry*& _entry) entry = new(std::nothrow) DIESharedType; break; default: + return B_ENTRY_NOT_FOUND; break; } diff --git a/src/apps/debugger/dwarf/DwarfFile.cpp b/src/apps/debugger/dwarf/DwarfFile.cpp index f07f10ae2a..f95d18ea4a 100644 --- a/src/apps/debugger/dwarf/DwarfFile.cpp +++ b/src/apps/debugger/dwarf/DwarfFile.cpp @@ -825,8 +825,12 @@ DwarfFile::_ParseDebugInfoEntry(DataReader& dataReader, DebugInfoEntry* entry; status_t error = fDebugInfoFactory.CreateDebugInfoEntry( abbreviationEntry.Tag(), entry); - if (error != B_OK) + if (error != B_OK) { + WARNING("Failed to generate entry for tag %lu, code %lu\n", + abbreviationEntry.Tag(), code); return error; + } + ObjectDeleter entryDeleter(entry); TRACE_DIE("%*sentry %p at %lld: %lu, tag: %s (%lu), children: %d\n", From 775afec4cc4fbd33e3a1d42d9376b089963e76fe Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Sat, 14 Jul 2012 22:01:14 +0200 Subject: [PATCH 05/46] Simplify source file names and go from .c to .cpp --- .../acpi/{oshaiku.cpp => ACPICAHaiku.cpp} | 0 .../bus_managers/acpi/{acpi_priv.h => ACPIPrivate.h} | 0 .../acpi/{acpi_busman.c => BusManager.cpp} | 0 .../bus_managers/acpi/{acpi_device.c => Device.cpp} | 0 ...mbedded_controller.cpp => EmbeddedController.cpp} | 0 ...pi_embedded_controller.h => EmbeddedController.h} | 0 src/add-ons/kernel/bus_managers/acpi/Jamfile | 12 ++++++------ .../bus_managers/acpi/{acpi_module.c => Module.cpp} | 0 .../acpi/{acpi_ns_dump.cpp => NamespaceDump.cpp} | 0 9 files changed, 6 insertions(+), 6 deletions(-) rename src/add-ons/kernel/bus_managers/acpi/{oshaiku.cpp => ACPICAHaiku.cpp} (100%) rename src/add-ons/kernel/bus_managers/acpi/{acpi_priv.h => ACPIPrivate.h} (100%) rename src/add-ons/kernel/bus_managers/acpi/{acpi_busman.c => BusManager.cpp} (100%) rename src/add-ons/kernel/bus_managers/acpi/{acpi_device.c => Device.cpp} (100%) rename src/add-ons/kernel/bus_managers/acpi/{acpi_embedded_controller.cpp => EmbeddedController.cpp} (100%) rename src/add-ons/kernel/bus_managers/acpi/{acpi_embedded_controller.h => EmbeddedController.h} (100%) rename src/add-ons/kernel/bus_managers/acpi/{acpi_module.c => Module.cpp} (100%) rename src/add-ons/kernel/bus_managers/acpi/{acpi_ns_dump.cpp => NamespaceDump.cpp} (100%) diff --git a/src/add-ons/kernel/bus_managers/acpi/oshaiku.cpp b/src/add-ons/kernel/bus_managers/acpi/ACPICAHaiku.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/oshaiku.cpp rename to src/add-ons/kernel/bus_managers/acpi/ACPICAHaiku.cpp diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_priv.h b/src/add-ons/kernel/bus_managers/acpi/ACPIPrivate.h similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/acpi_priv.h rename to src/add-ons/kernel/bus_managers/acpi/ACPIPrivate.h diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c b/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/acpi_busman.c rename to src/add-ons/kernel/bus_managers/acpi/BusManager.cpp diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_device.c b/src/add-ons/kernel/bus_managers/acpi/Device.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/acpi_device.c rename to src/add-ons/kernel/bus_managers/acpi/Device.cpp diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_embedded_controller.cpp b/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/acpi_embedded_controller.cpp rename to src/add-ons/kernel/bus_managers/acpi/EmbeddedController.cpp diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_embedded_controller.h b/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.h similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/acpi_embedded_controller.h rename to src/add-ons/kernel/bus_managers/acpi/EmbeddedController.h diff --git a/src/add-ons/kernel/bus_managers/acpi/Jamfile b/src/add-ons/kernel/bus_managers/acpi/Jamfile index 8852b64d3e..800fe4e296 100644 --- a/src/add-ons/kernel/bus_managers/acpi/Jamfile +++ b/src/add-ons/kernel/bus_managers/acpi/Jamfile @@ -200,12 +200,12 @@ SEARCH on [ FGristFiles $(tables_src) ] = [ FDirName $(HAIKU_TOP) src add-ons ke SEARCH on [ FGristFiles $(utilities_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components utilities ] ; KernelAddon acpi : - oshaiku.cpp - acpi_busman.c - acpi_module.c - acpi_device.c - acpi_ns_dump.cpp - acpi_embedded_controller.cpp + ACPICAHaiku.cpp + BusManager.cpp + Module.cpp + Device.cpp + NamespaceDump.cpp + EmbeddedController.cpp SmallResourceData.cpp : libacpi_ca.a diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_module.c b/src/add-ons/kernel/bus_managers/acpi/Module.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/acpi_module.c rename to src/add-ons/kernel/bus_managers/acpi/Module.cpp diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_ns_dump.cpp b/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/acpi/acpi_ns_dump.cpp rename to src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp From cad6c2c536aba66ada9eb1e65e1ba7bc62ff0feb Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Sat, 14 Jul 2012 22:10:48 +0200 Subject: [PATCH 06/46] Fix compilation after rename and switch to cpp. --- .../kernel/bus_managers/acpi/ACPIPrivate.h | 6 +-- .../kernel/bus_managers/acpi/BusManager.cpp | 16 ++++---- .../kernel/bus_managers/acpi/Device.cpp | 39 +++++++++---------- .../bus_managers/acpi/EmbeddedController.cpp | 4 +- .../bus_managers/acpi/EmbeddedController.h | 2 +- .../kernel/bus_managers/acpi/Module.cpp | 4 +- .../bus_managers/acpi/NamespaceDump.cpp | 26 ++++++------- 7 files changed, 48 insertions(+), 49 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/acpi/ACPIPrivate.h b/src/add-ons/kernel/bus_managers/acpi/ACPIPrivate.h index 5bf47e5271..7af1e5e705 100644 --- a/src/add-ons/kernel/bus_managers/acpi/ACPIPrivate.h +++ b/src/add-ons/kernel/bus_managers/acpi/ACPIPrivate.h @@ -3,8 +3,8 @@ * Copyright 2006, Jérôme Duval. All rights reserved. * Distributed under the terms of the MIT License. */ -#ifndef __ACPI_PRIV_H__ -#define __ACPI_PRIV_H__ +#ifndef _ACPI_PRIVATE_H +#define _ACPI_PRIVATE_H #include @@ -227,4 +227,4 @@ status_t get_table(const char* signature, uint32 instance, void** tableHeader); __END_DECLS -#endif /* __ACPI_PRIV_H__ */ +#endif /* _ACPI_PRIVATE_H */ diff --git a/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp b/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp index 557247ccdc..cab2bc40e3 100644 --- a/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp +++ b/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp @@ -20,11 +20,13 @@ #include +extern "C" { #include "acpi.h" #include "accommon.h" #include "acdisasm.h" #include "acnamesp.h" -#include "acpi_priv.h" +} +#include "ACPIPrivate.h" //#define TRACE_ACPI_BUS #ifdef TRACE_ACPI_BUS @@ -384,7 +386,7 @@ status_t install_fixed_event_handler(uint32 event, interrupt_handler* handler, void *data) { - return AcpiInstallFixedEventHandler(event, (void*)handler, data) == AE_OK + return AcpiInstallFixedEventHandler(event, (ACPI_EVENT_HANDLER)handler, data) == AE_OK ? B_OK : B_ERROR; } @@ -392,7 +394,7 @@ install_fixed_event_handler(uint32 event, interrupt_handler* handler, status_t remove_fixed_event_handler(uint32 event, interrupt_handler* handler) { - return AcpiRemoveFixedEventHandler(event, (void*)handler) == AE_OK + return AcpiRemoveFixedEventHandler(event, (ACPI_EVENT_HANDLER)handler) == AE_OK ? B_OK : B_ERROR; } @@ -441,7 +443,7 @@ get_device(const char* hid, uint32 index, char* result, size_t resultLength) char *buffer = NULL; TRACE("get_device %s, index %ld\n", hid, index); - status = AcpiGetDevices((ACPI_STRING)hid, (void*)&get_device_by_hid_callback, + status = AcpiGetDevices((ACPI_STRING)hid, (ACPI_WALK_CALLBACK)&get_device_by_hid_callback, counter, (void**)&buffer); if (status != AE_OK || buffer == NULL) return B_ENTRY_NOT_FOUND; @@ -523,7 +525,7 @@ get_object(const char* path, acpi_object_type** _returnValue) status = AcpiEvaluateObject(handle, NULL, NULL, &buffer); - *_returnValue = buffer.Pointer; + *_returnValue = (acpi_object_type*)buffer.Pointer; return status == AE_OK ? B_OK : B_ERROR; } @@ -545,7 +547,7 @@ get_object_typed(const char* path, acpi_object_type** _returnValue, status = AcpiEvaluateObjectTyped(handle, NULL, NULL, &buffer, objectType); - *_returnValue = buffer.Pointer; + *_returnValue = (acpi_object_type*)buffer.Pointer; return status == AE_OK ? B_OK : B_ERROR; } @@ -642,7 +644,7 @@ prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size) status_t status; // Note: The supplied code must already be locked into memory. - status = get_memory_map(wakeFunc, size, &wakeVector, 1); + status = get_memory_map((const void*)wakeFunc, size, &wakeVector, 1); if (status != B_OK) return status; diff --git a/src/add-ons/kernel/bus_managers/acpi/Device.cpp b/src/add-ons/kernel/bus_managers/acpi/Device.cpp index 6ac8361c60..77d1cc1d93 100644 --- a/src/add-ons/kernel/bus_managers/acpi/Device.cpp +++ b/src/add-ons/kernel/bus_managers/acpi/Device.cpp @@ -9,8 +9,10 @@ #include #include -#include "acpi_priv.h" +#include "ACPIPrivate.h" +extern "C" { #include "acpi.h" +} static status_t @@ -43,17 +45,17 @@ acpi_remove_address_space_handler(acpi_device device, uint32 spaceId, { return remove_address_space_handler(device->handle, spaceId, handler); } - -static uint32 + +static uint32 acpi_get_object_type(acpi_device device) { return device->type; } -static status_t -acpi_get_object(acpi_device device, const char *path, acpi_object_type **return_value) +static status_t +acpi_get_object(acpi_device device, const char *path, acpi_object_type **return_value) { if (path) { char objname[255]; @@ -64,9 +66,9 @@ acpi_get_object(acpi_device device, const char *path, acpi_object_type **return_ } -static status_t +static status_t acpi_evaluate_method(acpi_device device, const char *method, - acpi_objects *args, acpi_data *returnValue) + acpi_objects *args, acpi_data *returnValue) { return evaluate_method(device->handle, method, args, returnValue); } @@ -77,19 +79,17 @@ acpi_device_init_driver(device_node *node, void **cookie) { ACPI_HANDLE handle; const char *path; - acpi_device_cookie *device; - status_t status = B_OK; uint32 type; - + if (gDeviceManager->get_attr_uint32(node, ACPI_DEVICE_TYPE_ITEM, &type, false) != B_OK) return B_ERROR; if (gDeviceManager->get_attr_string(node, ACPI_DEVICE_PATH_ITEM, &path, false) != B_OK) return B_ERROR; - - device = malloc(sizeof(*device)); + + acpi_device_cookie *device = (acpi_device_cookie*)malloc(sizeof(*device)); if (device == NULL) return B_NO_MEMORY; - + memset(device, 0, sizeof(*device)); if (AcpiGetHandle(NULL, (ACPI_STRING)path, &handle) != AE_OK) { @@ -102,20 +102,17 @@ acpi_device_init_driver(device_node *node, void **cookie) device->type = type; device->node = node; - snprintf(device->name, sizeof(device->name), "acpi_device %s", - path); - + snprintf(device->name, sizeof(device->name), "acpi_device %s", path); *cookie = device; - - return status; + return B_OK; } static void acpi_device_uninit_driver(void *cookie) { - acpi_device_cookie *device = cookie; - + acpi_device_cookie *device = (acpi_device_cookie*)cookie; + free(device->path); free(device); } @@ -133,7 +130,7 @@ acpi_device_std_ops(int32 op, ...) return B_BAD_VALUE; } - + acpi_device_module_info gACPIDeviceModule = { { { diff --git a/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.cpp b/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.cpp index 9cbfbc7f08..e504a705ea 100644 --- a/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.cpp +++ b/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.cpp @@ -28,7 +28,7 @@ */ -#include "acpi_embedded_controller.h" +#include "EmbeddedController.h" #include #include @@ -555,7 +555,7 @@ EcGpeQueryHandler(void* context) if (status != B_OK) { TRACE("evaluation of query method %s failed\n", qxx); } - + // Reenable runtime GPE if its execution was deferred. if (sci_enqueued) { status = sc->ec_acpi_module->finish_gpe(sc->ec_gpehandle, sc->ec_gpebit); diff --git a/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.h b/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.h index e8e1ef2cf3..c9ad95d58e 100644 --- a/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.h +++ b/src/add-ons/kernel/bus_managers/acpi/EmbeddedController.h @@ -44,7 +44,7 @@ extern "C" { # include "accommon.h" # include "acnamesp.h" # include "actypes.h" -# include "acpi_priv.h" +# include "ACPIPrivate.h" } diff --git a/src/add-ons/kernel/bus_managers/acpi/Module.cpp b/src/add-ons/kernel/bus_managers/acpi/Module.cpp index fbddef1228..6b37c47275 100644 --- a/src/add-ons/kernel/bus_managers/acpi/Module.cpp +++ b/src/add-ons/kernel/bus_managers/acpi/Module.cpp @@ -9,7 +9,7 @@ #include #include -#include "acpi_priv.h" +#include "ACPIPrivate.h" #include #include @@ -126,7 +126,7 @@ acpi_enumerate_child_devices(device_node* node, const char* root) static status_t acpi_module_register_child_devices(void* cookie) { - device_node* node = cookie; + device_node* node = (device_node*)cookie; status_t status = gDeviceManager->publish_device(node, "acpi/namespace", ACPI_NS_DUMP_DEVICE_MODULE_NAME); diff --git a/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp b/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp index 2640920a85..3502fd4a84 100644 --- a/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp +++ b/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp @@ -1,5 +1,5 @@ /* ++++++++++ - ACPI namespace dump. + ACPI namespace dump. Nothing special here, just tree enumeration and type identification. +++++ */ @@ -9,7 +9,7 @@ #include #include -#include "acpi_priv.h" +#include "ACPIPrivate.h" #include #include @@ -17,7 +17,7 @@ class RingBuffer { public: RingBuffer(size_t size = 1024); - ~RingBuffer(); + ~RingBuffer(); size_t Read(void *buffer, ssize_t length); size_t Write(const void *buffer, ssize_t length); size_t WritableAmount() const; @@ -60,18 +60,18 @@ make_space(acpi_ns_device_info *device, size_t space) } snooze(10000); - if (!device->buffer->Lock()) + if (!device->buffer->Lock()) return false; - + } while (device->buffer->WritableAmount() < space); - + return true; -} +} -static void -dump_acpi_namespace(acpi_ns_device_info *device, char *root, int indenting) +static void +dump_acpi_namespace(acpi_ns_device_info *device, char *root, int indenting) { char result[255]; char output[320]; @@ -79,13 +79,13 @@ dump_acpi_namespace(acpi_ns_device_info *device, char *root, int indenting) char hid[16] = ""; int i; size_t written = 0; - for (i = 0; i < indenting; i++) + for (i = 0; i < indenting; i++) strlcat(tabs, "| ", sizeof(tabs)); strlcat(tabs, "|--- ", sizeof(tabs)); int depth = sizeof(char) * 5 * indenting + sizeof(char); // index into result where the device name will be. - + void *counter = NULL; while (device->acpi->get_next_entry(ACPI_TYPE_ANY, root, result, 255, &counter) == B_OK) { uint32 type = device->acpi->get_object_type(result); @@ -142,13 +142,13 @@ dump_acpi_namespace(acpi_ns_device_info *device, char *root, int indenting) written = 0; RingBuffer &ringBuffer = *device->buffer; size_t toWrite = strlen(output); - + if (toWrite <= 0) break; strlcat(output, "\n", sizeof(output)); toWrite++; - if (!ringBuffer.Lock()) + if (!ringBuffer.Lock()) break; if (ringBuffer.WritableAmount() < toWrite && From 6d51de482c740d2cc722ea6a39f0c29c6a6fb64e Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Sun, 15 Jul 2012 14:34:43 +0200 Subject: [PATCH 07/46] Disabling interrupts before entering sleepstates. This didn't work properly before but seems to work fine now. Also added a panic for now, to find out if it is an issue atm. --- src/add-ons/kernel/bus_managers/acpi/BusManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp b/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp index cab2bc40e3..0f2317dc21 100644 --- a/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp +++ b/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp @@ -678,7 +678,10 @@ enter_sleep_state(uint8 state, uint8 flags) TRACE("enter_sleep_state %d with flags %d\n", state, flags); + cpu_status cpu = disable_interrupts(); status = AcpiEnterSleepState(state, flags); + restore_interrupts(cpu); + panic("AcpiEnterSleepState should not return."); if (status != AE_OK) return B_ERROR; From e2339980052673d16a2457483ff7b92e8c4fd179 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 15 Jul 2012 11:58:19 -0500 Subject: [PATCH 08/46] radeon_hd: Skip 9DIN connector. * Since we really don't support multiple heads well, skip 9DIN for the moment as it is a luxury. --- src/add-ons/accelerants/radeon_hd/display.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/add-ons/accelerants/radeon_hd/display.cpp b/src/add-ons/accelerants/radeon_hd/display.cpp index ecd15a444c..47e8a32fed 100644 --- a/src/add-ons/accelerants/radeon_hd/display.cpp +++ b/src/add-ons/accelerants/radeon_hd/display.cpp @@ -257,6 +257,12 @@ detect_displays() if (displayIndex >= MAX_DISPLAY) continue; + if (gConnector[id]->type == VIDEO_CONNECTOR_9DIN) { + TRACE("%s: Skipping 9DIN connector (not yet supported)\n", + __func__); + continue; + } + // TODO: As DP aux transactions don't work yet, just use LVDS as a hack #if 0 if (gConnector[id]->encoderExternal.isDPBridge == true) { @@ -310,9 +316,11 @@ detect_displays() TRACE("%s: connector %" B_PRIu32 " has digital EDID " "and is not a analog encoder.\n", __func__, id); } else { - // ???, shouldn't happen... I think. - TRACE("%s: Warning: connector %" B_PRIu32 " has neither " - "digital EDID nor is an analog encoder?\n", + // This generally means the monitor is of poor design + // Since we *know* there is no load on the analog encoder + // we assume that it is a digital display. + TRACE("%s: Warning: monitor on connector %" B_PRIu32 " has " + "false digital EDID flag and unloaded analog encoder!\n", __func__, id); } } From 82931998313bba85fa6e41705e55f6e15502810a Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 15 Jul 2012 11:25:35 -0400 Subject: [PATCH 09/46] Add definition for a general-purpose action menu item. --- src/apps/debugger/Jamfile | 1 + .../gui/util/ActionMenuItem.cpp | 55 +++++++++++++++++++ .../user_interface/gui/util/ActionMenuItem.h | 31 +++++++++++ 3 files changed, 87 insertions(+) create mode 100644 src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp create mode 100644 src/apps/debugger/user_interface/gui/util/ActionMenuItem.h diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 9d04f5baa3..193bc20961 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -200,6 +200,7 @@ Application Debugger : VariablesView.cpp # user_interface/gui/util + ActionMenuItem.cpp GUISettingsUtils.cpp SettingsMenu.cpp TargetAddressTableColumn.cpp diff --git a/src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp b/src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp new file mode 100644 index 0000000000..4ef80d57e0 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp @@ -0,0 +1,55 @@ +/* + * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "ActionMenuItem.h" + +#include + +#include + + +// #pragma mark - ActionMenuItem + + +ActionMenuItem::ActionMenuItem(const char* label, BMessage* message, + char shortcut, uint32 modifiers) + : + BMenuItem(label, message, shortcut, modifiers) +{ +} + + +ActionMenuItem::ActionMenuItem(BMenu* menu, BMessage* message) + : + BMenuItem(menu, message) +{ +} + + +ActionMenuItem::~ActionMenuItem() +{ +} + + +void +ActionMenuItem::PrepareToShow(BLooper* parentLooper, BHandler* targetHandler) +{ +} + + +bool +ActionMenuItem::Finish(BLooper* parentLooper, BHandler* targetHandler, + bool force) +{ + return false; +} + + +void +ActionMenuItem::ItemSelected() +{ +} diff --git a/src/apps/debugger/user_interface/gui/util/ActionMenuItem.h b/src/apps/debugger/user_interface/gui/util/ActionMenuItem.h new file mode 100644 index 0000000000..074f88d564 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/util/ActionMenuItem.h @@ -0,0 +1,31 @@ +/* + * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef ACTION_MENU_ITEM_H +#define ACTION_MENU_ITEM_H + + +#include + + +class ActionMenuItem : public BMenuItem { +public: + ActionMenuItem(const char* label, + BMessage* message, char shortcut = 0, + uint32 modifiers = 0); + ActionMenuItem(BMenu* menu, + BMessage* message = NULL); + virtual ~ActionMenuItem(); + + virtual void PrepareToShow(BLooper* parentLooper, + BHandler* targetHandler); + virtual bool Finish(BLooper* parentLooper, + BHandler* targetHandler, bool force); + + virtual void ItemSelected(); +}; + + +#endif // ACTION_MENU_ITEM_H From 0712121cdb6b4dfe51d183615944a0f116447d1d Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 15 Jul 2012 11:40:16 -0400 Subject: [PATCH 10/46] Add support for actions to TableCellContextMenuTracker. - VariablesView's context menu tracker now optionally accepts contextual actions to add to the menu in addition to the current renderer settings. --- .../gui/team_window/VariablesView.cpp | 56 ++++++++++++++++++- .../gui/team_window/VariablesView.h | 2 + 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 922d8d49b7..85a26a291e 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2012, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -19,6 +19,7 @@ #include "table/TableColumns.h" +#include "ActionMenuItem.h" #include "Architecture.h" #include "FunctionID.h" #include "FunctionInstance.h" @@ -487,7 +488,9 @@ public: } status_t Init(Settings* rendererSettings, - SettingsMenu* rendererSettingsMenu) + SettingsMenu* rendererSettingsMenu, + ContextActionList* preSettingsActions = NULL, + ContextActionList* postSettingsActions = NULL) { fRendererSettings = rendererSettings; fRendererSettings->AcquireReference(); @@ -500,10 +503,23 @@ public: if (fContextMenu == NULL) return B_NO_MEMORY; - status_t error = fRendererSettingsMenu->AddToMenu(fContextMenu, 0); + status_t error = B_OK; + if (preSettingsActions != NULL) { + error = _AddActionItems(preSettingsActions); + if (error != B_OK) + return error; + } + + error = fRendererSettingsMenu->AddToMenu(fContextMenu, 0); if (error != B_OK) return error; + if (postSettingsActions != NULL) { + error = _AddActionItems(postSettingsActions); + if (error != B_OK) + return error; + } + AutoLocker settingsLocker(fRendererSettings); fRendererSettings->AddListener(this); @@ -516,6 +532,13 @@ public: { fRendererSettingsMenu->PrepareToShow(fParentLooper); + for (int32 i = 0; i < fContextMenu->CountItems(); i++) { + ActionMenuItem* item = dynamic_cast( + fContextMenu->ItemAt(i)); + if (item != NULL) + item->PrepareToShow(fParentLooper, fContextMenu); + } + fMenuPreparedToShow = true; BRect mouseRect(screenWhere, screenWhere); @@ -529,6 +552,15 @@ public: if (fMenuPreparedToShow) { stillActive = fRendererSettingsMenu->Finish(fParentLooper, force); + for (int32 i = 0; i < fContextMenu->CountItems(); i++) { + ActionMenuItem* item = dynamic_cast( + fContextMenu->ItemAt(i)); + if (item != NULL) { + stillActive |= item->Finish(fParentLooper, fContextMenu, + force); + } + } + fMenuPreparedToShow = stillActive; } @@ -559,6 +591,24 @@ private: } } + status_t _AddActionItems(ContextActionList* actions) + { + if (fContextMenu == NULL) + return B_BAD_VALUE; + + int32 index = fContextMenu->CountItems(); + for (int32 i = 0; ActionMenuItem* item = actions->ItemAt(i); i++) { + if (!fContextMenu->AddItem(item, index + i)) { + for (i--; i >= 0; i--) + fContextMenu->RemoveItem(fContextMenu->ItemAt(index + i)); + + return B_NO_MEMORY; + } + } + + return B_OK; + } + private: ModelNode* fNode; BLooper* fParentLooper; diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h index 0310dbd4de..d1fa54b55b 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h @@ -11,6 +11,7 @@ #include "table/TreeTable.h" +class ActionMenuItem; class CpuState; class SettingsMenu; class StackFrame; @@ -61,6 +62,7 @@ private: class VariableTableModel; class ContextMenu; class TableCellContextMenuTracker; + typedef BObjectList ContextActionList; private: void _Init(); From 544a66de684d83002ae308114d3e71f519418b38 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 15 Jul 2012 14:26:18 -0400 Subject: [PATCH 11/46] Extend MSG_SHOW_INSPECTOR_WINDOW to allow specifying an initial address. --- .../gui/team_window/TeamWindow.cpp | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index 61636f8531..e4363313d2 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -218,20 +218,26 @@ TeamWindow::MessageReceived(BMessage* message) { if (fInspectorWindow) { fInspectorWindow->Activate(true); - break; + } else { + try { + fInspectorWindow = InspectorWindow::Create(fTeam, + fListener, this); + if (fInspectorWindow != NULL) { + BMessage settings; + fInspectorWindow->LoadSettings(fUISettings); + fInspectorWindow->Show(); + } + } catch (...) { + // TODO: notify user + } } - try { - fInspectorWindow = InspectorWindow::Create(fTeam, fListener, - this); - if (fInspectorWindow != NULL) { - BMessage settings; - fInspectorWindow->LoadSettings(fUISettings); - fInspectorWindow->Show(); - } - } catch (...) { - // TODO: notify user - } + target_addr_t address; + if (message->FindUInt64("address", &address) == B_OK) { + BMessage addressMessage(MSG_INSPECT_ADDRESS); + addressMessage.AddUInt64("address", address); + fInspectorWindow->PostMessage(&addressMessage); + } break; } case MSG_INSPECTOR_WINDOW_CLOSED: From ae8018310aab267db14e6bac1495522e3731d5d3 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 15 Jul 2012 14:27:11 -0400 Subject: [PATCH 12/46] Set default target in PrepareToShow(). --- src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp b/src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp index 4ef80d57e0..27ca732de4 100644 --- a/src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp +++ b/src/apps/debugger/user_interface/gui/util/ActionMenuItem.cpp @@ -38,6 +38,7 @@ ActionMenuItem::~ActionMenuItem() void ActionMenuItem::PrepareToShow(BLooper* parentLooper, BHandler* targetHandler) { + SetTarget(targetHandler); } From 17ef26a9f8319415aa24e54aae6cfdbea1624071 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 15 Jul 2012 14:28:20 -0400 Subject: [PATCH 13/46] Add inspection context menu action. - TableCellContextMenuTracker now supports menus that don't have a settings submenu, since some variables won't have renderer settings but will still have context actions. - Add _GetContextActionsForNode() to retrieve the list of contextual actions available for a given model node. Currently this is only adds an action to inspect the memory address of the highlighted value, but will be extended for other actions later. --- .../gui/team_window/VariablesView.cpp | 142 ++++++++++++++---- .../gui/team_window/VariablesView.h | 3 +- 2 files changed, 113 insertions(+), 32 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 85a26a291e..04ad5d457b 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -37,6 +37,7 @@ #include "Value.h" #include "ValueHandler.h" #include "ValueHandlerRoster.h" +#include "ValueLocation.h" #include "ValueNode.h" #include "ValueNodeContainer.h" #include "Variable.h" @@ -492,11 +493,19 @@ public: ContextActionList* preSettingsActions = NULL, ContextActionList* postSettingsActions = NULL) { - fRendererSettings = rendererSettings; - fRendererSettings->AcquireReference(); + if (rendererSettings == NULL && preSettingsActions == NULL + && postSettingsActions == NULL) { + return B_BAD_VALUE; + } - fRendererSettingsMenu = rendererSettingsMenu; - fRendererSettingsMenu->AcquireReference(); + if (rendererSettings != NULL) { + fRendererSettings = rendererSettings; + fRendererSettings->AcquireReference(); + + + fRendererSettingsMenu = rendererSettingsMenu; + fRendererSettingsMenu->AcquireReference(); + } fContextMenu = new(std::nothrow) ContextMenu(fParent, "table cell settings popup"); @@ -504,39 +513,52 @@ public: return B_NO_MEMORY; status_t error = B_OK; - if (preSettingsActions != NULL) { + if (preSettingsActions != NULL + && preSettingsActions->CountItems() > 0) { error = _AddActionItems(preSettingsActions); if (error != B_OK) return error; + + if (fRendererSettingsMenu != NULL || postSettingsActions != NULL) + fContextMenu->AddSeparatorItem(); } - error = fRendererSettingsMenu->AddToMenu(fContextMenu, 0); - if (error != B_OK) - return error; + if (fRendererSettingsMenu != NULL) { + error = fRendererSettingsMenu->AddToMenu(fContextMenu, + fContextMenu->CountItems()); + if (error != B_OK) + return error; + + if (postSettingsActions != NULL) + fContextMenu->AddSeparatorItem(); + } if (postSettingsActions != NULL) { error = _AddActionItems(postSettingsActions); if (error != B_OK) return error; + } - AutoLocker settingsLocker(fRendererSettings); - fRendererSettings->AddListener(this); - - fRendererMenuAdded = true; + if (fRendererSettings != NULL) { + AutoLocker settingsLocker(fRendererSettings); + fRendererSettings->AddListener(this); + fRendererMenuAdded = true; + } return B_OK; } void ShowMenu(BPoint screenWhere) { - fRendererSettingsMenu->PrepareToShow(fParentLooper); + if (fRendererMenuAdded) + fRendererSettingsMenu->PrepareToShow(fParentLooper); for (int32 i = 0; i < fContextMenu->CountItems(); i++) { ActionMenuItem* item = dynamic_cast( fContextMenu->ItemAt(i)); if (item != NULL) - item->PrepareToShow(fParentLooper, fContextMenu); + item->PrepareToShow(fParentLooper, fParent.Target(NULL)); } fMenuPreparedToShow = true; @@ -551,13 +573,15 @@ public: bool stillActive = false; if (fMenuPreparedToShow) { - stillActive = fRendererSettingsMenu->Finish(fParentLooper, force); + if (fRendererMenuAdded) + stillActive = fRendererSettingsMenu->Finish(fParentLooper, + force); for (int32 i = 0; i < fContextMenu->CountItems(); i++) { ActionMenuItem* item = dynamic_cast( fContextMenu->ItemAt(i)); if (item != NULL) { - stillActive |= item->Finish(fParentLooper, fContextMenu, - force); + stillActive |= item->Finish(fParentLooper, + fParent.Target(NULL), force); } } @@ -1462,6 +1486,15 @@ void VariablesView::MessageReceived(BMessage* message) { switch (message->what) { + case MSG_SHOW_INSPECTOR_WINDOW: + { + // TODO: it'd probably be more ideal to extend the context + // action mechanism to allow one to specify an explicit + // target for each action rather than them all defaulting + // to targetting here. + Looper()->PostMessage(message); + break; + } case MSG_VALUE_NODE_CHANGED: { ValueNodeChild* nodeChild; @@ -1644,25 +1677,39 @@ VariablesView::TreeTableCellMouseDown(TreeTable* table, if (node == NULL) return; + Settings* settings = NULL; + SettingsMenu* settingsMenu = NULL; + BReference settingsMenuReference; + status_t error = B_OK; TableCellValueRenderer* cellRenderer = node->TableCellRenderer(); - if (cellRenderer == NULL) - return; - - Settings* settings = cellRenderer->GetSettings(); - if (settings == NULL) - return; - - SettingsMenu* settingsMenu; - status_t error = node->GetValueHandler()->CreateTableCellValueSettingsMenu( - node->GetValue(), settings, settingsMenu); - BReference settingsMenuReference(settingsMenu, true); - if (error != B_OK) - return; + if (cellRenderer != NULL) { + settings = cellRenderer->GetSettings(); + if (settings != NULL) { + error = node->GetValueHandler() + ->CreateTableCellValueSettingsMenu(node->GetValue(), settings, + settingsMenu); + settingsMenuReference.SetTo(settingsMenu, true); + if (error != B_OK) + return; + } + } TableCellContextMenuTracker* tracker = new(std::nothrow) TableCellContextMenuTracker(node, Looper(), this); BReference trackerReference(tracker); - if (tracker == NULL || tracker->Init(settings, settingsMenu) != B_OK) + + ContextActionList* preActionList = new(std::nothrow) ContextActionList; + if (preActionList == NULL) + return; + + BPrivate::ObjectDeleter preActionListDeleter( + preActionList); + + error = _GetContextActionsForNode(node, preActionList); + if (error != B_OK) + return; + + if (tracker == NULL || tracker->Init(settings, settingsMenu, preActionList) != B_OK) return; fTableCellContextMenuTracker = trackerReference.Detach(); @@ -1729,6 +1776,39 @@ VariablesView::_RequestNodeValue(ModelNode* node) } +status_t +VariablesView::_GetContextActionsForNode(ModelNode* node, + ContextActionList* actions) +{ + ValueLocation* location = node->NodeChild()->Location(); + + // if the location's stored somewhere other than in memory, + // then we won't be able to inspect it this way. + if (location->PieceAt(0).type != VALUE_PIECE_LOCATION_MEMORY) + return B_OK; + + BMessage* message = new BMessage(MSG_SHOW_INSPECTOR_WINDOW); + if (message == NULL) + return B_NO_MEMORY; + + ObjectDeleter messageDeleter(message); + message->AddUInt64("address", location->PieceAt(0).address); + + ActionMenuItem* item = new(std::nothrow) ActionMenuItem("Inspect", + message); + if (item == NULL) + return B_NO_MEMORY; + + messageDeleter.Detach(); + ObjectDeleter actionDeleter(item); + if (!actions->AddItem(item)) + return B_NO_MEMORY; + + actionDeleter.Detach(); + return B_OK; +} + + void VariablesView::_FinishContextMenu(bool force) { diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h index d1fa54b55b..30f3149fa9 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h @@ -68,8 +68,9 @@ private: void _Init(); void _RequestNodeValue(ModelNode* node); + status_t _GetContextActionsForNode(ModelNode* node, + ContextActionList* actions); void _FinishContextMenu(bool force); - void _SaveViewState() const; void _RestoreViewState(); status_t _AddViewStateDescendentNodeInfos( From 4bb5af765fc7c9e4daf911d5ad8db763403fdd21 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 15 Jul 2012 15:05:59 -0400 Subject: [PATCH 14/46] Add control mark color setting. #8054 An enhancement adding a setting to Colors under Appearance to set the mark color of radio button and check box controls. --- headers/os/interface/InterfaceDefs.h | 1 + headers/private/app/ServerReadOnlyMemory.h | 9 +++++---- src/bin/WindowShade.cpp | 1 + src/kits/interface/ControlLook.cpp | 5 +---- src/kits/interface/InterfaceDefs.cpp | 1 + src/preferences/appearance/ColorSet.cpp | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/headers/os/interface/InterfaceDefs.h b/headers/os/interface/InterfaceDefs.h index 0f85a486de..82c4bb72ce 100644 --- a/headers/os/interface/InterfaceDefs.h +++ b/headers/os/interface/InterfaceDefs.h @@ -294,6 +294,7 @@ enum color_which { B_CONTROL_TEXT_COLOR = 14, B_CONTROL_BORDER_COLOR = 15, B_CONTROL_HIGHLIGHT_COLOR = 16, + B_CONTROL_MARK_COLOR = 27, B_NAVIGATION_BASE_COLOR = 4, B_NAVIGATION_PULSE_COLOR = 17, B_SHINE_COLOR = 18, diff --git a/headers/private/app/ServerReadOnlyMemory.h b/headers/private/app/ServerReadOnlyMemory.h index 6ceadfde25..821de0372d 100644 --- a/headers/private/app/ServerReadOnlyMemory.h +++ b/headers/private/app/ServerReadOnlyMemory.h @@ -26,23 +26,24 @@ static inline int32 color_which_to_index(color_which which) { // NOTE: this must be kept in sync with InterfaceDefs.h color_which! - if (which <= B_WINDOW_INACTIVE_BORDER_COLOR) + if (which <= B_CONTROL_MARK_COLOR) return which - 1; if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR) - return which - B_SUCCESS_COLOR + B_WINDOW_INACTIVE_BORDER_COLOR; + return which - B_SUCCESS_COLOR + B_CONTROL_MARK_COLOR; return -1; } + static inline color_which index_to_color_which(int32 index) { if (index >= 0 && index < kNumColors) { - if ((color_which)index < B_WINDOW_INACTIVE_BORDER_COLOR) + if ((color_which)index < B_CONTROL_MARK_COLOR) return (color_which)(index + 1); else { return (color_which)(index + B_SUCCESS_COLOR - - B_WINDOW_INACTIVE_BORDER_COLOR); + - B_CONTROL_MARK_COLOR); } } diff --git a/src/bin/WindowShade.cpp b/src/bin/WindowShade.cpp index dcca8d2978..d8e29a64b1 100644 --- a/src/bin/WindowShade.cpp +++ b/src/bin/WindowShade.cpp @@ -43,6 +43,7 @@ static struct option const kLongOptions[] = { I(control_text_color, B_CONTROL_TEXT_COLOR), I(control_border_color, B_CONTROL_BORDER_COLOR), I(control_highlight_color, B_CONTROL_HIGHLIGHT_COLOR), + I(control_mark_color, B_CONTROL_MARK_COLOR) I(navigation_base_color, B_NAVIGATION_BASE_COLOR), I(navigation_pulse_color, B_NAVIGATION_PULSE_COLOR), I(shine_color, B_SHINE_COLOR), diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index cc3e6869c1..a0d8a11ec8 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -3197,10 +3197,7 @@ BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base, return false; } - // TODO: Get from UI settings - color.red = 27; - color.green = 82; - color.blue = 140; + color = ui_color(B_CONTROL_MARK_COLOR); float mix = 1.0; diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 1c53538c44..2a397a93a4 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -96,6 +96,7 @@ static const rgb_color _kDefaultColors[kNumColors] = { {80, 80, 80, 255}, // B_WINDOW_INACTIVE_TEXT_COLOR {224, 224, 224, 255}, // B_WINDOW_BORDER_COLOR {232, 232, 232, 255}, // B_WINDOW_INACTIVE_BORDER_COLOR + {27, 82, 140, 255}, // B_CONTROL_MARK_COLOR // 100... {0, 255, 0, 255}, // B_SUCCESS_COLOR {255, 0, 0, 255}, // B_FAILURE_COLOR diff --git a/src/preferences/appearance/ColorSet.cpp b/src/preferences/appearance/ColorSet.cpp index 757f711d8a..ccd6728f18 100644 --- a/src/preferences/appearance/ColorSet.cpp +++ b/src/preferences/appearance/ColorSet.cpp @@ -34,6 +34,7 @@ static ColorDescription sColorDescriptionTable[] = { B_CONTROL_TEXT_COLOR, B_TRANSLATE_MARK("Control text") }, { B_CONTROL_BORDER_COLOR, B_TRANSLATE_MARK("Control border") }, { B_CONTROL_HIGHLIGHT_COLOR, B_TRANSLATE_MARK("Control highlight") }, + { B_CONTROL_MARK_COLOR, B_TRANSLATE_MARK("Control mark") }, { B_NAVIGATION_BASE_COLOR, B_TRANSLATE_MARK("Navigation base") }, { B_NAVIGATION_PULSE_COLOR, B_TRANSLATE_MARK("Navigation pulse") }, { B_SHINE_COLOR, B_TRANSLATE_MARK("Shine") }, From 8c4773f75b06851586209f810ac1f8c759bf072f Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 15 Jul 2012 15:45:39 -0400 Subject: [PATCH 15/46] Adjust address semantics of CStringValueNode. - When resolving its value, CStringValueNode now sets its node child's address to the address of the string buffer rather than the location of the originating pointer, which allows things like Inspect to pick that up. --- .../value/value_nodes/CStringValueNode.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/apps/debugger/value/value_nodes/CStringValueNode.cpp b/src/apps/debugger/value/value_nodes/CStringValueNode.cpp index dc967113b4..3b5f90ce9d 100644 --- a/src/apps/debugger/value/value_nodes/CStringValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/CStringValueNode.cpp @@ -73,14 +73,24 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, if (dynamic_cast(fType) != NULL) { error = valueLoader->LoadValue(location, valueType, false, addressData); + if (error != B_OK) + return error; } else { addressData.SetTo(location->PieceAt(0).address); maxSize = dynamic_cast(fType) ->DimensionAt(0)->CountElements(); } - if (error != B_OK) - return error; + ValuePieceLocation piece; + piece.SetToMemory(addressData.ToUInt64()); + + ValueLocation* stringLocation = new(std::nothrow) ValueLocation( + valueLoader->GetArchitecture()->IsBigEndian(), piece); + + if (stringLocation == NULL) + return B_NO_MEMORY; + + BReference locationReference(stringLocation, true); error = valueLoader->LoadStringValue(addressData, maxSize, valueData); if (error != B_OK) @@ -91,8 +101,8 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, if (value == NULL) return B_NO_MEMORY; - location->AcquireReference(); - _location = location; + NodeChild()->SetLocation(stringLocation, B_OK); + _location = locationReference.Detach(); _value = value; return B_OK; } From c3c5b8e8ae931ac99282a2cd84fbb2f563b60d7c Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 15 Jul 2012 17:36:03 -0400 Subject: [PATCH 16/46] Update the Color Box border color in Appearance and put a TODO in. --- src/preferences/appearance/ColorWhichItem.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/preferences/appearance/ColorWhichItem.cpp b/src/preferences/appearance/ColorWhichItem.cpp index 23edda4f6d..7da8529d67 100644 --- a/src/preferences/appearance/ColorWhichItem.cpp +++ b/src/preferences/appearance/ColorWhichItem.cpp @@ -40,19 +40,23 @@ ColorWhichItem::DrawItem(BView *owner, BRect frame, bool complete) owner->FillRect(frame); } - rgb_color black = {0, 0, 0, 255}; + rgb_color border = (rgb_color){ 184, 184, 184, 255 }; BRect colorRect(frame); colorRect.InsetBy(2, 2); colorRect.right = colorRect.left + colorRect.Height(); owner->SetHighColor(fColor); owner->FillRect(colorRect); - owner->SetHighColor(black); + owner->SetHighColor(border); owner->StrokeRect(colorRect); owner->MovePenTo(frame.left + colorRect.Width() + 8, frame.top + BaselineOffset()); + // TODO: Don't hardcode black here, calculate based on background + // color or use B_CONTROL_TEXT_COLOR constant. + rgb_color black = (rgb_color){ 0, 0, 0, 255 }; + if (!IsEnabled()) owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT)); else From 2d4288086f2b04e6b1bbe9e8374f7903958669fe Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 14 Jul 2012 12:27:04 +1200 Subject: [PATCH 17/46] Make SpaceLayoutItem compose spacing using BControlLook. This allows for passing spacing/inset flags to BSpaceLayoutItem. Eg. in a builder, you could AddStrut(B_USE_ITEM_SPACING) --- src/kits/interface/SpaceLayoutItem.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/SpaceLayoutItem.cpp b/src/kits/interface/SpaceLayoutItem.cpp index ceadb8cf6e..a863780fe9 100644 --- a/src/kits/interface/SpaceLayoutItem.cpp +++ b/src/kits/interface/SpaceLayoutItem.cpp @@ -9,6 +9,7 @@ #include +#include #include @@ -18,6 +19,13 @@ namespace { const char* const kAlignmentField = "BSpaceLayoutItem:alignment"; const char* const kFrameField = "BSpaceLayoutItem:frame"; const char* const kVisibleField = "BSpaceLayoutItem:visible"; + + BSize& ComposeSpacingInPlace(BSize& size) + { + size.width = BControlLook::ComposeSpacing(size.width); + size.height = BControlLook::ComposeSpacing(size.height); + return size; + } } @@ -25,9 +33,9 @@ BSpaceLayoutItem::BSpaceLayoutItem(BSize minSize, BSize maxSize, BSize preferredSize, BAlignment alignment) : fFrame(), - fMinSize(minSize), - fMaxSize(maxSize), - fPreferredSize(preferredSize), + fMinSize(ComposeSpacingInPlace(minSize)), + fMaxSize(ComposeSpacingInPlace(maxSize)), + fPreferredSize(ComposeSpacingInPlace(preferredSize)), fAlignment(alignment), fVisible(true) { From a1ae8022797c710ead4307573ea988f92393ba11 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 14 Jul 2012 15:35:45 +1200 Subject: [PATCH 18/46] Convert Poorman to use the Layout API. Also includes many style fixes. This patch was done by tokyo6pm, and then updated by mks after changes to Poorman broke the patch. ticket: #3787 --- src/apps/poorman/PoorManAdvancedView.cpp | 50 +- src/apps/poorman/PoorManAdvancedView.h | 15 +- src/apps/poorman/PoorManLoggingView.cpp | 88 +-- src/apps/poorman/PoorManLoggingView.h | 42 +- src/apps/poorman/PoorManPreferencesWindow.cpp | 195 +++--- src/apps/poorman/PoorManPreferencesWindow.h | 97 ++- src/apps/poorman/PoorManSiteView.cpp | 90 +-- src/apps/poorman/PoorManSiteView.h | 36 +- src/apps/poorman/PoorManView.cpp | 2 +- src/apps/poorman/PoorManView.h | 8 +- src/apps/poorman/PoorManWindow.cpp | 626 ++++++++---------- src/apps/poorman/PoorManWindow.h | 151 +++-- src/apps/poorman/StatusSlider.cpp | 30 +- src/apps/poorman/StatusSlider.h | 26 +- 14 files changed, 654 insertions(+), 802 deletions(-) diff --git a/src/apps/poorman/PoorManAdvancedView.cpp b/src/apps/poorman/PoorManAdvancedView.cpp index 10ef09a8ca..e817428698 100644 --- a/src/apps/poorman/PoorManAdvancedView.cpp +++ b/src/apps/poorman/PoorManAdvancedView.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include "constants.h" @@ -19,46 +20,41 @@ #define B_TRANSLATION_CONTEXT "PoorMan" -PoorManAdvancedView::PoorManAdvancedView(BRect rect, const char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) +PoorManAdvancedView::PoorManAdvancedView(const char* name) + : + BView(name, B_WILL_DRAW, NULL) { - PoorManWindow * win; - win = ((PoorManApplication *)be_app)->GetPoorManWindow(); + PoorManWindow* win; + win = ((PoorManApplication*)be_app)->GetPoorManWindow(); - SetViewColor(BACKGROUND_COLOR); + SetLayout(new BGroupLayout(B_VERTICAL)); - // Console Logging BBox - BRect maxRect; - maxRect = rect; - maxRect.top -= 5.0; - maxRect.left -= 5.0; - maxRect.right -= 7.0; - maxRect.bottom -= 118.0; - - BBox * connectionOptions = new BBox(maxRect, B_TRANSLATE("Connections")); + BBox* connectionOptions = new BBox(B_TRANSLATE("Connections")); connectionOptions->SetLabel(STR_BBX_CONNECTION); - AddChild(connectionOptions); - BRect sliderRect; - sliderRect = connectionOptions->Bounds(); - sliderRect.InsetBy(10.0f, 10.0f); - sliderRect.top += 10; - sliderRect.bottom = sliderRect.top + 50.0; - - maxConnections = new StatusSlider(sliderRect, "Max Slider", STR_SLD_LABEL, - STR_SLD_STATUS_LABEL, new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200); + fMaxConnections = new StatusSlider("Max Slider", STR_SLD_LABEL, + STR_SLD_STATUS_LABEL, + new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200); // labels below the slider 1 and 200 - maxConnections->SetLimitLabels("1", "200"); + fMaxConnections->SetLimitLabels("1", "200"); SetMaxSimutaneousConnections(win->MaxConnections()); - connectionOptions->AddChild(maxConnections); + + connectionOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(fMaxConnections) + .SetInsets(5, 5, 5, 5)); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(connectionOptions) + .AddGlue() + .SetInsets(5, 5, 5, 5)); } void PoorManAdvancedView::SetMaxSimutaneousConnections(int32 num) { if (num <= 0 || num > 200) - maxConnections->SetValue(32); + fMaxConnections->SetValue(32); else - maxConnections->SetValue(num); + fMaxConnections->SetValue(num); } diff --git a/src/apps/poorman/PoorManAdvancedView.h b/src/apps/poorman/PoorManAdvancedView.h index fd693a77f1..9b6dc58a0e 100644 --- a/src/apps/poorman/PoorManAdvancedView.h +++ b/src/apps/poorman/PoorManAdvancedView.h @@ -13,16 +13,17 @@ #include "StatusSlider.h" -class PoorManAdvancedView: public BView -{ +class PoorManAdvancedView: public BView { public: - PoorManAdvancedView(BRect, const char *name); - int32 MaxSimultaneousConnections() { return maxConnections->Value(); } - void SetMaxSimutaneousConnections(int32 num); + PoorManAdvancedView(const char *name); + + int32 MaxSimultaneousConnections() + { return fMaxConnections->Value(); } + void SetMaxSimutaneousConnections(int32 num); private: - // Advanced Tab + // Advanced Tab // Connections Options - StatusSlider * maxConnections; + StatusSlider* fMaxConnections; }; #endif diff --git a/src/apps/poorman/PoorManLoggingView.cpp b/src/apps/poorman/PoorManLoggingView.cpp index 2f52c40a39..2d06194a1c 100644 --- a/src/apps/poorman/PoorManLoggingView.cpp +++ b/src/apps/poorman/PoorManLoggingView.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include "constants.h" @@ -19,80 +20,61 @@ #define B_TRANSLATION_CONTEXT "PoorMan" -PoorManLoggingView::PoorManLoggingView(BRect rect, const char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) +PoorManLoggingView::PoorManLoggingView(const char* name) + : + BView(name, B_WILL_DRAW, NULL) { - PoorManWindow * win; - win = ((PoorManApplication *)be_app)->GetPoorManWindow(); + PoorManWindow* win; + win = ((PoorManApplication*)be_app)->GetPoorManWindow(); - SetViewColor(BACKGROUND_COLOR); + SetLayout(new BGroupLayout(B_VERTICAL)); - // Console Logging BBox - BRect consoleLoggingRect; - consoleLoggingRect = rect; - consoleLoggingRect.top -= 5.0; - consoleLoggingRect.left -= 5.0; - consoleLoggingRect.right -= 7.0; - consoleLoggingRect.bottom -= 118.0; - - BBox * consoleLogging = new BBox(consoleLoggingRect, - B_TRANSLATE("Console Logging")); + BBox* consoleLogging = new BBox(B_TRANSLATE("Console Logging")); consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING); - AddChild(consoleLogging); - // File Logging BBox - BRect fileLoggingRect; - fileLoggingRect = consoleLoggingRect; - fileLoggingRect.top = consoleLoggingRect.bottom + 10.0; - fileLoggingRect.bottom = fileLoggingRect.top + 100.0; - - BBox * fileLogging = new BBox(fileLoggingRect, - B_TRANSLATE("File Logging")); + BBox* fileLogging = new BBox(B_TRANSLATE("File Logging")); fileLogging->SetLabel(STR_BBX_FILE_LOGGING); - AddChild(fileLogging); - - float left = 10.0; - float top = 20.0; - float box_size = 13.0; - BRect tempRect(left, top, consoleLoggingRect.Width() - 5.0, top + box_size); - + // Console Logging - logConsole = new BCheckBox(tempRect, B_TRANSLATE("Log To Console"), + fLogConsole = new BCheckBox(B_TRANSLATE("Log To Console"), STR_CBX_LOG_CONSOLE, new BMessage(MSG_PREF_LOG_CBX_CONSOLE)); // set the checkbox to the value the program has SetLogConsoleValue(win->LogConsoleFlag()); - consoleLogging->AddChild(logConsole); // File Logging - logFile = new BCheckBox(tempRect, B_TRANSLATE("Log To File"), - STR_CBX_LOG_FILE, new BMessage(MSG_PREF_LOG_CBX_FILE)); + fLogFile = new BCheckBox(B_TRANSLATE("Log To File"), STR_CBX_LOG_FILE, + new BMessage(MSG_PREF_LOG_CBX_FILE)); // set the checkbox to the value the program has SetLogFileValue(win->LogFileFlag()); - fileLogging->AddChild(logFile); // File Name - tempRect.top = tempRect.bottom + 10.0; - tempRect.bottom = tempRect.top + box_size; - tempRect.right -= 5.0; - - logFileName = new BTextControl(tempRect, B_TRANSLATE("File Name"), + fLogFileName = new BTextControl(B_TRANSLATE("File Name"), STR_TXT_LOG_FILE_NAME, NULL, NULL); - logFileName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); - logFileName->SetDivider(fileLogging->StringWidth(STR_TXT_LOG_FILE_NAME) + 8.0f); SetLogFileName(win->LogPath()); - fileLogging->AddChild(logFileName); // Create Log File - BRect createLogFileRect; - createLogFileRect.top = tempRect.bottom + 13.0; - createLogFileRect.right = tempRect.right + 2.0; - createLogFileRect.left = createLogFileRect.right - - fileLogging->StringWidth(B_TRANSLATE("Create Log File")) - 24.0; - createLogFileRect.bottom = createLogFileRect.top + 19.0; - - createLogFile = new BButton(createLogFileRect, B_TRANSLATE("Create Log File"), + fCreateLogFile = new BButton(B_TRANSLATE("Create Log File"), STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE)); - fileLogging->AddChild(createLogFile); + consoleLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) + .Add(fLogConsole) + .AddGlue()) + .SetInsets(5, 5, 5, 5)); + + fileLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) + .Add(fLogFile) + .AddGlue()) + .Add(fLogFileName) + .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) + .AddGlue() + .Add(fCreateLogFile)) + .SetInsets(5, 5, 5, 5)); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(consoleLogging) + .Add(fileLogging) + .SetInsets(5, 5, 5, 5)); } diff --git a/src/apps/poorman/PoorManLoggingView.h b/src/apps/poorman/PoorManLoggingView.h index 2ffa367606..9648f08be4 100644 --- a/src/apps/poorman/PoorManLoggingView.h +++ b/src/apps/poorman/PoorManLoggingView.h @@ -14,28 +14,36 @@ #include -class PoorManLoggingView: public BView -{ +class PoorManLoggingView: public BView { public: - PoorManLoggingView(BRect, const char *name); + PoorManLoggingView(const char* name); - void SetLogConsoleValue(bool state) {if (state) logConsole->SetValue(B_CONTROL_ON); - else logConsole->SetValue(B_CONTROL_OFF); } - bool LogConsoleValue() { return (logConsole->Value() == B_CONTROL_ON) ? true : false; } - void SetLogFileValue(bool state) {if (state) logFile->SetValue(B_CONTROL_ON); - else logFile->SetValue(B_CONTROL_OFF); } - bool LogFileValue() { return (logFile->Value() == B_CONTROL_ON) ? true : false; } -const char * LogFileName() { return logFileName->Text(); } - void SetLogFileName(const char * log) { logFileName->SetText(log); } -private: - // Logging Tab + void SetLogConsoleValue(bool state) + { if (state) + fLogConsole->SetValue(B_CONTROL_ON); + else fLogConsole->SetValue(B_CONTROL_OFF); } + bool LogConsoleValue() + { return (fLogConsole->Value() == B_CONTROL_ON) + ? true : false; } + void SetLogFileValue(bool state) + { if (state) fLogFile->SetValue(B_CONTROL_ON); + else fLogFile->SetValue(B_CONTROL_OFF); } + bool LogFileValue() + { return (fLogFile->Value() == B_CONTROL_ON) + ? true : false; } + const char* LogFileName() + { return fLogFileName->Text(); } + void SetLogFileName(const char* log) + { fLogFileName->SetText(log); } +private: + // Logging Tab // Console Logging - BCheckBox * logConsole; + BCheckBox* fLogConsole; // File Logging - BCheckBox * logFile; - BTextControl * logFileName; - BButton * createLogFile; + BCheckBox* fLogFile; + BTextControl* fLogFileName; + BButton * fCreateLogFile; }; #endif diff --git a/src/apps/poorman/PoorManPreferencesWindow.cpp b/src/apps/poorman/PoorManPreferencesWindow.cpp index 21a7137ee3..a09475de91 100644 --- a/src/apps/poorman/PoorManPreferencesWindow.cpp +++ b/src/apps/poorman/PoorManPreferencesWindow.cpp @@ -9,7 +9,10 @@ #include #include #include +#include +#include #include +#include #include #include "constants.h" @@ -25,110 +28,72 @@ PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name) : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE - | B_CLOSE_ON_ESCAPE), - webDirFilePanel(NULL), - logFilePanel(NULL) + | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS), + fWebDirFilePanel(NULL), + fLogFilePanel(NULL) { - frame = Bounds(); + SetLayout(new BGroupLayout(B_VERTICAL)); - prefView = new PoorManView(frame, STR_WIN_NAME_PREF); - //prefView->SetViewColor(216,216,216,255); - prefView->SetViewColor(BACKGROUND_COLOR); - AddChild(prefView); - - - // Button View - BRect buttonRect; - buttonRect = Bounds(); - buttonRect.top = buttonRect.bottom - 30; - - buttonView = new PoorManView(buttonRect, "Button View"); - buttonView->SetViewColor(BACKGROUND_COLOR); - prefView->AddChild(buttonView); - - // Buttons - float buttonTop = 0.0f; - float buttonHeight = 26.0f; - - float widthCancel = prefView->StringWidth(B_TRANSLATE("Cancel")) + 24.0f; - float widthDone = prefView->StringWidth(B_TRANSLATE("Done")) + 24.0f; - - float gap = 5.0f; - - BRect button1(prefView->Bounds().Width() - 2 * gap - widthCancel - - widthDone, buttonTop, prefView->Bounds().Width() - 2 * gap - widthDone, - buttonTop + buttonHeight); - cancelButton = new BButton(button1, "Cancel Button", B_TRANSLATE("Cancel"), + fCancelButton = new BButton("Cancel Button", B_TRANSLATE("Cancel"), new BMessage(MSG_PREF_BTN_CANCEL)); - - BRect button2(prefView->Bounds().Width() - gap - widthDone, buttonTop, - prefView->Bounds().Width() - gap, buttonTop + buttonHeight); - doneButton = new BButton(button2, "Done Button", B_TRANSLATE("Done"), + fDoneButton = new BButton("Done Button", B_TRANSLATE("Done"), new BMessage(MSG_PREF_BTN_DONE)); - buttonView->AddChild(cancelButton); - buttonView->AddChild(doneButton); - - // Create tabs - BRect r; - r = Bounds(); - //r.InsetBy(5, 5); - r.top += 8.0; - r.bottom -= 38.0; - - prefTabView = new BTabView(r, "Pref Tab View"); - prefTabView->SetViewColor(BACKGROUND_COLOR); - - r = prefTabView->Bounds(); - r.InsetBy(5, 5); - r.bottom -= prefTabView->TabHeight(); + fPrefTabView = new BTabView("Pref Tab View"); // Site Tab - siteTab = new BTab(); - siteView = new PoorManSiteView(r, "Site View"); - prefTabView->AddTab(siteView, siteTab); - siteTab->SetLabel(STR_TAB_SITE); + fSiteTab = new BTab(); + fSiteView = new PoorManSiteView("Site View"); + fPrefTabView->AddTab(fSiteView, fSiteTab); + fSiteTab->SetLabel(STR_TAB_SITE); // Logging Tab - loggingTab = new BTab(); - loggingView = new PoorManLoggingView(r, "Logging View"); - prefTabView->AddTab(loggingView, loggingTab); - loggingTab->SetLabel(STR_TAB_LOGGING); + fLoggingTab = new BTab(); + fLoggingView = new PoorManLoggingView("Logging View"); + fPrefTabView->AddTab(fLoggingView, fLoggingTab); + fLoggingTab->SetLabel(STR_TAB_LOGGING); // Advanced Tab - advancedTab = new BTab(); - advancedView = new PoorManAdvancedView(r, "Advanced View"); - prefTabView->AddTab(advancedView, advancedTab); - advancedTab->SetLabel(STR_TAB_ADVANCED); - - prefView->AddChild(prefTabView); + fAdvancedTab = new BTab(); + fAdvancedView = new PoorManAdvancedView("Advanced View"); + fPrefTabView->AddTab(fAdvancedView, fAdvancedTab); + fAdvancedTab->SetLabel(STR_TAB_ADVANCED); // FilePanels BWindow * change_title; BMessenger messenger(this); BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR); - webDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL, + fWebDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL, B_DIRECTORY_NODE, false, &message, NULL, true); - webDirFilePanel->SetPanelDirectory(new BDirectory("/boot/home/public_html")); - webDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); - change_title = webDirFilePanel->Window(); + fWebDirFilePanel->SetPanelDirectory( + new BDirectory("/boot/home/public_html")); + fWebDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); + change_title = fWebDirFilePanel->Window(); change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR); message.what = MSG_FILE_PANEL_CREATE_LOG_FILE; - logFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL, + fLogFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL, B_FILE_NODE, false, &message); - logFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create")); - change_title = logFilePanel->Window(); + fLogFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create")); + change_title = fLogFilePanel->Window(); change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(fPrefTabView) + .Add(BGroupLayoutBuilder(B_HORIZONTAL) + .AddGlue() + .Add(fCancelButton) + .Add(fDoneButton)) + .SetInsets(5, 5, 5, 5)); } PoorManPreferencesWindow::~PoorManPreferencesWindow() { - delete logFilePanel; - delete webDirFilePanel; + delete fLogFilePanel; + delete fWebDirFilePanel; } @@ -139,38 +104,38 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message) case MSG_PREF_BTN_DONE: PoorManWindow* win; PoorManServer* server; - win = ((PoorManApplication *)be_app)->GetPoorManWindow(); + win = ((PoorManApplication*)be_app)->GetPoorManWindow(); server = win->GetServer(); PRINT(("Pref Window: sendDir CheckBox: %d\n", - siteView->SendDirValue())); - server->SetListDir(siteView->SendDirValue()); - win->SetDirListFlag(siteView->SendDirValue()); + fSiteView->SendDirValue())); + server->SetListDir(fSiteView->SendDirValue()); + win->SetDirListFlag(fSiteView->SendDirValue()); PRINT(("Pref Window: indexFileName TextControl: %s\n", - siteView->IndexFileName())); - if (server->SetIndexName(siteView->IndexFileName()) == B_OK) - win->SetIndexFileName(siteView->IndexFileName()); - PRINT(("Pref Window: webDir: %s\n", siteView->WebDir())); - if (server->SetWebDir(siteView->WebDir()) == B_OK) { - win->SetWebDir(siteView->WebDir()); - win->SetDirLabel(siteView->WebDir()); + fSiteView->IndexFileName())); + if (server->SetIndexName(fSiteView->IndexFileName()) == B_OK) + win->SetIndexFileName(fSiteView->IndexFileName()); + PRINT(("Pref Window: webDir: %s\n", fSiteView->WebDir())); + if (server->SetWebDir(fSiteView->WebDir()) == B_OK) { + win->SetWebDir(fSiteView->WebDir()); + win->SetDirLabel(fSiteView->WebDir()); } PRINT(("Pref Window: logConsole CheckBox: %d\n", - loggingView->LogConsoleValue())); - win->SetLogConsoleFlag(loggingView->LogConsoleValue()); + fLoggingView->LogConsoleValue())); + win->SetLogConsoleFlag(fLoggingView->LogConsoleValue()); PRINT(("Pref Window: logFile CheckBox: %d\n", - loggingView->LogFileValue())); - win->SetLogFileFlag(loggingView->LogFileValue()); + fLoggingView->LogFileValue())); + win->SetLogFileFlag(fLoggingView->LogFileValue()); PRINT(("Pref Window: logFileName: %s\n", - loggingView->LogFileName())); - win->SetLogPath(loggingView->LogFileName()); + fLoggingView->LogFileName())); + win->SetLogPath(fLoggingView->LogFileName()); PRINT(("Pref Window: MaxConnections Slider: %ld\n", - advancedView->MaxSimultaneousConnections())); - server->SetMaxConns(advancedView->MaxSimultaneousConnections()); + fAdvancedView->MaxSimultaneousConnections())); + server->SetMaxConns(fAdvancedView->MaxSimultaneousConnections()); win->SetMaxConnections( - (int16)advancedView->MaxSimultaneousConnections()); + (int16)fAdvancedView->MaxSimultaneousConnections()); if (Lock()) Quit(); @@ -181,10 +146,10 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message) break; case MSG_PREF_SITE_BTN_SELECT: // Select the Web Directory, root directory to look in. - webDirFilePanel->SetTarget(this); - webDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR)); - if (!webDirFilePanel->IsShowing()) - webDirFilePanel->Show(); + fWebDirFilePanel->SetTarget(this); + fWebDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR)); + if (!fWebDirFilePanel->IsShowing()) + fWebDirFilePanel->Show(); break; case MSG_FILE_PANEL_SELECT_WEB_DIR: // handle the open BMessage from the Select Web Directory File Panel @@ -193,7 +158,7 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message) break; case MSG_PREF_LOG_BTN_CREATE_FILE: // Create the Log File - logFilePanel->Show(); + fLogFilePanel->Show(); break; case MSG_FILE_PANEL_CREATE_LOG_FILE: // handle the save BMessage from the Create Log File Panel @@ -201,8 +166,8 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message) CreateLogFile(message); break; case MSG_PREF_ADV_SLD_MAX_CONNECTION: - max_connections = advancedView->MaxSimultaneousConnections(); - PRINT(("Max Connections: %ld\n", max_connections)); + fMaxConnections = fAdvancedView->MaxSimultaneousConnections(); + PRINT(("Max Connections: %ld\n", fMaxConnections)); break; default: BWindow::MessageReceived(message); @@ -212,10 +177,10 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message) void -PoorManPreferencesWindow::SelectWebDir(BMessage * message) +PoorManPreferencesWindow::SelectWebDir(BMessage* message) { entry_ref ref; - const char * name; + const char* name; BPath path; BEntry entry; @@ -227,15 +192,15 @@ PoorManPreferencesWindow::SelectWebDir(BMessage * message) entry.GetPath(&path); PRINT(("DIR: %s\n", path.Path())); - siteView->SetWebDir(path.Path()); + fSiteView->SetWebDir(path.Path()); bool temp; if (message->FindBool("Default Dialog", &temp) == B_OK) { PoorManWindow* win = ((PoorManApplication *)be_app)->GetPoorManWindow(); win->StartServer(); - if (win->GetServer()->SetWebDir(siteView->WebDir()) == B_OK) { - win->SetWebDir(siteView->WebDir()); - win->SetDirLabel(siteView->WebDir()); + if (win->GetServer()->SetWebDir(fSiteView->WebDir()) == B_OK) { + win->SetWebDir(fSiteView->WebDir()); + win->SetDirLabel(fSiteView->WebDir()); win->SaveSettings(); win->Show(); } @@ -246,7 +211,7 @@ PoorManPreferencesWindow::SelectWebDir(BMessage * message) void -PoorManPreferencesWindow::CreateLogFile(BMessage * message) +PoorManPreferencesWindow::CreateLogFile(BMessage* message) { entry_ref ref; const char * name; @@ -268,8 +233,8 @@ PoorManPreferencesWindow::CreateLogFile(BMessage * message) PRINT(("Log File: %s\n", path.Path())); if (err == B_OK) { - loggingView->SetLogFileName(path.Path()); - loggingView->SetLogFileValue(true); + fLoggingView->SetLogFileName(path.Path()); + fLoggingView->SetLogFileValue(true); } // mark the checkbox @@ -283,8 +248,8 @@ PoorManPreferencesWindow::ShowWebDirFilePanel() BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR); message.AddBool("Default Dialog", true); - webDirFilePanel->SetTarget(be_app); - webDirFilePanel->SetMessage(&message); - if (!webDirFilePanel->IsShowing()) - webDirFilePanel->Show(); + fWebDirFilePanel->SetTarget(be_app); + fWebDirFilePanel->SetMessage(&message); + if (!fWebDirFilePanel->IsShowing()) + fWebDirFilePanel->Show(); } diff --git a/src/apps/poorman/PoorManPreferencesWindow.h b/src/apps/poorman/PoorManPreferencesWindow.h index 2aaace87ef..7758799dda 100644 --- a/src/apps/poorman/PoorManPreferencesWindow.h +++ b/src/apps/poorman/PoorManPreferencesWindow.h @@ -22,59 +22,56 @@ #include "PoorManAdvancedView.h" - - -class PoorManPreferencesWindow: public BWindow -{ -private: - - PoorManView * prefView; - PoorManView * buttonView; - - // ------------------------------------------------ - // Tabs - BTabView * prefTabView; - BTab * siteTab; - BTab * loggingTab; - BTab * advancedTab; - // Tab Views - PoorManSiteView * siteView; - PoorManLoggingView * loggingView; - PoorManAdvancedView * advancedView; - - // ------------------------------------------------ - // Buttons - BButton * cancelButton; - BButton * doneButton; - - // ------------------------------------------------ - // FilePanels - BFilePanel * webDirFilePanel; - BFilePanel * logFilePanel; - - - // ------------------------------------------------ - // temporary preference variables used to save and - // set the application to - // site tab - char web_directory[B_FILE_NAME_LENGTH]; - char index_file_name[64]; - bool send_dir; - // logging tab - bool log_to_console; - bool log_to_file; - char log_file_name[B_FILE_NAME_LENGTH]; - // advanced tab - int32 max_connections; +class PoorManPreferencesWindow: public BWindow { public: - PoorManPreferencesWindow(BRect frame, char * name); - ~PoorManPreferencesWindow(); + PoorManPreferencesWindow(BRect frame, char* name); + ~PoorManPreferencesWindow(); -virtual void MessageReceived(BMessage * message); + virtual void MessageReceived(BMessage* message); - void ShowWebDirFilePanel(); - void SelectWebDir(BMessage * message); - void CreateLogFile(BMessage * message); + void ShowWebDirFilePanel(); + void SelectWebDir(BMessage* message); + void CreateLogFile(BMessage* message); + +private: + PoorManView* fPrefView; + PoorManView* fButtonView; + + // ------------------------------------------------ + // Tabs + BTabView* fPrefTabView; + BTab* fSiteTab; + BTab* fLoggingTab; + BTab* fAdvancedTab; + // Tab Views + PoorManSiteView* fSiteView; + PoorManLoggingView* fLoggingView; + PoorManAdvancedView* fAdvancedView; + + // ------------------------------------------------ + // Buttons + BButton* fCancelButton; + BButton* fDoneButton; + + // ------------------------------------------------ + // FilePanels + BFilePanel* fWebDirFilePanel; + BFilePanel* fLogFilePanel; + + + // ------------------------------------------------ + // temporary preference variables used to save and + // set the application to + // site tab + char fWebDirectory[B_FILE_NAME_LENGTH]; + char fIndexFileName[64]; + bool fSendDir; + // logging tab + bool flogToConsole; + bool fLogToFile; + char fLogFileName[B_FILE_NAME_LENGTH]; + // advanced tab + int32 fMaxConnections; }; #endif diff --git a/src/apps/poorman/PoorManSiteView.cpp b/src/apps/poorman/PoorManSiteView.cpp index 4214d6c01f..532c0e65ad 100644 --- a/src/apps/poorman/PoorManSiteView.cpp +++ b/src/apps/poorman/PoorManSiteView.cpp @@ -6,91 +6,63 @@ */ #include +#include #include "constants.h" #include "PoorManSiteView.h" #include "PoorManWindow.h" #include "PoorManApplication.h" -PoorManSiteView::PoorManSiteView(BRect rect, const char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) +PoorManSiteView::PoorManSiteView(const char* name) + : BView(name, B_WILL_DRAW, NULL) { - PoorManWindow * win; + PoorManWindow* win; win = ((PoorManApplication *)be_app)->GetPoorManWindow(); - SetViewColor(BACKGROUND_COLOR); + SetLayout(new BGroupLayout(B_VERTICAL)); // Web Site Location BBox - BRect webLocationRect; - webLocationRect = rect; - webLocationRect.top -= 5.0; - webLocationRect.left -= 5.0; - webLocationRect.right -= 7.0; - webLocationRect.bottom -= 98.0; - - BBox * webSiteLocation = new BBox(webLocationRect, "Web Location"); + BBox* webSiteLocation = new BBox("Web Location"); webSiteLocation->SetLabel(STR_BBX_LOCATION); - AddChild(webSiteLocation); // Web Site Options BBox - BRect webOptionsRect; - webOptionsRect = webLocationRect; - webOptionsRect.top = webOptionsRect.bottom + 10.0; - webOptionsRect.bottom = webOptionsRect.top + 80.0; - - BBox * webSiteOptions = new BBox(webOptionsRect, "Web Options"); + BBox* webSiteOptions = new BBox("Web Options"); webSiteOptions->SetLabel(STR_BBX_OPTIONS); - AddChild(webSiteOptions); // Send Directory List if No Index - float left = 10.0; - float top = 20.0; - float box_size = 13.0; - BRect sendDirRect(left, top, webOptionsRect.Width() - 5.0, top + box_size); - sendDir = new BCheckBox(sendDirRect, "Send Dir", STR_CBX_DIR_LIST_LABEL, new BMessage(MSG_PREF_SITE_CBX_INDEX)); + fSendDir = new BCheckBox("Send Dir", STR_CBX_DIR_LIST_LABEL, + new BMessage(MSG_PREF_SITE_CBX_INDEX)); // set the checkbox to the value the program has SetSendDirValue(win->DirListFlag()); - webSiteOptions->AddChild(sendDir); - - // Finish the Web Site Location Section - BRect webSiteLocationRect; - webSiteLocationRect = webLocationRect; - webSiteLocationRect.InsetBy(10.0, 7.0); - webSiteLocationRect.top += 13.0; - webSiteLocationRect.bottom = webSiteLocationRect.top + 19.0; - // Web Directory Text Control - webDir = new BTextControl(webSiteLocationRect, "Web Dir", - STR_TXT_DIRECTORY, NULL, NULL); - webDir->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); - webDir->SetDivider(80.0); + fWebDir = new BTextControl("Web Dir", STR_TXT_DIRECTORY, NULL); SetWebDir(win->WebDir()); - webSiteLocation->AddChild(webDir); // Select Web Directory Button - BRect selectWebDirRect; - - selectWebDirRect.top = webSiteLocationRect.bottom + 5.0; - selectWebDirRect.right = webSiteLocationRect.right + 2.0; - selectWebDirRect.left = selectWebDirRect.right - - webSiteLocation->StringWidth("Select Web Dir") - 24.0; - selectWebDirRect.bottom = selectWebDirRect.top + 19.0; - - selectWebDir = new BButton(selectWebDirRect, "Select Web Dir", - STR_BTN_DIRECTORY, new BMessage(MSG_PREF_SITE_BTN_SELECT)); - webSiteLocation->AddChild(selectWebDir); + fSelectWebDir = new BButton("Select Web Dir", STR_BTN_DIRECTORY, + new BMessage(MSG_PREF_SITE_BTN_SELECT)); // Index File Name Text Control - //webDirRect.InsetBy(10.0, 7.0); - webSiteLocationRect.top += 63.0; - webSiteLocationRect.bottom = webSiteLocationRect.top + 19.0; - - indexFileName = new BTextControl(webSiteLocationRect, - "Index File Name", STR_TXT_INDEX, NULL, NULL); - indexFileName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); - indexFileName->SetDivider(80.0); + fIndexFileName = new BTextControl("Index File Name", STR_TXT_INDEX, NULL); SetIndexFileName(win->IndexFileName()); - webSiteLocation->AddChild(indexFileName); + webSiteOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) + .Add(fSendDir) + .AddGlue()) + .SetInsets(5, 5, 5, 5)); + + webSiteLocation->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(fWebDir) + .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) + .AddGlue() + .Add(fSelectWebDir)) + .Add(fIndexFileName) + .SetInsets(5, 5, 5, 5)); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + .Add(webSiteLocation) + .Add(webSiteOptions) + .SetInsets(5, 5, 5, 5)); } diff --git a/src/apps/poorman/PoorManSiteView.h b/src/apps/poorman/PoorManSiteView.h index 2fecd8f86c..8bd8716da4 100644 --- a/src/apps/poorman/PoorManSiteView.h +++ b/src/apps/poorman/PoorManSiteView.h @@ -14,26 +14,34 @@ #include -class PoorManSiteView: public BView -{ +class PoorManSiteView: public BView { public: - PoorManSiteView(BRect, const char *name); - void SetSendDirValue(bool state) {if (state) sendDir->SetValue(B_CONTROL_ON); - else sendDir->SetValue(B_CONTROL_OFF); } - bool SendDirValue() { return (sendDir->Value() == B_CONTROL_ON) ? true : false; } -const char * IndexFileName() { return indexFileName->Text(); } - void SetIndexFileName(const char * name) { indexFileName->SetText(name); } -const char * WebDir() { return webDir->Text(); } - void SetWebDir(const char * dir) { webDir->SetText(dir); } + PoorManSiteView(const char *name); + + void SetSendDirValue(bool state) + { if (state) fSendDir->SetValue(B_CONTROL_ON); + else fSendDir->SetValue(B_CONTROL_OFF); } + bool SendDirValue() + { return (fSendDir->Value() == B_CONTROL_ON) + ? true : false; } + const char* IndexFileName() + { return fIndexFileName->Text(); } + void SetIndexFileName(const char* name) + { fIndexFileName->SetText(name); } + const char* WebDir() + { return fWebDir->Text(); } + void SetWebDir(const char* dir) + { fWebDir->SetText(dir); } + private: // Site Tab // Web Site Location - BTextControl * webDir; - BTextControl * indexFileName; - BButton * selectWebDir; + BTextControl* fWebDir; + BTextControl* fIndexFileName; + BButton* fSelectWebDir; // Web Site Options - BCheckBox * sendDir; + BCheckBox* fSendDir; }; diff --git a/src/apps/poorman/PoorManView.cpp b/src/apps/poorman/PoorManView.cpp index 492162c9b6..9a27f517e1 100644 --- a/src/apps/poorman/PoorManView.cpp +++ b/src/apps/poorman/PoorManView.cpp @@ -10,7 +10,7 @@ #endif PoorManView::PoorManView(BRect rect, const char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW ) + : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) { } diff --git a/src/apps/poorman/PoorManView.h b/src/apps/poorman/PoorManView.h index 724dcadeb6..e4c40da3cc 100644 --- a/src/apps/poorman/PoorManView.h +++ b/src/apps/poorman/PoorManView.h @@ -12,11 +12,11 @@ #include #endif -class PoorManView: public BView -{ +class PoorManView: public BView { public: - PoorManView(BRect, const char *name); -virtual void AttachedToWindow(); + PoorManView(BRect, const char *name); + + virtual void AttachedToWindow(); }; #endif diff --git a/src/apps/poorman/PoorManWindow.cpp b/src/apps/poorman/PoorManWindow.cpp index 08eb8b83e8..07e5ba907e 100644 --- a/src/apps/poorman/PoorManWindow.cpp +++ b/src/apps/poorman/PoorManWindow.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -43,182 +44,111 @@ PoorManWindow::PoorManWindow(BRect frame) - : BWindow(frame, STR_APP_NAME, B_TITLED_WINDOW, 0), - status(false), hits(0), prefWindow(NULL), fLogFile(NULL), fServer(NULL) + : + BWindow(frame, STR_APP_NAME, B_TITLED_WINDOW, 0), + fStatus(false), + fHits(0), + fPrefWindow(NULL), + fLogFile(NULL), + fServer(NULL) { //preferences init - web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY); - index_file_name.SetTo("index.html"); - dir_list_flag = false; + fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY); + fIndexFileName.SetTo("index.html"); + fDirListFlag = false; - log_console_flag = true; - log_file_flag = false; - log_path.SetTo(""); + fLogConsoleFlag = true; + fLogFileFlag = false; + fLogPath.SetTo(""); - max_connections = (int16)32; + fMaxConnections = (int16)32; - is_zoomed = true; - last_width = 318.0f; - last_height = 320.0f; - this->frame = frame; - setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f); + fIsZoomed = true; + fLastWidth = 318.0f; + fLastHeight = 320.0f; + this->fFrame = frame; + fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f); // PoorMan Window SetSizeLimits(318, 1600, 53, 1200); // limit the size of the size of the window - //SetZoomLimits(1024, 768); - - //frame.Set(30.0f, 30.0f, 355.0f, 185.0f); - frame.OffsetTo(B_ORIGIN); - frame = Bounds(); - frame.top += 19.0; - - mainView = new PoorManView(frame, STR_APP_NAME); - mainView->SetViewColor(216,216,216,255); - - mainView->SetFont(be_bold_font); - mainView->SetFontSize(12); - AddChild(mainView); - - // BBox tests - BRect br; - br = mainView->Bounds(); - br.top = 1.0; - - BBox * bb = new BBox(br, "Background", B_FOLLOW_ALL_SIDES, - B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE); - bb->SetHighColor(WHITE); - bb->SetLowColor(GRAY); - bb->SetBorder(B_PLAIN_BORDER); - mainView->AddChild(bb); + SetLayout(new BGroupLayout(B_VERTICAL)); // ----------------------------------------------------------------- // Three Labels // Status String - BRect statusRect; - statusRect = Bounds(); - statusRect.left += 5; - statusRect.top += 3; - statusRect.bottom = statusRect.top + 15; - statusRect.right = statusRect.left + 100; // make the width wide enough for the string to display - - statusView = new BStringView(statusRect, "Status View", - B_TRANSLATE("Status: Stopped")); - bb->AddChild(statusView); + fStatusView = new BStringView("Status View", B_TRANSLATE("Status: Stopped")); // Directory String - BRect dirRect; - dirRect = Bounds(); - dirRect.top = statusRect.bottom - 1; - dirRect.bottom = dirRect.top + 15; - dirRect.left = statusRect.left; - dirRect.right -= 5; - - dirView = new BStringView(dirRect, "Dir View", - B_TRANSLATE("Directory: (none)"), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); - bb->AddChild(dirView); + fDirView = new BStringView("Dir View", B_TRANSLATE("Directory: (none)")); // Hits String - BRect hitsRect; - hitsRect = bb->Bounds(); - hitsRect.InsetBy(5.0f, 5.0f); - hitsRect.top = statusRect.top; - hitsRect.bottom = statusRect.bottom; - hitsRect.left = statusRect.right + 20; - - hitsView = new BStringView(hitsRect, "Hit View", B_TRANSLATE("Hits: 0"), - B_FOLLOW_RIGHT | B_FOLLOW_TOP); - hitsView->SetAlignment(B_ALIGN_RIGHT); - bb->AddChild(hitsView); + fHitsView = new BStringView("Hit View", B_TRANSLATE("Hits: 0")); // ----------------------------------------------------------------- // Logging View - - // logRect - BRect logRect = bb->Bounds();//(5.0, 36.0, 306.0, 131.0); - logRect.InsetBy(5, 5); - logRect.top = 36.0f; - logRect.right -= B_V_SCROLL_BAR_WIDTH; - - // textRect - BRect textRect; //(1.0, 1.0, 175.0, 75.0); - textRect = logRect; - textRect.top = 0.0; - textRect.left = 2.0; - textRect.right = logRect.right - logRect.left - 2.0; - textRect.bottom = logRect.bottom - logRect.top; - fLogViewFont = new BFont(be_plain_font); - fLogViewFont->SetSize(11.0); + fLoggingView = new BTextView(STR_TXT_VIEW, B_WILL_DRAW ); - loggingView = new BTextView(logRect, STR_TXT_VIEW, textRect, - fLogViewFont, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW ); - - loggingView->MakeEditable(false); // user cannot change the text - loggingView->MakeSelectable(true); - loggingView->SetViewColor(WHITE); - loggingView->SetStylable(true); + fLoggingView->MakeEditable(false); // user cannot change the text + fLoggingView->MakeSelectable(true); + fLoggingView->SetViewColor(WHITE); + fLoggingView->SetStylable(true); // create the scroll view - scrollView = new BScrollView("Scroll View", loggingView, B_FOLLOW_ALL_SIDES, - B_WILL_DRAW | B_FRAME_EVENTS, + fScrollView = new BScrollView("Scroll View", fLoggingView, + B_WILL_DRAW | B_FRAME_EVENTS | B_FOLLOW_ALL_SIDES, // Make sure articles on border do not occur when resizing false, true); - bb->AddChild(scrollView); - loggingView->MakeFocus(true); + fLoggingView->MakeFocus(true); // ----------------------------------------------------------------- // menu bar - BRect menuRect; - menuRect = Bounds(); - menuRect.bottom = 18.0f; - - FileMenuBar = new BMenuBar(menuRect, "File Menu Bar"); + fFileMenuBar = new BMenuBar("File Menu Bar"); // menus - FileMenu = BuildFileMenu(); - if (FileMenu) - FileMenuBar->AddItem(FileMenu); + fFileMenu = BuildFileMenu(); + if (fFileMenu) + fFileMenuBar->AddItem(fFileMenu); - EditMenu = BuildEditMenu(); - if (EditMenu) - FileMenuBar->AddItem(EditMenu); + fEditMenu = BuildEditMenu(); + if (fEditMenu) + fFileMenuBar->AddItem(fEditMenu); - ControlsMenu = BuildControlsMenu(); - if (ControlsMenu) - FileMenuBar->AddItem(ControlsMenu); + fControlsMenu = BuildControlsMenu(); + if (fControlsMenu) + fFileMenuBar->AddItem(fControlsMenu); // File Panels BWindow* change_title; - BMessenger messenger(this); - saveConsoleFilePanel = new BFilePanel( - B_SAVE_PANEL, - &messenger, - NULL, - B_FILE_NODE, - false, + fSaveConsoleFilePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), + NULL, B_FILE_NODE, false, new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE)); - - change_title = saveConsoleFilePanel->Window(); + change_title = fSaveConsoleFilePanel->Window(); change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE); - saveConsoleSelectionFilePanel = new BFilePanel( - B_SAVE_PANEL, - &messenger, - NULL, - B_FILE_NODE, - false, + fSaveConsoleSelectionFilePanel = new BFilePanel(B_SAVE_PANEL, + new BMessenger(this), NULL, B_FILE_NODE, false, new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION)); - - change_title = saveConsoleSelectionFilePanel->Window(); + change_title = fSaveConsoleSelectionFilePanel->Window(); change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE_SELECTION); - - AddChild(FileMenuBar); + AddChild(BGroupLayoutBuilder(B_VERTICAL) + .Add(fFileMenuBar) + .Add(BGroupLayoutBuilder(B_VERTICAL, 5) + .Add(BGroupLayoutBuilder(B_HORIZONTAL) + .Add(fStatusView) + .AddGlue() + .Add(fHitsView)) + .Add(BGroupLayoutBuilder(B_HORIZONTAL) + .Add(fDirView) + .AddGlue()) + .Add(fScrollView) + .SetInsets(10, 10, 10, 10))); pthread_rwlock_init(&fLogFileLock, NULL); } @@ -227,7 +157,6 @@ PoorManWindow::PoorManWindow(BRect frame) PoorManWindow::~PoorManWindow() { delete fServer; - delete fLogViewFont; delete fLogFile; pthread_rwlock_destroy(&fLogFileLock); } @@ -237,129 +166,127 @@ void PoorManWindow::MessageReceived(BMessage* message) { switch (message->what) { - case MSG_MENU_FILE_SAVE_AS: - saveConsoleFilePanel->Show(); - break; - case MSG_FILE_PANEL_SAVE_CONSOLE: - printf("FilePanel: Save console\n"); - SaveConsole(message, false); - break; - case MSG_MENU_FILE_SAVE_SELECTION: - saveConsoleSelectionFilePanel->Show(); - break; - case MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION: - printf("FilePanel: Save console selection\n"); - SaveConsole(message, true); - break; - case MSG_FILE_PANEL_SELECT_WEB_DIR: - prefWindow->MessageReceived(message); - break; - case MSG_MENU_EDIT_PREF: - prefWindow = new PoorManPreferencesWindow( - setwindow_frame, - STR_WIN_NAME_PREF); - prefWindow->Show(); - break; - case MSG_MENU_CTRL_RUN: - if (status) - StopServer(); - else - StartServer(); - break; - case MSG_MENU_CTRL_CLEAR_HIT: - SetHits(0); - //UpdateHitsLabel(); - break; - case MSG_MENU_CTRL_CLEAR_CONSOLE: - loggingView->SelectAll(); - loggingView->Delete(); - break; - case MSG_MENU_CTRL_CLEAR_LOG: - FILE * f; - f = fopen(log_path.String(), "w"); - fclose(f); - break; - case MSG_LOG: { - if (!log_console_flag && !log_file_flag) + case MSG_MENU_FILE_SAVE_AS: + fSaveConsoleFilePanel->Show(); break; + case MSG_FILE_PANEL_SAVE_CONSOLE: + printf("FilePanel: Save console\n"); + SaveConsole(message, false); + break; + case MSG_MENU_FILE_SAVE_SELECTION: + fSaveConsoleSelectionFilePanel->Show(); + break; + case MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION: + printf("FilePanel: Save console selection\n"); + SaveConsole(message, true); + break; + case MSG_FILE_PANEL_SELECT_WEB_DIR: + fPrefWindow->MessageReceived(message); + break; + case MSG_MENU_EDIT_PREF: + fPrefWindow = new PoorManPreferencesWindow(fSetwindowFrame, + STR_WIN_NAME_PREF); + fPrefWindow->Show(); + break; + case MSG_MENU_CTRL_RUN: + if (fStatus) + StopServer(); + else + StartServer(); + break; + case MSG_MENU_CTRL_CLEAR_HIT: + SetHits(0); + //UpdateHitsLabel(); + break; + case MSG_MENU_CTRL_CLEAR_CONSOLE: + fLoggingView->SelectAll(); + fLoggingView->Delete(); + break; + case MSG_MENU_CTRL_CLEAR_LOG: + FILE* f; + f = fopen(fLogPath.String(), "w"); + fclose(f); + break; + case MSG_LOG: { + if (!fLogConsoleFlag && !fLogFileFlag) + break; - time_t time; - in_addr_t address; - rgb_color color; - const void* pointer; - ssize_t size; - const char* msg; - BString line; + time_t time; + in_addr_t address; + rgb_color color; + const void* pointer; + ssize_t size; + const char* msg; + BString line; - if (message->FindString("cstring", &msg) != B_OK) - break; - if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK) - time = -1; - else - time = *static_cast(pointer); + if (message->FindString("cstring", &msg) != B_OK) + break; + if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK) + time = -1; + else + time = *static_cast(pointer); - if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK) - address = INADDR_NONE; - else - address = *static_cast(pointer); + if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK) + address = INADDR_NONE; + else + address = *static_cast(pointer); - if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK) - color = BLACK; - else - color = *static_cast(pointer); + if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK) + color = BLACK; + else + color = *static_cast(pointer); - if (time != -1) { - BString timeString; - if (BLocale::Default()->FormatDateTime(&timeString, time, - DATE_FORMAT, TIME_FORMAT) == B_OK) { - line << '[' << timeString << "]: "; - } - } - - if (address != INADDR_NONE) { - char addr[INET_ADDRSTRLEN]; - struct in_addr sin_addr; - sin_addr.s_addr = address; - if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL) { - addr[strlen(addr)] = '\0'; - line << '(' << addr << ") "; - } - } - - line << msg; - - text_run run; - text_run_array runs; - - run.offset = 0; - run.font = *fLogViewFont; - run.color = color; - - runs.count = 1; - runs.runs[0] = run; - - if (Lock()) { - if (log_console_flag) { - loggingView->Insert(loggingView->TextLength(), - line.String(), line.Length(), &runs); - loggingView->ScrollToOffset(loggingView->TextLength()); - } - - if (log_file_flag) { - if (pthread_rwlock_rdlock(&fLogFileLock) == 0) { - fLogFile->Write(line.String(), line.Length()); - pthread_rwlock_unlock(&fLogFileLock); + if (time != -1) { + BString timeString; + if (BLocale::Default()->FormatDateTime(&timeString, time, + DATE_FORMAT, TIME_FORMAT) == B_OK) { + line << '[' << timeString << "]: "; } } - - Unlock(); - } - break; - } - default: - BWindow::MessageReceived(message); - break; + if (address != INADDR_NONE) { + char addr[INET_ADDRSTRLEN]; + struct in_addr sin_addr; + sin_addr.s_addr = address; + if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL) { + addr[strlen(addr)] = '\0'; + line << '(' << addr << ") "; + } + } + + line << msg; + + text_run run; + text_run_array runs; + + run.offset = 0; + run.color = color; + + runs.count = 1; + runs.runs[0] = run; + + if (Lock()) { + if (fLogConsoleFlag) { + fLoggingView->Insert(fLoggingView->TextLength(), + line.String(), line.Length(), &runs); + fLoggingView->ScrollToOffset(fLoggingView->TextLength()); + } + + if (fLogFileFlag) { + if (pthread_rwlock_rdlock(&fLogFileLock) == 0) { + fLogFile->Write(line.String(), line.Length()); + pthread_rwlock_unlock(&fLogFileLock); + } + } + + Unlock(); + } + + break; + } + default: + BWindow::MessageReceived(message); + break; } } @@ -367,17 +294,17 @@ PoorManWindow::MessageReceived(BMessage* message) void PoorManWindow::FrameMoved(BPoint origin) { - frame.left = origin.x; - frame.top = origin.y; + fFrame.left = origin.x; + fFrame.top = origin.y; } void PoorManWindow::FrameResized(float width, float height) { - if (is_zoomed) { - last_width = width; - last_height = height; + if (fIsZoomed) { + fLastWidth = width; + fLastHeight = height; } } @@ -385,7 +312,7 @@ PoorManWindow::FrameResized(float width, float height) bool PoorManWindow::QuitRequested() { - if (status) { + if (fStatus) { time_t now = time(NULL); BString timeString; BLocale::Default()->FormatDateTime(&timeString, now, @@ -395,21 +322,21 @@ PoorManWindow::QuitRequested() line << "[" << timeString << "]: " << B_TRANSLATE("Shutting down.") << "\n"; - if (log_console_flag) { - loggingView->Insert(loggingView->TextLength(), - line, line.Length()); - loggingView->ScrollToOffset(loggingView->TextLength()); + if (fLogConsoleFlag) { + fLoggingView->Insert(fLoggingView->TextLength(), + line, line.Length()); + fLoggingView->ScrollToOffset(fLoggingView->TextLength()); } - if (log_file_flag) { + if (fLogFileFlag) { if (pthread_rwlock_rdlock(&fLogFileLock) == 0) { - fLogFile->Write(line, line.Length()); - pthread_rwlock_unlock(&fLogFileLock); + fLogFile->Write(line, line.Length()); + pthread_rwlock_unlock(&fLogFileLock); } } fServer->Stop(); - status = false; + fStatus = false; UpdateStatusLabelAndMenuItem(); } @@ -422,14 +349,14 @@ PoorManWindow::QuitRequested() void PoorManWindow::Zoom(BPoint origin, float width, float height) { - if (is_zoomed) { + if (fIsZoomed) { // Change to the Minimal size - is_zoomed = false; + fIsZoomed = false; ResizeTo(318, 53); } else { // Change to the Zoomed size - is_zoomed = true; - ResizeTo(last_width, last_height); + fIsZoomed = true; + ResizeTo(fLastWidth, fLastHeight); } } @@ -437,7 +364,7 @@ PoorManWindow::Zoom(BPoint origin, float width, float height) void PoorManWindow::SetHits(uint32 num) { - hits = num; + fHits = num; UpdateHitsLabel(); } @@ -445,10 +372,10 @@ PoorManWindow::SetHits(uint32 num) // Private: Methods ------------------------------------------ -BMenu * +BMenu* PoorManWindow::BuildFileMenu() const { - BMenu * ptrFileMenu = new BMenu(STR_MNU_FILE); + BMenu* ptrFileMenu = new BMenu(STR_MNU_FILE); ptrFileMenu->AddItem(new BMenuItem(STR_MNU_FILE_SAVE_AS, new BMessage(MSG_MENU_FILE_SAVE_AS), CMD_FILE_SAVE_AS)); @@ -465,28 +392,28 @@ PoorManWindow::BuildFileMenu() const } -BMenu * +BMenu* PoorManWindow::BuildEditMenu() const { - BMenu * ptrEditMenu = new BMenu(STR_MNU_EDIT); + BMenu* ptrEditMenu = new BMenu(STR_MNU_EDIT); - BMenuItem * CopyMenuItem = new BMenuItem(STR_MNU_EDIT_COPY, + BMenuItem* CopyMenuItem = new BMenuItem(STR_MNU_EDIT_COPY, new BMessage(B_COPY), CMD_EDIT_COPY); ptrEditMenu->AddItem(CopyMenuItem); - CopyMenuItem->SetTarget(loggingView, NULL); + CopyMenuItem->SetTarget(fLoggingView, NULL); ptrEditMenu->AddSeparatorItem(); - BMenuItem * SelectAllMenuItem = new BMenuItem(STR_MNU_EDIT_SELECT_ALL, + BMenuItem* SelectAllMenuItem = new BMenuItem(STR_MNU_EDIT_SELECT_ALL, new BMessage(B_SELECT_ALL), CMD_EDIT_SELECT_ALL); ptrEditMenu->AddItem(SelectAllMenuItem); - SelectAllMenuItem->SetTarget(loggingView, NULL); + SelectAllMenuItem->SetTarget(fLoggingView, NULL); ptrEditMenu->AddSeparatorItem(); - BMenuItem * PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF, + BMenuItem* PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF, new BMessage(MSG_MENU_EDIT_PREF)); ptrEditMenu->AddItem(PrefMenuItem); @@ -494,27 +421,27 @@ PoorManWindow::BuildEditMenu() const } -BMenu * +BMenu* PoorManWindow::BuildControlsMenu() const { - BMenu * ptrControlMenu = new BMenu(STR_MNU_CTRL); + BMenu* ptrControlMenu = new BMenu(STR_MNU_CTRL); - BMenuItem * RunServerMenuItem = new BMenuItem(STR_MNU_CTRL_RUN_SERVER, + BMenuItem* RunServerMenuItem = new BMenuItem(STR_MNU_CTRL_RUN_SERVER, new BMessage(MSG_MENU_CTRL_RUN)); RunServerMenuItem->SetMarked(false); ptrControlMenu->AddItem(RunServerMenuItem); - BMenuItem * ClearHitCounterMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_HIT_COUNTER, + BMenuItem* ClearHitCounterMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_HIT_COUNTER, new BMessage(MSG_MENU_CTRL_CLEAR_HIT)); ptrControlMenu->AddItem(ClearHitCounterMenuItem); ptrControlMenu->AddSeparatorItem(); - BMenuItem * ClearConsoleLogMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_CONSOLE, + BMenuItem* ClearConsoleLogMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_CONSOLE, new BMessage(MSG_MENU_CTRL_CLEAR_CONSOLE)); ptrControlMenu->AddItem(ClearConsoleLogMenuItem); - BMenuItem * ClearLogFileMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_LOG_FILE, + BMenuItem* ClearLogFileMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_LOG_FILE, new BMessage(MSG_MENU_CTRL_CLEAR_LOG)); ptrControlMenu->AddItem(ClearLogFileMenuItem); @@ -523,13 +450,13 @@ PoorManWindow::BuildControlsMenu() const void -PoorManWindow::SetDirLabel(const char * name) +PoorManWindow::SetDirLabel(const char* name) { BString dirPath(B_TRANSLATE("Directory: ")); dirPath.Append(name); if (Lock()) { - dirView->SetText(dirPath.String()); + fDirView->SetText(dirPath.String()); Unlock(); } } @@ -539,11 +466,11 @@ void PoorManWindow::UpdateStatusLabelAndMenuItem() { if (Lock()) { - if (status) - statusView->SetText(B_TRANSLATE("Status: Running")); + if (fStatus) + fStatusView->SetText(B_TRANSLATE("Status: Running")); else - statusView->SetText(B_TRANSLATE("Status: Stopped")); - ControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(status); + fStatusView->SetText(B_TRANSLATE("Status: Stopped")); + fControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(fStatus); Unlock(); } } @@ -553,8 +480,8 @@ void PoorManWindow::UpdateHitsLabel() { if (Lock()) { - sprintf(hitsLabel, B_TRANSLATE("Hits: %lu"), GetHits()); - hitsView->SetText(hitsLabel); + sprintf(fHitsLabel, B_TRANSLATE("Hits: %lu"), GetHits()); + fHitsView->SetText(fHitsLabel); Unlock(); } @@ -562,22 +489,25 @@ PoorManWindow::UpdateHitsLabel() status_t -PoorManWindow::SaveConsole(BMessage * message, bool selection) +PoorManWindow::SaveConsole(BMessage* message, bool selection) { entry_ref ref; - const char * name; + const char* name; BPath path; BEntry entry; status_t err = B_OK; - FILE *f; + FILE* f; - if ((err = message->FindRef("directory", &ref)) != B_OK) + err = message->FindRef("directory", &ref); + if (err != B_OK) return err; - if ((err = message->FindString("name", &name)) != B_OK) + err = message->FindString("name", &name); + if (err != B_OK) return err; - if ((err = entry.SetTo(&ref)) != B_OK) + err = entry.SetTo(&ref); + if (err != B_OK) return err; entry.GetPath(&path); @@ -588,20 +518,21 @@ PoorManWindow::SaveConsole(BMessage * message, bool selection) if (!selection) { // write the data to the file - err = fwrite(loggingView->Text(), 1, loggingView->TextLength(), f); + err = fwrite(fLoggingView->Text(), 1, fLoggingView->TextLength(), f); } else { // find the selected text and write it to a file int32 start = 0, end = 0; - loggingView->GetSelection(&start, &end); + fLoggingView->GetSelection(&start, &end); BString buffer; char * buffData = buffer.LockBuffer(end - start + 1); // copy the selected text from the TextView to the buffer - loggingView->GetText(start, end - start, buffData); + fLoggingView->GetText(start, end - start, buffData); buffer.UnlockBuffer(end - start + 1); err = fwrite(buffer.String(), 1, end - start + 1, f); } + fclose(f); return err; @@ -627,10 +558,10 @@ PoorManWindow::DefaultSettings() break; case 1: - prefWindow = new PoorManPreferencesWindow( - setwindow_frame, + fPrefWindow = new PoorManPreferencesWindow( + fSetwindowFrame, STR_WIN_NAME_PREF); - prefWindow->ShowWebDirFilePanel(); + fPrefWindow->ShowWebDirFilePanel(); break; case 2: @@ -674,49 +605,49 @@ PoorManWindow::ReadSettings() return B_ERROR; //site tab - if (m.FindString("web_directory", &web_directory) != B_OK) - web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY); - if (m.FindString("index_file_name", &index_file_name) != B_OK) - index_file_name.SetTo("index.html"); - if (m.FindBool("dir_list_flag", &dir_list_flag) != B_OK) - dir_list_flag = false; + if (m.FindString("fWebDirectory", &fWebDirectory) != B_OK) + fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY); + if (m.FindString("fIndexFileName", &fIndexFileName) != B_OK) + fIndexFileName.SetTo("index.html"); + if (m.FindBool("fDirListFlag", &fDirListFlag) != B_OK) + fDirListFlag = false; //logging tab - if (m.FindBool("log_console_flag", &log_console_flag) != B_OK) - log_console_flag = true; - if (m.FindBool("log_file_flag", &log_file_flag) != B_OK) - log_file_flag = false; - if (m.FindString("log_path", &log_path) != B_OK) - log_path.SetTo(""); + if (m.FindBool("fLogConsoleFlag", &fLogConsoleFlag) != B_OK) + fLogConsoleFlag = true; + if (m.FindBool("fLogFileFlag", &fLogFileFlag) != B_OK) + fLogFileFlag = false; + if (m.FindString("fLogPath", &fLogPath) != B_OK) + fLogPath.SetTo(""); //advance tab - if (m.FindInt16("max_connections", &max_connections) != B_OK) - max_connections = (int16)32; + if (m.FindInt16("fMaxConnections", &fMaxConnections) != B_OK) + fMaxConnections = (int16)32; //windows' position and size - if (m.FindRect("frame", &frame) != B_OK) - frame.Set(82.0f, 30.0f, 400.0f, 350.0f); - if (m.FindRect("setwindow_frame", &setwindow_frame) != B_OK) - setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f); - if (m.FindBool("is_zoomed", &is_zoomed) != B_OK) - is_zoomed = true; - if (m.FindFloat("last_width", &last_width) != B_OK) - last_width = 318.0f; - if (m.FindFloat("last_height", &last_height) != B_OK) - last_height = 320.0f; + if (m.FindRect("frame", &fFrame) != B_OK) + fFrame.Set(82.0f, 30.0f, 400.0f, 350.0f); + if (m.FindRect("fSetwindowFrame", &fSetwindowFrame) != B_OK) + fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f); + if (m.FindBool("fIsZoomed", &fIsZoomed) != B_OK) + fIsZoomed = true; + if (m.FindFloat("fLastWidth", &fLastWidth) != B_OK) + fLastWidth = 318.0f; + if (m.FindFloat("fLastHeight", &fLastHeight) != B_OK) + fLastHeight = 320.0f; - is_zoomed?ResizeTo(last_width, last_height):ResizeTo(318, 53); - MoveTo(frame.left, frame.top); + fIsZoomed?ResizeTo(fLastWidth, fLastHeight):ResizeTo(318, 53); + MoveTo(fFrame.left, fFrame.top); - fLogFile = new BFile(log_path.String(), B_CREATE_FILE | B_WRITE_ONLY + fLogFile = new BFile(fLogPath.String(), B_CREATE_FILE | B_WRITE_ONLY | B_OPEN_AT_END); if (fLogFile->InitCheck() != B_OK) { - log_file_flag = false; + fLogFileFlag = false; //log it to console, "log to file unavailable." return B_OK; } - SetDirLabel(web_directory.String()); + SetDirLabel(fWebDirectory.String()); return B_OK; } @@ -730,24 +661,24 @@ PoorManWindow::SaveSettings() BMessage m(MSG_PREF_FILE); //site tab - m.AddString("web_directory", web_directory); - m.AddString("index_file_name", index_file_name); - m.AddBool("dir_list_flag", dir_list_flag); + m.AddString("fWebDirectory", fWebDirectory); + m.AddString("fIndexFileName", fIndexFileName); + m.AddBool("fDirListFlag", fDirListFlag); //logging tab - m.AddBool("log_console_flag", log_console_flag); - m.AddBool("log_file_flag", log_file_flag); - m.AddString("log_path", log_path); + m.AddBool("fLogConsoleFlag", fLogConsoleFlag); + m.AddBool("fLogFileFlag", fLogFileFlag); + m.AddString("fLogPath", fLogPath); //advance tab - m.AddInt16("max_connections", max_connections); + m.AddInt16("fMaxConnections", fMaxConnections); //windows' position and size - m.AddRect("frame", frame); - m.AddRect("setwindow_frame", setwindow_frame); - m.AddBool("is_zoomed", is_zoomed); - m.AddFloat("last_width", last_width); - m.AddFloat("last_height", last_height); + m.AddRect("frame", fFrame); + m.AddRect("fSetwindowFrame", fSetwindowFrame); + m.AddBool("fIsZoomed", fIsZoomed); + m.AddFloat("fLastWidth", fLastWidth); + m.AddFloat("fLastHeight", fLastHeight); if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK) return B_ERROR; @@ -768,18 +699,15 @@ status_t PoorManWindow::StartServer() { if (fServer == NULL) - fServer = new PoorManServer( - web_directory.String(), - max_connections, - dir_list_flag, - index_file_name.String()); + fServer = new PoorManServer(fWebDirectory.String(), fMaxConnections, + fDirListFlag, fIndexFileName.String()); poorman_log(B_TRANSLATE("Starting up... ")); if (fServer->Run() != B_OK) { return B_ERROR; } - status = true; + fStatus = true; UpdateStatusLabelAndMenuItem(); poorman_log(B_TRANSLATE("done.\n"), false, INADDR_NONE, GREEN); @@ -795,7 +723,7 @@ PoorManWindow::StopServer() poorman_log(B_TRANSLATE("Shutting down.\n")); fServer->Stop(); - status = false; + fStatus = false; UpdateStatusLabelAndMenuItem(); return B_OK; } @@ -804,7 +732,7 @@ PoorManWindow::StopServer() void PoorManWindow::SetLogPath(const char* str) { - if (!strcmp(log_path, str)) + if (!strcmp(fLogPath, str)) return; BFile* temp = new BFile(str, B_CREATE_FILE | B_WRITE_ONLY | B_OPEN_AT_END); @@ -823,5 +751,5 @@ PoorManWindow::SetLogPath(const char* str) return; } - log_path.SetTo(str); + fLogPath.SetTo(str); } diff --git a/src/apps/poorman/PoorManWindow.h b/src/apps/poorman/PoorManWindow.h index bdbca27bcf..a2ddc516ea 100644 --- a/src/apps/poorman/PoorManWindow.h +++ b/src/apps/poorman/PoorManWindow.h @@ -33,125 +33,132 @@ class PoorManServer; class PoorManWindow: public BWindow { public: - PoorManWindow(BRect frame); -virtual ~PoorManWindow(); -virtual void MessageReceived(BMessage * message); + PoorManWindow(BRect frame); + virtual ~PoorManWindow(); + virtual void MessageReceived(BMessage* message); -virtual void FrameMoved(BPoint origin); -virtual void FrameResized(float width, float height); -virtual bool QuitRequested(); -virtual void Zoom(BPoint origin, float width, float height); + virtual void FrameMoved(BPoint origin); + virtual void FrameResized(float width, float height); + virtual bool QuitRequested(); + virtual void Zoom(BPoint origin, float width, float height); // ------------------------------------------- // Public PoorMan Window Methods - void SetDirLabel(const char * name); - void SetHits(uint32 num); - uint32 GetHits() { return hits; } - status_t SaveConsole(BMessage * message, bool); + void SetDirLabel(const char* name); + void SetHits(uint32 num); + uint32 GetHits() { return fHits; } + status_t SaveConsole(BMessage* message, bool); - status_t SaveSettings(); - status_t ReadSettings(); - void DefaultSettings(); + status_t SaveSettings(); + status_t ReadSettings(); + void DefaultSettings(); - status_t StartServer(); - status_t StopServer(); + status_t StartServer(); + status_t StopServer(); - PoorManServer* GetServer()const{return fServer;} + PoorManServer* GetServer() const { return fServer;} // ------------------------------------------- // Preferences and Settings // Site Tab - bool DirListFlag() { return dir_list_flag; } - void SetDirListFlag(bool flag) { dir_list_flag = flag; } - const char * IndexFileName() { return index_file_name.String(); } - void SetIndexFileName(const char * str) { index_file_name.SetTo(str); } - const char * WebDir() { return web_directory.String(); } - void SetWebDir(const char * str) { web_directory.SetTo(str); } + bool DirListFlag() + { return fDirListFlag; } + void SetDirListFlag(bool flag) + { fDirListFlag = flag; } + const char* IndexFileName() + { return fIndexFileName.String(); } + void SetIndexFileName(const char* str) + { fIndexFileName.SetTo(str); } + const char* WebDir() + { return fWebDirectory.String(); } + void SetWebDir(const char* str) + { fWebDirectory.SetTo(str); } // Logging Tab - bool LogConsoleFlag() { return log_console_flag; } - void SetLogConsoleFlag(bool flag) { log_console_flag = flag; } - bool LogFileFlag() { return log_file_flag; } - void SetLogFileFlag(bool flag) { log_file_flag = flag; } - const char * LogPath() { return log_path.String(); } - void SetLogPath(const char * str); + bool LogConsoleFlag() + { return fLogConsoleFlag; } + void SetLogConsoleFlag(bool flag) + { fLogConsoleFlag = flag; } + bool LogFileFlag() + { return fLogFileFlag; } + void SetLogFileFlag(bool flag) + { fLogFileFlag = flag; } + const char* LogPath() + { return fLogPath.String(); } + void SetLogPath(const char* str); // Advanced Tab - int16 MaxConnections() { return max_connections; } - void SetMaxConnections(int16 num) { max_connections = num; } - + int16 MaxConnections() + { return fMaxConnections; } + void SetMaxConnections(int16 num) + { fMaxConnections = num; } private: // ------------------------------------------- // PoorMan Window Methods - void UpdateStatusLabelAndMenuItem(); - void UpdateHitsLabel(); + void UpdateStatusLabelAndMenuItem(); + void UpdateHitsLabel(); private: - // ------------------------------------------- - // PoorMan Window - PoorManView * mainView; - // ------------------------------------------- // Build Menu Methods - BMenu * BuildFileMenu() const; - BMenu * BuildEditMenu() const; - BMenu * BuildControlsMenu() const; + BMenu* BuildFileMenu() const; + BMenu* BuildEditMenu() const; + BMenu* BuildControlsMenu() const; // -------------------------------------------- // MenuBar & Menu items - BMenuBar * FileMenuBar; - BMenu * FileMenu; - BMenu * EditMenu; - BMenu * ControlsMenu; + BMenuBar* fFileMenuBar; + BMenu* fFileMenu; + BMenu* fEditMenu; + BMenu* fControlsMenu; // -------------------------------------------- // Status, Hits, Directory - BStringView * statusView; - BStringView * hitsView; - BStringView * dirView; + BStringView* fStatusView; + BStringView* fHitsView; + BStringView* fDirView; - bool status; - uint32 hits; - char hitsLabel[25]; + bool fStatus; + uint32 fHits; + char fHitsLabel[25]; // -------------------------------------------- // Logging View - BScrollView * scrollView; - BTextView * loggingView; + BScrollView* fScrollView; + BTextView* fLoggingView; // use asctime() for format of [Date/Time]: // ------------------------------------------- // PoorMan Preference Window - PoorManPreferencesWindow * prefWindow; + PoorManPreferencesWindow * fPrefWindow; // site tab - BString web_directory; - BString index_file_name; - bool dir_list_flag; + BString fWebDirectory; + BString fIndexFileName; + bool fDirListFlag; // logging tab - bool log_console_flag; - bool log_file_flag; - BString log_path; + bool fLogConsoleFlag; + bool fLogFileFlag; + BString fLogPath; // advanced tab - int16 max_connections; + int16 fMaxConnections; - bool is_zoomed; - float last_width; - float last_height; - BRect frame; - BRect setwindow_frame; + bool fIsZoomed; + float fLastWidth; + float fLastHeight; + BRect fFrame; + BRect fSetwindowFrame; // File Panels - BFilePanel * saveConsoleFilePanel; - BFilePanel * saveConsoleSelectionFilePanel; + BFilePanel* fSaveConsoleFilePanel; + BFilePanel* fSaveConsoleSelectionFilePanel; - BFile* fLogFile; - BFont* fLogViewFont; + BFile* fLogFile; - PoorManServer* fServer; + PoorManServer* fServer; - pthread_rwlock_t fLogFileLock; + pthread_rwlock_t fLogFileLock; }; #endif diff --git a/src/apps/poorman/StatusSlider.cpp b/src/apps/poorman/StatusSlider.cpp index deaa1b03a1..694cda00c3 100644 --- a/src/apps/poorman/StatusSlider.cpp +++ b/src/apps/poorman/StatusSlider.cpp @@ -11,31 +11,19 @@ #include -StatusSlider::StatusSlider (BRect frame, - const char *name, - const char *label, - char *statusPrefix, - BMessage *message, - int32 minValue, - int32 maxValue) - - : BSlider(frame, - name, - label, - message, - minValue, - maxValue - ), - StatusPrefix(statusPrefix) +StatusSlider::StatusSlider(const char* name, const char* label, + char* statusPrefix, BMessage* message, int32 minValue, int32 maxValue) + : + BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL), + fStatusPrefix(statusPrefix) { - temp = str; + fTemp = fStr; } const char* StatusSlider::UpdateText() const { - - sprintf(temp, "%ld %s", Value(), StatusPrefix); - - return temp; + sprintf(fTemp, "%ld %s", Value(), fStatusPrefix); + + return fTemp; } diff --git a/src/apps/poorman/StatusSlider.h b/src/apps/poorman/StatusSlider.h index b9003d7ccc..e7d0d27082 100644 --- a/src/apps/poorman/StatusSlider.h +++ b/src/apps/poorman/StatusSlider.h @@ -13,21 +13,21 @@ #include -class StatusSlider: public BSlider -{ +class StatusSlider: public BSlider { public: - StatusSlider(BRect frame, - const char *name, - const char *label, - char *statusPrefix, - BMessage *message, - int32 minValue, - int32 maxValue); -virtual const char* UpdateText() const; + StatusSlider(const char* name, + const char* label, + char* statusPrefix, + BMessage* message, + int32 minValue, + int32 maxValue); + + virtual const char* UpdateText() const; + private: - char * StatusPrefix; - char * temp; - char str[128]; + char* fStatusPrefix; + char* fTemp; + char fStr[128]; }; #endif From c5a09a88e954244862a0573146dd2bfeb9137ab8 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 14 Jul 2012 12:29:20 +1200 Subject: [PATCH 19/46] In PoorMan: use templatized layout builders. Also clean up layout a bit. --- src/apps/poorman/PoorManAdvancedView.cpp | 22 +++++---- src/apps/poorman/PoorManLoggingView.cpp | 46 ++++++++++--------- src/apps/poorman/PoorManPreferencesWindow.cpp | 15 +++--- src/apps/poorman/PoorManSiteView.cpp | 46 +++++++++++-------- src/apps/poorman/PoorManWindow.cpp | 23 +++++----- 5 files changed, 82 insertions(+), 70 deletions(-) diff --git a/src/apps/poorman/PoorManAdvancedView.cpp b/src/apps/poorman/PoorManAdvancedView.cpp index e817428698..260da72b9c 100644 --- a/src/apps/poorman/PoorManAdvancedView.cpp +++ b/src/apps/poorman/PoorManAdvancedView.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include "constants.h" @@ -27,8 +27,6 @@ PoorManAdvancedView::PoorManAdvancedView(const char* name) PoorManWindow* win; win = ((PoorManApplication*)be_app)->GetPoorManWindow(); - SetLayout(new BGroupLayout(B_VERTICAL)); - BBox* connectionOptions = new BBox(B_TRANSLATE("Connections")); connectionOptions->SetLabel(STR_BBX_CONNECTION); @@ -40,14 +38,18 @@ PoorManAdvancedView::PoorManAdvancedView(const char* name) fMaxConnections->SetLimitLabels("1", "200"); SetMaxSimutaneousConnections(win->MaxConnections()); - connectionOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(fMaxConnections) - .SetInsets(5, 5, 5, 5)); - - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(connectionOptions) + + BGroupLayout* connectionOptionsLayout = new BGroupLayout(B_VERTICAL, 0); + connectionOptions->SetLayout(connectionOptionsLayout); + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .AddGroup(connectionOptionsLayout) + .SetInsets(B_USE_ITEM_INSETS) + .AddStrut(B_USE_ITEM_SPACING) + .Add(fMaxConnections) + .End() .AddGlue() - .SetInsets(5, 5, 5, 5)); + .SetInsets(B_USE_ITEM_INSETS); } void diff --git a/src/apps/poorman/PoorManLoggingView.cpp b/src/apps/poorman/PoorManLoggingView.cpp index 2d06194a1c..dacef76463 100644 --- a/src/apps/poorman/PoorManLoggingView.cpp +++ b/src/apps/poorman/PoorManLoggingView.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include "constants.h" @@ -27,8 +27,6 @@ PoorManLoggingView::PoorManLoggingView(const char* name) PoorManWindow* win; win = ((PoorManApplication*)be_app)->GetPoorManWindow(); - SetLayout(new BGroupLayout(B_VERTICAL)); - BBox* consoleLogging = new BBox(B_TRANSLATE("Console Logging")); consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING); @@ -57,24 +55,28 @@ PoorManLoggingView::PoorManLoggingView(const char* name) fCreateLogFile = new BButton(B_TRANSLATE("Create Log File"), STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE)); - consoleLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) - .Add(fLogConsole) - .AddGlue()) - .SetInsets(5, 5, 5, 5)); - - fileLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) - .Add(fLogFile) - .AddGlue()) - .Add(fLogFileName) - .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) - .AddGlue() - .Add(fCreateLogFile)) - .SetInsets(5, 5, 5, 5)); + BGroupLayout* consoleLoggingLayout = new BGroupLayout(B_VERTICAL, 0); + consoleLogging->SetLayout(consoleLoggingLayout); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(consoleLogging) - .Add(fileLogging) - .SetInsets(5, 5, 5, 5)); + BGroupLayout* fileLoggingLayout = new BGroupLayout(B_VERTICAL, + B_USE_SMALL_SPACING); + fileLogging->SetLayout(fileLoggingLayout); + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_ITEM_INSETS) + .AddGroup(consoleLoggingLayout) + .SetInsets(B_USE_ITEM_INSETS) + .AddGroup(B_HORIZONTAL) + .SetInsets(0, B_USE_ITEM_INSETS, 0, 0) + .Add(fLogConsole) + .AddGlue() + .End() + .End() + .AddGroup(fileLoggingLayout) + .SetInsets(B_USE_ITEM_INSETS) + .AddGrid(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) + .SetInsets(0, B_USE_ITEM_INSETS, 0, 0) + .Add(fLogFile, 0, 0) + .AddTextControl(fLogFileName, 0, 1, B_ALIGN_LEFT, 1, 2) + .Add(fCreateLogFile, 2, 2); } diff --git a/src/apps/poorman/PoorManPreferencesWindow.cpp b/src/apps/poorman/PoorManPreferencesWindow.cpp index a09475de91..5535f338b2 100644 --- a/src/apps/poorman/PoorManPreferencesWindow.cpp +++ b/src/apps/poorman/PoorManPreferencesWindow.cpp @@ -9,10 +9,8 @@ #include #include #include -#include -#include +#include #include -#include #include #include "constants.h" @@ -32,8 +30,6 @@ PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name) fWebDirFilePanel(NULL), fLogFilePanel(NULL) { - SetLayout(new BGroupLayout(B_VERTICAL)); - fCancelButton = new BButton("Cancel Button", B_TRANSLATE("Cancel"), new BMessage(MSG_PREF_BTN_CANCEL)); fDoneButton = new BButton("Done Button", B_TRANSLATE("Done"), @@ -80,13 +76,14 @@ PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name) change_title = fLogFilePanel->Window(); change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_WINDOW_INSETS) .Add(fPrefTabView) - .Add(BGroupLayoutBuilder(B_HORIZONTAL) + .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fCancelButton) - .Add(fDoneButton)) - .SetInsets(5, 5, 5, 5)); + .Add(fDoneButton); } diff --git a/src/apps/poorman/PoorManSiteView.cpp b/src/apps/poorman/PoorManSiteView.cpp index 532c0e65ad..a31ce8584a 100644 --- a/src/apps/poorman/PoorManSiteView.cpp +++ b/src/apps/poorman/PoorManSiteView.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include "constants.h" #include "PoorManSiteView.h" @@ -24,7 +24,7 @@ PoorManSiteView::PoorManSiteView(const char* name) // Web Site Location BBox BBox* webSiteLocation = new BBox("Web Location"); webSiteLocation->SetLabel(STR_BBX_LOCATION); - + // Web Site Options BBox BBox* webSiteOptions = new BBox("Web Options"); webSiteOptions->SetLabel(STR_BBX_OPTIONS); @@ -47,22 +47,32 @@ PoorManSiteView::PoorManSiteView(const char* name) fIndexFileName = new BTextControl("Index File Name", STR_TXT_INDEX, NULL); SetIndexFileName(win->IndexFileName()); - webSiteOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) - .Add(fSendDir) - .AddGlue()) - .SetInsets(5, 5, 5, 5)); - webSiteLocation->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(fWebDir) - .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) - .AddGlue() - .Add(fSelectWebDir)) - .Add(fIndexFileName) - .SetInsets(5, 5, 5, 5)); + BGroupLayout* webSiteLocationLayout = new BGroupLayout(B_VERTICAL, 0); + webSiteLocation->SetLayout(webSiteLocationLayout); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(webSiteLocation) - .Add(webSiteOptions) - .SetInsets(5, 5, 5, 5)); + BGroupLayout* webSiteOptionsLayout = new BGroupLayout(B_VERTICAL, 0); + webSiteOptions->SetLayout(webSiteOptionsLayout); + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_ITEM_INSETS) + .AddGroup(webSiteLocationLayout) + .SetInsets(B_USE_ITEM_INSETS) + .AddGrid(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) + .SetInsets(0, B_USE_ITEM_INSETS, 0, 0) + .AddTextControl(fWebDir, 0, 0, B_ALIGN_LEFT, 1, 2) + .Add(fSelectWebDir, 2, 1) + .AddTextControl(fIndexFileName, 0, 2, B_ALIGN_LEFT, 1, 2) + .SetColumnWeight(1, 10.f) + .End() + .End() + .AddGroup(webSiteOptionsLayout) + .SetInsets(B_USE_ITEM_INSETS) + .AddStrut(B_USE_ITEM_SPACING) + .AddGroup(B_HORIZONTAL) + .SetInsets(0) + .Add(fSendDir) + .AddGlue() + .End() + .AddGlue(); } diff --git a/src/apps/poorman/PoorManWindow.cpp b/src/apps/poorman/PoorManWindow.cpp index 07e5ba907e..019ecc1e8a 100644 --- a/src/apps/poorman/PoorManWindow.cpp +++ b/src/apps/poorman/PoorManWindow.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -73,8 +73,6 @@ PoorManWindow::PoorManWindow(BRect frame) SetSizeLimits(318, 1600, 53, 1200); // limit the size of the size of the window - SetLayout(new BGroupLayout(B_VERTICAL)); - // ----------------------------------------------------------------- // Three Labels @@ -137,18 +135,21 @@ PoorManWindow::PoorManWindow(BRect frame) change_title = fSaveConsoleSelectionFilePanel->Window(); change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE_SELECTION); - AddChild(BGroupLayoutBuilder(B_VERTICAL) + BLayoutBuilder::Group<>(this, B_VERTICAL, 0) + .SetInsets(0) .Add(fFileMenuBar) - .Add(BGroupLayoutBuilder(B_VERTICAL, 5) - .Add(BGroupLayoutBuilder(B_HORIZONTAL) + .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) + .SetInsets(B_USE_WINDOW_INSETS) + .AddGroup(B_HORIZONTAL) .Add(fStatusView) .AddGlue() - .Add(fHitsView)) - .Add(BGroupLayoutBuilder(B_HORIZONTAL) + .Add(fHitsView) + .End() + .AddGroup(B_HORIZONTAL) .Add(fDirView) - .AddGlue()) - .Add(fScrollView) - .SetInsets(10, 10, 10, 10))); + .AddGlue() + .End() + .Add(fScrollView); pthread_rwlock_init(&fLogFileLock, NULL); } From 0a96da93d180a27d0d4ae58915dd516b17f1f6ba Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Mon, 16 Jul 2012 13:31:51 +1200 Subject: [PATCH 20/46] Fix style on inline methods in PoorMan. --- src/apps/poorman/PoorManLoggingView.h | 52 +++++++++----- src/apps/poorman/PoorManSiteView.h | 46 +++++++++---- src/apps/poorman/PoorManWindow.h | 98 +++++++++++++++++++-------- 3 files changed, 136 insertions(+), 60 deletions(-) diff --git a/src/apps/poorman/PoorManLoggingView.h b/src/apps/poorman/PoorManLoggingView.h index 9648f08be4..4203505f79 100644 --- a/src/apps/poorman/PoorManLoggingView.h +++ b/src/apps/poorman/PoorManLoggingView.h @@ -18,23 +18,41 @@ class PoorManLoggingView: public BView { public: PoorManLoggingView(const char* name); - void SetLogConsoleValue(bool state) - { if (state) - fLogConsole->SetValue(B_CONTROL_ON); - else fLogConsole->SetValue(B_CONTROL_OFF); } - bool LogConsoleValue() - { return (fLogConsole->Value() == B_CONTROL_ON) - ? true : false; } - void SetLogFileValue(bool state) - { if (state) fLogFile->SetValue(B_CONTROL_ON); - else fLogFile->SetValue(B_CONTROL_OFF); } - bool LogFileValue() - { return (fLogFile->Value() == B_CONTROL_ON) - ? true : false; } - const char* LogFileName() - { return fLogFileName->Text(); } - void SetLogFileName(const char* log) - { fLogFileName->SetText(log); } + void SetLogConsoleValue(bool state) + { + if (state) + fLogConsole->SetValue(B_CONTROL_ON); + else + fLogConsole->SetValue(B_CONTROL_OFF); + } + + bool LogConsoleValue() + { + return (fLogConsole->Value() == B_CONTROL_ON); + } + + void SetLogFileValue(bool state) + { + if (state) + fLogFile->SetValue(B_CONTROL_ON); + else + fLogFile->SetValue(B_CONTROL_OFF); + } + + bool LogFileValue() + { + return (fLogFile->Value() == B_CONTROL_ON); + } + + const char* LogFileName() + { + return fLogFileName->Text(); + } + + void SetLogFileName(const char* log) + { + fLogFileName->SetText(log); + } private: // Logging Tab diff --git a/src/apps/poorman/PoorManSiteView.h b/src/apps/poorman/PoorManSiteView.h index 8bd8716da4..8765347219 100644 --- a/src/apps/poorman/PoorManSiteView.h +++ b/src/apps/poorman/PoorManSiteView.h @@ -18,20 +18,38 @@ class PoorManSiteView: public BView { public: PoorManSiteView(const char *name); - void SetSendDirValue(bool state) - { if (state) fSendDir->SetValue(B_CONTROL_ON); - else fSendDir->SetValue(B_CONTROL_OFF); } - bool SendDirValue() - { return (fSendDir->Value() == B_CONTROL_ON) - ? true : false; } - const char* IndexFileName() - { return fIndexFileName->Text(); } - void SetIndexFileName(const char* name) - { fIndexFileName->SetText(name); } - const char* WebDir() - { return fWebDir->Text(); } - void SetWebDir(const char* dir) - { fWebDir->SetText(dir); } + void SetSendDirValue(bool state) + { + if (state) + fSendDir->SetValue(B_CONTROL_ON); + else + fSendDir->SetValue(B_CONTROL_OFF); + } + + bool SendDirValue() + { + return (fSendDir->Value() == B_CONTROL_ON); + } + + const char* IndexFileName() + { + return fIndexFileName->Text(); + } + + void SetIndexFileName(const char* name) + { + fIndexFileName->SetText(name); + } + + const char* WebDir() + { + return fWebDir->Text(); + } + + void SetWebDir(const char* dir) + { + fWebDir->SetText(dir); + } private: // Site Tab diff --git a/src/apps/poorman/PoorManWindow.h b/src/apps/poorman/PoorManWindow.h index a2ddc516ea..20367ec78e 100644 --- a/src/apps/poorman/PoorManWindow.h +++ b/src/apps/poorman/PoorManWindow.h @@ -60,35 +60,75 @@ public: // ------------------------------------------- // Preferences and Settings // Site Tab - bool DirListFlag() - { return fDirListFlag; } - void SetDirListFlag(bool flag) - { fDirListFlag = flag; } - const char* IndexFileName() - { return fIndexFileName.String(); } - void SetIndexFileName(const char* str) - { fIndexFileName.SetTo(str); } - const char* WebDir() - { return fWebDirectory.String(); } - void SetWebDir(const char* str) - { fWebDirectory.SetTo(str); } - // Logging Tab - bool LogConsoleFlag() - { return fLogConsoleFlag; } - void SetLogConsoleFlag(bool flag) - { fLogConsoleFlag = flag; } - bool LogFileFlag() - { return fLogFileFlag; } - void SetLogFileFlag(bool flag) - { fLogFileFlag = flag; } - const char* LogPath() - { return fLogPath.String(); } - void SetLogPath(const char* str); - // Advanced Tab - int16 MaxConnections() - { return fMaxConnections; } - void SetMaxConnections(int16 num) - { fMaxConnections = num; } + bool DirListFlag() + { + return fDirListFlag; + } + + void SetDirListFlag(bool flag) + { + fDirListFlag = flag; + } + + const char* IndexFileName() + { + return fIndexFileName.String(); + } + + void SetIndexFileName(const char* str) + { + fIndexFileName.SetTo(str); + } + + const char* WebDir() + { + return fWebDirectory.String(); + } + + void SetWebDir(const char* str) + { + fWebDirectory.SetTo(str); + } + + // Logging Tab + + bool LogConsoleFlag() + { + return fLogConsoleFlag; + } + + void SetLogConsoleFlag(bool flag) + { + fLogConsoleFlag = flag; + } + + bool LogFileFlag() + { + return fLogFileFlag; + } + + void SetLogFileFlag(bool flag) + { + fLogFileFlag = flag; + } + + const char* LogPath() + { + return fLogPath.String(); + } + + void SetLogPath(const char* str); + + // Advanced Tab + int16 MaxConnections() + { + return fMaxConnections; + } + + void SetMaxConnections(int16 num) + { + fMaxConnections = num; + } private: // ------------------------------------------- From 3bbf781c1a27f5c0e8d4f3c632908174ed1f6ede Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Mon, 16 Jul 2012 14:52:56 +1200 Subject: [PATCH 21/46] Fix #8706 in Poorman - Selecting a web dir There is no 'name' entry in the message from a B_OPEN_PANEL BFilePanel. Also fix a little memory leak along the way. --- src/apps/poorman/PoorManPreferencesWindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apps/poorman/PoorManPreferencesWindow.cpp b/src/apps/poorman/PoorManPreferencesWindow.cpp index 5535f338b2..0095c82deb 100644 --- a/src/apps/poorman/PoorManPreferencesWindow.cpp +++ b/src/apps/poorman/PoorManPreferencesWindow.cpp @@ -142,12 +142,15 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message) Quit(); break; case MSG_PREF_SITE_BTN_SELECT: + { // Select the Web Directory, root directory to look in. fWebDirFilePanel->SetTarget(this); - fWebDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR)); + BMessage webDirSelectedMsg(MSG_FILE_PANEL_SELECT_WEB_DIR); + fWebDirFilePanel->SetMessage(&webDirSelectedMsg); if (!fWebDirFilePanel->IsShowing()) fWebDirFilePanel->Show(); break; + } case MSG_FILE_PANEL_SELECT_WEB_DIR: // handle the open BMessage from the Select Web Directory File Panel PRINT(("Select Web Directory:\n")); @@ -177,13 +180,10 @@ void PoorManPreferencesWindow::SelectWebDir(BMessage* message) { entry_ref ref; - const char* name; BPath path; BEntry entry; - if (message->FindRef("refs", &ref) != B_OK - || message->FindString("name", &name) != B_OK - || entry.SetTo(&ref) != B_OK) { + if (message->FindRef("refs", &ref) != B_OK || entry.SetTo(&ref) != B_OK) { return; } entry.GetPath(&path); From 73fc635b3d87970ed7843eacd0ac7a5ffcac0e9b Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Mon, 16 Jul 2012 13:41:08 +0200 Subject: [PATCH 22/46] Tick at 1000Hz not 1MHz. Our FreeBSD networking code defined hz to 1MHz and 1 tick = 1 / hz, but the clock code ticked 1 tick at 1000Hz. This caused all calculations that are done on ticks, autonegotiation and wlan scanning to be done very often as FreeBSD uses 1000 Hz (100Hz for ARM). Defaults for autonegotiation is 5 and 17 ticks. (Another interesting thing is that callouts are using 8% cpu...) --- src/libs/compat/freebsd_network/Condvar.cpp | 5 +---- src/libs/compat/freebsd_network/callout.cpp | 6 +++--- src/libs/compat/freebsd_network/clock.c | 20 ++++--------------- .../freebsd_network/compat/sys/kernel.h | 18 ++++++++--------- .../compat/freebsd_network/compat/sys/time.h | 2 +- 5 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/libs/compat/freebsd_network/Condvar.cpp b/src/libs/compat/freebsd_network/Condvar.cpp index c1343b3ce2..74499ef0cb 100644 --- a/src/libs/compat/freebsd_network/Condvar.cpp +++ b/src/libs/compat/freebsd_network/Condvar.cpp @@ -12,9 +12,6 @@ extern "C" { #include "Condvar.h" -#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz) - - void conditionInit(struct cv* variable, const char* description) { @@ -23,7 +20,7 @@ conditionInit(struct cv* variable, const char* description) void -conditionPublish(struct cv* variable, const void* waitChannel, +conditionPublish(struct cv* variable, const void* waitChannel, const char* description) { variable->condition.Publish(waitChannel, description); diff --git a/src/libs/compat/freebsd_network/callout.cpp b/src/libs/compat/freebsd_network/callout.cpp index f062da5824..1541580500 100644 --- a/src/libs/compat/freebsd_network/callout.cpp +++ b/src/libs/compat/freebsd_network/callout.cpp @@ -62,9 +62,9 @@ callout_thread(void* /*data*/) if (mutex != NULL) mtx_lock(mutex); - + c->c_func(c->c_arg); - + if (mutex != NULL) mtx_unlock(mutex); @@ -116,7 +116,7 @@ init_callout(void) } sThread = spawn_kernel_thread(callout_thread, "fbsd callout", - B_URGENT_DISPLAY_PRIORITY, NULL); + B_DISPLAY_PRIORITY, NULL); if (sThread < 0) { status = sThread; goto err2; diff --git a/src/libs/compat/freebsd_network/clock.c b/src/libs/compat/freebsd_network/clock.c index aa3612c745..91a095429d 100644 --- a/src/libs/compat/freebsd_network/clock.c +++ b/src/libs/compat/freebsd_network/clock.c @@ -5,10 +5,7 @@ #include "device.h" - - -#define CONVERT_HZ_TO_USECS(hertz) (1000000LL / (hertz)) -#define FREEBSD_CLOCK_FREQUENCY_IN_HZ 1000 +#include "kernel.h" int ticks; @@ -27,24 +24,15 @@ hardClock(timer* hardClockTimer) /*! - * Initialization of the hardclock timer. - * - * Note: We are not using the FreeBSD variable hz as the invocation frequency - * as it is the case in FreeBSD's hardclock function. This is due to lower - * system load. The hz (see compat/sys/kernel.h) variable in the compat layer is - * set to 1000000 Hz, whereas it is usually set to 1000 Hz for FreeBSD. + * Initialization of the hardclock timer which ticks according to hz defined in + * compat/sys/kernel.h. */ status_t init_hard_clock() { - status_t status; - ticks = 0; - status = add_timer(&sHardClockTimer, hardClock, - CONVERT_HZ_TO_USECS(FREEBSD_CLOCK_FREQUENCY_IN_HZ), + return add_timer(&sHardClockTimer, hardClock, ticks_to_usecs(1), B_PERIODIC_TIMER); - - return status; } diff --git a/src/libs/compat/freebsd_network/compat/sys/kernel.h b/src/libs/compat/freebsd_network/compat/sys/kernel.h index 6c8c545f7d..615b9f760d 100644 --- a/src/libs/compat/freebsd_network/compat/sys/kernel.h +++ b/src/libs/compat/freebsd_network/compat/sys/kernel.h @@ -17,18 +17,18 @@ /* * - * In FreeBSD hz holds the count of how often the thread scheduler is invoked - * per second. Moreover this is the rate at which FreeBSD can generate callouts - * (kind of timeout mechanism). - * For FreeBSD 8 this is typically 1000 times per second. This value is defined - * in a file called subr_param.c + * The rate at which FreeBSD can generate callouts (kind of timeout mechanism). + * For FreeBSD 8 this is typically 1000 times per second (100 for ARM). + * This value is defined in a file called subr_param.c * - * For Haiku this value is much higher, due to using another timeout scheduling - * mechanism, which has a resolution of 1 MHz. So hz for Haiku is set to - * 1000000. Suffixing LL prevents integer overflows during calculations. + * WHile Haiku can have a much higher granularity, it is not a good idea to have + * this since FreeBSD tries to do certain tasks based on ticks, for instance + * autonegotiation and wlan scanning. + * Suffixing LL prevents integer overflows during calculations. * as it defines a long long constant.*/ -#define hz 1000000LL +#define hz 1000LL +#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz) typedef void (*system_init_func_t)(void *); diff --git a/src/libs/compat/freebsd_network/compat/sys/time.h b/src/libs/compat/freebsd_network/compat/sys/time.h index 1bbabb743a..4b061e3ad4 100644 --- a/src/libs/compat/freebsd_network/compat/sys/time.h +++ b/src/libs/compat/freebsd_network/compat/sys/time.h @@ -12,7 +12,7 @@ #include -#define time_uptime system_time() / 1000000 +#define time_uptime (system_time() / 1000000) int ppsratecheck(struct timeval*, int*, int); From ee3a1ebebf84abaa336df5b7a57547285921f1c7 Mon Sep 17 00:00:00 2001 From: czeidler Date: Tue, 17 Jul 2012 11:28:59 +1200 Subject: [PATCH 23/46] Fix possible crash. --- src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp b/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp index 7ad21e7f63..25a391d6ed 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp @@ -112,6 +112,9 @@ POP3Protocol::Connect() status_t POP3Protocol::Disconnect() { + if (fServerConnection == NULL) + return B_OK; + SendCommand("QUIT" CRLF); fServerConnection->Disconnect(); From 19d67b5513f0f33c8e739445d30c9c1f14452850 Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Wed, 18 Jul 2012 15:30:13 +0200 Subject: [PATCH 24/46] This is set in opt_wlan.h, and should only be done in one place. --- src/libs/compat/freebsd_wlan/net80211/Jamfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/compat/freebsd_wlan/net80211/Jamfile b/src/libs/compat/freebsd_wlan/net80211/Jamfile index 6e63b3eb1e..bff3d75686 100644 --- a/src/libs/compat/freebsd_wlan/net80211/Jamfile +++ b/src/libs/compat/freebsd_wlan/net80211/Jamfile @@ -11,9 +11,9 @@ UsePrivateKernelHeaders ; Includes [ FGristFiles kernel_c++_structs.h ] : kernel_c++_struct_sizes.h ; -SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 IEEE80211_DEBUG=1 ] +SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] -Wno-format -Wno-unused -Wno-uninitialized ; -SubDirC++Flags [ FDefines _KERNEL=1 FBSD_DRIVER=1 IEEE80211_DEBUG=1 ] +SubDirC++Flags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] -Wno-format -Wno-unused -Wno-uninitialized ; SEARCH_SOURCE += [ FDirName $(SUBDIR) .. crypto rijndael ] ; From 4feeeb4a8fedd4089e4d874d6e2c5a6ce8185bb5 Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Wed, 18 Jul 2012 15:31:14 +0200 Subject: [PATCH 25/46] Don't write wast amounts of debug info about scanning. --- src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp index 5fad3885c8..d4910cdef5 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp @@ -539,7 +539,6 @@ ieee80211_sysctl_vattach(struct ieee80211vap* vap) | IEEE80211_MSG_NODE | IEEE80211_MSG_ASSOC | IEEE80211_MSG_AUTH - | IEEE80211_MSG_SCAN | IEEE80211_MSG_STATE | IEEE80211_MSG_POWER | IEEE80211_MSG_WME From a2e7d8df7bf39721a597b0473831f25813d71b0e Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Wed, 18 Jul 2012 17:09:36 +0200 Subject: [PATCH 26/46] callout_schedule uses ticks as timeunit, not usecs. As suggested by Rene Gollent, we used ticks as usecs. --- src/libs/compat/freebsd_network/callout.cpp | 10 +++++----- src/libs/compat/freebsd_network/compat/sys/callout.h | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libs/compat/freebsd_network/callout.cpp b/src/libs/compat/freebsd_network/callout.cpp index 1541580500..da06a5b310 100644 --- a/src/libs/compat/freebsd_network/callout.cpp +++ b/src/libs/compat/freebsd_network/callout.cpp @@ -172,7 +172,7 @@ callout_init_mtx(struct callout *c, struct mtx *mtx, int flags) int -callout_reset(struct callout *c, int when, void (*func)(void *), void *arg) +callout_reset(struct callout *c, int ticks, void (*func)(void *), void *arg) { int canceled = callout_stop(c); @@ -183,12 +183,12 @@ callout_reset(struct callout *c, int when, void (*func)(void *), void *arg) TRACE("callout_reset %p, func %p, arg %p\n", c, c->c_func, c->c_arg); - if (when >= 0) { + if (ticks >= 0) { // reschedule or add this timer if (c->due <= 0) list_add_item(&sTimers, c); - c->due = system_time() + when; + c->due = system_time() + ticks_to_usecs(ticks); // notify timer about the change if necessary if (sTimeout > c->due) @@ -200,9 +200,9 @@ callout_reset(struct callout *c, int when, void (*func)(void *), void *arg) int -callout_schedule(struct callout *callout, int toTicks) +callout_schedule(struct callout *callout, int ticks) { - return callout_reset(callout, toTicks, callout->c_func, callout->c_arg); + return callout_reset(callout, ticks, callout->c_func, callout->c_arg); } diff --git a/src/libs/compat/freebsd_network/compat/sys/callout.h b/src/libs/compat/freebsd_network/compat/sys/callout.h index 50909aa95f..9d4da3b944 100644 --- a/src/libs/compat/freebsd_network/compat/sys/callout.h +++ b/src/libs/compat/freebsd_network/compat/sys/callout.h @@ -30,8 +30,9 @@ struct callout { void callout_init(struct callout *c, int mpsafe); void callout_init_mtx(struct callout *c, struct mtx *mutex, int flags); -int callout_schedule(struct callout *c, int when); -int callout_reset(struct callout *c, int when, void (*func)(void *), void *arg); +/* Time values are in ticks, see compat/sys/kernel.h for its definition */ +int callout_schedule(struct callout *c, int ticks); +int callout_reset(struct callout *c, int ticks, void (*func)(void *), void *arg); int callout_pending(struct callout *c); int callout_active(struct callout *c); From 489cc3566148e0889a035fc49e5a16b0499e208c Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 17 Jul 2012 19:10:35 -0400 Subject: [PATCH 27/46] Add Tooltip support to TreeTable. --- .../debuganalyzer/gui/table/TreeTable.cpp | 42 +++++++++++++++++++ src/apps/debuganalyzer/gui/table/TreeTable.h | 20 +++++++++ 2 files changed, 62 insertions(+) diff --git a/src/apps/debuganalyzer/gui/table/TreeTable.cpp b/src/apps/debuganalyzer/gui/table/TreeTable.cpp index 0c20843914..851342a4cd 100644 --- a/src/apps/debuganalyzer/gui/table/TreeTable.cpp +++ b/src/apps/debuganalyzer/gui/table/TreeTable.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2012, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -226,6 +227,14 @@ TreeTableModel::NotifyNodesChanged(const TreeTablePath& path, int32 childIndex, } +// #pragma mark - TreeTableToolTipProvider + + +TreeTableToolTipProvider::~TreeTableToolTipProvider() +{ +} + + // #pragma mark - TreeTableListener @@ -650,6 +659,7 @@ TreeTable::TreeTable(const char* name, uint32 flags, border_style borderStyle, : AbstractTable(name, flags, borderStyle, showHorizontalScrollbar), fModel(NULL), + fToolTipProvider(NULL), fRootNode(NULL), fSelectionModel(this), fIgnoreSelectionChange(0) @@ -731,6 +741,13 @@ TreeTable::SetTreeTableModel(TreeTableModel* model) } +void +TreeTable::SetToolTipProvider(TreeTableToolTipProvider* toolTipProvider) +{ + fToolTipProvider = toolTipProvider; +} + + TreeTableSelectionModel* TreeTable::SelectionModel() { @@ -810,6 +827,31 @@ TreeTable::RemoveTreeTableListener(TreeTableListener* listener) } +bool +TreeTable::GetToolTipAt(BPoint point, BToolTip** _tip) +{ + if (fToolTipProvider == NULL) + return AbstractTable::GetToolTipAt(point, _tip); + + // get the table row + BRow* row = RowAt(point); + if (row == NULL) + return AbstractTable::GetToolTipAt(point, _tip); + + TreeTableRow* treeRow = dynamic_cast(row); + // get the table column + BColumn* column = ColumnAt(point); + + int32 columnIndex = column != NULL ? column->LogicalFieldNum() : -1; + + TreeTablePath path; + _GetPathForNode(treeRow->Node(), path); + + return fToolTipProvider->GetToolTipForTablePath(path, columnIndex, + _tip); +} + + void TreeTable::SelectionChanged() { diff --git a/src/apps/debuganalyzer/gui/table/TreeTable.h b/src/apps/debuganalyzer/gui/table/TreeTable.h index a4758690e3..b006e083f1 100644 --- a/src/apps/debuganalyzer/gui/table/TreeTable.h +++ b/src/apps/debuganalyzer/gui/table/TreeTable.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2012, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef TREE_TABLE_H @@ -122,6 +123,17 @@ private: }; +class TreeTableToolTipProvider { +public: + virtual ~TreeTableToolTipProvider(); + + virtual bool GetToolTipForTablePath( + const TreeTablePath& path, + int32 columnIndex, BToolTip** _tip) = 0; + // columnIndex can be -1, if not in a column +}; + + class TreeTableListener { public: virtual ~TreeTableListener(); @@ -157,6 +169,11 @@ public: bool SetTreeTableModel(TreeTableModel* model); TreeTableModel* GetTreeTableModel() const { return fModel; } + void SetToolTipProvider( + TreeTableToolTipProvider* toolTipProvider); + TreeTableToolTipProvider* ToolTipProvider() const + { return fToolTipProvider; } + TreeTableSelectionModel* SelectionModel(); void SelectNode(const TreeTablePath& path, @@ -177,6 +194,8 @@ public: TreeTableListener* listener); protected: + virtual bool GetToolTipAt(BPoint point, BToolTip** _tip); + virtual void SelectionChanged(); virtual AbstractColumn* CreateColumn(TableColumn* column); @@ -226,6 +245,7 @@ private: private: TreeTableModel* fModel; + TreeTableToolTipProvider* fToolTipProvider; TreeTableNode* fRootNode; TreeTableSelectionModel fSelectionModel; ListenerList fListeners; From 2216ccb7e2396a7356edfb5b1c8777fc853937be Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 17 Jul 2012 19:12:47 -0400 Subject: [PATCH 28/46] Implement support for tooltips in VariableView. Implements #8286. - These show the memory or register location(s) of the variable over which the mouse is hovering. --- .../gui/team_window/VariablesView.cpp | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 04ad5d457b..0c0dc4c98d 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -345,7 +346,8 @@ protected: // #pragma mark - VariableTableModel -class VariablesView::VariableTableModel : public TreeTableModel { +class VariablesView::VariableTableModel : public TreeTableModel, + public TreeTableToolTipProvider { public: VariableTableModel(); ~VariableTableModel(); @@ -379,6 +381,10 @@ public: void NotifyNodeChanged(ModelNode* node); void NotifyNodeHidden(ModelNode* node); + virtual bool GetToolTipForTablePath( + const TreeTablePath& path, + int32 columnIndex, BToolTip** _tip); + private: struct NodeHashDefinition { typedef ValueNodeChild* KeyType; @@ -1159,6 +1165,45 @@ VariablesView::VariableTableModel::NotifyNodeHidden(ModelNode* node) } +bool +VariablesView::VariableTableModel::GetToolTipForTablePath( + const TreeTablePath& path, int32 columnIndex, BToolTip** _tip) +{ + ModelNode* node = (ModelNode*)NodeForPath(path); + if (node == NULL) + return false; + + if (node->NodeChild()->LocationResolutionState() != B_OK) + return false; + + ValueLocation* location = node->NodeChild()->Location(); + BString tipData("Location piece(s):"); + for (int32 i = 0; i < location->CountPieces(); i++) { + ValuePieceLocation piece = location->PieceAt(i); + BString pieceData; + switch (piece.type) { + case VALUE_PIECE_LOCATION_MEMORY: + pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx", + i, piece.address); + break; + case VALUE_PIECE_LOCATION_REGISTER: + pieceData.SetToFormat("\n\t(%ld): Register (%lu)", + i, piece.reg); + break; + default: + break; + } + tipData += pieceData; + } + + *_tip = new(std::nothrow) BTextToolTip(tipData); + if (*_tip == NULL) + return false; + + return true; +} + + status_t VariablesView::VariableTableModel::_AddNode(Variable* variable, ModelNode* parent, ValueNodeChild* nodeChild, bool isPresentationNode, @@ -1734,6 +1779,7 @@ VariablesView::_Init() if (fVariableTableModel->Init() != B_OK) throw std::bad_alloc(); fVariableTable->SetTreeTableModel(fVariableTableModel); + fVariableTable->SetToolTipProvider(fVariableTableModel); fContainerListener = new ContainerListener(this); fVariableTableModel->SetContainerListener(fContainerListener); From 666222d3fd5bb1964565da7875df2570a0783673 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 17 Jul 2012 20:58:40 -0400 Subject: [PATCH 29/46] Resolve register names, print memory piece size information. --- .../gui/team_window/VariablesView.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 0c0dc4c98d..ece58364d8 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -26,6 +26,7 @@ #include "FunctionInstance.h" #include "GUISettingsUtils.h" #include "MessageCodes.h" +#include "Register.h" #include "SettingsMenu.h" #include "StackFrame.h" #include "StackFrameValues.h" @@ -1183,13 +1184,17 @@ VariablesView::VariableTableModel::GetToolTipForTablePath( BString pieceData; switch (piece.type) { case VALUE_PIECE_LOCATION_MEMORY: - pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx", - i, piece.address); + pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx, Size: " + "%lld bytes", i, piece.address, piece.size); break; case VALUE_PIECE_LOCATION_REGISTER: - pieceData.SetToFormat("\n\t(%ld): Register (%lu)", - i, piece.reg); + { + Architecture* architecture = fThread->GetTeam()->GetArchitecture(); + pieceData.SetToFormat("\n\t(%ld): Register (%s)", + i, architecture->Registers()[piece.reg].Name()); + break; + } default: break; } From 3a5779744ed04ad4dd000e1680e0872b3b99b56e Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 18 Jul 2012 18:42:25 -0400 Subject: [PATCH 30/46] Handle compound node values in variables view. - If the node we're looking at is a compound node, retrieve its location and show that as the value with an indicator to clarify that it's an object. - Minor tweaks to tooltip format. - Style cleanups. --- .../gui/team_window/VariablesView.cpp | 65 ++++++++++++++----- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index ece58364d8..b0beb9c0e9 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -314,10 +314,12 @@ protected: targetView); return; } + } else if (value.Type() == B_STRING_TYPE) { + fField.SetString(value.ToString()); + } else { + // fall back to drawing an empty string + fField.SetString(""); } - - // fall back to drawing an empty string - fField.SetString(""); fField.SetWidth(Width()); fColumn.DrawField(&fField, rect, targetView); } @@ -1112,8 +1114,29 @@ VariablesView::VariableTableModel::GetValueAt(void* object, int32 columnIndex, _value.SetTo(node->Name(), B_VARIANT_DONT_COPY_DATA); return true; case 1: - if (node->GetValue() == NULL) + if (node->GetValue() == NULL) { + ValueLocation* location = node->NodeChild()->Location(); + if (location == NULL) + return false; + + Type* nodeChildRawType = node->NodeChild()->Node()->GetType() + ->ResolveRawType(false); + if (nodeChildRawType->Kind() == TYPE_COMPOUND) + { + if (location->CountPieces() > 1) + return false; + + BString data; + ValuePieceLocation piece = location->PieceAt(0); + if (piece.type != VALUE_PIECE_LOCATION_MEMORY) + return false; + + data.SetToFormat("[@ 0x%llx]", piece.address); + _value.SetTo(data); + return true; + } return false; + } _value.SetTo(node, VALUE_NODE_TYPE); return true; @@ -1178,29 +1201,35 @@ VariablesView::VariableTableModel::GetToolTipForTablePath( return false; ValueLocation* location = node->NodeChild()->Location(); - BString tipData("Location piece(s):"); + BString tipData; for (int32 i = 0; i < location->CountPieces(); i++) { ValuePieceLocation piece = location->PieceAt(i); BString pieceData; switch (piece.type) { - case VALUE_PIECE_LOCATION_MEMORY: - pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx, Size: " - "%lld bytes", i, piece.address, piece.size); - break; - case VALUE_PIECE_LOCATION_REGISTER: - { - Architecture* architecture = fThread->GetTeam()->GetArchitecture(); - pieceData.SetToFormat("\n\t(%ld): Register (%s)", - i, architecture->Registers()[piece.reg].Name()); + case VALUE_PIECE_LOCATION_MEMORY: + pieceData.SetToFormat("(%ld): Address: 0x%llx, Size: " + "%lld bytes", i, piece.address, piece.size); + break; + case VALUE_PIECE_LOCATION_REGISTER: + { + Architecture* architecture = fThread->GetTeam()->GetArchitecture(); + pieceData.SetToFormat("(%ld): Register (%s)", + i, architecture->Registers()[piece.reg].Name()); - break; - } - default: - break; + break; + } + default: + break; } + tipData += pieceData; + if (i < location->CountPieces() - 1) + tipData += "\n"; } + if (tipData.IsEmpty()) + return false; + *_tip = new(std::nothrow) BTextToolTip(tipData); if (*_tip == NULL) return false; From 1820d4fd1591a43c3788064b9c3790d4dafd0577 Mon Sep 17 00:00:00 2001 From: Scott McCreary Date: Wed, 18 Jul 2012 23:32:47 +0000 Subject: [PATCH 31/46] Added XZ-Utils as a dependency for LibXML2 --- build/jam/OptionalPackageDependencies | 1 + 1 file changed, 1 insertion(+) diff --git a/build/jam/OptionalPackageDependencies b/build/jam/OptionalPackageDependencies index 650783dc8f..aa4a525d3b 100644 --- a/build/jam/OptionalPackageDependencies +++ b/build/jam/OptionalPackageDependencies @@ -20,6 +20,7 @@ OptionalPackageDependencies Git : Expat Curl OpenSSL LibIconv ; OptionalPackageDependencies GitDoc : Man Git ; OptionalPackageDependencies ICU-devel : DevelopmentBase ; OptionalPackageDependencies LibLayout : DevelopmentBase ; +OptionalPackageDependencies LibXML2 : XZ-Utils ; OptionalPackageDependencies Man : Groff ; OptionalPackageDependencies Tar : LibIconv ; OptionalPackageDependencies Python : Bzip ; From 95c8d9513aa426e3cab2f3ef0d0ab2c9e48c774b Mon Sep 17 00:00:00 2001 From: Scott McCreary Date: Wed, 18 Jul 2012 23:33:36 +0000 Subject: [PATCH 32/46] Updated build for XZ-Utils --- build/jam/OptionalPackages | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index ad77d54041..06c37c2ed1 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -1986,8 +1986,8 @@ if [ IsOptionalHaikuImagePackageAdded XZ-Utils ] { Echo "No optional package XZ-Utils available for $(TARGET_ARCH)" ; } else { InstallOptionalHaikuImagePackage - xz-utils-5.0.1-r1a3-x86-gcc4-2011-05-24.zip - : $(baseURL)/xz-utils-5.0.1-r1a3-x86-gcc4-2011-05-24.zip ; + xz-utils-5.0.1-x86-gcc4-2012-07-18.zip + : $(baseURL)/xz-utils-5.0.1-x86-gcc4-2012-07-18.zip ; AddExpanderRuleToHaikuImage "application/x-xz" : .tar.xz : "tar -Jtvf \\0045s" : "tar -Jxvf \\0045s" From 0783fe388de666cecf6305172550feb3f3dcd8b2 Mon Sep 17 00:00:00 2001 From: Scott McCreary Date: Wed, 18 Jul 2012 23:37:00 +0000 Subject: [PATCH 33/46] Updated build for LibXML2 --- build/jam/OptionalPackages | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index 06c37c2ed1..6e17c22ac1 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -1206,12 +1206,12 @@ if [ IsOptionalHaikuImagePackageAdded LibXML2 ] { } else { if $(HAIKU_GCC_VERSION[1]) >= 4 { InstallOptionalHaikuImagePackage - libxml2-2.8.0-x86-gcc4-2012-06-18.zip - : $(baseURL)/libxml2-2.8.0-x86-gcc4-2012-06-18.zip ; + libxml2-2.8.0-x86-gcc4-2012-07-18.zip + : $(baseURL)/libxml2-2.8.0-x86-gcc4-2012-07-18.zip ; } else { InstallOptionalHaikuImagePackage - libxml2-2.8.0-x86-gcc2-2012-06-21.zip - : $(baseURL)/libxml2-2.8.0-x86-gcc2-2012-06-21.zip ; + libxml2-2.8.0-x86-gcc2-2012-07-17.zip + : $(baseURL)/libxml2-2.8.0-x86-gcc2-2012-07-17.zip ; } } } From af2f75a0167a11a9a9fa212a0a4e5d2671cfd8a1 Mon Sep 17 00:00:00 2001 From: Scott McCreary Date: Wed, 18 Jul 2012 23:38:53 +0000 Subject: [PATCH 34/46] Updated cmake to 2.8.5 --- build/jam/OptionalPackages | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index 6e17c22ac1..f4b3dd97b6 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -475,13 +475,13 @@ if [ IsOptionalHaikuImagePackageAdded CMake ] { } else { if $(HAIKU_GCC_VERSION[1]) >= 4 { InstallOptionalHaikuImagePackage - cmake-2.8.4-r1a3-x86-gcc4-2011-05-23.zip - : $(baseURL)/cmake-2.8.4-r1a3-x86-gcc4-2011-05-23.zip + cmake-2.8.5-x86-gcc4-2012-07-18.zip + : $(baseURL)/cmake-2.8.5-x86-gcc4-2012-07-18.zip : : true ; } else { InstallOptionalHaikuImagePackage - cmake-2.8.4-r1a3-x86-gcc2-2011-05-19.zip - : $(baseURL)/cmake-2.8.4-r1a3-x86-gcc2-2011-05-19.zip + cmake-2.8.5-x86-gcc2-2012-07-16.zip + : $(baseURL)/cmake-2.8.5-x86-gcc2-2012-07-16.zip : : true ; } } From ed15f1b8fb8b635349829c655678177ad3032ccc Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 18 Jul 2012 23:00:53 -0400 Subject: [PATCH 35/46] Fix scrollbar handling when removing rows in BCLV. - If removing a row results in there no longer being any rows whatsoever visible, force a scroll back into the visible range. Fixes #8287. --- src/kits/interface/ColumnListView.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index baa05a2822..8123c690d3 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -4090,6 +4090,16 @@ OutlineView::RemoveRow(BRow* row) fItemsHeight -= subTreeHeight; FixScrollBar(false); + int32 indent = 0; + float top = 0.0; + if (FindRow(fVisibleRect.top, &indent, &top) == NULL && ScrollBar(B_VERTICAL) != NULL) { + // after removing this row, no rows are actually visible any more, + // force a scroll to make them visible again + if (fItemsHeight > fVisibleRect.Height()) + ScrollBy(0.0, fItemsHeight - fVisibleRect.Height() - Bounds().top); + else + ScrollBy(0.0, -Bounds().top); + } if (parentRow != NULL) { parentRow->fChildList->RemoveItem(row); if (parentRow->fChildList->CountItems() == 0) { @@ -4294,7 +4304,7 @@ OutlineView::FixScrollBar(bool scrollToFit) float maxScrollBarValue = fItemsHeight - fVisibleRect.Height(); vScrollBar->SetProportion(fVisibleRect.Height() / fItemsHeight); - // If the user is scrolled down too far when makes the range smaller, the list + // If the user is scrolled down too far when making the range smaller, the list // will jump suddenly, which is undesirable. In this case, don't fix the scroll // bar here. In ScrollTo, it checks to see if this has occured, and will // fix the scroll bars sneakily if the user has scrolled up far enough. From 03aa456e2effa939895246dce37cd2454f5534d7 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 18 Jul 2012 23:21:06 -0400 Subject: [PATCH 36/46] Fix mouse down handling error. - When handling a mouse click, the button was hardcoded instead of passing the actual button clicked by the user. Spotted by Chris Roberts. --- src/kits/interface/ColumnListView.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index 8123c690d3..b31cf0c0a4 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -3512,8 +3512,11 @@ OutlineView::MouseDown(BPoint position) fCurrentRow = new_row; fCurrentField = new_field; fCurrentCode = B_INSIDE_VIEW; + BMessage* message = Window()->CurrentMessage(); + int32 buttons = 1; + message->FindInt32("buttons", &buttons); fCurrentColumn->MouseDown(fMasterView, fCurrentRow, - fCurrentField, fFieldRect, position, 1); + fCurrentField, fFieldRect, position, buttons); } if (!fEditMode) { From 8959a4e0c37873f56f44ea1743902de0ec0e44d4 Mon Sep 17 00:00:00 2001 From: Andreas Henriksson Date: Thu, 19 Jul 2012 23:37:42 +0200 Subject: [PATCH 37/46] An unused dirty block would put again into the unused list. * This could cause bug #8123. While this fixes the crash, one underlying problem is still there, as dirty blocks should never leave a transaction. --- src/system/kernel/cache/block_cache.cpp | 4 +++- src/tools/fs_shell/block_cache.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index b49bf6e902..e0c258b804 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -1268,7 +1268,7 @@ BlockWriter::_BlockDone(cached_block* block, hash_iterator* iterator) fDeletedTransaction = true; } } - if (block->transaction == NULL && block->ref_count == 0) { + if (block->transaction == NULL && block->ref_count == 0 && !block->unused) { // the block is no longer used block->unused = true; fCache->unused_blocks.Add(block); @@ -1761,7 +1761,9 @@ put_cached_block(block_cache* cache, cached_block* block) cache->RemoveBlock(block); } else { // put this block in the list of unused blocks + ASSERT(!block->unused); block->unused = true; + ASSERT(block->original_data == NULL && block->parent_data == NULL); cache->unused_blocks.Add(block); diff --git a/src/tools/fs_shell/block_cache.cpp b/src/tools/fs_shell/block_cache.cpp index 78f69d2865..2f47a094dc 100644 --- a/src/tools/fs_shell/block_cache.cpp +++ b/src/tools/fs_shell/block_cache.cpp @@ -927,7 +927,7 @@ write_cached_block(block_cache* cache, cached_block* block, } } } - if (block->transaction == NULL && block->ref_count == 0) { + if (block->transaction == NULL && block->ref_count == 0 && !block->unused) { // the block is no longer used block->unused = true; cache->unused_blocks.Add(block); From 9be0c9b03c9e25270699d59a363355cea083f63b Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Thu, 19 Jul 2012 23:24:52 +0200 Subject: [PATCH 38/46] Improve SVG image identification (close #8653) * add a sniff rule * until we have an image translator for SVG, and since Web+ is not included by default in Haiku images, made Web+ preferred app for SVG images. Note that for compressed SVGZ (*.svgz), the sniff rule will still fail miserably. Our sniffer will need decompression support before being able to do that... --- src/data/beos_mime/image/svg+xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/data/beos_mime/image/svg+xml b/src/data/beos_mime/image/svg+xml index 88ef6db6c1..94532c1cfa 100644 --- a/src/data/beos_mime/image/svg+xml +++ b/src/data/beos_mime/image/svg+xml @@ -5,8 +5,15 @@ resource(1, "META:TYPE") "image/svg+xml"; resource(2, "META:S:DESC") #'MSDC' "SVG image"; -resource(3, "META:EXTENS") message(234) { +resource(3, "META:SNIFF_RULE") #'CSTR' array { + "0.60 [0:511] ( -i \" Date: Thu, 19 Jul 2012 23:55:18 +0200 Subject: [PATCH 39/46] Added a bit of documentation, minor cleanup. * Documented the cached_block::transaction, and previous_transaction members. --- src/system/kernel/cache/block_cache.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index e0c258b804..cc5b663531 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -89,7 +89,17 @@ struct cached_block { bool busy_reading_waiters : 1; bool busy_writing_waiters : 1; cache_transaction* transaction; + // This is the current active transaction, if any, the block is + // currently in (meaning was changed as a part of it). cache_transaction* previous_transaction; + // This is set to the last transaction that was ended containing this + // block. In this case, the block has not yet written back yet, and + // the changed data is either in current_data, or original_data -- the + // latter if the block is already being part of another transaction. + // There can only be one previous transaction, so when the active + // transaction ends, the changes of the previous transaction have to + // be written back before that transaction becomes the next previous + // transaction. bool CanBeWritten() const; int32 LastAccess() const @@ -1189,7 +1199,7 @@ BlockWriter::WriteBlock(block_cache* cache, cached_block* block) void* BlockWriter::_Data(cached_block* block) const { - return block->previous_transaction && block->original_data + return block->previous_transaction != NULL && block->original_data != NULL ? block->original_data : block->current_data; // We first need to write back changes from previous transactions } From 752f5c972f1a874cc7f93787e1a3bce6396c891e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 19 Jul 2012 23:57:10 +0200 Subject: [PATCH 40/46] cache_abort_[sub_]transaction() did not work correctly. * cache_abort_transaction() left the block dirty which was causing bug #8123 as well. * cache_abort_sub_transaction() did, in addition to not clearing the dirty flag, not reset the block's transaction member either if the block was not part of the parent transaction. --- src/system/kernel/cache/block_cache.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index cc5b663531..943e6517f0 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -2877,6 +2877,8 @@ cache_abort_transaction(void* _cache, int32 id) block->transaction_next = NULL; block->transaction = NULL; block->discard = false; + if (block->previous_transaction == NULL) + block->is_dirty = false; } hash_remove(cache->transaction_hash, transaction); @@ -3028,17 +3030,24 @@ cache_abort_sub_transaction(void* _cache, int32 id) next = block->transaction_next; if (block->parent_data == NULL) { - // the parent transaction didn't change the block, but the sub - // transaction did - we need to revert from the original data + // The parent transaction didn't change the block, but the sub + // transaction did - we need to revert to the original data. + // The block is no longer part of the transaction ASSERT(block->original_data != NULL); memcpy(block->current_data, block->original_data, cache->block_size); + block->transaction_next = NULL; + block->transaction = NULL; + if (block->previous_transaction == NULL) + block->is_dirty = false; } else if (block->parent_data != block->current_data) { - // the block has been changed and must be restored + // The block has been changed and must be restored - the block + // is still dirty and part of the transaction TRACE(("cache_abort_sub_transaction(id = %ld): restored contents " "of block %Ld\n", transaction->id, block->block_number)); memcpy(block->current_data, block->parent_data, cache->block_size); cache->Free(block->parent_data); + // The block stays dirty } block->parent_data = NULL; From 173f54f1473bd6a6511c5fc6dc899c91fb8dd667 Mon Sep 17 00:00:00 2001 From: Matt Madia Date: Thu, 19 Jul 2012 18:11:40 +0000 Subject: [PATCH 41/46] Updated copyright in headers. No functional change. --- headers/posix/alloca.h | 2 +- headers/posix/arch/arm/arch_setjmp.h | 2 +- headers/posix/arch/arm/signal.h | 4 ++-- headers/posix/arch/m68k/arch_setjmp.h | 2 +- headers/posix/arch/m68k/signal.h | 4 ++-- headers/posix/arch/mipsel/arch_setjmp.h | 2 +- headers/posix/arch/mipsel/signal.h | 4 ++-- headers/posix/arch/ppc/arch_setjmp.h | 2 +- headers/posix/arch/ppc/signal.h | 4 ++-- headers/posix/arch/x86/arch_setjmp.h | 2 +- headers/posix/arch/x86/signal.h | 2 +- headers/posix/arch/x86_64/arch_setjmp.h | 2 +- headers/posix/arch/x86_64/signal.h | 4 ++-- headers/posix/arpa/inet.h | 2 +- headers/posix/arpa/nameser.h | 2 +- headers/posix/assert.h | 2 +- headers/posix/bsd_mem.h | 2 +- headers/posix/compat/sys/stat.h | 2 +- headers/posix/ctype.h | 2 +- headers/posix/dirent.h | 2 +- headers/posix/div_t.h | 2 +- headers/posix/dlfcn.h | 2 +- headers/posix/endian.h | 2 +- headers/posix/errno.h | 6 +++--- headers/posix/fcntl.h | 2 +- headers/posix/getopt.h | 2 +- headers/posix/grp.h | 2 +- headers/posix/inttypes.h | 2 +- headers/posix/iovec.h | 2 +- headers/posix/langinfo.h | 2 +- headers/posix/libgen.h | 2 +- headers/posix/limits.h | 2 +- headers/posix/locale.h | 2 +- headers/posix/malloc.h | 4 ++-- headers/posix/malloc_debug.h | 2 +- headers/posix/math.h | 2 +- headers/posix/memory.h | 6 +++--- headers/posix/monetary.h | 2 +- headers/posix/net/if.h | 2 +- headers/posix/net/if_dl.h | 2 +- headers/posix/net/if_media.h | 2 +- headers/posix/net/if_types.h | 2 +- headers/posix/net/route.h | 2 +- headers/posix/netdb.h | 2 +- headers/posix/netinet/in.h | 2 +- headers/posix/netinet/tcp.h | 4 ++-- headers/posix/netinet6/in6.h | 2 +- headers/posix/nl_types.h | 2 +- headers/posix/null.h | 2 +- headers/posix/poll.h | 2 +- headers/posix/pwd.h | 2 +- headers/posix/resolv.h | 2 +- headers/posix/sched.h | 2 +- headers/posix/search.h | 8 ++++---- headers/posix/semaphore.h | 2 +- headers/posix/setjmp.h | 2 +- headers/posix/shadow.h | 2 +- headers/posix/size_t.h | 2 +- headers/posix/stdint.h | 2 +- headers/posix/stdio.h | 2 +- headers/posix/stdio_ext.h | 2 +- headers/posix/stdio_post.h | 2 +- headers/posix/stdio_pre.h | 2 +- headers/posix/stdlib.h | 2 +- headers/posix/string.h | 2 +- headers/posix/sys/file.h | 2 +- headers/posix/sys/ioctl.h | 2 +- headers/posix/sys/ipc.h | 2 +- headers/posix/sys/mman.h | 2 +- headers/posix/sys/msg.h | 2 +- headers/posix/sys/param.h | 2 +- headers/posix/sys/poll.h | 2 +- headers/posix/sys/resource.h | 2 +- headers/posix/sys/select.h | 2 +- headers/posix/sys/sem.h | 2 +- headers/posix/sys/socket.h | 6 +++--- headers/posix/sys/sockio.h | 6 +++--- headers/posix/sys/stat.h | 2 +- headers/posix/sys/statvfs.h | 2 +- headers/posix/sys/time.h | 2 +- headers/posix/sys/timeb.h | 2 +- headers/posix/sys/times.h | 4 ++-- headers/posix/sys/types.h | 2 +- headers/posix/sys/uio.h | 2 +- headers/posix/sys/un.h | 4 ++-- headers/posix/sys/utsname.h | 2 +- headers/posix/syslog.h | 2 +- headers/posix/termios.h | 2 +- headers/posix/utime.h | 2 +- headers/posix/wchar.h | 2 +- headers/posix/wchar_t.h | 2 +- headers/posix/wctype.h | 2 +- 92 files changed, 112 insertions(+), 112 deletions(-) diff --git a/headers/posix/alloca.h b/headers/posix/alloca.h index 82bc2971c0..dfe8f0d180 100644 --- a/headers/posix/alloca.h +++ b/headers/posix/alloca.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ALLOCA_H diff --git a/headers/posix/arch/arm/arch_setjmp.h b/headers/posix/arch/arm/arch_setjmp.h index 7db0bea9fe..d1f1a14a10 100644 --- a/headers/posix/arch/arm/arch_setjmp.h +++ b/headers/posix/arch/arm/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/arm/signal.h b/headers/posix/arch/arm/signal.h index a6572ab074..19a593d5db 100644 --- a/headers/posix/arch/arm/signal.h +++ b/headers/posix/arch/arm/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -32,7 +32,7 @@ struct vregs ulong cpsr; #warning ARM: fix floats in vregs, add missing stuff. }; -#endif /* __ARM__ */ +#endif /* __ARM__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/m68k/arch_setjmp.h b/headers/posix/arch/m68k/arch_setjmp.h index 6bf077a3f3..4aa8146a7f 100644 --- a/headers/posix/arch/m68k/arch_setjmp.h +++ b/headers/posix/arch/m68k/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2010 Haiku Inc. All Rights Reserved. + * Copyright 2007-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/m68k/signal.h b/headers/posix/arch/m68k/signal.h index 8ff2f3e23a..6623e7a09d 100644 --- a/headers/posix/arch/m68k/signal.h +++ b/headers/posix/arch/m68k/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -21,7 +21,7 @@ struct vregs double f0, /* fp scratch */ f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13; /* fp volatile regs */ }; -#endif /* __M68K__ */ +#endif /* __M68K__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/mipsel/arch_setjmp.h b/headers/posix/arch/mipsel/arch_setjmp.h index 8c7189cddc..66e147e37e 100644 --- a/headers/posix/arch/mipsel/arch_setjmp.h +++ b/headers/posix/arch/mipsel/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/mipsel/signal.h b/headers/posix/arch/mipsel/signal.h index 37dfb97261..a3e1f22318 100644 --- a/headers/posix/arch/mipsel/signal.h +++ b/headers/posix/arch/mipsel/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -18,7 +18,7 @@ struct vregs #warning MIPSEL: fixme }; -#endif /* __MIPSEL__ */ +#endif /* __MIPSEL__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/ppc/arch_setjmp.h b/headers/posix/arch/ppc/arch_setjmp.h index 93d552b1f4..f4e9cf16e5 100644 --- a/headers/posix/arch/ppc/arch_setjmp.h +++ b/headers/posix/arch/ppc/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/ppc/signal.h b/headers/posix/arch/ppc/signal.h index bdb67ce940..c1ef3f58d7 100644 --- a/headers/posix/arch/ppc/signal.h +++ b/headers/posix/arch/ppc/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -27,7 +27,7 @@ struct vregs fpscr, /* fp condition codes */ ctr, xer, cr, msr, lr; /* misc. status */ }; -#endif /* __POWERPC__ */ +#endif /* __POWERPC__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/x86/arch_setjmp.h b/headers/posix/arch/x86/arch_setjmp.h index 5221087a78..f5d944f4b3 100644 --- a/headers/posix/arch/x86/arch_setjmp.h +++ b/headers/posix/arch/x86/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/x86/signal.h b/headers/posix/arch/x86/signal.h index 6d04281499..be3e743055 100644 --- a/headers/posix/arch/x86/signal.h +++ b/headers/posix/arch/x86/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ diff --git a/headers/posix/arch/x86_64/arch_setjmp.h b/headers/posix/arch/x86_64/arch_setjmp.h index 3780e9bb78..8371471f01 100644 --- a/headers/posix/arch/x86_64/arch_setjmp.h +++ b/headers/posix/arch/x86_64/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/x86_64/signal.h b/headers/posix/arch/x86_64/signal.h index bc97f98c6e..f48a72f5fa 100644 --- a/headers/posix/arch/x86_64/signal.h +++ b/headers/posix/arch/x86_64/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -40,7 +40,7 @@ struct vregs { */ }; - + #endif /* __x86_64__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arpa/inet.h b/headers/posix/arpa/inet.h index 1c3c19168b..95ee6e3a91 100644 --- a/headers/posix/arpa/inet.h +++ b/headers/posix/arpa/inet.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Haiku Inc. All Rights Reserved. + * Copyright 2009-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _INET_H_ diff --git a/headers/posix/arpa/nameser.h b/headers/posix/arpa/nameser.h index f62cdc496c..ae88a7a9aa 100644 --- a/headers/posix/arpa/nameser.h +++ b/headers/posix/arpa/nameser.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/assert.h b/headers/posix/assert.h index 1d47bd0ad6..b8668925d9 100644 --- a/headers/posix/assert.h +++ b/headers/posix/assert.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ASSERT_H_ diff --git a/headers/posix/bsd_mem.h b/headers/posix/bsd_mem.h index 0d2182aac5..a0e773cbee 100644 --- a/headers/posix/bsd_mem.h +++ b/headers/posix/bsd_mem.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/compat/sys/stat.h b/headers/posix/compat/sys/stat.h index 9722e118c3..94aeca1933 100644 --- a/headers/posix/compat/sys/stat.h +++ b/headers/posix/compat/sys/stat.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _COMPAT_SYS_STAT_H_ diff --git a/headers/posix/ctype.h b/headers/posix/ctype.h index 9d75cea58c..57b2820eff 100644 --- a/headers/posix/ctype.h +++ b/headers/posix/ctype.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _CTYPE_H diff --git a/headers/posix/dirent.h b/headers/posix/dirent.h index ea8d941be8..9622a265ac 100644 --- a/headers/posix/dirent.h +++ b/headers/posix/dirent.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _DIRENT_H diff --git a/headers/posix/div_t.h b/headers/posix/div_t.h index 990240b93c..94b783225a 100644 --- a/headers/posix/div_t.h +++ b/headers/posix/div_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _DIV_T_H_ diff --git a/headers/posix/dlfcn.h b/headers/posix/dlfcn.h index 2b0a63fe09..7fdce4fc64 100644 --- a/headers/posix/dlfcn.h +++ b/headers/posix/dlfcn.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _DLFCN_H diff --git a/headers/posix/endian.h b/headers/posix/endian.h index a02cf9efe9..ba93bb128a 100644 --- a/headers/posix/endian.h +++ b/headers/posix/endian.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All rights reserved. + * Copyright 2003-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _ENDIAN_H_ diff --git a/headers/posix/errno.h b/headers/posix/errno.h index e124f0ea89..045b24ec74 100644 --- a/headers/posix/errno.h +++ b/headers/posix/errno.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _POSIX_ERRNO_H @@ -9,7 +9,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif #include @@ -21,6 +21,6 @@ extern int *_errnop(void); #ifdef __cplusplus } /* "C" */ -#endif +#endif #endif /* _POSIX_ERRNO_H */ diff --git a/headers/posix/fcntl.h b/headers/posix/fcntl.h index a5561b3cd9..ad762f5b0d 100644 --- a/headers/posix/fcntl.h +++ b/headers/posix/fcntl.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _FCNTL_H diff --git a/headers/posix/getopt.h b/headers/posix/getopt.h index c39556bdd0..49694a6c1b 100644 --- a/headers/posix/getopt.h +++ b/headers/posix/getopt.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _GETOPT_H diff --git a/headers/posix/grp.h b/headers/posix/grp.h index 7be9cca96f..e44c15c9f6 100644 --- a/headers/posix/grp.h +++ b/headers/posix/grp.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _GRP_H_ diff --git a/headers/posix/inttypes.h b/headers/posix/inttypes.h index 5f24eda435..8abc015b68 100644 --- a/headers/posix/inttypes.h +++ b/headers/posix/inttypes.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All rights reserved. + * Copyright 2002-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _INTTYPES_H_ diff --git a/headers/posix/iovec.h b/headers/posix/iovec.h index ec10f21acd..be253e3f01 100644 --- a/headers/posix/iovec.h +++ b/headers/posix/iovec.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _IOVEC_H diff --git a/headers/posix/langinfo.h b/headers/posix/langinfo.h index 1ee23de3da..cbd63bd8b2 100644 --- a/headers/posix/langinfo.h +++ b/headers/posix/langinfo.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _LANGINFO_H_ diff --git a/headers/posix/libgen.h b/headers/posix/libgen.h index a89bf98678..3cff2618f7 100644 --- a/headers/posix/libgen.h +++ b/headers/posix/libgen.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Haiku Inc. All Rights Reserved. + * Copyright 2009-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _LIBGEN_H diff --git a/headers/posix/limits.h b/headers/posix/limits.h index 5f90d74059..e010cf3ea2 100644 --- a/headers/posix/limits.h +++ b/headers/posix/limits.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2012 Haiku Inc. All rights reserved. + * Copyright 2001-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _LIBC_LIMITS_H_ diff --git a/headers/posix/locale.h b/headers/posix/locale.h index 624c717844..2cc8717623 100644 --- a/headers/posix/locale.h +++ b/headers/posix/locale.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _LOCALE_H_ diff --git a/headers/posix/malloc.h b/headers/posix/malloc.h index c5cc068e95..b36b17d9e9 100644 --- a/headers/posix/malloc.h +++ b/headers/posix/malloc.h @@ -1,12 +1,12 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _MALLOC_H #define _MALLOC_H -#include +#include #ifdef __cplusplus diff --git a/headers/posix/malloc_debug.h b/headers/posix/malloc_debug.h index 1bfe75a809..0c23bbb9e7 100644 --- a/headers/posix/malloc_debug.h +++ b/headers/posix/malloc_debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef MALLOC_DEBUG_H diff --git a/headers/posix/math.h b/headers/posix/math.h index 1089c05d83..df34b2594c 100644 --- a/headers/posix/math.h +++ b/headers/posix/math.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010 Haiku Inc. All Rights Reserved. + * Copyright 2001-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _MATH_H_ diff --git a/headers/posix/memory.h b/headers/posix/memory.h index f218fba642..16940bbe40 100644 --- a/headers/posix/memory.h +++ b/headers/posix/memory.h @@ -1,8 +1,8 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ - - + + #include diff --git a/headers/posix/monetary.h b/headers/posix/monetary.h index a2877576d4..0624f4c31c 100644 --- a/headers/posix/monetary.h +++ b/headers/posix/monetary.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _MONETARY_H_ diff --git a/headers/posix/net/if.h b/headers/posix/net/if.h index fdeff5d579..80522f2bc8 100644 --- a/headers/posix/net/if.h +++ b/headers/posix/net/if.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_H diff --git a/headers/posix/net/if_dl.h b/headers/posix/net/if_dl.h index 50bb72250a..b7dc7ad99b 100644 --- a/headers/posix/net/if_dl.h +++ b/headers/posix/net/if_dl.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_DL_H diff --git a/headers/posix/net/if_media.h b/headers/posix/net/if_media.h index 4e70897c6a..e0fdc4e76d 100644 --- a/headers/posix/net/if_media.h +++ b/headers/posix/net/if_media.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2010 Haiku Inc. All Rights Reserved. + * Copyright 2007-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_MEDIA_H diff --git a/headers/posix/net/if_types.h b/headers/posix/net/if_types.h index f954c33048..fda4534f03 100644 --- a/headers/posix/net/if_types.h +++ b/headers/posix/net/if_types.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_TYPES_H diff --git a/headers/posix/net/route.h b/headers/posix/net/route.h index 4e021fd620..70e81e8d9e 100644 --- a/headers/posix/net/route.h +++ b/headers/posix/net/route.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_ROUTE_H diff --git a/headers/posix/netdb.h b/headers/posix/netdb.h index d29eceed06..c6a6aff208 100644 --- a/headers/posix/netdb.h +++ b/headers/posix/netdb.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/netinet/in.h b/headers/posix/netinet/in.h index c729b738d2..36310d1161 100644 --- a/headers/posix/netinet/in.h +++ b/headers/posix/netinet/in.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NETINET_IN_H_ diff --git a/headers/posix/netinet/tcp.h b/headers/posix/netinet/tcp.h index 4d3124653a..f865c58239 100644 --- a/headers/posix/netinet/tcp.h +++ b/headers/posix/netinet/tcp.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef NETINET_TCP_H @@ -15,7 +15,7 @@ struct tcphdr { uint16_t th_dport; /* destination port */ uint32_t th_seq; uint32_t th_ack; - + #if BIG_ENDIAN uint8_t th_off : 4; /* data offset */ uint8_t th_x2 : 4; /* unused */ diff --git a/headers/posix/netinet6/in6.h b/headers/posix/netinet6/in6.h index 1898617d66..f348d60a27 100644 --- a/headers/posix/netinet6/in6.h +++ b/headers/posix/netinet6/in6.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NETINET6_IN6_H_ diff --git a/headers/posix/nl_types.h b/headers/posix/nl_types.h index 6a91f93fbc..a437a9e328 100644 --- a/headers/posix/nl_types.h +++ b/headers/posix/nl_types.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NL_TYPES_H_ diff --git a/headers/posix/null.h b/headers/posix/null.h index 9d63e4f46e..c74b189c9a 100644 --- a/headers/posix/null.h +++ b/headers/posix/null.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NULL_H diff --git a/headers/posix/poll.h b/headers/posix/poll.h index 3580699c4d..8935f66fae 100644 --- a/headers/posix/poll.h +++ b/headers/posix/poll.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _POLL_H diff --git a/headers/posix/pwd.h b/headers/posix/pwd.h index ea5b604ec6..f08e96c6df 100644 --- a/headers/posix/pwd.h +++ b/headers/posix/pwd.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _PWD_H_ diff --git a/headers/posix/resolv.h b/headers/posix/resolv.h index 7ed5767697..2b1b569b1f 100644 --- a/headers/posix/resolv.h +++ b/headers/posix/resolv.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Haiku Inc. All Rights Reserved. + * Copyright 2009-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/sched.h b/headers/posix/sched.h index 543c2a3523..c37f757049 100644 --- a/headers/posix/sched.h +++ b/headers/posix/sched.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All rights reserved. + * Copyright 2008-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. */ #ifndef _SCHED_H_ diff --git a/headers/posix/search.h b/headers/posix/search.h index 8892c9b4fd..60bb76f77a 100644 --- a/headers/posix/search.h +++ b/headers/posix/search.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SEARCH_H_ @@ -9,9 +9,9 @@ #include -typedef enum { - FIND, - ENTER +typedef enum { + FIND, + ENTER } ACTION; typedef struct entry { diff --git a/headers/posix/semaphore.h b/headers/posix/semaphore.h index 8d6708f360..6be5f81bfb 100644 --- a/headers/posix/semaphore.h +++ b/headers/posix/semaphore.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. + * Copyright 2008-2012 Haiku, Inc. * Distributed under the terms of the MIT License. */ #ifndef _SEMAPHORE_H_ diff --git a/headers/posix/setjmp.h b/headers/posix/setjmp.h index 30b24ea0be..67f4ec04be 100644 --- a/headers/posix/setjmp.h +++ b/headers/posix/setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. + * Copyright 2004-2012 Haiku, Inc. * Distributed under the terms of the MIT License. */ #ifndef _SETJMP_H_ diff --git a/headers/posix/shadow.h b/headers/posix/shadow.h index 1866be6a06..ed85ee07ec 100644 --- a/headers/posix/shadow.h +++ b/headers/posix/shadow.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SHADOW_H_ diff --git a/headers/posix/size_t.h b/headers/posix/size_t.h index aaf4bc0cb3..f8235c914f 100644 --- a/headers/posix/size_t.h +++ b/headers/posix/size_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SIZE_T_H_ diff --git a/headers/posix/stdint.h b/headers/posix/stdint.h index 37c5e67bd4..eb07104a5a 100644 --- a/headers/posix/stdint.h +++ b/headers/posix/stdint.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDINT_H_ diff --git a/headers/posix/stdio.h b/headers/posix/stdio.h index aa8fd9e5ef..f5ad972b07 100644 --- a/headers/posix/stdio.h +++ b/headers/posix/stdio.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_H_ diff --git a/headers/posix/stdio_ext.h b/headers/posix/stdio_ext.h index 95d533da0a..fb0c4c28a3 100644 --- a/headers/posix/stdio_ext.h +++ b/headers/posix/stdio_ext.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_EXT_H_ diff --git a/headers/posix/stdio_post.h b/headers/posix/stdio_post.h index 83662d8cdf..71a841dfc2 100644 --- a/headers/posix/stdio_post.h +++ b/headers/posix/stdio_post.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_POST_H_ diff --git a/headers/posix/stdio_pre.h b/headers/posix/stdio_pre.h index 5e973422aa..3d37b86e4d 100644 --- a/headers/posix/stdio_pre.h +++ b/headers/posix/stdio_pre.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_PRE_H_ diff --git a/headers/posix/stdlib.h b/headers/posix/stdlib.h index efec9062a5..aef3e9184e 100644 --- a/headers/posix/stdlib.h +++ b/headers/posix/stdlib.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDLIB_H_ diff --git a/headers/posix/string.h b/headers/posix/string.h index f7e4ab4b1f..d3a9035364 100644 --- a/headers/posix/string.h +++ b/headers/posix/string.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STRING_H_ diff --git a/headers/posix/sys/file.h b/headers/posix/sys/file.h index 01839a6236..a7c3384c9d 100644 --- a/headers/posix/sys/file.h +++ b/headers/posix/sys/file.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_FILE_H diff --git a/headers/posix/sys/ioctl.h b/headers/posix/sys/ioctl.h index ee32b3c718..22c3094cfa 100644 --- a/headers/posix/sys/ioctl.h +++ b/headers/posix/sys/ioctl.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_IOCTL_H diff --git a/headers/posix/sys/ipc.h b/headers/posix/sys/ipc.h index 2b2cbff93a..90ed41ef87 100644 --- a/headers/posix/sys/ipc.h +++ b/headers/posix/sys/ipc.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_IPC_H diff --git a/headers/posix/sys/mman.h b/headers/posix/sys/mman.h index c5f9f2ce40..a69991ac05 100644 --- a/headers/posix/sys/mman.h +++ b/headers/posix/sys/mman.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_MMAN_H diff --git a/headers/posix/sys/msg.h b/headers/posix/sys/msg.h index 9d5256d9a6..5ab90b46af 100644 --- a/headers/posix/sys/msg.h +++ b/headers/posix/sys/msg.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_MSG_H diff --git a/headers/posix/sys/param.h b/headers/posix/sys/param.h index e28f0239cb..3e5c2b0b66 100644 --- a/headers/posix/sys/param.h +++ b/headers/posix/sys/param.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_PARAM_H diff --git a/headers/posix/sys/poll.h b/headers/posix/sys/poll.h index 529cd331a8..c8f1144ee1 100644 --- a/headers/posix/sys/poll.h +++ b/headers/posix/sys/poll.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_POLL_H diff --git a/headers/posix/sys/resource.h b/headers/posix/sys/resource.h index 66e4c2d597..96ac924a20 100644 --- a/headers/posix/sys/resource.h +++ b/headers/posix/sys/resource.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_RESOURCE_H diff --git a/headers/posix/sys/select.h b/headers/posix/sys/select.h index 4a99504312..ebc9d0e49d 100644 --- a/headers/posix/sys/select.h +++ b/headers/posix/sys/select.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SELECT_H diff --git a/headers/posix/sys/sem.h b/headers/posix/sys/sem.h index 0a80354655..4dc8540005 100644 --- a/headers/posix/sys/sem.h +++ b/headers/posix/sys/sem.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SEM_H diff --git a/headers/posix/sys/socket.h b/headers/posix/sys/socket.h index 1962acea96..0514d91dda 100644 --- a/headers/posix/sys/socket.h +++ b/headers/posix/sys/socket.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SOCKET_H @@ -47,7 +47,7 @@ typedef uint32_t socklen_t; #define SOCK_MISC 255 /* Socket options for SOL_SOCKET level */ -#define SOL_SOCKET -1 +#define SOL_SOCKET -1 #define SO_ACCEPTCONN 0x00000001 /* socket has had listen() */ #define SO_BROADCAST 0x00000002 /* permit sending of broadcast msgs */ @@ -85,7 +85,7 @@ struct linger { }; struct sockaddr { - uint8_t sa_len; + uint8_t sa_len; uint8_t sa_family; uint8_t sa_data[30]; }; diff --git a/headers/posix/sys/sockio.h b/headers/posix/sys/sockio.h index 666f05fa76..e486f50241 100644 --- a/headers/posix/sys/sockio.h +++ b/headers/posix/sys/sockio.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SOCKIO_H @@ -47,9 +47,9 @@ #define SIOCGIFSTATS 8929 /* get interface stats */ #define SIOCGIFTYPE 8931 /* get interface type */ -#define SIOCSPACKETCAP 8932 +#define SIOCSPACKETCAP 8932 /* Start capturing packets on an interface */ -#define SIOCCPACKETCAP 8933 +#define SIOCCPACKETCAP 8933 /* Stop capturing packets on an interface */ #define SIOCSHIWAT 8934 /* set high watermark */ diff --git a/headers/posix/sys/stat.h b/headers/posix/sys/stat.h index 90a10d0d38..358354c6a8 100644 --- a/headers/posix/sys/stat.h +++ b/headers/posix/sys/stat.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_STAT_H_ diff --git a/headers/posix/sys/statvfs.h b/headers/posix/sys/statvfs.h index 916f06083a..4d86ad229c 100644 --- a/headers/posix/sys/statvfs.h +++ b/headers/posix/sys/statvfs.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STAT_VFS_H_ diff --git a/headers/posix/sys/time.h b/headers/posix/sys/time.h index e8606791fc..62f2efee0c 100644 --- a/headers/posix/sys/time.h +++ b/headers/posix/sys/time.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TIME_H diff --git a/headers/posix/sys/timeb.h b/headers/posix/sys/timeb.h index c338d45d49..e1e2742b8a 100644 --- a/headers/posix/sys/timeb.h +++ b/headers/posix/sys/timeb.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TIMEB_H diff --git a/headers/posix/sys/times.h b/headers/posix/sys/times.h index 296e814900..bef2d83072 100644 --- a/headers/posix/sys/times.h +++ b/headers/posix/sys/times.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TIMES_H @@ -21,6 +21,6 @@ extern #ifdef __cplusplus "C" #endif -clock_t times(struct tms *tms); +clock_t times(struct tms *tms); #endif /* _SYS_TIMES_H */ diff --git a/headers/posix/sys/types.h b/headers/posix/sys/types.h index 4a12ba06f8..7ae5450630 100644 --- a/headers/posix/sys/types.h +++ b/headers/posix/sys/types.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TYPES_H diff --git a/headers/posix/sys/uio.h b/headers/posix/sys/uio.h index ea23c1513b..2e637e40f3 100644 --- a/headers/posix/sys/uio.h +++ b/headers/posix/sys/uio.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_UIO_H diff --git a/headers/posix/sys/un.h b/headers/posix/sys/un.h index 4f55ea4a4a..0cdd5783ae 100644 --- a/headers/posix/sys/un.h +++ b/headers/posix/sys/un.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_UN_H @@ -10,7 +10,7 @@ struct sockaddr_un { - uint8_t sun_len; + uint8_t sun_len; uint8_t sun_family; char sun_path[126]; }; diff --git a/headers/posix/sys/utsname.h b/headers/posix/sys/utsname.h index 43fd413871..8b3db846b1 100644 --- a/headers/posix/sys/utsname.h +++ b/headers/posix/sys/utsname.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_UTSNAME_H diff --git a/headers/posix/syslog.h b/headers/posix/syslog.h index aae1ad8d8c..d0ee5ca577 100644 --- a/headers/posix/syslog.h +++ b/headers/posix/syslog.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYSLOG_H_ diff --git a/headers/posix/termios.h b/headers/posix/termios.h index 88db94675a..ccf13ea7c2 100644 --- a/headers/posix/termios.h +++ b/headers/posix/termios.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _TERMIOS_H_ diff --git a/headers/posix/utime.h b/headers/posix/utime.h index b29d46191b..485eea9b7a 100644 --- a/headers/posix/utime.h +++ b/headers/posix/utime.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _UTIME_H_ diff --git a/headers/posix/wchar.h b/headers/posix/wchar.h index d2bebb9213..eebc4e5bba 100644 --- a/headers/posix/wchar.h +++ b/headers/posix/wchar.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2011 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _WCHAR_H diff --git a/headers/posix/wchar_t.h b/headers/posix/wchar_t.h index a0b412335a..30077e5791 100644 --- a/headers/posix/wchar_t.h +++ b/headers/posix/wchar_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/wctype.h b/headers/posix/wctype.h index f71bac7393..00d7776542 100644 --- a/headers/posix/wctype.h +++ b/headers/posix/wctype.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2011 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _WCTYPE_H_ From d9879eddbf9e4b01f07679af1769e9f439d4e0ef Mon Sep 17 00:00:00 2001 From: ahenriksson Date: Tue, 17 Jul 2012 21:11:18 +0200 Subject: [PATCH 42/46] A duplicate array with a single value is not allowed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Such arrays could be created by the BFS code between hrev43837 and hrev43924, and cause the array to not be free'd when the entry is removed. The check in _InsertDuplicate() is not changed, as doing an insertion will actually repair this problem. Potentially, the code could be modified to handle this state instead, but since checkfs can fix it, it doesn't seem necessary. Signed-off-by: Axel Dörfler --- src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp index 90972f37ec..51b896a17b 100644 --- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp @@ -1782,7 +1782,7 @@ BPlusTree::_RemoveDuplicate(Transaction& transaction, bplustree_node::FragmentIndex(oldValue)); int32 arrayCount = array->Count(); - if (arrayCount > NUM_FRAGMENT_VALUES || arrayCount < 1) { + if (arrayCount > NUM_FRAGMENT_VALUES || arrayCount <= 1) { FATAL(("_RemoveDuplicate: Invalid array[%d] size in fragment %" B_PRIdOFF " == %" B_PRId32 ", inode %" B_PRIdOFF "!\n", (int)bplustree_node::FragmentIndex(oldValue), duplicateOffset, @@ -2361,7 +2361,7 @@ BPlusTree::_ValidateChildren(TreeCheck& check, uint32 level, off_t offset, } int32 arrayCount = array->Count(); - if (arrayCount < 1 || arrayCount > maxSize) { + if (arrayCount <= 1 || arrayCount > maxSize) { dprintf("inode %" B_PRIdOFF ": duplicate at %" B_PRIdOFF " has invalid array size %" B_PRId32 "!\n", fStream->ID(), duplicateOffset, arrayCount); From 02378956042046a9fc635820f73d2cbeb7a4b5df Mon Sep 17 00:00:00 2001 From: ahenriksson Date: Tue, 17 Jul 2012 21:23:22 +0200 Subject: [PATCH 43/46] CheckBlocks() calculated the group block incorrectly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Axel Dörfler --- src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index 8dc8f3f4b0..b0d446f75b 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -1699,9 +1699,11 @@ BlockAllocator::CheckBlocks(off_t start, off_t length, bool allocated) if (start < 0 || start + length > fVolume->NumBlocks()) return B_BAD_VALUE; - uint32 group = start >> fVolume->AllocationGroupShift(); - uint32 groupBlock = start / (fVolume->BlockSize() << 3); - uint32 blockOffset = start % fVolume->BlockSize(); + int32 group = start >> fVolume->AllocationGroupShift(); + uint32 bitmapBlock = start / (fVolume->BlockSize() << 3); + uint32 blockOffset = start % (fVolume->BlockSize() << 3); + + uint32 groupBlock = bitmapBlock % fBlocksPerGroup; AllocationBlock cached(fVolume); From 1f80f2eec3fcca13f5d0f4e146bde2058672a0ab Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 19 Jul 2012 20:21:06 -0400 Subject: [PATCH 44/46] Fix #8749. - When a job needs to go dependent on another job, we no longer use recursion to manage the execution stack. Instead the job is simply marked as waiting and we execute other jobs with no dependencies in the meantime. When a job completes, all dependents are moved back onto the unscheduled list and executed as needed. - Adjustments to ResolveValueNodeJob to handle the now asynchronous nature of waiting. --- src/apps/debugger/Jobs.cpp | 6 +++++ src/apps/debugger/Worker.cpp | 45 +++++++++++++++++------------------- src/apps/debugger/Worker.h | 2 +- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/apps/debugger/Jobs.cpp b/src/apps/debugger/Jobs.cpp index 0e812cc114..bfd2fe11dc 100644 --- a/src/apps/debugger/Jobs.cpp +++ b/src/apps/debugger/Jobs.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2012, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -523,6 +524,9 @@ ResolveValueNodeValueJob::_ResolveNodeValue() fValueNode, fValueNode->Name().String(), parentNode); return error; } + + if (State() == JOB_STATE_WAITING) + return B_OK; } // resolve the node child location, if necessary @@ -629,6 +633,8 @@ ResolveValueNodeValueJob::_ResolveParentNodeValue(ValueNode* parentNode) // "Not found" can happen due to a race condition between // unlocking the worker and starting to wait. break; + case JOB_DEPENDENCY_ACTIVE: + return B_OK; case JOB_DEPENDENCY_FAILED: case JOB_DEPENDENCY_ABORTED: default: diff --git a/src/apps/debugger/Worker.cpp b/src/apps/debugger/Worker.cpp index dc1f06af09..409ff2b5b9 100644 --- a/src/apps/debugger/Worker.cpp +++ b/src/apps/debugger/Worker.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2012, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -138,6 +139,15 @@ void Job::SetWaitStatus(job_wait_status status) { fWaitStatus = status; + switch (fWaitStatus) { + case JOB_DEPENDENCY_ACTIVE: + fState = JOB_STATE_WAITING; + break; + default: + fState = JOB_STATE_ACTIVE; + break; + + } } @@ -346,18 +356,6 @@ Worker::WaitForJob(Job* waitingJob, const JobKey& key) waitingJob->SetDependency(job); job->DependentJobs().Add(waitingJob); - // TODO: Continuations would be nice. For the time being we have to use - // recursion. Disadvantages are that we'll use more stack and that aborting - // a job waiting for a dependency won't abort the job before the dependency - // is done. - locker.Unlock(); - _ProcessJobs(waitingJob); - locker.Lock(); - - // ignore the actual wait status when the game is over anyway - if (fTerminating || waitingJob->State() == JOB_STATE_ABORTED) - return JOB_DEPENDENCY_ABORTED; - return waitingJob->WaitStatus(); } @@ -372,7 +370,7 @@ Worker::_WorkerLoopEntry(void* data) status_t Worker::_WorkerLoop() { - _ProcessJobs(NULL); + _ProcessJobs(); // clean up aborted jobs AutoLocker locker(this); @@ -384,7 +382,7 @@ Worker::_WorkerLoop() void -Worker::_ProcessJobs(Job* waitingJob) +Worker::_ProcessJobs() { while (true) { AutoLocker locker(this); @@ -395,8 +393,10 @@ Worker::_ProcessJobs(Job* waitingJob) status_t error = acquire_sem(fWorkToDoSem); if (error != B_OK) { - if (error == B_INTERRUPTED) + if (error == B_INTERRUPTED) { + locker.Lock(); continue; + } break; } @@ -404,13 +404,9 @@ Worker::_ProcessJobs(Job* waitingJob) } // clean up aborted jobs - while (Job* job = fAbortedJobs.RemoveHead()) { + while (Job* job = fAbortedJobs.RemoveHead()) _FinishJob(job); - if (waitingJob != NULL && waitingJob->State() != JOB_STATE_WAITING) - break; - } - // process the next job if (Job* job = fUnscheduledJobs.RemoveHead()) { job->SetState(JOB_STATE_ACTIVE); @@ -422,12 +418,10 @@ Worker::_ProcessJobs(Job* waitingJob) if (job->State() == JOB_STATE_ACTIVE) { job->SetState( error == B_OK ? JOB_STATE_SUCCEEDED : JOB_STATE_FAILED); - } + } else if (job->State() == JOB_STATE_WAITING) + continue; _FinishJob(job); - - if (waitingJob != NULL && waitingJob->State() != JOB_STATE_WAITING) - break; } } } @@ -492,7 +486,10 @@ Worker::_FinishJob(Job* job) while (Job* dependentJob = job->DependentJobs().RemoveHead()) { dependentJob->SetDependency(NULL); dependentJob->SetWaitStatus(waitStatus); + fUnscheduledJobs.Add(dependentJob); } + + release_sem(fWorkToDoSem); } if (job->State() != JOB_STATE_ABORTED) diff --git a/src/apps/debugger/Worker.h b/src/apps/debugger/Worker.h index 241a3f4afa..7e356992a7 100644 --- a/src/apps/debugger/Worker.h +++ b/src/apps/debugger/Worker.h @@ -182,7 +182,7 @@ private: static status_t _WorkerLoopEntry(void* data); status_t _WorkerLoop(); - void _ProcessJobs(Job* waitingJob); + void _ProcessJobs(); void _AbortJob(Job* job, bool removeFromTable); void _FinishJob(Job* job); From 0b4ae860860072dfbca7f50bdad5ab5e232bab72 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 19 Jul 2012 20:58:57 -0400 Subject: [PATCH 45/46] Fix #8751 and possibly also #7198. - The cdrecord port was using the wrong path for searching for SCSI devices. This led to it failing to find SATA CD drives. Updated package by Chris Roberts. --- build/jam/OptionalPackageDependencies | 2 +- build/jam/OptionalPackages | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/jam/OptionalPackageDependencies b/build/jam/OptionalPackageDependencies index aa4a525d3b..9bca225c2e 100644 --- a/build/jam/OptionalPackageDependencies +++ b/build/jam/OptionalPackageDependencies @@ -10,7 +10,7 @@ OptionalPackageDependencies ArmyKnife : TagLib ; OptionalPackageDependencies Beam : LibIconv LibLayout OpenSSL PCRE ; OptionalPackageDependencies BeHappy : BeBook NetSurf ; OptionalPackageDependencies BurnItNow : CDRecord ; -OptionalPackageDependencies CDRecord : LibIconv ; +OptionalPackageDependencies CDRecord : GetText LibIconv ; OptionalPackageDependencies Curl : OpenSSL ; OptionalPackageDependencies DevelopmentBase : CDRecord DevelopmentMin Yasm ; OptionalPackageDependencies Development : DevelopmentBase Perl ; diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index f4b3dd97b6..caf1e5e71a 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -409,12 +409,12 @@ if [ IsOptionalHaikuImagePackageAdded CDRecord ] { Echo "No optional package CDRecord available for $(TARGET_ARCH)" ; } else if $(HAIKU_GCC_VERSION[1]) >= 4 { InstallOptionalHaikuImagePackage - cdrtools-3.01a06-x86-gcc4-2012-06-19.zip - : $(baseURL)/cdrtools-3.01a06-x86-gcc4-2012-06-19.zip ; + cdrtools-3.01a07-x86-gcc4-2012-06-19.zip + : $(baseURL)/cdrtools-3.01a07-x86-gcc4-2012-07-19.zip ; } else { InstallOptionalHaikuImagePackage - cdrtools-3.01a06-x86-gcc2-2012-06-20.zip - : $(baseURL)/cdrtools-3.01a06-x86-gcc2-2012-06-20.zip ; + cdrtools-3.01a07-x86-gcc2-2012-07-19-r2.zip + : $(baseURL)/cdrtools-3.01a07-x86-gcc2-2012-07-19-r2.zip ; } } From fe0407cd4604f8c1fe33d3ca436daeae112173b7 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 20 Jul 2012 07:34:11 -0400 Subject: [PATCH 46/46] Fix indentation. --- src/apps/debugger/Worker.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/apps/debugger/Worker.cpp b/src/apps/debugger/Worker.cpp index 409ff2b5b9..304c3bd033 100644 --- a/src/apps/debugger/Worker.cpp +++ b/src/apps/debugger/Worker.cpp @@ -140,13 +140,12 @@ Job::SetWaitStatus(job_wait_status status) { fWaitStatus = status; switch (fWaitStatus) { - case JOB_DEPENDENCY_ACTIVE: - fState = JOB_STATE_WAITING; - break; - default: - fState = JOB_STATE_ACTIVE; - break; - + case JOB_DEPENDENCY_ACTIVE: + fState = JOB_STATE_WAITING; + break; + default: + fState = JOB_STATE_ACTIVE; + break; } }