Merge branch 'master' of ssh://git.haiku-os.org/haiku

This commit is contained in:
Adrien Destugues - PulkoMandy
2012-07-16 19:57:30 +02:00
35 changed files with 1089 additions and 905 deletions
+1
View File
@@ -294,6 +294,7 @@ enum color_which {
B_CONTROL_TEXT_COLOR = 14, B_CONTROL_TEXT_COLOR = 14,
B_CONTROL_BORDER_COLOR = 15, B_CONTROL_BORDER_COLOR = 15,
B_CONTROL_HIGHLIGHT_COLOR = 16, B_CONTROL_HIGHLIGHT_COLOR = 16,
B_CONTROL_MARK_COLOR = 27,
B_NAVIGATION_BASE_COLOR = 4, B_NAVIGATION_BASE_COLOR = 4,
B_NAVIGATION_PULSE_COLOR = 17, B_NAVIGATION_PULSE_COLOR = 17,
B_SHINE_COLOR = 18, B_SHINE_COLOR = 18,
+5 -4
View File
@@ -26,23 +26,24 @@ static inline int32
color_which_to_index(color_which which) color_which_to_index(color_which which)
{ {
// NOTE: this must be kept in sync with InterfaceDefs.h color_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; return which - 1;
if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR) 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; return -1;
} }
static inline color_which static inline color_which
index_to_color_which(int32 index) index_to_color_which(int32 index)
{ {
if (index >= 0 && index < kNumColors) { 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); return (color_which)(index + 1);
else { else {
return (color_which)(index + B_SUCCESS_COLOR return (color_which)(index + B_SUCCESS_COLOR
- B_WINDOW_INACTIVE_BORDER_COLOR); - B_CONTROL_MARK_COLOR);
} }
} }
+11 -3
View File
@@ -257,6 +257,12 @@ detect_displays()
if (displayIndex >= MAX_DISPLAY) if (displayIndex >= MAX_DISPLAY)
continue; 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 // TODO: As DP aux transactions don't work yet, just use LVDS as a hack
#if 0 #if 0
if (gConnector[id]->encoderExternal.isDPBridge == true) { if (gConnector[id]->encoderExternal.isDPBridge == true) {
@@ -310,9 +316,11 @@ detect_displays()
TRACE("%s: connector %" B_PRIu32 " has digital EDID " TRACE("%s: connector %" B_PRIu32 " has digital EDID "
"and is not a analog encoder.\n", __func__, id); "and is not a analog encoder.\n", __func__, id);
} else { } else {
// ???, shouldn't happen... I think. // This generally means the monitor is of poor design
TRACE("%s: Warning: connector %" B_PRIu32 " has neither " // Since we *know* there is no load on the analog encoder
"digital EDID nor is an analog encoder?\n", // 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); __func__, id);
} }
} }
+1
View File
@@ -200,6 +200,7 @@ Application Debugger :
VariablesView.cpp VariablesView.cpp
# user_interface/gui/util # user_interface/gui/util
ActionMenuItem.cpp
GUISettingsUtils.cpp GUISettingsUtils.cpp
SettingsMenu.cpp SettingsMenu.cpp
TargetAddressTableColumn.cpp TargetAddressTableColumn.cpp
@@ -218,20 +218,26 @@ TeamWindow::MessageReceived(BMessage* message)
{ {
if (fInspectorWindow) { if (fInspectorWindow) {
fInspectorWindow->Activate(true); 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 { target_addr_t address;
fInspectorWindow = InspectorWindow::Create(fTeam, fListener, if (message->FindUInt64("address", &address) == B_OK) {
this); BMessage addressMessage(MSG_INSPECT_ADDRESS);
if (fInspectorWindow != NULL) { addressMessage.AddUInt64("address", address);
BMessage settings; fInspectorWindow->PostMessage(&addressMessage);
fInspectorWindow->LoadSettings(fUISettings); }
fInspectorWindow->Show();
}
} catch (...) {
// TODO: notify user
}
break; break;
} }
case MSG_INSPECTOR_WINDOW_CLOSED: case MSG_INSPECTOR_WINDOW_CLOSED:
@@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * 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. * Distributed under the terms of the MIT License.
*/ */
@@ -19,6 +19,7 @@
#include "table/TableColumns.h" #include "table/TableColumns.h"
#include "ActionMenuItem.h"
#include "Architecture.h" #include "Architecture.h"
#include "FunctionID.h" #include "FunctionID.h"
#include "FunctionInstance.h" #include "FunctionInstance.h"
@@ -36,6 +37,7 @@
#include "Value.h" #include "Value.h"
#include "ValueHandler.h" #include "ValueHandler.h"
#include "ValueHandlerRoster.h" #include "ValueHandlerRoster.h"
#include "ValueLocation.h"
#include "ValueNode.h" #include "ValueNode.h"
#include "ValueNodeContainer.h" #include "ValueNodeContainer.h"
#include "Variable.h" #include "Variable.h"
@@ -487,34 +489,77 @@ public:
} }
status_t Init(Settings* rendererSettings, status_t Init(Settings* rendererSettings,
SettingsMenu* rendererSettingsMenu) SettingsMenu* rendererSettingsMenu,
ContextActionList* preSettingsActions = NULL,
ContextActionList* postSettingsActions = NULL)
{ {
fRendererSettings = rendererSettings; if (rendererSettings == NULL && preSettingsActions == NULL
fRendererSettings->AcquireReference(); && postSettingsActions == NULL) {
return B_BAD_VALUE;
}
fRendererSettingsMenu = rendererSettingsMenu; if (rendererSettings != NULL) {
fRendererSettingsMenu->AcquireReference(); fRendererSettings = rendererSettings;
fRendererSettings->AcquireReference();
fRendererSettingsMenu = rendererSettingsMenu;
fRendererSettingsMenu->AcquireReference();
}
fContextMenu = new(std::nothrow) ContextMenu(fParent, fContextMenu = new(std::nothrow) ContextMenu(fParent,
"table cell settings popup"); "table cell settings popup");
if (fContextMenu == NULL) if (fContextMenu == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
status_t error = fRendererSettingsMenu->AddToMenu(fContextMenu, 0); status_t error = B_OK;
if (error != B_OK) if (preSettingsActions != NULL
return error; && preSettingsActions->CountItems() > 0) {
error = _AddActionItems(preSettingsActions);
if (error != B_OK)
return error;
AutoLocker<Settings> settingsLocker(fRendererSettings); if (fRendererSettingsMenu != NULL || postSettingsActions != NULL)
fRendererSettings->AddListener(this); fContextMenu->AddSeparatorItem();
}
fRendererMenuAdded = true; 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;
}
if (fRendererSettings != NULL) {
AutoLocker<Settings> settingsLocker(fRendererSettings);
fRendererSettings->AddListener(this);
fRendererMenuAdded = true;
}
return B_OK; return B_OK;
} }
void ShowMenu(BPoint screenWhere) void ShowMenu(BPoint screenWhere)
{ {
fRendererSettingsMenu->PrepareToShow(fParentLooper); if (fRendererMenuAdded)
fRendererSettingsMenu->PrepareToShow(fParentLooper);
for (int32 i = 0; i < fContextMenu->CountItems(); i++) {
ActionMenuItem* item = dynamic_cast<ActionMenuItem*>(
fContextMenu->ItemAt(i));
if (item != NULL)
item->PrepareToShow(fParentLooper, fParent.Target(NULL));
}
fMenuPreparedToShow = true; fMenuPreparedToShow = true;
@@ -528,7 +573,18 @@ public:
bool stillActive = false; bool stillActive = false;
if (fMenuPreparedToShow) { 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<ActionMenuItem*>(
fContextMenu->ItemAt(i));
if (item != NULL) {
stillActive |= item->Finish(fParentLooper,
fParent.Target(NULL), force);
}
}
fMenuPreparedToShow = stillActive; fMenuPreparedToShow = stillActive;
} }
@@ -559,6 +615,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: private:
ModelNode* fNode; ModelNode* fNode;
BLooper* fParentLooper; BLooper* fParentLooper;
@@ -1412,6 +1486,15 @@ void
VariablesView::MessageReceived(BMessage* message) VariablesView::MessageReceived(BMessage* message)
{ {
switch (message->what) { 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: case MSG_VALUE_NODE_CHANGED:
{ {
ValueNodeChild* nodeChild; ValueNodeChild* nodeChild;
@@ -1594,25 +1677,39 @@ VariablesView::TreeTableCellMouseDown(TreeTable* table,
if (node == NULL) if (node == NULL)
return; return;
Settings* settings = NULL;
SettingsMenu* settingsMenu = NULL;
BReference<SettingsMenu> settingsMenuReference;
status_t error = B_OK;
TableCellValueRenderer* cellRenderer = node->TableCellRenderer(); TableCellValueRenderer* cellRenderer = node->TableCellRenderer();
if (cellRenderer == NULL) if (cellRenderer != NULL) {
return; settings = cellRenderer->GetSettings();
if (settings != NULL) {
Settings* settings = cellRenderer->GetSettings(); error = node->GetValueHandler()
if (settings == NULL) ->CreateTableCellValueSettingsMenu(node->GetValue(), settings,
return; settingsMenu);
settingsMenuReference.SetTo(settingsMenu, true);
SettingsMenu* settingsMenu; if (error != B_OK)
status_t error = node->GetValueHandler()->CreateTableCellValueSettingsMenu( return;
node->GetValue(), settings, settingsMenu); }
BReference<SettingsMenu> settingsMenuReference(settingsMenu, true); }
if (error != B_OK)
return;
TableCellContextMenuTracker* tracker = new(std::nothrow) TableCellContextMenuTracker* tracker = new(std::nothrow)
TableCellContextMenuTracker(node, Looper(), this); TableCellContextMenuTracker(node, Looper(), this);
BReference<TableCellContextMenuTracker> trackerReference(tracker); BReference<TableCellContextMenuTracker> trackerReference(tracker);
if (tracker == NULL || tracker->Init(settings, settingsMenu) != B_OK)
ContextActionList* preActionList = new(std::nothrow) ContextActionList;
if (preActionList == NULL)
return;
BPrivate::ObjectDeleter<ContextActionList> preActionListDeleter(
preActionList);
error = _GetContextActionsForNode(node, preActionList);
if (error != B_OK)
return;
if (tracker == NULL || tracker->Init(settings, settingsMenu, preActionList) != B_OK)
return; return;
fTableCellContextMenuTracker = trackerReference.Detach(); fTableCellContextMenuTracker = trackerReference.Detach();
@@ -1679,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<BMessage> 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<ActionMenuItem> actionDeleter(item);
if (!actions->AddItem(item))
return B_NO_MEMORY;
actionDeleter.Detach();
return B_OK;
}
void void
VariablesView::_FinishContextMenu(bool force) VariablesView::_FinishContextMenu(bool force)
{ {
@@ -11,6 +11,7 @@
#include "table/TreeTable.h" #include "table/TreeTable.h"
class ActionMenuItem;
class CpuState; class CpuState;
class SettingsMenu; class SettingsMenu;
class StackFrame; class StackFrame;
@@ -61,13 +62,15 @@ private:
class VariableTableModel; class VariableTableModel;
class ContextMenu; class ContextMenu;
class TableCellContextMenuTracker; class TableCellContextMenuTracker;
typedef BObjectList<ActionMenuItem> ContextActionList;
private: private:
void _Init(); void _Init();
void _RequestNodeValue(ModelNode* node); void _RequestNodeValue(ModelNode* node);
status_t _GetContextActionsForNode(ModelNode* node,
ContextActionList* actions);
void _FinishContextMenu(bool force); void _FinishContextMenu(bool force);
void _SaveViewState() const; void _SaveViewState() const;
void _RestoreViewState(); void _RestoreViewState();
status_t _AddViewStateDescendentNodeInfos( status_t _AddViewStateDescendentNodeInfos(
@@ -0,0 +1,56 @@
/*
* 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 <new>
#include <Looper.h>
// #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)
{
SetTarget(targetHandler);
}
bool
ActionMenuItem::Finish(BLooper* parentLooper, BHandler* targetHandler,
bool force)
{
return false;
}
void
ActionMenuItem::ItemSelected()
{
}
@@ -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 <MenuItem.h>
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
@@ -73,14 +73,24 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
if (dynamic_cast<AddressType*>(fType) != NULL) { if (dynamic_cast<AddressType*>(fType) != NULL) {
error = valueLoader->LoadValue(location, valueType, false, error = valueLoader->LoadValue(location, valueType, false,
addressData); addressData);
if (error != B_OK)
return error;
} else { } else {
addressData.SetTo(location->PieceAt(0).address); addressData.SetTo(location->PieceAt(0).address);
maxSize = dynamic_cast<ArrayType*>(fType) maxSize = dynamic_cast<ArrayType*>(fType)
->DimensionAt(0)->CountElements(); ->DimensionAt(0)->CountElements();
} }
if (error != B_OK) ValuePieceLocation piece;
return error; piece.SetToMemory(addressData.ToUInt64());
ValueLocation* stringLocation = new(std::nothrow) ValueLocation(
valueLoader->GetArchitecture()->IsBigEndian(), piece);
if (stringLocation == NULL)
return B_NO_MEMORY;
BReference<ValueLocation> locationReference(stringLocation, true);
error = valueLoader->LoadStringValue(addressData, maxSize, valueData); error = valueLoader->LoadStringValue(addressData, maxSize, valueData);
if (error != B_OK) if (error != B_OK)
@@ -91,8 +101,8 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
if (value == NULL) if (value == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
location->AcquireReference(); NodeChild()->SetLocation(stringLocation, B_OK);
_location = location; _location = locationReference.Detach();
_value = value; _value = value;
return B_OK; return B_OK;
} }
+26 -28
View File
@@ -7,6 +7,7 @@
#include <Box.h> #include <Box.h>
#include <Catalog.h> #include <Catalog.h>
#include <LayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include "constants.h" #include "constants.h"
@@ -19,46 +20,43 @@
#define B_TRANSLATION_CONTEXT "PoorMan" #define B_TRANSLATION_CONTEXT "PoorMan"
PoorManAdvancedView::PoorManAdvancedView(BRect rect, const char *name) PoorManAdvancedView::PoorManAdvancedView(const char* name)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) :
BView(name, B_WILL_DRAW, NULL)
{ {
PoorManWindow * win; PoorManWindow* win;
win = ((PoorManApplication *)be_app)->GetPoorManWindow(); win = ((PoorManApplication*)be_app)->GetPoorManWindow();
SetViewColor(BACKGROUND_COLOR); BBox* connectionOptions = new BBox(B_TRANSLATE("Connections"));
// 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"));
connectionOptions->SetLabel(STR_BBX_CONNECTION); connectionOptions->SetLabel(STR_BBX_CONNECTION);
AddChild(connectionOptions);
BRect sliderRect; fMaxConnections = new StatusSlider("Max Slider", STR_SLD_LABEL,
sliderRect = connectionOptions->Bounds(); STR_SLD_STATUS_LABEL,
sliderRect.InsetBy(10.0f, 10.0f); new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200);
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);
// labels below the slider 1 and 200 // labels below the slider 1 and 200
maxConnections->SetLimitLabels("1", "200"); fMaxConnections->SetLimitLabels("1", "200");
SetMaxSimutaneousConnections(win->MaxConnections()); SetMaxSimutaneousConnections(win->MaxConnections());
connectionOptions->AddChild(maxConnections);
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(B_USE_ITEM_INSETS);
} }
void void
PoorManAdvancedView::SetMaxSimutaneousConnections(int32 num) PoorManAdvancedView::SetMaxSimutaneousConnections(int32 num)
{ {
if (num <= 0 || num > 200) if (num <= 0 || num > 200)
maxConnections->SetValue(32); fMaxConnections->SetValue(32);
else else
maxConnections->SetValue(num); fMaxConnections->SetValue(num);
} }
+8 -7
View File
@@ -13,16 +13,17 @@
#include "StatusSlider.h" #include "StatusSlider.h"
class PoorManAdvancedView: public BView class PoorManAdvancedView: public BView {
{
public: public:
PoorManAdvancedView(BRect, const char *name); PoorManAdvancedView(const char *name);
int32 MaxSimultaneousConnections() { return maxConnections->Value(); }
void SetMaxSimutaneousConnections(int32 num); int32 MaxSimultaneousConnections()
{ return fMaxConnections->Value(); }
void SetMaxSimutaneousConnections(int32 num);
private: private:
// Advanced Tab // Advanced Tab
// Connections Options // Connections Options
StatusSlider * maxConnections; StatusSlider* fMaxConnections;
}; };
#endif #endif
+38 -54
View File
@@ -7,6 +7,7 @@
#include <Box.h> #include <Box.h>
#include <Catalog.h> #include <Catalog.h>
#include <LayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include "constants.h" #include "constants.h"
@@ -19,80 +20,63 @@
#define B_TRANSLATION_CONTEXT "PoorMan" #define B_TRANSLATION_CONTEXT "PoorMan"
PoorManLoggingView::PoorManLoggingView(BRect rect, const char *name) PoorManLoggingView::PoorManLoggingView(const char* name)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) :
BView(name, B_WILL_DRAW, NULL)
{ {
PoorManWindow * win; PoorManWindow* win;
win = ((PoorManApplication *)be_app)->GetPoorManWindow(); win = ((PoorManApplication*)be_app)->GetPoorManWindow();
SetViewColor(BACKGROUND_COLOR); BBox* consoleLogging = new BBox(B_TRANSLATE("Console Logging"));
// 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"));
consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING); consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING);
AddChild(consoleLogging);
// File Logging BBox // File Logging BBox
BRect fileLoggingRect; BBox* fileLogging = new BBox(B_TRANSLATE("File Logging"));
fileLoggingRect = consoleLoggingRect;
fileLoggingRect.top = consoleLoggingRect.bottom + 10.0;
fileLoggingRect.bottom = fileLoggingRect.top + 100.0;
BBox * fileLogging = new BBox(fileLoggingRect,
B_TRANSLATE("File Logging"));
fileLogging->SetLabel(STR_BBX_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 // 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)); STR_CBX_LOG_CONSOLE, new BMessage(MSG_PREF_LOG_CBX_CONSOLE));
// set the checkbox to the value the program has // set the checkbox to the value the program has
SetLogConsoleValue(win->LogConsoleFlag()); SetLogConsoleValue(win->LogConsoleFlag());
consoleLogging->AddChild(logConsole);
// File Logging // File Logging
logFile = new BCheckBox(tempRect, B_TRANSLATE("Log To File"), fLogFile = new BCheckBox(B_TRANSLATE("Log To File"), STR_CBX_LOG_FILE,
STR_CBX_LOG_FILE, new BMessage(MSG_PREF_LOG_CBX_FILE)); new BMessage(MSG_PREF_LOG_CBX_FILE));
// set the checkbox to the value the program has // set the checkbox to the value the program has
SetLogFileValue(win->LogFileFlag()); SetLogFileValue(win->LogFileFlag());
fileLogging->AddChild(logFile);
// File Name // File Name
tempRect.top = tempRect.bottom + 10.0; fLogFileName = new BTextControl(B_TRANSLATE("File Name"),
tempRect.bottom = tempRect.top + box_size;
tempRect.right -= 5.0;
logFileName = new BTextControl(tempRect, B_TRANSLATE("File Name"),
STR_TXT_LOG_FILE_NAME, NULL, NULL); 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()); SetLogFileName(win->LogPath());
fileLogging->AddChild(logFileName);
// Create Log File // Create Log File
BRect createLogFileRect; fCreateLogFile = new BButton(B_TRANSLATE("Create Log File"),
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"),
STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE)); STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE));
fileLogging->AddChild(createLogFile);
BGroupLayout* consoleLoggingLayout = new BGroupLayout(B_VERTICAL, 0);
consoleLogging->SetLayout(consoleLoggingLayout);
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);
} }
+43 -17
View File
@@ -14,28 +14,54 @@
#include <CheckBox.h> #include <CheckBox.h>
class PoorManLoggingView: public BView class PoorManLoggingView: public BView {
{
public: public:
PoorManLoggingView(BRect, const char *name); PoorManLoggingView(const char* name);
void SetLogConsoleValue(bool state) {if (state) logConsole->SetValue(B_CONTROL_ON); void SetLogConsoleValue(bool state)
else logConsole->SetValue(B_CONTROL_OFF); } {
bool LogConsoleValue() { return (logConsole->Value() == B_CONTROL_ON) ? true : false; } if (state)
void SetLogFileValue(bool state) {if (state) logFile->SetValue(B_CONTROL_ON); fLogConsole->SetValue(B_CONTROL_ON);
else logFile->SetValue(B_CONTROL_OFF); } else
bool LogFileValue() { return (logFile->Value() == B_CONTROL_ON) ? true : false; } fLogConsole->SetValue(B_CONTROL_OFF);
const char * LogFileName() { return logFileName->Text(); } }
void SetLogFileName(const char * log) { logFileName->SetText(log); }
private:
// Logging Tab
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
// Console Logging // Console Logging
BCheckBox * logConsole; BCheckBox* fLogConsole;
// File Logging // File Logging
BCheckBox * logFile; BCheckBox* fLogFile;
BTextControl * logFileName; BTextControl* fLogFileName;
BButton * createLogFile; BButton * fCreateLogFile;
}; };
#endif #endif
+81 -119
View File
@@ -9,6 +9,7 @@
#include <Catalog.h> #include <Catalog.h>
#include <Debug.h> #include <Debug.h>
#include <Directory.h> #include <Directory.h>
#include <LayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include <Window.h> #include <Window.h>
@@ -25,110 +26,71 @@
PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name) PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name)
: BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE
| B_CLOSE_ON_ESCAPE), | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS),
webDirFilePanel(NULL), fWebDirFilePanel(NULL),
logFilePanel(NULL) fLogFilePanel(NULL)
{ {
frame = Bounds(); fCancelButton = new BButton("Cancel Button", B_TRANSLATE("Cancel"),
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"),
new BMessage(MSG_PREF_BTN_CANCEL)); new BMessage(MSG_PREF_BTN_CANCEL));
fDoneButton = new BButton("Done Button", B_TRANSLATE("Done"),
BRect button2(prefView->Bounds().Width() - gap - widthDone, buttonTop,
prefView->Bounds().Width() - gap, buttonTop + buttonHeight);
doneButton = new BButton(button2, "Done Button", B_TRANSLATE("Done"),
new BMessage(MSG_PREF_BTN_DONE)); new BMessage(MSG_PREF_BTN_DONE));
buttonView->AddChild(cancelButton); fPrefTabView = new BTabView("Pref Tab View");
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();
// Site Tab // Site Tab
siteTab = new BTab(); fSiteTab = new BTab();
siteView = new PoorManSiteView(r, "Site View"); fSiteView = new PoorManSiteView("Site View");
prefTabView->AddTab(siteView, siteTab); fPrefTabView->AddTab(fSiteView, fSiteTab);
siteTab->SetLabel(STR_TAB_SITE); fSiteTab->SetLabel(STR_TAB_SITE);
// Logging Tab // Logging Tab
loggingTab = new BTab(); fLoggingTab = new BTab();
loggingView = new PoorManLoggingView(r, "Logging View"); fLoggingView = new PoorManLoggingView("Logging View");
prefTabView->AddTab(loggingView, loggingTab); fPrefTabView->AddTab(fLoggingView, fLoggingTab);
loggingTab->SetLabel(STR_TAB_LOGGING); fLoggingTab->SetLabel(STR_TAB_LOGGING);
// Advanced Tab // Advanced Tab
advancedTab = new BTab(); fAdvancedTab = new BTab();
advancedView = new PoorManAdvancedView(r, "Advanced View"); fAdvancedView = new PoorManAdvancedView("Advanced View");
prefTabView->AddTab(advancedView, advancedTab); fPrefTabView->AddTab(fAdvancedView, fAdvancedTab);
advancedTab->SetLabel(STR_TAB_ADVANCED); fAdvancedTab->SetLabel(STR_TAB_ADVANCED);
prefView->AddChild(prefTabView);
// FilePanels // FilePanels
BWindow * change_title; BWindow * change_title;
BMessenger messenger(this); BMessenger messenger(this);
BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR); 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); B_DIRECTORY_NODE, false, &message, NULL, true);
webDirFilePanel->SetPanelDirectory(new BDirectory("/boot/home/public_html")); fWebDirFilePanel->SetPanelDirectory(
webDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); new BDirectory("/boot/home/public_html"));
change_title = webDirFilePanel->Window(); fWebDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select"));
change_title = fWebDirFilePanel->Window();
change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR); change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR);
message.what = MSG_FILE_PANEL_CREATE_LOG_FILE; 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); B_FILE_NODE, false, &message);
logFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create")); fLogFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create"));
change_title = logFilePanel->Window(); change_title = fLogFilePanel->Window();
change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE); change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE);
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_WINDOW_INSETS)
.Add(fPrefTabView)
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fCancelButton)
.Add(fDoneButton);
} }
PoorManPreferencesWindow::~PoorManPreferencesWindow() PoorManPreferencesWindow::~PoorManPreferencesWindow()
{ {
delete logFilePanel; delete fLogFilePanel;
delete webDirFilePanel; delete fWebDirFilePanel;
} }
@@ -139,38 +101,38 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
case MSG_PREF_BTN_DONE: case MSG_PREF_BTN_DONE:
PoorManWindow* win; PoorManWindow* win;
PoorManServer* server; PoorManServer* server;
win = ((PoorManApplication *)be_app)->GetPoorManWindow(); win = ((PoorManApplication*)be_app)->GetPoorManWindow();
server = win->GetServer(); server = win->GetServer();
PRINT(("Pref Window: sendDir CheckBox: %d\n", PRINT(("Pref Window: sendDir CheckBox: %d\n",
siteView->SendDirValue())); fSiteView->SendDirValue()));
server->SetListDir(siteView->SendDirValue()); server->SetListDir(fSiteView->SendDirValue());
win->SetDirListFlag(siteView->SendDirValue()); win->SetDirListFlag(fSiteView->SendDirValue());
PRINT(("Pref Window: indexFileName TextControl: %s\n", PRINT(("Pref Window: indexFileName TextControl: %s\n",
siteView->IndexFileName())); fSiteView->IndexFileName()));
if (server->SetIndexName(siteView->IndexFileName()) == B_OK) if (server->SetIndexName(fSiteView->IndexFileName()) == B_OK)
win->SetIndexFileName(siteView->IndexFileName()); win->SetIndexFileName(fSiteView->IndexFileName());
PRINT(("Pref Window: webDir: %s\n", siteView->WebDir())); PRINT(("Pref Window: webDir: %s\n", fSiteView->WebDir()));
if (server->SetWebDir(siteView->WebDir()) == B_OK) { if (server->SetWebDir(fSiteView->WebDir()) == B_OK) {
win->SetWebDir(siteView->WebDir()); win->SetWebDir(fSiteView->WebDir());
win->SetDirLabel(siteView->WebDir()); win->SetDirLabel(fSiteView->WebDir());
} }
PRINT(("Pref Window: logConsole CheckBox: %d\n", PRINT(("Pref Window: logConsole CheckBox: %d\n",
loggingView->LogConsoleValue())); fLoggingView->LogConsoleValue()));
win->SetLogConsoleFlag(loggingView->LogConsoleValue()); win->SetLogConsoleFlag(fLoggingView->LogConsoleValue());
PRINT(("Pref Window: logFile CheckBox: %d\n", PRINT(("Pref Window: logFile CheckBox: %d\n",
loggingView->LogFileValue())); fLoggingView->LogFileValue()));
win->SetLogFileFlag(loggingView->LogFileValue()); win->SetLogFileFlag(fLoggingView->LogFileValue());
PRINT(("Pref Window: logFileName: %s\n", PRINT(("Pref Window: logFileName: %s\n",
loggingView->LogFileName())); fLoggingView->LogFileName()));
win->SetLogPath(loggingView->LogFileName()); win->SetLogPath(fLoggingView->LogFileName());
PRINT(("Pref Window: MaxConnections Slider: %ld\n", PRINT(("Pref Window: MaxConnections Slider: %ld\n",
advancedView->MaxSimultaneousConnections())); fAdvancedView->MaxSimultaneousConnections()));
server->SetMaxConns(advancedView->MaxSimultaneousConnections()); server->SetMaxConns(fAdvancedView->MaxSimultaneousConnections());
win->SetMaxConnections( win->SetMaxConnections(
(int16)advancedView->MaxSimultaneousConnections()); (int16)fAdvancedView->MaxSimultaneousConnections());
if (Lock()) if (Lock())
Quit(); Quit();
@@ -180,12 +142,15 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
Quit(); Quit();
break; break;
case MSG_PREF_SITE_BTN_SELECT: case MSG_PREF_SITE_BTN_SELECT:
{
// Select the Web Directory, root directory to look in. // Select the Web Directory, root directory to look in.
webDirFilePanel->SetTarget(this); fWebDirFilePanel->SetTarget(this);
webDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR)); BMessage webDirSelectedMsg(MSG_FILE_PANEL_SELECT_WEB_DIR);
if (!webDirFilePanel->IsShowing()) fWebDirFilePanel->SetMessage(&webDirSelectedMsg);
webDirFilePanel->Show(); if (!fWebDirFilePanel->IsShowing())
fWebDirFilePanel->Show();
break; break;
}
case MSG_FILE_PANEL_SELECT_WEB_DIR: case MSG_FILE_PANEL_SELECT_WEB_DIR:
// handle the open BMessage from the Select Web Directory File Panel // handle the open BMessage from the Select Web Directory File Panel
PRINT(("Select Web Directory:\n")); PRINT(("Select Web Directory:\n"));
@@ -193,7 +158,7 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
break; break;
case MSG_PREF_LOG_BTN_CREATE_FILE: case MSG_PREF_LOG_BTN_CREATE_FILE:
// Create the Log File // Create the Log File
logFilePanel->Show(); fLogFilePanel->Show();
break; break;
case MSG_FILE_PANEL_CREATE_LOG_FILE: case MSG_FILE_PANEL_CREATE_LOG_FILE:
// handle the save BMessage from the Create Log File Panel // handle the save BMessage from the Create Log File Panel
@@ -201,8 +166,8 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
CreateLogFile(message); CreateLogFile(message);
break; break;
case MSG_PREF_ADV_SLD_MAX_CONNECTION: case MSG_PREF_ADV_SLD_MAX_CONNECTION:
max_connections = advancedView->MaxSimultaneousConnections(); fMaxConnections = fAdvancedView->MaxSimultaneousConnections();
PRINT(("Max Connections: %ld\n", max_connections)); PRINT(("Max Connections: %ld\n", fMaxConnections));
break; break;
default: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
@@ -212,30 +177,27 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
void void
PoorManPreferencesWindow::SelectWebDir(BMessage * message) PoorManPreferencesWindow::SelectWebDir(BMessage* message)
{ {
entry_ref ref; entry_ref ref;
const char * name;
BPath path; BPath path;
BEntry entry; BEntry entry;
if (message->FindRef("refs", &ref) != B_OK if (message->FindRef("refs", &ref) != B_OK || entry.SetTo(&ref) != B_OK) {
|| message->FindString("name", &name) != B_OK
|| entry.SetTo(&ref) != B_OK) {
return; return;
} }
entry.GetPath(&path); entry.GetPath(&path);
PRINT(("DIR: %s\n", path.Path())); PRINT(("DIR: %s\n", path.Path()));
siteView->SetWebDir(path.Path()); fSiteView->SetWebDir(path.Path());
bool temp; bool temp;
if (message->FindBool("Default Dialog", &temp) == B_OK) { if (message->FindBool("Default Dialog", &temp) == B_OK) {
PoorManWindow* win = ((PoorManApplication *)be_app)->GetPoorManWindow(); PoorManWindow* win = ((PoorManApplication *)be_app)->GetPoorManWindow();
win->StartServer(); win->StartServer();
if (win->GetServer()->SetWebDir(siteView->WebDir()) == B_OK) { if (win->GetServer()->SetWebDir(fSiteView->WebDir()) == B_OK) {
win->SetWebDir(siteView->WebDir()); win->SetWebDir(fSiteView->WebDir());
win->SetDirLabel(siteView->WebDir()); win->SetDirLabel(fSiteView->WebDir());
win->SaveSettings(); win->SaveSettings();
win->Show(); win->Show();
} }
@@ -246,7 +208,7 @@ PoorManPreferencesWindow::SelectWebDir(BMessage * message)
void void
PoorManPreferencesWindow::CreateLogFile(BMessage * message) PoorManPreferencesWindow::CreateLogFile(BMessage* message)
{ {
entry_ref ref; entry_ref ref;
const char * name; const char * name;
@@ -268,8 +230,8 @@ PoorManPreferencesWindow::CreateLogFile(BMessage * message)
PRINT(("Log File: %s\n", path.Path())); PRINT(("Log File: %s\n", path.Path()));
if (err == B_OK) { if (err == B_OK) {
loggingView->SetLogFileName(path.Path()); fLoggingView->SetLogFileName(path.Path());
loggingView->SetLogFileValue(true); fLoggingView->SetLogFileValue(true);
} }
// mark the checkbox // mark the checkbox
@@ -283,8 +245,8 @@ PoorManPreferencesWindow::ShowWebDirFilePanel()
BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR); BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR);
message.AddBool("Default Dialog", true); message.AddBool("Default Dialog", true);
webDirFilePanel->SetTarget(be_app); fWebDirFilePanel->SetTarget(be_app);
webDirFilePanel->SetMessage(&message); fWebDirFilePanel->SetMessage(&message);
if (!webDirFilePanel->IsShowing()) if (!fWebDirFilePanel->IsShowing())
webDirFilePanel->Show(); fWebDirFilePanel->Show();
} }
+47 -50
View File
@@ -22,59 +22,56 @@
#include "PoorManAdvancedView.h" #include "PoorManAdvancedView.h"
class PoorManPreferencesWindow: public BWindow {
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;
public: public:
PoorManPreferencesWindow(BRect frame, char * name); PoorManPreferencesWindow(BRect frame, char* name);
~PoorManPreferencesWindow(); ~PoorManPreferencesWindow();
virtual void MessageReceived(BMessage * message); virtual void MessageReceived(BMessage* message);
void ShowWebDirFilePanel(); void ShowWebDirFilePanel();
void SelectWebDir(BMessage * message); void SelectWebDir(BMessage* message);
void CreateLogFile(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 #endif
+42 -60
View File
@@ -6,91 +6,73 @@
*/ */
#include <Box.h> #include <Box.h>
#include <LayoutBuilder.h>
#include "constants.h" #include "constants.h"
#include "PoorManSiteView.h" #include "PoorManSiteView.h"
#include "PoorManWindow.h" #include "PoorManWindow.h"
#include "PoorManApplication.h" #include "PoorManApplication.h"
PoorManSiteView::PoorManSiteView(BRect rect, const char *name) PoorManSiteView::PoorManSiteView(const char* name)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) : BView(name, B_WILL_DRAW, NULL)
{ {
PoorManWindow * win; PoorManWindow* win;
win = ((PoorManApplication *)be_app)->GetPoorManWindow(); win = ((PoorManApplication *)be_app)->GetPoorManWindow();
SetViewColor(BACKGROUND_COLOR); SetLayout(new BGroupLayout(B_VERTICAL));
// Web Site Location BBox // Web Site Location BBox
BRect webLocationRect; BBox* webSiteLocation = new BBox("Web Location");
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");
webSiteLocation->SetLabel(STR_BBX_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"); // Web Site Options BBox
BBox* webSiteOptions = new BBox("Web Options");
webSiteOptions->SetLabel(STR_BBX_OPTIONS); webSiteOptions->SetLabel(STR_BBX_OPTIONS);
AddChild(webSiteOptions);
// Send Directory List if No Index // Send Directory List if No Index
float left = 10.0; fSendDir = new BCheckBox("Send Dir", STR_CBX_DIR_LIST_LABEL,
float top = 20.0; new BMessage(MSG_PREF_SITE_CBX_INDEX));
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));
// set the checkbox to the value the program has // set the checkbox to the value the program has
SetSendDirValue(win->DirListFlag()); 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 // Web Directory Text Control
webDir = new BTextControl(webSiteLocationRect, "Web Dir", fWebDir = new BTextControl("Web Dir", STR_TXT_DIRECTORY, NULL);
STR_TXT_DIRECTORY, NULL, NULL);
webDir->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
webDir->SetDivider(80.0);
SetWebDir(win->WebDir()); SetWebDir(win->WebDir());
webSiteLocation->AddChild(webDir);
// Select Web Directory Button // Select Web Directory Button
BRect selectWebDirRect; fSelectWebDir = new BButton("Select Web Dir", STR_BTN_DIRECTORY,
new BMessage(MSG_PREF_SITE_BTN_SELECT));
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);
// Index File Name Text Control // Index File Name Text Control
//webDirRect.InsetBy(10.0, 7.0); fIndexFileName = new BTextControl("Index File Name", STR_TXT_INDEX, NULL);
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);
SetIndexFileName(win->IndexFileName()); SetIndexFileName(win->IndexFileName());
webSiteLocation->AddChild(indexFileName);
BGroupLayout* webSiteLocationLayout = new BGroupLayout(B_VERTICAL, 0);
webSiteLocation->SetLayout(webSiteLocationLayout);
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();
} }
+40 -14
View File
@@ -14,26 +14,52 @@
#include <CheckBox.h> #include <CheckBox.h>
class PoorManSiteView: public BView class PoorManSiteView: public BView {
{
public: public:
PoorManSiteView(BRect, const char *name); PoorManSiteView(const char *name);
void SetSendDirValue(bool state) {if (state) sendDir->SetValue(B_CONTROL_ON);
else sendDir->SetValue(B_CONTROL_OFF); } void SetSendDirValue(bool state)
bool SendDirValue() { return (sendDir->Value() == B_CONTROL_ON) ? true : false; } {
const char * IndexFileName() { return indexFileName->Text(); } if (state)
void SetIndexFileName(const char * name) { indexFileName->SetText(name); } fSendDir->SetValue(B_CONTROL_ON);
const char * WebDir() { return webDir->Text(); } else
void SetWebDir(const char * dir) { webDir->SetText(dir); } 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: private:
// Site Tab // Site Tab
// Web Site Location // Web Site Location
BTextControl * webDir; BTextControl* fWebDir;
BTextControl * indexFileName; BTextControl* fIndexFileName;
BButton * selectWebDir; BButton* fSelectWebDir;
// Web Site Options // Web Site Options
BCheckBox * sendDir; BCheckBox* fSendDir;
}; };
+1 -1
View File
@@ -10,7 +10,7 @@
#endif #endif
PoorManView::PoorManView(BRect rect, const char *name) 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)
{ {
} }
+4 -4
View File
@@ -12,11 +12,11 @@
#include <View.h> #include <View.h>
#endif #endif
class PoorManView: public BView class PoorManView: public BView {
{
public: public:
PoorManView(BRect, const char *name); PoorManView(BRect, const char *name);
virtual void AttachedToWindow();
virtual void AttachedToWindow();
}; };
#endif #endif
+279 -350
View File
@@ -17,6 +17,7 @@
#include <Directory.h> #include <Directory.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <LayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
@@ -43,182 +44,112 @@
PoorManWindow::PoorManWindow(BRect frame) 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 //preferences init
web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY); fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
index_file_name.SetTo("index.html"); fIndexFileName.SetTo("index.html");
dir_list_flag = false; fDirListFlag = false;
log_console_flag = true; fLogConsoleFlag = true;
log_file_flag = false; fLogFileFlag = false;
log_path.SetTo(""); fLogPath.SetTo("");
max_connections = (int16)32; fMaxConnections = (int16)32;
is_zoomed = true; fIsZoomed = true;
last_width = 318.0f; fLastWidth = 318.0f;
last_height = 320.0f; fLastHeight = 320.0f;
this->frame = frame; this->fFrame = frame;
setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f); fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f);
// PoorMan Window // PoorMan Window
SetSizeLimits(318, 1600, 53, 1200); SetSizeLimits(318, 1600, 53, 1200);
// limit the size of the size of the window // 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);
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// Three Labels // Three Labels
// Status String // Status String
BRect statusRect; fStatusView = new BStringView("Status View", B_TRANSLATE("Status: Stopped"));
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);
// Directory String // Directory String
BRect dirRect; fDirView = new BStringView("Dir View", B_TRANSLATE("Directory: (none)"));
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);
// Hits String // Hits String
BRect hitsRect; fHitsView = new BStringView("Hit View", B_TRANSLATE("Hits: 0"));
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);
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// Logging View // 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); fLoggingView = new BTextView(STR_TXT_VIEW, B_WILL_DRAW );
fLogViewFont->SetSize(11.0);
loggingView = new BTextView(logRect, STR_TXT_VIEW, textRect, fLoggingView->MakeEditable(false); // user cannot change the text
fLogViewFont, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW ); fLoggingView->MakeSelectable(true);
fLoggingView->SetViewColor(WHITE);
loggingView->MakeEditable(false); // user cannot change the text fLoggingView->SetStylable(true);
loggingView->MakeSelectable(true);
loggingView->SetViewColor(WHITE);
loggingView->SetStylable(true);
// create the scroll view // create the scroll view
scrollView = new BScrollView("Scroll View", loggingView, B_FOLLOW_ALL_SIDES, fScrollView = new BScrollView("Scroll View", fLoggingView,
B_WILL_DRAW | B_FRAME_EVENTS, B_WILL_DRAW | B_FRAME_EVENTS | B_FOLLOW_ALL_SIDES,
// Make sure articles on border do not occur when resizing // Make sure articles on border do not occur when resizing
false, true); false, true);
bb->AddChild(scrollView); fLoggingView->MakeFocus(true);
loggingView->MakeFocus(true);
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// menu bar // menu bar
BRect menuRect; fFileMenuBar = new BMenuBar("File Menu Bar");
menuRect = Bounds();
menuRect.bottom = 18.0f;
FileMenuBar = new BMenuBar(menuRect, "File Menu Bar");
// menus // menus
FileMenu = BuildFileMenu(); fFileMenu = BuildFileMenu();
if (FileMenu) if (fFileMenu)
FileMenuBar->AddItem(FileMenu); fFileMenuBar->AddItem(fFileMenu);
EditMenu = BuildEditMenu(); fEditMenu = BuildEditMenu();
if (EditMenu) if (fEditMenu)
FileMenuBar->AddItem(EditMenu); fFileMenuBar->AddItem(fEditMenu);
ControlsMenu = BuildControlsMenu(); fControlsMenu = BuildControlsMenu();
if (ControlsMenu) if (fControlsMenu)
FileMenuBar->AddItem(ControlsMenu); fFileMenuBar->AddItem(fControlsMenu);
// File Panels // File Panels
BWindow* change_title; BWindow* change_title;
BMessenger messenger(this); fSaveConsoleFilePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this),
saveConsoleFilePanel = new BFilePanel( NULL, B_FILE_NODE, false,
B_SAVE_PANEL,
&messenger,
NULL,
B_FILE_NODE,
false,
new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE)); new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE));
change_title = fSaveConsoleFilePanel->Window();
change_title = saveConsoleFilePanel->Window();
change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE); change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE);
saveConsoleSelectionFilePanel = new BFilePanel( fSaveConsoleSelectionFilePanel = new BFilePanel(B_SAVE_PANEL,
B_SAVE_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false,
&messenger,
NULL,
B_FILE_NODE,
false,
new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION)); new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION));
change_title = fSaveConsoleSelectionFilePanel->Window();
change_title = saveConsoleSelectionFilePanel->Window();
change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE_SELECTION); change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE_SELECTION);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
AddChild(FileMenuBar); .SetInsets(0)
.Add(fFileMenuBar)
.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
.SetInsets(B_USE_WINDOW_INSETS)
.AddGroup(B_HORIZONTAL)
.Add(fStatusView)
.AddGlue()
.Add(fHitsView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(fDirView)
.AddGlue()
.End()
.Add(fScrollView);
pthread_rwlock_init(&fLogFileLock, NULL); pthread_rwlock_init(&fLogFileLock, NULL);
} }
@@ -227,7 +158,6 @@ PoorManWindow::PoorManWindow(BRect frame)
PoorManWindow::~PoorManWindow() PoorManWindow::~PoorManWindow()
{ {
delete fServer; delete fServer;
delete fLogViewFont;
delete fLogFile; delete fLogFile;
pthread_rwlock_destroy(&fLogFileLock); pthread_rwlock_destroy(&fLogFileLock);
} }
@@ -237,129 +167,127 @@ void
PoorManWindow::MessageReceived(BMessage* message) PoorManWindow::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case MSG_MENU_FILE_SAVE_AS: case MSG_MENU_FILE_SAVE_AS:
saveConsoleFilePanel->Show(); fSaveConsoleFilePanel->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)
break; 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; time_t time;
in_addr_t address; in_addr_t address;
rgb_color color; rgb_color color;
const void* pointer; const void* pointer;
ssize_t size; ssize_t size;
const char* msg; const char* msg;
BString line; BString line;
if (message->FindString("cstring", &msg) != B_OK) if (message->FindString("cstring", &msg) != B_OK)
break; break;
if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK) if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK)
time = -1; time = -1;
else else
time = *static_cast<const time_t*>(pointer); time = *static_cast<const time_t*>(pointer);
if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK) if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK)
address = INADDR_NONE; address = INADDR_NONE;
else else
address = *static_cast<const in_addr_t*>(pointer); address = *static_cast<const in_addr_t*>(pointer);
if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK) if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK)
color = BLACK; color = BLACK;
else else
color = *static_cast<const rgb_color*>(pointer); color = *static_cast<const rgb_color*>(pointer);
if (time != -1) { if (time != -1) {
BString timeString; BString timeString;
if (BLocale::Default()->FormatDateTime(&timeString, time, if (BLocale::Default()->FormatDateTime(&timeString, time,
DATE_FORMAT, TIME_FORMAT) == B_OK) { DATE_FORMAT, TIME_FORMAT) == B_OK) {
line << '[' << timeString << "]: "; 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);
} }
} }
Unlock();
}
break; if (address != INADDR_NONE) {
} char addr[INET_ADDRSTRLEN];
default: struct in_addr sin_addr;
BWindow::MessageReceived(message); sin_addr.s_addr = address;
break; 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 +295,17 @@ PoorManWindow::MessageReceived(BMessage* message)
void void
PoorManWindow::FrameMoved(BPoint origin) PoorManWindow::FrameMoved(BPoint origin)
{ {
frame.left = origin.x; fFrame.left = origin.x;
frame.top = origin.y; fFrame.top = origin.y;
} }
void void
PoorManWindow::FrameResized(float width, float height) PoorManWindow::FrameResized(float width, float height)
{ {
if (is_zoomed) { if (fIsZoomed) {
last_width = width; fLastWidth = width;
last_height = height; fLastHeight = height;
} }
} }
@@ -385,7 +313,7 @@ PoorManWindow::FrameResized(float width, float height)
bool bool
PoorManWindow::QuitRequested() PoorManWindow::QuitRequested()
{ {
if (status) { if (fStatus) {
time_t now = time(NULL); time_t now = time(NULL);
BString timeString; BString timeString;
BLocale::Default()->FormatDateTime(&timeString, now, BLocale::Default()->FormatDateTime(&timeString, now,
@@ -395,21 +323,21 @@ PoorManWindow::QuitRequested()
line << "[" << timeString << "]: " << B_TRANSLATE("Shutting down.") line << "[" << timeString << "]: " << B_TRANSLATE("Shutting down.")
<< "\n"; << "\n";
if (log_console_flag) { if (fLogConsoleFlag) {
loggingView->Insert(loggingView->TextLength(), fLoggingView->Insert(fLoggingView->TextLength(),
line, line.Length()); line, line.Length());
loggingView->ScrollToOffset(loggingView->TextLength()); fLoggingView->ScrollToOffset(fLoggingView->TextLength());
} }
if (log_file_flag) { if (fLogFileFlag) {
if (pthread_rwlock_rdlock(&fLogFileLock) == 0) { if (pthread_rwlock_rdlock(&fLogFileLock) == 0) {
fLogFile->Write(line, line.Length()); fLogFile->Write(line, line.Length());
pthread_rwlock_unlock(&fLogFileLock); pthread_rwlock_unlock(&fLogFileLock);
} }
} }
fServer->Stop(); fServer->Stop();
status = false; fStatus = false;
UpdateStatusLabelAndMenuItem(); UpdateStatusLabelAndMenuItem();
} }
@@ -422,14 +350,14 @@ PoorManWindow::QuitRequested()
void void
PoorManWindow::Zoom(BPoint origin, float width, float height) PoorManWindow::Zoom(BPoint origin, float width, float height)
{ {
if (is_zoomed) { if (fIsZoomed) {
// Change to the Minimal size // Change to the Minimal size
is_zoomed = false; fIsZoomed = false;
ResizeTo(318, 53); ResizeTo(318, 53);
} else { } else {
// Change to the Zoomed size // Change to the Zoomed size
is_zoomed = true; fIsZoomed = true;
ResizeTo(last_width, last_height); ResizeTo(fLastWidth, fLastHeight);
} }
} }
@@ -437,7 +365,7 @@ PoorManWindow::Zoom(BPoint origin, float width, float height)
void void
PoorManWindow::SetHits(uint32 num) PoorManWindow::SetHits(uint32 num)
{ {
hits = num; fHits = num;
UpdateHitsLabel(); UpdateHitsLabel();
} }
@@ -445,10 +373,10 @@ PoorManWindow::SetHits(uint32 num)
// Private: Methods ------------------------------------------ // Private: Methods ------------------------------------------
BMenu * BMenu*
PoorManWindow::BuildFileMenu() const 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, ptrFileMenu->AddItem(new BMenuItem(STR_MNU_FILE_SAVE_AS,
new BMessage(MSG_MENU_FILE_SAVE_AS), CMD_FILE_SAVE_AS)); new BMessage(MSG_MENU_FILE_SAVE_AS), CMD_FILE_SAVE_AS));
@@ -465,28 +393,28 @@ PoorManWindow::BuildFileMenu() const
} }
BMenu * BMenu*
PoorManWindow::BuildEditMenu() const 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); new BMessage(B_COPY), CMD_EDIT_COPY);
ptrEditMenu->AddItem(CopyMenuItem); ptrEditMenu->AddItem(CopyMenuItem);
CopyMenuItem->SetTarget(loggingView, NULL); CopyMenuItem->SetTarget(fLoggingView, NULL);
ptrEditMenu->AddSeparatorItem(); 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); new BMessage(B_SELECT_ALL), CMD_EDIT_SELECT_ALL);
ptrEditMenu->AddItem(SelectAllMenuItem); ptrEditMenu->AddItem(SelectAllMenuItem);
SelectAllMenuItem->SetTarget(loggingView, NULL); SelectAllMenuItem->SetTarget(fLoggingView, NULL);
ptrEditMenu->AddSeparatorItem(); ptrEditMenu->AddSeparatorItem();
BMenuItem * PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF, BMenuItem* PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF,
new BMessage(MSG_MENU_EDIT_PREF)); new BMessage(MSG_MENU_EDIT_PREF));
ptrEditMenu->AddItem(PrefMenuItem); ptrEditMenu->AddItem(PrefMenuItem);
@@ -494,27 +422,27 @@ PoorManWindow::BuildEditMenu() const
} }
BMenu * BMenu*
PoorManWindow::BuildControlsMenu() const 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)); new BMessage(MSG_MENU_CTRL_RUN));
RunServerMenuItem->SetMarked(false); RunServerMenuItem->SetMarked(false);
ptrControlMenu->AddItem(RunServerMenuItem); 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)); new BMessage(MSG_MENU_CTRL_CLEAR_HIT));
ptrControlMenu->AddItem(ClearHitCounterMenuItem); ptrControlMenu->AddItem(ClearHitCounterMenuItem);
ptrControlMenu->AddSeparatorItem(); 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)); new BMessage(MSG_MENU_CTRL_CLEAR_CONSOLE));
ptrControlMenu->AddItem(ClearConsoleLogMenuItem); 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)); new BMessage(MSG_MENU_CTRL_CLEAR_LOG));
ptrControlMenu->AddItem(ClearLogFileMenuItem); ptrControlMenu->AddItem(ClearLogFileMenuItem);
@@ -523,13 +451,13 @@ PoorManWindow::BuildControlsMenu() const
void void
PoorManWindow::SetDirLabel(const char * name) PoorManWindow::SetDirLabel(const char* name)
{ {
BString dirPath(B_TRANSLATE("Directory: ")); BString dirPath(B_TRANSLATE("Directory: "));
dirPath.Append(name); dirPath.Append(name);
if (Lock()) { if (Lock()) {
dirView->SetText(dirPath.String()); fDirView->SetText(dirPath.String());
Unlock(); Unlock();
} }
} }
@@ -539,11 +467,11 @@ void
PoorManWindow::UpdateStatusLabelAndMenuItem() PoorManWindow::UpdateStatusLabelAndMenuItem()
{ {
if (Lock()) { if (Lock()) {
if (status) if (fStatus)
statusView->SetText(B_TRANSLATE("Status: Running")); fStatusView->SetText(B_TRANSLATE("Status: Running"));
else else
statusView->SetText(B_TRANSLATE("Status: Stopped")); fStatusView->SetText(B_TRANSLATE("Status: Stopped"));
ControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(status); fControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(fStatus);
Unlock(); Unlock();
} }
} }
@@ -553,8 +481,8 @@ void
PoorManWindow::UpdateHitsLabel() PoorManWindow::UpdateHitsLabel()
{ {
if (Lock()) { if (Lock()) {
sprintf(hitsLabel, B_TRANSLATE("Hits: %lu"), GetHits()); sprintf(fHitsLabel, B_TRANSLATE("Hits: %lu"), GetHits());
hitsView->SetText(hitsLabel); fHitsView->SetText(fHitsLabel);
Unlock(); Unlock();
} }
@@ -562,22 +490,25 @@ PoorManWindow::UpdateHitsLabel()
status_t status_t
PoorManWindow::SaveConsole(BMessage * message, bool selection) PoorManWindow::SaveConsole(BMessage* message, bool selection)
{ {
entry_ref ref; entry_ref ref;
const char * name; const char* name;
BPath path; BPath path;
BEntry entry; BEntry entry;
status_t err = B_OK; 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; return err;
if ((err = message->FindString("name", &name)) != B_OK) err = message->FindString("name", &name);
if (err != B_OK)
return err; return err;
if ((err = entry.SetTo(&ref)) != B_OK) err = entry.SetTo(&ref);
if (err != B_OK)
return err; return err;
entry.GetPath(&path); entry.GetPath(&path);
@@ -588,20 +519,21 @@ PoorManWindow::SaveConsole(BMessage * message, bool selection)
if (!selection) { if (!selection) {
// write the data to the file // write the data to the file
err = fwrite(loggingView->Text(), 1, loggingView->TextLength(), f); err = fwrite(fLoggingView->Text(), 1, fLoggingView->TextLength(), f);
} else { } else {
// find the selected text and write it to a file // find the selected text and write it to a file
int32 start = 0, end = 0; int32 start = 0, end = 0;
loggingView->GetSelection(&start, &end); fLoggingView->GetSelection(&start, &end);
BString buffer; BString buffer;
char * buffData = buffer.LockBuffer(end - start + 1); char * buffData = buffer.LockBuffer(end - start + 1);
// copy the selected text from the TextView to the buffer // 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); buffer.UnlockBuffer(end - start + 1);
err = fwrite(buffer.String(), 1, end - start + 1, f); err = fwrite(buffer.String(), 1, end - start + 1, f);
} }
fclose(f); fclose(f);
return err; return err;
@@ -627,10 +559,10 @@ PoorManWindow::DefaultSettings()
break; break;
case 1: case 1:
prefWindow = new PoorManPreferencesWindow( fPrefWindow = new PoorManPreferencesWindow(
setwindow_frame, fSetwindowFrame,
STR_WIN_NAME_PREF); STR_WIN_NAME_PREF);
prefWindow->ShowWebDirFilePanel(); fPrefWindow->ShowWebDirFilePanel();
break; break;
case 2: case 2:
@@ -674,49 +606,49 @@ PoorManWindow::ReadSettings()
return B_ERROR; return B_ERROR;
//site tab //site tab
if (m.FindString("web_directory", &web_directory) != B_OK) if (m.FindString("fWebDirectory", &fWebDirectory) != B_OK)
web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY); fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
if (m.FindString("index_file_name", &index_file_name) != B_OK) if (m.FindString("fIndexFileName", &fIndexFileName) != B_OK)
index_file_name.SetTo("index.html"); fIndexFileName.SetTo("index.html");
if (m.FindBool("dir_list_flag", &dir_list_flag) != B_OK) if (m.FindBool("fDirListFlag", &fDirListFlag) != B_OK)
dir_list_flag = false; fDirListFlag = false;
//logging tab //logging tab
if (m.FindBool("log_console_flag", &log_console_flag) != B_OK) if (m.FindBool("fLogConsoleFlag", &fLogConsoleFlag) != B_OK)
log_console_flag = true; fLogConsoleFlag = true;
if (m.FindBool("log_file_flag", &log_file_flag) != B_OK) if (m.FindBool("fLogFileFlag", &fLogFileFlag) != B_OK)
log_file_flag = false; fLogFileFlag = false;
if (m.FindString("log_path", &log_path) != B_OK) if (m.FindString("fLogPath", &fLogPath) != B_OK)
log_path.SetTo(""); fLogPath.SetTo("");
//advance tab //advance tab
if (m.FindInt16("max_connections", &max_connections) != B_OK) if (m.FindInt16("fMaxConnections", &fMaxConnections) != B_OK)
max_connections = (int16)32; fMaxConnections = (int16)32;
//windows' position and size //windows' position and size
if (m.FindRect("frame", &frame) != B_OK) if (m.FindRect("frame", &fFrame) != B_OK)
frame.Set(82.0f, 30.0f, 400.0f, 350.0f); fFrame.Set(82.0f, 30.0f, 400.0f, 350.0f);
if (m.FindRect("setwindow_frame", &setwindow_frame) != B_OK) if (m.FindRect("fSetwindowFrame", &fSetwindowFrame) != B_OK)
setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f); fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f);
if (m.FindBool("is_zoomed", &is_zoomed) != B_OK) if (m.FindBool("fIsZoomed", &fIsZoomed) != B_OK)
is_zoomed = true; fIsZoomed = true;
if (m.FindFloat("last_width", &last_width) != B_OK) if (m.FindFloat("fLastWidth", &fLastWidth) != B_OK)
last_width = 318.0f; fLastWidth = 318.0f;
if (m.FindFloat("last_height", &last_height) != B_OK) if (m.FindFloat("fLastHeight", &fLastHeight) != B_OK)
last_height = 320.0f; fLastHeight = 320.0f;
is_zoomed?ResizeTo(last_width, last_height):ResizeTo(318, 53); fIsZoomed?ResizeTo(fLastWidth, fLastHeight):ResizeTo(318, 53);
MoveTo(frame.left, frame.top); 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); | B_OPEN_AT_END);
if (fLogFile->InitCheck() != B_OK) { if (fLogFile->InitCheck() != B_OK) {
log_file_flag = false; fLogFileFlag = false;
//log it to console, "log to file unavailable." //log it to console, "log to file unavailable."
return B_OK; return B_OK;
} }
SetDirLabel(web_directory.String()); SetDirLabel(fWebDirectory.String());
return B_OK; return B_OK;
} }
@@ -730,24 +662,24 @@ PoorManWindow::SaveSettings()
BMessage m(MSG_PREF_FILE); BMessage m(MSG_PREF_FILE);
//site tab //site tab
m.AddString("web_directory", web_directory); m.AddString("fWebDirectory", fWebDirectory);
m.AddString("index_file_name", index_file_name); m.AddString("fIndexFileName", fIndexFileName);
m.AddBool("dir_list_flag", dir_list_flag); m.AddBool("fDirListFlag", fDirListFlag);
//logging tab //logging tab
m.AddBool("log_console_flag", log_console_flag); m.AddBool("fLogConsoleFlag", fLogConsoleFlag);
m.AddBool("log_file_flag", log_file_flag); m.AddBool("fLogFileFlag", fLogFileFlag);
m.AddString("log_path", log_path); m.AddString("fLogPath", fLogPath);
//advance tab //advance tab
m.AddInt16("max_connections", max_connections); m.AddInt16("fMaxConnections", fMaxConnections);
//windows' position and size //windows' position and size
m.AddRect("frame", frame); m.AddRect("frame", fFrame);
m.AddRect("setwindow_frame", setwindow_frame); m.AddRect("fSetwindowFrame", fSetwindowFrame);
m.AddBool("is_zoomed", is_zoomed); m.AddBool("fIsZoomed", fIsZoomed);
m.AddFloat("last_width", last_width); m.AddFloat("fLastWidth", fLastWidth);
m.AddFloat("last_height", last_height); m.AddFloat("fLastHeight", fLastHeight);
if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK) if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK)
return B_ERROR; return B_ERROR;
@@ -768,18 +700,15 @@ status_t
PoorManWindow::StartServer() PoorManWindow::StartServer()
{ {
if (fServer == NULL) if (fServer == NULL)
fServer = new PoorManServer( fServer = new PoorManServer(fWebDirectory.String(), fMaxConnections,
web_directory.String(), fDirListFlag, fIndexFileName.String());
max_connections,
dir_list_flag,
index_file_name.String());
poorman_log(B_TRANSLATE("Starting up... ")); poorman_log(B_TRANSLATE("Starting up... "));
if (fServer->Run() != B_OK) { if (fServer->Run() != B_OK) {
return B_ERROR; return B_ERROR;
} }
status = true; fStatus = true;
UpdateStatusLabelAndMenuItem(); UpdateStatusLabelAndMenuItem();
poorman_log(B_TRANSLATE("done.\n"), false, INADDR_NONE, GREEN); poorman_log(B_TRANSLATE("done.\n"), false, INADDR_NONE, GREEN);
@@ -795,7 +724,7 @@ PoorManWindow::StopServer()
poorman_log(B_TRANSLATE("Shutting down.\n")); poorman_log(B_TRANSLATE("Shutting down.\n"));
fServer->Stop(); fServer->Stop();
status = false; fStatus = false;
UpdateStatusLabelAndMenuItem(); UpdateStatusLabelAndMenuItem();
return B_OK; return B_OK;
} }
@@ -804,7 +733,7 @@ PoorManWindow::StopServer()
void void
PoorManWindow::SetLogPath(const char* str) PoorManWindow::SetLogPath(const char* str)
{ {
if (!strcmp(log_path, str)) if (!strcmp(fLogPath, str))
return; return;
BFile* temp = new BFile(str, B_CREATE_FILE | B_WRITE_ONLY | B_OPEN_AT_END); BFile* temp = new BFile(str, B_CREATE_FILE | B_WRITE_ONLY | B_OPEN_AT_END);
@@ -823,5 +752,5 @@ PoorManWindow::SetLogPath(const char* str)
return; return;
} }
log_path.SetTo(str); fLogPath.SetTo(str);
} }
+120 -73
View File
@@ -33,125 +33,172 @@ class PoorManServer;
class PoorManWindow: public BWindow class PoorManWindow: public BWindow
{ {
public: public:
PoorManWindow(BRect frame); PoorManWindow(BRect frame);
virtual ~PoorManWindow(); virtual ~PoorManWindow();
virtual void MessageReceived(BMessage * message); virtual void MessageReceived(BMessage* message);
virtual void FrameMoved(BPoint origin); virtual void FrameMoved(BPoint origin);
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void Zoom(BPoint origin, float width, float height); virtual void Zoom(BPoint origin, float width, float height);
// ------------------------------------------- // -------------------------------------------
// Public PoorMan Window Methods // Public PoorMan Window Methods
void SetDirLabel(const char * name); void SetDirLabel(const char* name);
void SetHits(uint32 num); void SetHits(uint32 num);
uint32 GetHits() { return hits; } uint32 GetHits() { return fHits; }
status_t SaveConsole(BMessage * message, bool); status_t SaveConsole(BMessage* message, bool);
status_t SaveSettings(); status_t SaveSettings();
status_t ReadSettings(); status_t ReadSettings();
void DefaultSettings(); void DefaultSettings();
status_t StartServer(); status_t StartServer();
status_t StopServer(); status_t StopServer();
PoorManServer* GetServer()const{return fServer;} PoorManServer* GetServer() const { return fServer;}
// ------------------------------------------- // -------------------------------------------
// Preferences and Settings // Preferences and Settings
// Site Tab // Site Tab
bool DirListFlag() { return dir_list_flag; } bool DirListFlag()
void SetDirListFlag(bool flag) { dir_list_flag = flag; } {
const char * IndexFileName() { return index_file_name.String(); } return fDirListFlag;
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); }
// 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);
// Advanced Tab
int16 MaxConnections() { return max_connections; }
void SetMaxConnections(int16 num) { max_connections = num; }
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: private:
// ------------------------------------------- // -------------------------------------------
// PoorMan Window Methods // PoorMan Window Methods
void UpdateStatusLabelAndMenuItem(); void UpdateStatusLabelAndMenuItem();
void UpdateHitsLabel(); void UpdateHitsLabel();
private: private:
// -------------------------------------------
// PoorMan Window
PoorManView * mainView;
// ------------------------------------------- // -------------------------------------------
// Build Menu Methods // Build Menu Methods
BMenu * BuildFileMenu() const; BMenu* BuildFileMenu() const;
BMenu * BuildEditMenu() const; BMenu* BuildEditMenu() const;
BMenu * BuildControlsMenu() const; BMenu* BuildControlsMenu() const;
// -------------------------------------------- // --------------------------------------------
// MenuBar & Menu items // MenuBar & Menu items
BMenuBar * FileMenuBar; BMenuBar* fFileMenuBar;
BMenu * FileMenu; BMenu* fFileMenu;
BMenu * EditMenu; BMenu* fEditMenu;
BMenu * ControlsMenu; BMenu* fControlsMenu;
// -------------------------------------------- // --------------------------------------------
// Status, Hits, Directory // Status, Hits, Directory
BStringView * statusView; BStringView* fStatusView;
BStringView * hitsView; BStringView* fHitsView;
BStringView * dirView; BStringView* fDirView;
bool status; bool fStatus;
uint32 hits; uint32 fHits;
char hitsLabel[25]; char fHitsLabel[25];
// -------------------------------------------- // --------------------------------------------
// Logging View // Logging View
BScrollView * scrollView; BScrollView* fScrollView;
BTextView * loggingView; BTextView* fLoggingView;
// use asctime() for format of [Date/Time]: // use asctime() for format of [Date/Time]:
// ------------------------------------------- // -------------------------------------------
// PoorMan Preference Window // PoorMan Preference Window
PoorManPreferencesWindow * prefWindow; PoorManPreferencesWindow * fPrefWindow;
// site tab // site tab
BString web_directory; BString fWebDirectory;
BString index_file_name; BString fIndexFileName;
bool dir_list_flag; bool fDirListFlag;
// logging tab // logging tab
bool log_console_flag; bool fLogConsoleFlag;
bool log_file_flag; bool fLogFileFlag;
BString log_path; BString fLogPath;
// advanced tab // advanced tab
int16 max_connections; int16 fMaxConnections;
bool is_zoomed; bool fIsZoomed;
float last_width; float fLastWidth;
float last_height; float fLastHeight;
BRect frame; BRect fFrame;
BRect setwindow_frame; BRect fSetwindowFrame;
// File Panels // File Panels
BFilePanel * saveConsoleFilePanel; BFilePanel* fSaveConsoleFilePanel;
BFilePanel * saveConsoleSelectionFilePanel; BFilePanel* fSaveConsoleSelectionFilePanel;
BFile* fLogFile; BFile* fLogFile;
BFont* fLogViewFont;
PoorManServer* fServer; PoorManServer* fServer;
pthread_rwlock_t fLogFileLock; pthread_rwlock_t fLogFileLock;
}; };
#endif #endif
+9 -21
View File
@@ -11,31 +11,19 @@
#include <stdio.h> #include <stdio.h>
StatusSlider::StatusSlider (BRect frame, StatusSlider::StatusSlider(const char* name, const char* label,
const char *name, char* statusPrefix, BMessage* message, int32 minValue, int32 maxValue)
const char *label, :
char *statusPrefix, BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL),
BMessage *message, fStatusPrefix(statusPrefix)
int32 minValue,
int32 maxValue)
: BSlider(frame,
name,
label,
message,
minValue,
maxValue
),
StatusPrefix(statusPrefix)
{ {
temp = str; fTemp = fStr;
} }
const char* const char*
StatusSlider::UpdateText() const StatusSlider::UpdateText() const
{ {
sprintf(fTemp, "%ld %s", Value(), fStatusPrefix);
sprintf(temp, "%ld %s", Value(), StatusPrefix);
return fTemp;
return temp;
} }
+13 -13
View File
@@ -13,21 +13,21 @@
#include <Slider.h> #include <Slider.h>
class StatusSlider: public BSlider class StatusSlider: public BSlider {
{
public: public:
StatusSlider(BRect frame, StatusSlider(const char* name,
const char *name, const char* label,
const char *label, char* statusPrefix,
char *statusPrefix, BMessage* message,
BMessage *message, int32 minValue,
int32 minValue, int32 maxValue);
int32 maxValue);
virtual const char* UpdateText() const; virtual const char* UpdateText() const;
private: private:
char * StatusPrefix; char* fStatusPrefix;
char * temp; char* fTemp;
char str[128]; char fStr[128];
}; };
#endif #endif
+1
View File
@@ -43,6 +43,7 @@ static struct option const kLongOptions[] = {
I(control_text_color, B_CONTROL_TEXT_COLOR), I(control_text_color, B_CONTROL_TEXT_COLOR),
I(control_border_color, B_CONTROL_BORDER_COLOR), I(control_border_color, B_CONTROL_BORDER_COLOR),
I(control_highlight_color, B_CONTROL_HIGHLIGHT_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_base_color, B_NAVIGATION_BASE_COLOR),
I(navigation_pulse_color, B_NAVIGATION_PULSE_COLOR), I(navigation_pulse_color, B_NAVIGATION_PULSE_COLOR),
I(shine_color, B_SHINE_COLOR), I(shine_color, B_SHINE_COLOR),
+1 -4
View File
@@ -3197,10 +3197,7 @@ BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base,
return false; return false;
} }
// TODO: Get from UI settings color = ui_color(B_CONTROL_MARK_COLOR);
color.red = 27;
color.green = 82;
color.blue = 140;
float mix = 1.0; float mix = 1.0;
+1
View File
@@ -96,6 +96,7 @@ static const rgb_color _kDefaultColors[kNumColors] = {
{80, 80, 80, 255}, // B_WINDOW_INACTIVE_TEXT_COLOR {80, 80, 80, 255}, // B_WINDOW_INACTIVE_TEXT_COLOR
{224, 224, 224, 255}, // B_WINDOW_BORDER_COLOR {224, 224, 224, 255}, // B_WINDOW_BORDER_COLOR
{232, 232, 232, 255}, // B_WINDOW_INACTIVE_BORDER_COLOR {232, 232, 232, 255}, // B_WINDOW_INACTIVE_BORDER_COLOR
{27, 82, 140, 255}, // B_CONTROL_MARK_COLOR
// 100... // 100...
{0, 255, 0, 255}, // B_SUCCESS_COLOR {0, 255, 0, 255}, // B_SUCCESS_COLOR
{255, 0, 0, 255}, // B_FAILURE_COLOR {255, 0, 0, 255}, // B_FAILURE_COLOR
+11 -3
View File
@@ -9,6 +9,7 @@
#include <new> #include <new>
#include <ControlLook.h>
#include <Message.h> #include <Message.h>
@@ -18,6 +19,13 @@ namespace {
const char* const kAlignmentField = "BSpaceLayoutItem:alignment"; const char* const kAlignmentField = "BSpaceLayoutItem:alignment";
const char* const kFrameField = "BSpaceLayoutItem:frame"; const char* const kFrameField = "BSpaceLayoutItem:frame";
const char* const kVisibleField = "BSpaceLayoutItem:visible"; 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) BSize preferredSize, BAlignment alignment)
: :
fFrame(), fFrame(),
fMinSize(minSize), fMinSize(ComposeSpacingInPlace(minSize)),
fMaxSize(maxSize), fMaxSize(ComposeSpacingInPlace(maxSize)),
fPreferredSize(preferredSize), fPreferredSize(ComposeSpacingInPlace(preferredSize)),
fAlignment(alignment), fAlignment(alignment),
fVisible(true) fVisible(true)
{ {
+1 -4
View File
@@ -12,9 +12,6 @@ extern "C" {
#include "Condvar.h" #include "Condvar.h"
#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz)
void void
conditionInit(struct cv* variable, const char* description) conditionInit(struct cv* variable, const char* description)
{ {
@@ -23,7 +20,7 @@ conditionInit(struct cv* variable, const char* description)
void void
conditionPublish(struct cv* variable, const void* waitChannel, conditionPublish(struct cv* variable, const void* waitChannel,
const char* description) const char* description)
{ {
variable->condition.Publish(waitChannel, description); variable->condition.Publish(waitChannel, description);
+3 -3
View File
@@ -62,9 +62,9 @@ callout_thread(void* /*data*/)
if (mutex != NULL) if (mutex != NULL)
mtx_lock(mutex); mtx_lock(mutex);
c->c_func(c->c_arg); c->c_func(c->c_arg);
if (mutex != NULL) if (mutex != NULL)
mtx_unlock(mutex); mtx_unlock(mutex);
@@ -116,7 +116,7 @@ init_callout(void)
} }
sThread = spawn_kernel_thread(callout_thread, "fbsd callout", sThread = spawn_kernel_thread(callout_thread, "fbsd callout",
B_URGENT_DISPLAY_PRIORITY, NULL); B_DISPLAY_PRIORITY, NULL);
if (sThread < 0) { if (sThread < 0) {
status = sThread; status = sThread;
goto err2; goto err2;
+4 -16
View File
@@ -5,10 +5,7 @@
#include "device.h" #include "device.h"
#include "kernel.h"
#define CONVERT_HZ_TO_USECS(hertz) (1000000LL / (hertz))
#define FREEBSD_CLOCK_FREQUENCY_IN_HZ 1000
int ticks; int ticks;
@@ -27,24 +24,15 @@ hardClock(timer* hardClockTimer)
/*! /*!
* Initialization of the hardclock timer. * Initialization of the hardclock timer which ticks according to hz defined in
* * compat/sys/kernel.h.
* 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.
*/ */
status_t status_t
init_hard_clock() init_hard_clock()
{ {
status_t status;
ticks = 0; ticks = 0;
status = add_timer(&sHardClockTimer, hardClock, return add_timer(&sHardClockTimer, hardClock, ticks_to_usecs(1),
CONVERT_HZ_TO_USECS(FREEBSD_CLOCK_FREQUENCY_IN_HZ),
B_PERIODIC_TIMER); B_PERIODIC_TIMER);
return status;
} }
@@ -17,18 +17,18 @@
/* /*
* *
* In FreeBSD hz holds the count of how often the thread scheduler is invoked * The rate at which FreeBSD can generate callouts (kind of timeout mechanism).
* per second. Moreover this is the rate at which FreeBSD can generate callouts * For FreeBSD 8 this is typically 1000 times per second (100 for ARM).
* (kind of timeout mechanism). * This value is defined in a file called subr_param.c
* For FreeBSD 8 this is typically 1000 times per second. This value is defined
* in a file called subr_param.c
* *
* For Haiku this value is much higher, due to using another timeout scheduling * WHile Haiku can have a much higher granularity, it is not a good idea to have
* mechanism, which has a resolution of 1 MHz. So hz for Haiku is set to * this since FreeBSD tries to do certain tasks based on ticks, for instance
* 1000000. Suffixing LL prevents integer overflows during calculations. * autonegotiation and wlan scanning.
* Suffixing LL prevents integer overflows during calculations.
* as it defines a long long constant.*/ * 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 *); typedef void (*system_init_func_t)(void *);
@@ -12,7 +12,7 @@
#include <sys/types.h> #include <sys/types.h>
#define time_uptime system_time() / 1000000 #define time_uptime (system_time() / 1000000)
int ppsratecheck(struct timeval*, int*, int); int ppsratecheck(struct timeval*, int*, int);
+1
View File
@@ -34,6 +34,7 @@ static ColorDescription sColorDescriptionTable[] =
{ B_CONTROL_TEXT_COLOR, B_TRANSLATE_MARK("Control text") }, { B_CONTROL_TEXT_COLOR, B_TRANSLATE_MARK("Control text") },
{ B_CONTROL_BORDER_COLOR, B_TRANSLATE_MARK("Control border") }, { B_CONTROL_BORDER_COLOR, B_TRANSLATE_MARK("Control border") },
{ B_CONTROL_HIGHLIGHT_COLOR, B_TRANSLATE_MARK("Control highlight") }, { 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_BASE_COLOR, B_TRANSLATE_MARK("Navigation base") },
{ B_NAVIGATION_PULSE_COLOR, B_TRANSLATE_MARK("Navigation pulse") }, { B_NAVIGATION_PULSE_COLOR, B_TRANSLATE_MARK("Navigation pulse") },
{ B_SHINE_COLOR, B_TRANSLATE_MARK("Shine") }, { B_SHINE_COLOR, B_TRANSLATE_MARK("Shine") },
@@ -40,19 +40,23 @@ ColorWhichItem::DrawItem(BView *owner, BRect frame, bool complete)
owner->FillRect(frame); owner->FillRect(frame);
} }
rgb_color black = {0, 0, 0, 255}; rgb_color border = (rgb_color){ 184, 184, 184, 255 };
BRect colorRect(frame); BRect colorRect(frame);
colorRect.InsetBy(2, 2); colorRect.InsetBy(2, 2);
colorRect.right = colorRect.left + colorRect.Height(); colorRect.right = colorRect.left + colorRect.Height();
owner->SetHighColor(fColor); owner->SetHighColor(fColor);
owner->FillRect(colorRect); owner->FillRect(colorRect);
owner->SetHighColor(black); owner->SetHighColor(border);
owner->StrokeRect(colorRect); owner->StrokeRect(colorRect);
owner->MovePenTo(frame.left + colorRect.Width() + 8, frame.top owner->MovePenTo(frame.left + colorRect.Width() + 8, frame.top
+ BaselineOffset()); + 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()) if (!IsEnabled())
owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT)); owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
else else