Ticket #3787: poorman.2.diff
File poorman.2.diff, 65.8 KB (added by , 12 years ago) |
---|
-
src/apps/poorman/PoorManAdvancedView.cpp
diff --git a/src/apps/poorman/PoorManAdvancedView.cpp b/src/apps/poorman/PoorManAdvancedView.cpp index 10ef09a..e817428 100644
a b 7 7 8 8 #include <Box.h> 9 9 #include <Catalog.h> 10 #include <GroupLayoutBuilder.h> 10 11 #include <Locale.h> 11 12 12 13 #include "constants.h" … … 19 20 #define B_TRANSLATION_CONTEXT "PoorMan" 20 21 21 22 22 PoorManAdvancedView::PoorManAdvancedView(BRect rect, const char *name) 23 : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) 23 PoorManAdvancedView::PoorManAdvancedView(const char* name) 24 : 25 BView(name, B_WILL_DRAW, NULL) 24 26 { 25 PoorManWindow *win;26 win = ((PoorManApplication 27 PoorManWindow* win; 28 win = ((PoorManApplication*)be_app)->GetPoorManWindow(); 27 29 28 Set ViewColor(BACKGROUND_COLOR);30 SetLayout(new BGroupLayout(B_VERTICAL)); 29 31 30 // Console Logging BBox 31 BRect maxRect; 32 maxRect = rect; 33 maxRect.top -= 5.0; 34 maxRect.left -= 5.0; 35 maxRect.right -= 7.0; 36 maxRect.bottom -= 118.0; 37 38 BBox * connectionOptions = new BBox(maxRect, B_TRANSLATE("Connections")); 32 BBox* connectionOptions = new BBox(B_TRANSLATE("Connections")); 39 33 connectionOptions->SetLabel(STR_BBX_CONNECTION); 40 AddChild(connectionOptions);41 42 BRect sliderRect;43 sliderRect = connectionOptions->Bounds();44 sliderRect.InsetBy(10.0f, 10.0f);45 sliderRect.top += 10;46 sliderRect.bottom = sliderRect.top + 50.0;47 34 48 maxConnections = new StatusSlider(sliderRect, "Max Slider", STR_SLD_LABEL, 49 STR_SLD_STATUS_LABEL, new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200); 35 fMaxConnections = new StatusSlider("Max Slider", STR_SLD_LABEL, 36 STR_SLD_STATUS_LABEL, 37 new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200); 50 38 51 39 // labels below the slider 1 and 200 52 maxConnections->SetLimitLabels("1", "200");40 fMaxConnections->SetLimitLabels("1", "200"); 53 41 SetMaxSimutaneousConnections(win->MaxConnections()); 54 connectionOptions->AddChild(maxConnections); 42 43 connectionOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 44 .Add(fMaxConnections) 45 .SetInsets(5, 5, 5, 5)); 46 47 AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 48 .Add(connectionOptions) 49 .AddGlue() 50 .SetInsets(5, 5, 5, 5)); 55 51 } 56 52 57 53 void 58 54 PoorManAdvancedView::SetMaxSimutaneousConnections(int32 num) 59 55 { 60 56 if (num <= 0 || num > 200) 61 maxConnections->SetValue(32);57 fMaxConnections->SetValue(32); 62 58 else 63 maxConnections->SetValue(num);59 fMaxConnections->SetValue(num); 64 60 } -
src/apps/poorman/PoorManAdvancedView.h
diff --git a/src/apps/poorman/PoorManAdvancedView.h b/src/apps/poorman/PoorManAdvancedView.h index fd693a7..9b6dc58 100644
a b 13 13 #include "StatusSlider.h" 14 14 15 15 16 class PoorManAdvancedView: public BView 17 { 16 class PoorManAdvancedView: public BView { 18 17 public: 19 PoorManAdvancedView(BRect, const char *name); 20 int32 MaxSimultaneousConnections() { return maxConnections->Value(); } 21 void SetMaxSimutaneousConnections(int32 num); 18 PoorManAdvancedView(const char *name); 19 20 int32 MaxSimultaneousConnections() 21 { return fMaxConnections->Value(); } 22 void SetMaxSimutaneousConnections(int32 num); 22 23 private: 23 // Advanced Tab24 // Advanced Tab 24 25 // Connections Options 25 StatusSlider * maxConnections;26 StatusSlider* fMaxConnections; 26 27 }; 27 28 28 29 #endif -
src/apps/poorman/PoorManLoggingView.cpp
diff --git a/src/apps/poorman/PoorManLoggingView.cpp b/src/apps/poorman/PoorManLoggingView.cpp index 2f52c40..2d06194 100644
a b 7 7 8 8 #include <Box.h> 9 9 #include <Catalog.h> 10 #include <GroupLayoutBuilder.h> 10 11 #include <Locale.h> 11 12 12 13 #include "constants.h" … … 19 20 #define B_TRANSLATION_CONTEXT "PoorMan" 20 21 21 22 22 PoorManLoggingView::PoorManLoggingView(BRect rect, const char *name) 23 : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) 23 PoorManLoggingView::PoorManLoggingView(const char* name) 24 : 25 BView(name, B_WILL_DRAW, NULL) 24 26 { 25 PoorManWindow *win;26 win = ((PoorManApplication 27 PoorManWindow* win; 28 win = ((PoorManApplication*)be_app)->GetPoorManWindow(); 27 29 28 Set ViewColor(BACKGROUND_COLOR);30 SetLayout(new BGroupLayout(B_VERTICAL)); 29 31 30 // Console Logging BBox 31 BRect consoleLoggingRect; 32 consoleLoggingRect = rect; 33 consoleLoggingRect.top -= 5.0; 34 consoleLoggingRect.left -= 5.0; 35 consoleLoggingRect.right -= 7.0; 36 consoleLoggingRect.bottom -= 118.0; 37 38 BBox * consoleLogging = new BBox(consoleLoggingRect, 39 B_TRANSLATE("Console Logging")); 32 BBox* consoleLogging = new BBox(B_TRANSLATE("Console Logging")); 40 33 consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING); 41 AddChild(consoleLogging);42 43 34 44 35 // File Logging BBox 45 BRect fileLoggingRect; 46 fileLoggingRect = consoleLoggingRect; 47 fileLoggingRect.top = consoleLoggingRect.bottom + 10.0; 48 fileLoggingRect.bottom = fileLoggingRect.top + 100.0; 49 50 BBox * fileLogging = new BBox(fileLoggingRect, 51 B_TRANSLATE("File Logging")); 36 BBox* fileLogging = new BBox(B_TRANSLATE("File Logging")); 52 37 fileLogging->SetLabel(STR_BBX_FILE_LOGGING); 53 AddChild(fileLogging); 54 55 float left = 10.0; 56 float top = 20.0; 57 float box_size = 13.0; 58 BRect tempRect(left, top, consoleLoggingRect.Width() - 5.0, top + box_size); 59 38 60 39 // Console Logging 61 logConsole = new BCheckBox(tempRect,B_TRANSLATE("Log To Console"),40 fLogConsole = new BCheckBox(B_TRANSLATE("Log To Console"), 62 41 STR_CBX_LOG_CONSOLE, new BMessage(MSG_PREF_LOG_CBX_CONSOLE)); 63 42 // set the checkbox to the value the program has 64 43 SetLogConsoleValue(win->LogConsoleFlag()); 65 consoleLogging->AddChild(logConsole);66 44 67 45 // File Logging 68 logFile = new BCheckBox(tempRect, B_TRANSLATE("Log To File"),69 STR_CBX_LOG_FILE,new BMessage(MSG_PREF_LOG_CBX_FILE));46 fLogFile = new BCheckBox(B_TRANSLATE("Log To File"), STR_CBX_LOG_FILE, 47 new BMessage(MSG_PREF_LOG_CBX_FILE)); 70 48 // set the checkbox to the value the program has 71 49 SetLogFileValue(win->LogFileFlag()); 72 fileLogging->AddChild(logFile);73 50 74 51 // File Name 75 tempRect.top = tempRect.bottom + 10.0; 76 tempRect.bottom = tempRect.top + box_size; 77 tempRect.right -= 5.0; 78 79 logFileName = new BTextControl(tempRect, B_TRANSLATE("File Name"), 52 fLogFileName = new BTextControl(B_TRANSLATE("File Name"), 80 53 STR_TXT_LOG_FILE_NAME, NULL, NULL); 81 logFileName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);82 logFileName->SetDivider(fileLogging->StringWidth(STR_TXT_LOG_FILE_NAME) + 8.0f);83 54 SetLogFileName(win->LogPath()); 84 fileLogging->AddChild(logFileName);85 55 86 56 // Create Log File 87 BRect createLogFileRect; 88 createLogFileRect.top = tempRect.bottom + 13.0; 89 createLogFileRect.right = tempRect.right + 2.0; 90 createLogFileRect.left = createLogFileRect.right 91 - fileLogging->StringWidth(B_TRANSLATE("Create Log File")) - 24.0; 92 createLogFileRect.bottom = createLogFileRect.top + 19.0; 93 94 createLogFile = new BButton(createLogFileRect, B_TRANSLATE("Create Log File"), 57 fCreateLogFile = new BButton(B_TRANSLATE("Create Log File"), 95 58 STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE)); 96 fileLogging->AddChild(createLogFile);97 59 60 consoleLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 61 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 62 .Add(fLogConsole) 63 .AddGlue()) 64 .SetInsets(5, 5, 5, 5)); 65 66 fileLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 67 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 68 .Add(fLogFile) 69 .AddGlue()) 70 .Add(fLogFileName) 71 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 72 .AddGlue() 73 .Add(fCreateLogFile)) 74 .SetInsets(5, 5, 5, 5)); 75 76 AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 77 .Add(consoleLogging) 78 .Add(fileLogging) 79 .SetInsets(5, 5, 5, 5)); 98 80 } -
src/apps/poorman/PoorManLoggingView.h
diff --git a/src/apps/poorman/PoorManLoggingView.h b/src/apps/poorman/PoorManLoggingView.h index 2ffa367..9648f08 100644
a b 14 14 #include <CheckBox.h> 15 15 16 16 17 class PoorManLoggingView: public BView 18 { 17 class PoorManLoggingView: public BView { 19 18 public: 20 PoorManLoggingView(BRect, const char *name);19 PoorManLoggingView(const char* name); 21 20 22 void SetLogConsoleValue(bool state) {if (state) logConsole->SetValue(B_CONTROL_ON); 23 else logConsole->SetValue(B_CONTROL_OFF); } 24 bool LogConsoleValue() { return (logConsole->Value() == B_CONTROL_ON) ? true : false; } 25 void SetLogFileValue(bool state) {if (state) logFile->SetValue(B_CONTROL_ON); 26 else logFile->SetValue(B_CONTROL_OFF); } 27 bool LogFileValue() { return (logFile->Value() == B_CONTROL_ON) ? true : false; } 28 const char * LogFileName() { return logFileName->Text(); } 29 void SetLogFileName(const char * log) { logFileName->SetText(log); } 30 private: 31 // Logging Tab 21 void SetLogConsoleValue(bool state) 22 { if (state) 23 fLogConsole->SetValue(B_CONTROL_ON); 24 else fLogConsole->SetValue(B_CONTROL_OFF); } 25 bool LogConsoleValue() 26 { return (fLogConsole->Value() == B_CONTROL_ON) 27 ? true : false; } 28 void SetLogFileValue(bool state) 29 { if (state) fLogFile->SetValue(B_CONTROL_ON); 30 else fLogFile->SetValue(B_CONTROL_OFF); } 31 bool LogFileValue() 32 { return (fLogFile->Value() == B_CONTROL_ON) 33 ? true : false; } 34 const char* LogFileName() 35 { return fLogFileName->Text(); } 36 void SetLogFileName(const char* log) 37 { fLogFileName->SetText(log); } 32 38 39 private: 40 // Logging Tab 33 41 // Console Logging 34 BCheckBox * logConsole;42 BCheckBox* fLogConsole; 35 43 // File Logging 36 BCheckBox * logFile;37 BTextControl * logFileName;38 BButton * createLogFile;44 BCheckBox* fLogFile; 45 BTextControl* fLogFileName; 46 BButton * fCreateLogFile; 39 47 }; 40 48 41 49 #endif -
src/apps/poorman/PoorManPreferencesWindow.cpp
diff --git a/src/apps/poorman/PoorManPreferencesWindow.cpp b/src/apps/poorman/PoorManPreferencesWindow.cpp index 21a7137..a09475d 100644
a b 9 9 #include <Catalog.h> 10 10 #include <Debug.h> 11 11 #include <Directory.h> 12 #include <GroupLayoutBuilder.h> 13 #include <GroupView.h> 12 14 #include <Locale.h> 15 #include <SpaceLayoutItem.h> 13 16 #include <Window.h> 14 17 15 18 #include "constants.h" … … 25 28 26 29 PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name) 27 30 : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE 28 | B_CLOSE_ON_ESCAPE ),29 webDirFilePanel(NULL),30 logFilePanel(NULL)31 | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS), 32 fWebDirFilePanel(NULL), 33 fLogFilePanel(NULL) 31 34 { 32 frame = Bounds();35 SetLayout(new BGroupLayout(B_VERTICAL)); 33 36 34 prefView = new PoorManView(frame, STR_WIN_NAME_PREF); 35 //prefView->SetViewColor(216,216,216,255); 36 prefView->SetViewColor(BACKGROUND_COLOR); 37 AddChild(prefView); 38 39 40 // Button View 41 BRect buttonRect; 42 buttonRect = Bounds(); 43 buttonRect.top = buttonRect.bottom - 30; 44 45 buttonView = new PoorManView(buttonRect, "Button View"); 46 buttonView->SetViewColor(BACKGROUND_COLOR); 47 prefView->AddChild(buttonView); 48 49 // Buttons 50 float buttonTop = 0.0f; 51 float buttonHeight = 26.0f; 52 53 float widthCancel = prefView->StringWidth(B_TRANSLATE("Cancel")) + 24.0f; 54 float widthDone = prefView->StringWidth(B_TRANSLATE("Done")) + 24.0f; 55 56 float gap = 5.0f; 57 58 BRect button1(prefView->Bounds().Width() - 2 * gap - widthCancel 59 - widthDone, buttonTop, prefView->Bounds().Width() - 2 * gap - widthDone, 60 buttonTop + buttonHeight); 61 cancelButton = new BButton(button1, "Cancel Button", B_TRANSLATE("Cancel"), 37 fCancelButton = new BButton("Cancel Button", B_TRANSLATE("Cancel"), 62 38 new BMessage(MSG_PREF_BTN_CANCEL)); 63 64 BRect button2(prefView->Bounds().Width() - gap - widthDone, buttonTop, 65 prefView->Bounds().Width() - gap, buttonTop + buttonHeight); 66 doneButton = new BButton(button2, "Done Button", B_TRANSLATE("Done"), 39 fDoneButton = new BButton("Done Button", B_TRANSLATE("Done"), 67 40 new BMessage(MSG_PREF_BTN_DONE)); 68 41 69 buttonView->AddChild(cancelButton); 70 buttonView->AddChild(doneButton); 71 72 // Create tabs 73 BRect r; 74 r = Bounds(); 75 //r.InsetBy(5, 5); 76 r.top += 8.0; 77 r.bottom -= 38.0; 78 79 prefTabView = new BTabView(r, "Pref Tab View"); 80 prefTabView->SetViewColor(BACKGROUND_COLOR); 81 82 r = prefTabView->Bounds(); 83 r.InsetBy(5, 5); 84 r.bottom -= prefTabView->TabHeight(); 42 fPrefTabView = new BTabView("Pref Tab View"); 85 43 86 44 // Site Tab 87 siteTab = new BTab();88 siteView = new PoorManSiteView(r,"Site View");89 prefTabView->AddTab(siteView, siteTab);90 siteTab->SetLabel(STR_TAB_SITE);45 fSiteTab = new BTab(); 46 fSiteView = new PoorManSiteView("Site View"); 47 fPrefTabView->AddTab(fSiteView, fSiteTab); 48 fSiteTab->SetLabel(STR_TAB_SITE); 91 49 92 50 // Logging Tab 93 loggingTab = new BTab();94 loggingView = new PoorManLoggingView(r,"Logging View");95 prefTabView->AddTab(loggingView, loggingTab);96 loggingTab->SetLabel(STR_TAB_LOGGING);51 fLoggingTab = new BTab(); 52 fLoggingView = new PoorManLoggingView("Logging View"); 53 fPrefTabView->AddTab(fLoggingView, fLoggingTab); 54 fLoggingTab->SetLabel(STR_TAB_LOGGING); 97 55 98 56 // Advanced Tab 99 advancedTab = new BTab(); 100 advancedView = new PoorManAdvancedView(r, "Advanced View"); 101 prefTabView->AddTab(advancedView, advancedTab); 102 advancedTab->SetLabel(STR_TAB_ADVANCED); 103 104 prefView->AddChild(prefTabView); 57 fAdvancedTab = new BTab(); 58 fAdvancedView = new PoorManAdvancedView("Advanced View"); 59 fPrefTabView->AddTab(fAdvancedView, fAdvancedTab); 60 fAdvancedTab->SetLabel(STR_TAB_ADVANCED); 105 61 106 62 // FilePanels 107 63 BWindow * change_title; 108 64 109 65 BMessenger messenger(this); 110 66 BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR); 111 webDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,67 fWebDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL, 112 68 B_DIRECTORY_NODE, false, &message, NULL, true); 113 69 114 webDirFilePanel->SetPanelDirectory(new BDirectory("/boot/home/public_html")); 115 webDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); 116 change_title = webDirFilePanel->Window(); 70 fWebDirFilePanel->SetPanelDirectory( 71 new BDirectory("/boot/home/public_html")); 72 fWebDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); 73 change_title = fWebDirFilePanel->Window(); 117 74 change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR); 118 75 119 76 message.what = MSG_FILE_PANEL_CREATE_LOG_FILE; 120 logFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL,77 fLogFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL, 121 78 B_FILE_NODE, false, &message); 122 logFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create"));123 change_title = logFilePanel->Window();79 fLogFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create")); 80 change_title = fLogFilePanel->Window(); 124 81 change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE); 82 83 AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 84 .Add(fPrefTabView) 85 .Add(BGroupLayoutBuilder(B_HORIZONTAL) 86 .AddGlue() 87 .Add(fCancelButton) 88 .Add(fDoneButton)) 89 .SetInsets(5, 5, 5, 5)); 125 90 } 126 91 127 92 128 93 PoorManPreferencesWindow::~PoorManPreferencesWindow() 129 94 { 130 delete logFilePanel;131 delete webDirFilePanel;95 delete fLogFilePanel; 96 delete fWebDirFilePanel; 132 97 } 133 98 134 99 … … PoorManPreferencesWindow::MessageReceived(BMessage* message) 139 104 case MSG_PREF_BTN_DONE: 140 105 PoorManWindow* win; 141 106 PoorManServer* server; 142 win = ((PoorManApplication 107 win = ((PoorManApplication*)be_app)->GetPoorManWindow(); 143 108 server = win->GetServer(); 144 109 145 110 PRINT(("Pref Window: sendDir CheckBox: %d\n", 146 siteView->SendDirValue()));147 server->SetListDir( siteView->SendDirValue());148 win->SetDirListFlag( siteView->SendDirValue());111 fSiteView->SendDirValue())); 112 server->SetListDir(fSiteView->SendDirValue()); 113 win->SetDirListFlag(fSiteView->SendDirValue()); 149 114 PRINT(("Pref Window: indexFileName TextControl: %s\n", 150 siteView->IndexFileName()));151 if (server->SetIndexName( siteView->IndexFileName()) == B_OK)152 win->SetIndexFileName( siteView->IndexFileName());153 PRINT(("Pref Window: webDir: %s\n", siteView->WebDir()));154 if (server->SetWebDir( siteView->WebDir()) == B_OK) {155 win->SetWebDir( siteView->WebDir());156 win->SetDirLabel( siteView->WebDir());115 fSiteView->IndexFileName())); 116 if (server->SetIndexName(fSiteView->IndexFileName()) == B_OK) 117 win->SetIndexFileName(fSiteView->IndexFileName()); 118 PRINT(("Pref Window: webDir: %s\n", fSiteView->WebDir())); 119 if (server->SetWebDir(fSiteView->WebDir()) == B_OK) { 120 win->SetWebDir(fSiteView->WebDir()); 121 win->SetDirLabel(fSiteView->WebDir()); 157 122 } 158 123 159 124 PRINT(("Pref Window: logConsole CheckBox: %d\n", 160 loggingView->LogConsoleValue()));161 win->SetLogConsoleFlag( loggingView->LogConsoleValue());125 fLoggingView->LogConsoleValue())); 126 win->SetLogConsoleFlag(fLoggingView->LogConsoleValue()); 162 127 PRINT(("Pref Window: logFile CheckBox: %d\n", 163 loggingView->LogFileValue()));164 win->SetLogFileFlag( loggingView->LogFileValue());128 fLoggingView->LogFileValue())); 129 win->SetLogFileFlag(fLoggingView->LogFileValue()); 165 130 PRINT(("Pref Window: logFileName: %s\n", 166 loggingView->LogFileName()));167 win->SetLogPath( loggingView->LogFileName());131 fLoggingView->LogFileName())); 132 win->SetLogPath(fLoggingView->LogFileName()); 168 133 169 134 PRINT(("Pref Window: MaxConnections Slider: %ld\n", 170 advancedView->MaxSimultaneousConnections()));171 server->SetMaxConns( advancedView->MaxSimultaneousConnections());135 fAdvancedView->MaxSimultaneousConnections())); 136 server->SetMaxConns(fAdvancedView->MaxSimultaneousConnections()); 172 137 win->SetMaxConnections( 173 (int16) advancedView->MaxSimultaneousConnections());138 (int16)fAdvancedView->MaxSimultaneousConnections()); 174 139 175 140 if (Lock()) 176 141 Quit(); … … PoorManPreferencesWindow::MessageReceived(BMessage* message) 181 146 break; 182 147 case MSG_PREF_SITE_BTN_SELECT: 183 148 // Select the Web Directory, root directory to look in. 184 webDirFilePanel->SetTarget(this);185 webDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR));186 if (! webDirFilePanel->IsShowing())187 webDirFilePanel->Show();149 fWebDirFilePanel->SetTarget(this); 150 fWebDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR)); 151 if (!fWebDirFilePanel->IsShowing()) 152 fWebDirFilePanel->Show(); 188 153 break; 189 154 case MSG_FILE_PANEL_SELECT_WEB_DIR: 190 155 // handle the open BMessage from the Select Web Directory File Panel … … PoorManPreferencesWindow::MessageReceived(BMessage* message) 193 158 break; 194 159 case MSG_PREF_LOG_BTN_CREATE_FILE: 195 160 // Create the Log File 196 logFilePanel->Show();161 fLogFilePanel->Show(); 197 162 break; 198 163 case MSG_FILE_PANEL_CREATE_LOG_FILE: 199 164 // handle the save BMessage from the Create Log File Panel … … PoorManPreferencesWindow::MessageReceived(BMessage* message) 201 166 CreateLogFile(message); 202 167 break; 203 168 case MSG_PREF_ADV_SLD_MAX_CONNECTION: 204 max_connections = advancedView->MaxSimultaneousConnections();205 PRINT(("Max Connections: %ld\n", max_connections));169 fMaxConnections = fAdvancedView->MaxSimultaneousConnections(); 170 PRINT(("Max Connections: %ld\n", fMaxConnections)); 206 171 break; 207 172 default: 208 173 BWindow::MessageReceived(message); … … PoorManPreferencesWindow::MessageReceived(BMessage* message) 212 177 213 178 214 179 void 215 PoorManPreferencesWindow::SelectWebDir(BMessage 180 PoorManPreferencesWindow::SelectWebDir(BMessage* message) 216 181 { 217 182 entry_ref ref; 218 const char 183 const char* name; 219 184 BPath path; 220 185 BEntry entry; 221 186 … … PoorManPreferencesWindow::SelectWebDir(BMessage * message) 227 192 entry.GetPath(&path); 228 193 229 194 PRINT(("DIR: %s\n", path.Path())); 230 siteView->SetWebDir(path.Path());195 fSiteView->SetWebDir(path.Path()); 231 196 232 197 bool temp; 233 198 if (message->FindBool("Default Dialog", &temp) == B_OK) { 234 199 PoorManWindow* win = ((PoorManApplication *)be_app)->GetPoorManWindow(); 235 200 win->StartServer(); 236 if (win->GetServer()->SetWebDir( siteView->WebDir()) == B_OK) {237 win->SetWebDir( siteView->WebDir());238 win->SetDirLabel( siteView->WebDir());201 if (win->GetServer()->SetWebDir(fSiteView->WebDir()) == B_OK) { 202 win->SetWebDir(fSiteView->WebDir()); 203 win->SetDirLabel(fSiteView->WebDir()); 239 204 win->SaveSettings(); 240 205 win->Show(); 241 206 } … … PoorManPreferencesWindow::SelectWebDir(BMessage * message) 246 211 247 212 248 213 void 249 PoorManPreferencesWindow::CreateLogFile(BMessage 214 PoorManPreferencesWindow::CreateLogFile(BMessage* message) 250 215 { 251 216 entry_ref ref; 252 217 const char * name; … … PoorManPreferencesWindow::CreateLogFile(BMessage * message) 268 233 PRINT(("Log File: %s\n", path.Path())); 269 234 270 235 if (err == B_OK) { 271 loggingView->SetLogFileName(path.Path());272 loggingView->SetLogFileValue(true);236 fLoggingView->SetLogFileName(path.Path()); 237 fLoggingView->SetLogFileValue(true); 273 238 } 274 239 275 240 // mark the checkbox … … PoorManPreferencesWindow::ShowWebDirFilePanel() 283 248 BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR); 284 249 message.AddBool("Default Dialog", true); 285 250 286 webDirFilePanel->SetTarget(be_app);287 webDirFilePanel->SetMessage(&message);288 if (! webDirFilePanel->IsShowing())289 webDirFilePanel->Show();251 fWebDirFilePanel->SetTarget(be_app); 252 fWebDirFilePanel->SetMessage(&message); 253 if (!fWebDirFilePanel->IsShowing()) 254 fWebDirFilePanel->Show(); 290 255 } -
src/apps/poorman/PoorManPreferencesWindow.h
diff --git a/src/apps/poorman/PoorManPreferencesWindow.h b/src/apps/poorman/PoorManPreferencesWindow.h index 2aaace8..7758799 100644
a b 22 22 #include "PoorManAdvancedView.h" 23 23 24 24 25 class PoorManPreferencesWindow: public BWindow { 26 public: 27 PoorManPreferencesWindow(BRect frame, char* name); 28 ~PoorManPreferencesWindow(); 25 29 30 virtual void MessageReceived(BMessage* message); 26 31 27 class PoorManPreferencesWindow: public BWindow 28 { 29 private: 30 31 PoorManView * prefView; 32 PoorManView * buttonView; 33 34 // ------------------------------------------------ 35 // Tabs 36 BTabView * prefTabView; 37 BTab * siteTab; 38 BTab * loggingTab; 39 BTab * advancedTab; 40 // Tab Views 41 PoorManSiteView * siteView; 42 PoorManLoggingView * loggingView; 43 PoorManAdvancedView * advancedView; 44 45 // ------------------------------------------------ 46 // Buttons 47 BButton * cancelButton; 48 BButton * doneButton; 32 void ShowWebDirFilePanel(); 33 void SelectWebDir(BMessage* message); 34 void CreateLogFile(BMessage* message); 49 35 50 // ------------------------------------------------ 51 // FilePanels 52 BFilePanel * webDirFilePanel; 53 BFilePanel * logFilePanel; 36 private: 37 PoorManView* fPrefView; 38 PoorManView* fButtonView; 39 40 // ------------------------------------------------ 41 // Tabs 42 BTabView* fPrefTabView; 43 BTab* fSiteTab; 44 BTab* fLoggingTab; 45 BTab* fAdvancedTab; 46 // Tab Views 47 PoorManSiteView* fSiteView; 48 PoorManLoggingView* fLoggingView; 49 PoorManAdvancedView* fAdvancedView; 50 51 // ------------------------------------------------ 52 // Buttons 53 BButton* fCancelButton; 54 BButton* fDoneButton; 55 56 // ------------------------------------------------ 57 // FilePanels 58 BFilePanel* fWebDirFilePanel; 59 BFilePanel* fLogFilePanel; 54 60 55 61 56 62 // ------------------------------------------------ 57 // temporary preference variables used to save and 58 // set the application to 59 // site tab 60 char web_directory[B_FILE_NAME_LENGTH]; 61 char index_file_name[64]; 62 bool send_dir; 63 // logging tab 64 bool log_to_console; 65 bool log_to_file; 66 char log_file_name[B_FILE_NAME_LENGTH]; 67 // advanced tab 68 int32 max_connections; 69 public: 70 PoorManPreferencesWindow(BRect frame, char * name); 71 ~PoorManPreferencesWindow(); 72 73 virtual void MessageReceived(BMessage * message); 74 75 void ShowWebDirFilePanel(); 76 void SelectWebDir(BMessage * message); 77 void CreateLogFile(BMessage * message); 63 // temporary preference variables used to save and 64 // set the application to 65 // site tab 66 char fWebDirectory[B_FILE_NAME_LENGTH]; 67 char fIndexFileName[64]; 68 bool fSendDir; 69 // logging tab 70 bool flogToConsole; 71 bool fLogToFile; 72 char fLogFileName[B_FILE_NAME_LENGTH]; 73 // advanced tab 74 int32 fMaxConnections; 78 75 }; 79 76 80 77 #endif -
src/apps/poorman/PoorManSiteView.cpp
diff --git a/src/apps/poorman/PoorManSiteView.cpp b/src/apps/poorman/PoorManSiteView.cpp index 4214d6c..532c0e6 100644
a b 6 6 */ 7 7 8 8 #include <Box.h> 9 #include <GroupLayoutBuilder.h> 9 10 10 11 #include "constants.h" 11 12 #include "PoorManSiteView.h" 12 13 #include "PoorManWindow.h" 13 14 #include "PoorManApplication.h" 14 15 15 PoorManSiteView::PoorManSiteView( BRect rect, const char *name)16 : BView( rect, name, B_FOLLOW_ALL, B_WILL_DRAW)16 PoorManSiteView::PoorManSiteView(const char* name) 17 : BView(name, B_WILL_DRAW, NULL) 17 18 { 18 PoorManWindow *win;19 PoorManWindow* win; 19 20 win = ((PoorManApplication *)be_app)->GetPoorManWindow(); 20 21 21 Set ViewColor(BACKGROUND_COLOR);22 SetLayout(new BGroupLayout(B_VERTICAL)); 22 23 23 24 // Web Site Location BBox 24 BRect webLocationRect; 25 webLocationRect = rect; 26 webLocationRect.top -= 5.0; 27 webLocationRect.left -= 5.0; 28 webLocationRect.right -= 7.0; 29 webLocationRect.bottom -= 98.0; 30 31 BBox * webSiteLocation = new BBox(webLocationRect, "Web Location"); 25 BBox* webSiteLocation = new BBox("Web Location"); 32 26 webSiteLocation->SetLabel(STR_BBX_LOCATION); 33 AddChild(webSiteLocation);34 27 35 28 // Web Site Options BBox 36 BRect webOptionsRect; 37 webOptionsRect = webLocationRect; 38 webOptionsRect.top = webOptionsRect.bottom + 10.0; 39 webOptionsRect.bottom = webOptionsRect.top + 80.0; 40 41 BBox * webSiteOptions = new BBox(webOptionsRect, "Web Options"); 29 BBox* webSiteOptions = new BBox("Web Options"); 42 30 webSiteOptions->SetLabel(STR_BBX_OPTIONS); 43 AddChild(webSiteOptions);44 31 45 32 // Send Directory List if No Index 46 float left = 10.0; 47 float top = 20.0; 48 float box_size = 13.0; 49 BRect sendDirRect(left, top, webOptionsRect.Width() - 5.0, top + box_size); 50 sendDir = new BCheckBox(sendDirRect, "Send Dir", STR_CBX_DIR_LIST_LABEL, new BMessage(MSG_PREF_SITE_CBX_INDEX)); 33 fSendDir = new BCheckBox("Send Dir", STR_CBX_DIR_LIST_LABEL, 34 new BMessage(MSG_PREF_SITE_CBX_INDEX)); 51 35 // set the checkbox to the value the program has 52 36 SetSendDirValue(win->DirListFlag()); 53 webSiteOptions->AddChild(sendDir);54 55 37 56 // Finish the Web Site Location Section57 BRect webSiteLocationRect;58 webSiteLocationRect = webLocationRect;59 webSiteLocationRect.InsetBy(10.0, 7.0);60 webSiteLocationRect.top += 13.0;61 webSiteLocationRect.bottom = webSiteLocationRect.top + 19.0;62 63 38 // Web Directory Text Control 64 webDir = new BTextControl(webSiteLocationRect, "Web Dir", 65 STR_TXT_DIRECTORY, NULL, NULL); 66 webDir->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); 67 webDir->SetDivider(80.0); 39 fWebDir = new BTextControl("Web Dir", STR_TXT_DIRECTORY, NULL); 68 40 SetWebDir(win->WebDir()); 69 webSiteLocation->AddChild(webDir);70 41 71 42 // Select Web Directory Button 72 BRect selectWebDirRect; 73 74 selectWebDirRect.top = webSiteLocationRect.bottom + 5.0; 75 selectWebDirRect.right = webSiteLocationRect.right + 2.0; 76 selectWebDirRect.left = selectWebDirRect.right 77 - webSiteLocation->StringWidth("Select Web Dir") - 24.0; 78 selectWebDirRect.bottom = selectWebDirRect.top + 19.0; 79 80 selectWebDir = new BButton(selectWebDirRect, "Select Web Dir", 81 STR_BTN_DIRECTORY, new BMessage(MSG_PREF_SITE_BTN_SELECT)); 82 webSiteLocation->AddChild(selectWebDir); 43 fSelectWebDir = new BButton("Select Web Dir", STR_BTN_DIRECTORY, 44 new BMessage(MSG_PREF_SITE_BTN_SELECT)); 83 45 84 46 // Index File Name Text Control 85 //webDirRect.InsetBy(10.0, 7.0); 86 webSiteLocationRect.top += 63.0; 87 webSiteLocationRect.bottom = webSiteLocationRect.top + 19.0; 88 89 indexFileName = new BTextControl(webSiteLocationRect, 90 "Index File Name", STR_TXT_INDEX, NULL, NULL); 91 indexFileName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); 92 indexFileName->SetDivider(80.0); 47 fIndexFileName = new BTextControl("Index File Name", STR_TXT_INDEX, NULL); 93 48 SetIndexFileName(win->IndexFileName()); 94 webSiteLocation->AddChild(indexFileName);95 49 50 webSiteOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 51 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 52 .Add(fSendDir) 53 .AddGlue()) 54 .SetInsets(5, 5, 5, 5)); 55 56 webSiteLocation->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 57 .Add(fWebDir) 58 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 59 .AddGlue() 60 .Add(fSelectWebDir)) 61 .Add(fIndexFileName) 62 .SetInsets(5, 5, 5, 5)); 63 64 AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 65 .Add(webSiteLocation) 66 .Add(webSiteOptions) 67 .SetInsets(5, 5, 5, 5)); 96 68 } -
src/apps/poorman/PoorManSiteView.h
diff --git a/src/apps/poorman/PoorManSiteView.h b/src/apps/poorman/PoorManSiteView.h index 2fecd8f..8bd8716 100644
a b 14 14 #include <CheckBox.h> 15 15 16 16 17 class PoorManSiteView: public BView 18 { 17 class PoorManSiteView: public BView { 19 18 public: 20 PoorManSiteView(BRect, const char *name); 21 void SetSendDirValue(bool state) {if (state) sendDir->SetValue(B_CONTROL_ON); 22 else sendDir->SetValue(B_CONTROL_OFF); } 23 bool SendDirValue() { return (sendDir->Value() == B_CONTROL_ON) ? true : false; } 24 const char * IndexFileName() { return indexFileName->Text(); } 25 void SetIndexFileName(const char * name) { indexFileName->SetText(name); } 26 const char * WebDir() { return webDir->Text(); } 27 void SetWebDir(const char * dir) { webDir->SetText(dir); } 19 PoorManSiteView(const char *name); 20 21 void SetSendDirValue(bool state) 22 { if (state) fSendDir->SetValue(B_CONTROL_ON); 23 else fSendDir->SetValue(B_CONTROL_OFF); } 24 bool SendDirValue() 25 { return (fSendDir->Value() == B_CONTROL_ON) 26 ? true : false; } 27 const char* IndexFileName() 28 { return fIndexFileName->Text(); } 29 void SetIndexFileName(const char* name) 30 { fIndexFileName->SetText(name); } 31 const char* WebDir() 32 { return fWebDir->Text(); } 33 void SetWebDir(const char* dir) 34 { fWebDir->SetText(dir); } 35 28 36 private: 29 37 // Site Tab 30 38 // Web Site Location 31 BTextControl * webDir;32 BTextControl * indexFileName;33 BButton * selectWebDir;39 BTextControl* fWebDir; 40 BTextControl* fIndexFileName; 41 BButton* fSelectWebDir; 34 42 35 43 // Web Site Options 36 BCheckBox * sendDir;44 BCheckBox* fSendDir; 37 45 38 46 }; 39 47 -
src/apps/poorman/PoorManView.cpp
diff --git a/src/apps/poorman/PoorManView.cpp b/src/apps/poorman/PoorManView.cpp index 492162c..9a27f51 100644
a b 10 10 #endif 11 11 12 12 PoorManView::PoorManView(BRect rect, const char *name) 13 : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW 13 : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) 14 14 { 15 15 } 16 16 -
src/apps/poorman/PoorManView.h
diff --git a/src/apps/poorman/PoorManView.h b/src/apps/poorman/PoorManView.h index 724dcad..e4c40da 100644
a b 12 12 #include <View.h> 13 13 #endif 14 14 15 class PoorManView: public BView 16 { 15 class PoorManView: public BView { 17 16 public: 18 PoorManView(BRect, const char *name); 19 virtual void AttachedToWindow(); 17 PoorManView(BRect, const char *name); 18 19 virtual void AttachedToWindow(); 20 20 }; 21 21 22 22 #endif -
src/apps/poorman/PoorManWindow.cpp
diff --git a/src/apps/poorman/PoorManWindow.cpp b/src/apps/poorman/PoorManWindow.cpp index 08eb8b8..07e5ba9 100644
a b 17 17 #include <Directory.h> 18 18 #include <File.h> 19 19 #include <FindDirectory.h> 20 #include <GroupLayoutBuilder.h> 20 21 #include <Locale.h> 21 22 #include <Menu.h> 22 23 #include <MenuBar.h> … … 43 44 44 45 45 46 PoorManWindow::PoorManWindow(BRect frame) 46 : BWindow(frame, STR_APP_NAME, B_TITLED_WINDOW, 0), 47 status(false), hits(0), prefWindow(NULL), fLogFile(NULL), fServer(NULL) 47 : 48 BWindow(frame, STR_APP_NAME, B_TITLED_WINDOW, 0), 49 fStatus(false), 50 fHits(0), 51 fPrefWindow(NULL), 52 fLogFile(NULL), 53 fServer(NULL) 48 54 { 49 55 //preferences init 50 web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY);51 index_file_name.SetTo("index.html");52 dir_list_flag = false;56 fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY); 57 fIndexFileName.SetTo("index.html"); 58 fDirListFlag = false; 53 59 54 log_console_flag = true;55 log_file_flag = false;56 log_path.SetTo("");60 fLogConsoleFlag = true; 61 fLogFileFlag = false; 62 fLogPath.SetTo(""); 57 63 58 max_connections = (int16)32;64 fMaxConnections = (int16)32; 59 65 60 is_zoomed = true;61 last_width = 318.0f;62 last_height = 320.0f;63 this->f rame = frame;64 setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f);66 fIsZoomed = true; 67 fLastWidth = 318.0f; 68 fLastHeight = 320.0f; 69 this->fFrame = frame; 70 fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f); 65 71 66 72 // PoorMan Window 67 73 SetSizeLimits(318, 1600, 53, 1200); 68 74 // limit the size of the size of the window 69 75 70 //SetZoomLimits(1024, 768); 71 72 //frame.Set(30.0f, 30.0f, 355.0f, 185.0f); 73 frame.OffsetTo(B_ORIGIN); 74 frame = Bounds(); 75 frame.top += 19.0; 76 77 mainView = new PoorManView(frame, STR_APP_NAME); 78 mainView->SetViewColor(216,216,216,255); 79 80 mainView->SetFont(be_bold_font); 81 mainView->SetFontSize(12); 82 AddChild(mainView); 83 84 // BBox tests 85 BRect br; 86 br = mainView->Bounds(); 87 br.top = 1.0; 88 89 BBox * bb = new BBox(br, "Background", B_FOLLOW_ALL_SIDES, 90 B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE); 91 bb->SetHighColor(WHITE); 92 bb->SetLowColor(GRAY); 93 bb->SetBorder(B_PLAIN_BORDER); 94 mainView->AddChild(bb); 76 SetLayout(new BGroupLayout(B_VERTICAL)); 95 77 96 78 // ----------------------------------------------------------------- 97 79 // Three Labels 98 80 99 81 // Status String 100 BRect statusRect; 101 statusRect = Bounds(); 102 statusRect.left += 5; 103 statusRect.top += 3; 104 statusRect.bottom = statusRect.top + 15; 105 statusRect.right = statusRect.left + 100; // make the width wide enough for the string to display 106 107 statusView = new BStringView(statusRect, "Status View", 108 B_TRANSLATE("Status: Stopped")); 109 bb->AddChild(statusView); 82 fStatusView = new BStringView("Status View", B_TRANSLATE("Status: Stopped")); 110 83 111 84 // Directory String 112 BRect dirRect; 113 dirRect = Bounds(); 114 dirRect.top = statusRect.bottom - 1; 115 dirRect.bottom = dirRect.top + 15; 116 dirRect.left = statusRect.left; 117 dirRect.right -= 5; 118 119 dirView = new BStringView(dirRect, "Dir View", 120 B_TRANSLATE("Directory: (none)"), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); 121 bb->AddChild(dirView); 85 fDirView = new BStringView("Dir View", B_TRANSLATE("Directory: (none)")); 122 86 123 87 // Hits String 124 BRect hitsRect; 125 hitsRect = bb->Bounds(); 126 hitsRect.InsetBy(5.0f, 5.0f); 127 hitsRect.top = statusRect.top; 128 hitsRect.bottom = statusRect.bottom; 129 hitsRect.left = statusRect.right + 20; 130 131 hitsView = new BStringView(hitsRect, "Hit View", B_TRANSLATE("Hits: 0"), 132 B_FOLLOW_RIGHT | B_FOLLOW_TOP); 133 hitsView->SetAlignment(B_ALIGN_RIGHT); 134 bb->AddChild(hitsView); 88 fHitsView = new BStringView("Hit View", B_TRANSLATE("Hits: 0")); 135 89 136 90 // ----------------------------------------------------------------- 137 91 // Logging View 138 139 // logRect 140 BRect logRect = bb->Bounds();//(5.0, 36.0, 306.0, 131.0); 141 logRect.InsetBy(5, 5); 142 logRect.top = 36.0f; 143 logRect.right -= B_V_SCROLL_BAR_WIDTH; 144 145 // textRect 146 BRect textRect; //(1.0, 1.0, 175.0, 75.0); 147 textRect = logRect; 148 textRect.top = 0.0; 149 textRect.left = 2.0; 150 textRect.right = logRect.right - logRect.left - 2.0; 151 textRect.bottom = logRect.bottom - logRect.top; 152 153 fLogViewFont = new BFont(be_plain_font); 154 fLogViewFont->SetSize(11.0); 155 156 loggingView = new BTextView(logRect, STR_TXT_VIEW, textRect, 157 fLogViewFont, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW ); 158 159 loggingView->MakeEditable(false); // user cannot change the text 160 loggingView->MakeSelectable(true); 161 loggingView->SetViewColor(WHITE); 162 loggingView->SetStylable(true); 92 93 fLoggingView = new BTextView(STR_TXT_VIEW, B_WILL_DRAW ); 94 95 fLoggingView->MakeEditable(false); // user cannot change the text 96 fLoggingView->MakeSelectable(true); 97 fLoggingView->SetViewColor(WHITE); 98 fLoggingView->SetStylable(true); 163 99 164 100 // create the scroll view 165 scrollView = new BScrollView("Scroll View", loggingView, B_FOLLOW_ALL_SIDES,166 B_WILL_DRAW | B_FRAME_EVENTS ,101 fScrollView = new BScrollView("Scroll View", fLoggingView, 102 B_WILL_DRAW | B_FRAME_EVENTS | B_FOLLOW_ALL_SIDES, 167 103 // Make sure articles on border do not occur when resizing 168 104 false, true); 169 bb->AddChild(scrollView); 170 loggingView->MakeFocus(true); 105 fLoggingView->MakeFocus(true); 171 106 172 107 173 108 // ----------------------------------------------------------------- 174 109 // menu bar 175 BRect menuRect; 176 menuRect = Bounds(); 177 menuRect.bottom = 18.0f; 178 179 FileMenuBar = new BMenuBar(menuRect, "File Menu Bar"); 110 fFileMenuBar = new BMenuBar("File Menu Bar"); 180 111 181 112 // menus 182 FileMenu = BuildFileMenu();183 if ( FileMenu)184 FileMenuBar->AddItem(FileMenu);113 fFileMenu = BuildFileMenu(); 114 if (fFileMenu) 115 fFileMenuBar->AddItem(fFileMenu); 185 116 186 EditMenu = BuildEditMenu();187 if ( EditMenu)188 FileMenuBar->AddItem(EditMenu);117 fEditMenu = BuildEditMenu(); 118 if (fEditMenu) 119 fFileMenuBar->AddItem(fEditMenu); 189 120 190 ControlsMenu = BuildControlsMenu();191 if ( ControlsMenu)192 FileMenuBar->AddItem(ControlsMenu);121 fControlsMenu = BuildControlsMenu(); 122 if (fControlsMenu) 123 fFileMenuBar->AddItem(fControlsMenu); 193 124 194 125 // File Panels 195 126 BWindow* change_title; 196 127 197 BMessenger messenger(this); 198 saveConsoleFilePanel = new BFilePanel( 199 B_SAVE_PANEL, 200 &messenger, 201 NULL, 202 B_FILE_NODE, 203 false, 128 fSaveConsoleFilePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), 129 NULL, B_FILE_NODE, false, 204 130 new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE)); 205 206 change_title = saveConsoleFilePanel->Window(); 131 change_title = fSaveConsoleFilePanel->Window(); 207 132 change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE); 208 133 209 saveConsoleSelectionFilePanel = new BFilePanel( 210 B_SAVE_PANEL, 211 &messenger, 212 NULL, 213 B_FILE_NODE, 214 false, 134 fSaveConsoleSelectionFilePanel = new BFilePanel(B_SAVE_PANEL, 135 new BMessenger(this), NULL, B_FILE_NODE, false, 215 136 new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION)); 216 217 change_title = saveConsoleSelectionFilePanel->Window(); 137 change_title = fSaveConsoleSelectionFilePanel->Window(); 218 138 change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE_SELECTION); 219 139 220 221 AddChild(FileMenuBar); 140 AddChild(BGroupLayoutBuilder(B_VERTICAL) 141 .Add(fFileMenuBar) 142 .Add(BGroupLayoutBuilder(B_VERTICAL, 5) 143 .Add(BGroupLayoutBuilder(B_HORIZONTAL) 144 .Add(fStatusView) 145 .AddGlue() 146 .Add(fHitsView)) 147 .Add(BGroupLayoutBuilder(B_HORIZONTAL) 148 .Add(fDirView) 149 .AddGlue()) 150 .Add(fScrollView) 151 .SetInsets(10, 10, 10, 10))); 222 152 223 153 pthread_rwlock_init(&fLogFileLock, NULL); 224 154 } … … PoorManWindow::PoorManWindow(BRect frame) 227 157 PoorManWindow::~PoorManWindow() 228 158 { 229 159 delete fServer; 230 delete fLogViewFont;231 160 delete fLogFile; 232 161 pthread_rwlock_destroy(&fLogFileLock); 233 162 } … … void 237 166 PoorManWindow::MessageReceived(BMessage* message) 238 167 { 239 168 switch (message->what) { 240 case MSG_MENU_FILE_SAVE_AS: 241 saveConsoleFilePanel->Show(); 242 break; 243 case MSG_FILE_PANEL_SAVE_CONSOLE: 244 printf("FilePanel: Save console\n"); 245 SaveConsole(message, false); 246 break; 247 case MSG_MENU_FILE_SAVE_SELECTION: 248 saveConsoleSelectionFilePanel->Show(); 249 break; 250 case MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION: 251 printf("FilePanel: Save console selection\n"); 252 SaveConsole(message, true); 253 break; 254 case MSG_FILE_PANEL_SELECT_WEB_DIR: 255 prefWindow->MessageReceived(message); 256 break; 257 case MSG_MENU_EDIT_PREF: 258 prefWindow = new PoorManPreferencesWindow( 259 setwindow_frame, 260 STR_WIN_NAME_PREF); 261 prefWindow->Show(); 262 break; 263 case MSG_MENU_CTRL_RUN: 264 if (status) 265 StopServer(); 266 else 267 StartServer(); 268 break; 269 case MSG_MENU_CTRL_CLEAR_HIT: 270 SetHits(0); 271 //UpdateHitsLabel(); 272 break; 273 case MSG_MENU_CTRL_CLEAR_CONSOLE: 274 loggingView->SelectAll(); 275 loggingView->Delete(); 276 break; 277 case MSG_MENU_CTRL_CLEAR_LOG: 278 FILE * f; 279 f = fopen(log_path.String(), "w"); 280 fclose(f); 281 break; 282 case MSG_LOG: { 283 if (!log_console_flag && !log_file_flag) 169 case MSG_MENU_FILE_SAVE_AS: 170 fSaveConsoleFilePanel->Show(); 171 break; 172 case MSG_FILE_PANEL_SAVE_CONSOLE: 173 printf("FilePanel: Save console\n"); 174 SaveConsole(message, false); 175 break; 176 case MSG_MENU_FILE_SAVE_SELECTION: 177 fSaveConsoleSelectionFilePanel->Show(); 178 break; 179 case MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION: 180 printf("FilePanel: Save console selection\n"); 181 SaveConsole(message, true); 182 break; 183 case MSG_FILE_PANEL_SELECT_WEB_DIR: 184 fPrefWindow->MessageReceived(message); 185 break; 186 case MSG_MENU_EDIT_PREF: 187 fPrefWindow = new PoorManPreferencesWindow(fSetwindowFrame, 188 STR_WIN_NAME_PREF); 189 fPrefWindow->Show(); 190 break; 191 case MSG_MENU_CTRL_RUN: 192 if (fStatus) 193 StopServer(); 194 else 195 StartServer(); 196 break; 197 case MSG_MENU_CTRL_CLEAR_HIT: 198 SetHits(0); 199 //UpdateHitsLabel(); 200 break; 201 case MSG_MENU_CTRL_CLEAR_CONSOLE: 202 fLoggingView->SelectAll(); 203 fLoggingView->Delete(); 204 break; 205 case MSG_MENU_CTRL_CLEAR_LOG: 206 FILE* f; 207 f = fopen(fLogPath.String(), "w"); 208 fclose(f); 284 209 break; 210 case MSG_LOG: { 211 if (!fLogConsoleFlag && !fLogFileFlag) 212 break; 285 213 286 time_t time;287 in_addr_t address;288 rgb_color color;289 const void* pointer;290 ssize_t size;291 const char* msg;292 BString line;214 time_t time; 215 in_addr_t address; 216 rgb_color color; 217 const void* pointer; 218 ssize_t size; 219 const char* msg; 220 BString line; 293 221 294 if (message->FindString("cstring", &msg) != B_OK)295 break;296 if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK)297 time = -1;298 else299 time = *static_cast<const time_t*>(pointer);300 301 if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK)302 address = INADDR_NONE;303 else304 address = *static_cast<const in_addr_t*>(pointer);305 306 if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK)307 color = BLACK;308 else309 color = *static_cast<const rgb_color*>(pointer);222 if (message->FindString("cstring", &msg) != B_OK) 223 break; 224 if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK) 225 time = -1; 226 else 227 time = *static_cast<const time_t*>(pointer); 228 229 if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK) 230 address = INADDR_NONE; 231 else 232 address = *static_cast<const in_addr_t*>(pointer); 233 234 if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK) 235 color = BLACK; 236 else 237 color = *static_cast<const rgb_color*>(pointer); 310 238 311 if (time != -1) { 312 BString timeString; 313 if (BLocale::Default()->FormatDateTime(&timeString, time, 314 DATE_FORMAT, TIME_FORMAT) == B_OK) { 315 line << '[' << timeString << "]: "; 239 if (time != -1) { 240 BString timeString; 241 if (BLocale::Default()->FormatDateTime(&timeString, time, 242 DATE_FORMAT, TIME_FORMAT) == B_OK) { 243 line << '[' << timeString << "]: "; 244 } 316 245 } 317 }318 246 319 if (address != INADDR_NONE) { 320 char addr[INET_ADDRSTRLEN]; 321 struct in_addr sin_addr; 322 sin_addr.s_addr = address; 323 if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL) { 324 addr[strlen(addr)] = '\0'; 325 line << '(' << addr << ") "; 247 if (address != INADDR_NONE) { 248 char addr[INET_ADDRSTRLEN]; 249 struct in_addr sin_addr; 250 sin_addr.s_addr = address; 251 if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL) { 252 addr[strlen(addr)] = '\0'; 253 line << '(' << addr << ") "; 254 } 326 255 } 327 }328 256 329 line << msg;257 line << msg; 330 258 331 text_run run;332 text_run_array runs;259 text_run run; 260 text_run_array runs; 333 261 334 run.offset = 0; 335 run.font = *fLogViewFont; 336 run.color = color; 262 run.offset = 0; 263 run.color = color; 337 264 338 runs.count = 1;339 runs.runs[0] = run;265 runs.count = 1; 266 runs.runs[0] = run; 340 267 341 if (Lock()) {342 if (log_console_flag) {343 loggingView->Insert(loggingView->TextLength(),344 line.String(), line.Length(), &runs);345 loggingView->ScrollToOffset(loggingView->TextLength());346 }268 if (Lock()) { 269 if (fLogConsoleFlag) { 270 fLoggingView->Insert(fLoggingView->TextLength(), 271 line.String(), line.Length(), &runs); 272 fLoggingView->ScrollToOffset(fLoggingView->TextLength()); 273 } 347 274 348 if (log_file_flag) { 349 if (pthread_rwlock_rdlock(&fLogFileLock) == 0) { 350 fLogFile->Write(line.String(), line.Length()); 351 pthread_rwlock_unlock(&fLogFileLock); 275 if (fLogFileFlag) { 276 if (pthread_rwlock_rdlock(&fLogFileLock) == 0) { 277 fLogFile->Write(line.String(), line.Length()); 278 pthread_rwlock_unlock(&fLogFileLock); 279 } 352 280 } 353 }354 281 355 Unlock();356 }282 Unlock(); 283 } 357 284 358 break;359 }360 default:361 BWindow::MessageReceived(message);362 break;285 break; 286 } 287 default: 288 BWindow::MessageReceived(message); 289 break; 363 290 } 364 291 } 365 292 … … PoorManWindow::MessageReceived(BMessage* message) 367 294 void 368 295 PoorManWindow::FrameMoved(BPoint origin) 369 296 { 370 f rame.left = origin.x;371 f rame.top = origin.y;297 fFrame.left = origin.x; 298 fFrame.top = origin.y; 372 299 } 373 300 374 301 375 302 void 376 303 PoorManWindow::FrameResized(float width, float height) 377 304 { 378 if ( is_zoomed) {379 last_width = width;380 last_height = height;305 if (fIsZoomed) { 306 fLastWidth = width; 307 fLastHeight = height; 381 308 } 382 309 } 383 310 … … PoorManWindow::FrameResized(float width, float height) 385 312 bool 386 313 PoorManWindow::QuitRequested() 387 314 { 388 if ( status) {315 if (fStatus) { 389 316 time_t now = time(NULL); 390 317 BString timeString; 391 318 BLocale::Default()->FormatDateTime(&timeString, now, … … PoorManWindow::QuitRequested() 395 322 line << "[" << timeString << "]: " << B_TRANSLATE("Shutting down.") 396 323 << "\n"; 397 324 398 if ( log_console_flag) {399 loggingView->Insert(loggingView->TextLength(),400 401 loggingView->ScrollToOffset(loggingView->TextLength());325 if (fLogConsoleFlag) { 326 fLoggingView->Insert(fLoggingView->TextLength(), 327 line, line.Length()); 328 fLoggingView->ScrollToOffset(fLoggingView->TextLength()); 402 329 } 403 330 404 if ( log_file_flag) {331 if (fLogFileFlag) { 405 332 if (pthread_rwlock_rdlock(&fLogFileLock) == 0) { 406 407 333 fLogFile->Write(line, line.Length()); 334 pthread_rwlock_unlock(&fLogFileLock); 408 335 } 409 336 } 410 337 411 338 fServer->Stop(); 412 status = false;339 fStatus = false; 413 340 UpdateStatusLabelAndMenuItem(); 414 341 } 415 342 … … PoorManWindow::QuitRequested() 422 349 void 423 350 PoorManWindow::Zoom(BPoint origin, float width, float height) 424 351 { 425 if ( is_zoomed) {352 if (fIsZoomed) { 426 353 // Change to the Minimal size 427 is_zoomed = false;354 fIsZoomed = false; 428 355 ResizeTo(318, 53); 429 356 } else { 430 357 // Change to the Zoomed size 431 is_zoomed = true;432 ResizeTo( last_width, last_height);358 fIsZoomed = true; 359 ResizeTo(fLastWidth, fLastHeight); 433 360 } 434 361 } 435 362 … … PoorManWindow::Zoom(BPoint origin, float width, float height) 437 364 void 438 365 PoorManWindow::SetHits(uint32 num) 439 366 { 440 hits = num;367 fHits = num; 441 368 UpdateHitsLabel(); 442 369 } 443 370 … … PoorManWindow::SetHits(uint32 num) 445 372 // Private: Methods ------------------------------------------ 446 373 447 374 448 BMenu 375 BMenu* 449 376 PoorManWindow::BuildFileMenu() const 450 377 { 451 BMenu 378 BMenu* ptrFileMenu = new BMenu(STR_MNU_FILE); 452 379 453 380 ptrFileMenu->AddItem(new BMenuItem(STR_MNU_FILE_SAVE_AS, 454 381 new BMessage(MSG_MENU_FILE_SAVE_AS), CMD_FILE_SAVE_AS)); … … PoorManWindow::BuildFileMenu() const 465 392 } 466 393 467 394 468 BMenu 395 BMenu* 469 396 PoorManWindow::BuildEditMenu() const 470 397 { 471 BMenu 398 BMenu* ptrEditMenu = new BMenu(STR_MNU_EDIT); 472 399 473 BMenuItem 400 BMenuItem* CopyMenuItem = new BMenuItem(STR_MNU_EDIT_COPY, 474 401 new BMessage(B_COPY), CMD_EDIT_COPY); 475 402 476 403 ptrEditMenu->AddItem(CopyMenuItem); 477 CopyMenuItem->SetTarget( loggingView, NULL);404 CopyMenuItem->SetTarget(fLoggingView, NULL); 478 405 479 406 ptrEditMenu->AddSeparatorItem(); 480 407 481 BMenuItem 408 BMenuItem* SelectAllMenuItem = new BMenuItem(STR_MNU_EDIT_SELECT_ALL, 482 409 new BMessage(B_SELECT_ALL), CMD_EDIT_SELECT_ALL); 483 410 484 411 ptrEditMenu->AddItem(SelectAllMenuItem); 485 SelectAllMenuItem->SetTarget( loggingView, NULL);412 SelectAllMenuItem->SetTarget(fLoggingView, NULL); 486 413 487 414 ptrEditMenu->AddSeparatorItem(); 488 415 489 BMenuItem 416 BMenuItem* PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF, 490 417 new BMessage(MSG_MENU_EDIT_PREF)); 491 418 ptrEditMenu->AddItem(PrefMenuItem); 492 419 … … PoorManWindow::BuildEditMenu() const 494 421 } 495 422 496 423 497 BMenu 424 BMenu* 498 425 PoorManWindow::BuildControlsMenu() const 499 426 { 500 BMenu 427 BMenu* ptrControlMenu = new BMenu(STR_MNU_CTRL); 501 428 502 BMenuItem 429 BMenuItem* RunServerMenuItem = new BMenuItem(STR_MNU_CTRL_RUN_SERVER, 503 430 new BMessage(MSG_MENU_CTRL_RUN)); 504 431 RunServerMenuItem->SetMarked(false); 505 432 ptrControlMenu->AddItem(RunServerMenuItem); 506 433 507 BMenuItem 434 BMenuItem* ClearHitCounterMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_HIT_COUNTER, 508 435 new BMessage(MSG_MENU_CTRL_CLEAR_HIT)); 509 436 ptrControlMenu->AddItem(ClearHitCounterMenuItem); 510 437 511 438 ptrControlMenu->AddSeparatorItem(); 512 439 513 BMenuItem 440 BMenuItem* ClearConsoleLogMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_CONSOLE, 514 441 new BMessage(MSG_MENU_CTRL_CLEAR_CONSOLE)); 515 442 ptrControlMenu->AddItem(ClearConsoleLogMenuItem); 516 443 517 BMenuItem 444 BMenuItem* ClearLogFileMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_LOG_FILE, 518 445 new BMessage(MSG_MENU_CTRL_CLEAR_LOG)); 519 446 ptrControlMenu->AddItem(ClearLogFileMenuItem); 520 447 … … PoorManWindow::BuildControlsMenu() const 523 450 524 451 525 452 void 526 PoorManWindow::SetDirLabel(const char 453 PoorManWindow::SetDirLabel(const char* name) 527 454 { 528 455 BString dirPath(B_TRANSLATE("Directory: ")); 529 456 dirPath.Append(name); 530 457 531 458 if (Lock()) { 532 dirView->SetText(dirPath.String());459 fDirView->SetText(dirPath.String()); 533 460 Unlock(); 534 461 } 535 462 } … … void 539 466 PoorManWindow::UpdateStatusLabelAndMenuItem() 540 467 { 541 468 if (Lock()) { 542 if ( status)543 statusView->SetText(B_TRANSLATE("Status: Running"));469 if (fStatus) 470 fStatusView->SetText(B_TRANSLATE("Status: Running")); 544 471 else 545 statusView->SetText(B_TRANSLATE("Status: Stopped"));546 ControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(status);472 fStatusView->SetText(B_TRANSLATE("Status: Stopped")); 473 fControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(fStatus); 547 474 Unlock(); 548 475 } 549 476 } … … void 553 480 PoorManWindow::UpdateHitsLabel() 554 481 { 555 482 if (Lock()) { 556 sprintf( hitsLabel, B_TRANSLATE("Hits: %lu"), GetHits());557 hitsView->SetText(hitsLabel);483 sprintf(fHitsLabel, B_TRANSLATE("Hits: %lu"), GetHits()); 484 fHitsView->SetText(fHitsLabel); 558 485 559 486 Unlock(); 560 487 } … … PoorManWindow::UpdateHitsLabel() 562 489 563 490 564 491 status_t 565 PoorManWindow::SaveConsole(BMessage 492 PoorManWindow::SaveConsole(BMessage* message, bool selection) 566 493 { 567 494 entry_ref ref; 568 const char 495 const char* name; 569 496 BPath path; 570 497 BEntry entry; 571 498 status_t err = B_OK; 572 FILE *f;499 FILE* f; 573 500 574 if ((err = message->FindRef("directory", &ref)) != B_OK) 501 err = message->FindRef("directory", &ref); 502 if (err != B_OK) 575 503 return err; 576 504 577 if ((err = message->FindString("name", &name)) != B_OK) 505 err = message->FindString("name", &name); 506 if (err != B_OK) 578 507 return err; 579 508 580 if ((err = entry.SetTo(&ref)) != B_OK) 509 err = entry.SetTo(&ref); 510 if (err != B_OK) 581 511 return err; 582 512 583 513 entry.GetPath(&path); … … PoorManWindow::SaveConsole(BMessage * message, bool selection) 588 518 589 519 if (!selection) { 590 520 // write the data to the file 591 err = fwrite( loggingView->Text(), 1, loggingView->TextLength(), f);521 err = fwrite(fLoggingView->Text(), 1, fLoggingView->TextLength(), f); 592 522 } else { 593 523 // find the selected text and write it to a file 594 524 int32 start = 0, end = 0; 595 loggingView->GetSelection(&start, &end);525 fLoggingView->GetSelection(&start, &end); 596 526 597 527 BString buffer; 598 528 char * buffData = buffer.LockBuffer(end - start + 1); 599 529 // copy the selected text from the TextView to the buffer 600 loggingView->GetText(start, end - start, buffData);530 fLoggingView->GetText(start, end - start, buffData); 601 531 buffer.UnlockBuffer(end - start + 1); 602 532 603 533 err = fwrite(buffer.String(), 1, end - start + 1, f); 604 534 } 535 605 536 fclose(f); 606 537 607 538 return err; … … PoorManWindow::DefaultSettings() 627 558 break; 628 559 629 560 case 1: 630 prefWindow = new PoorManPreferencesWindow(631 setwindow_frame,561 fPrefWindow = new PoorManPreferencesWindow( 562 fSetwindowFrame, 632 563 STR_WIN_NAME_PREF); 633 prefWindow->ShowWebDirFilePanel();564 fPrefWindow->ShowWebDirFilePanel(); 634 565 break; 635 566 636 567 case 2: … … PoorManWindow::ReadSettings() 674 605 return B_ERROR; 675 606 676 607 //site tab 677 if (m.FindString(" web_directory", &web_directory) != B_OK)678 web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY);679 if (m.FindString(" index_file_name", &index_file_name) != B_OK)680 index_file_name.SetTo("index.html");681 if (m.FindBool(" dir_list_flag", &dir_list_flag) != B_OK)682 dir_list_flag = false;608 if (m.FindString("fWebDirectory", &fWebDirectory) != B_OK) 609 fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY); 610 if (m.FindString("fIndexFileName", &fIndexFileName) != B_OK) 611 fIndexFileName.SetTo("index.html"); 612 if (m.FindBool("fDirListFlag", &fDirListFlag) != B_OK) 613 fDirListFlag = false; 683 614 684 615 //logging tab 685 if (m.FindBool(" log_console_flag", &log_console_flag) != B_OK)686 log_console_flag = true;687 if (m.FindBool(" log_file_flag", &log_file_flag) != B_OK)688 log_file_flag = false;689 if (m.FindString(" log_path", &log_path) != B_OK)690 log_path.SetTo("");616 if (m.FindBool("fLogConsoleFlag", &fLogConsoleFlag) != B_OK) 617 fLogConsoleFlag = true; 618 if (m.FindBool("fLogFileFlag", &fLogFileFlag) != B_OK) 619 fLogFileFlag = false; 620 if (m.FindString("fLogPath", &fLogPath) != B_OK) 621 fLogPath.SetTo(""); 691 622 692 623 //advance tab 693 if (m.FindInt16(" max_connections", &max_connections) != B_OK)694 max_connections = (int16)32;624 if (m.FindInt16("fMaxConnections", &fMaxConnections) != B_OK) 625 fMaxConnections = (int16)32; 695 626 696 627 //windows' position and size 697 if (m.FindRect("frame", &f rame) != B_OK)698 f rame.Set(82.0f, 30.0f, 400.0f, 350.0f);699 if (m.FindRect(" setwindow_frame", &setwindow_frame) != B_OK)700 setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f);701 if (m.FindBool(" is_zoomed", &is_zoomed) != B_OK)702 is_zoomed = true;703 if (m.FindFloat(" last_width", &last_width) != B_OK)704 last_width = 318.0f;705 if (m.FindFloat(" last_height", &last_height) != B_OK)706 last_height = 320.0f;707 708 is_zoomed?ResizeTo(last_width, last_height):ResizeTo(318, 53);709 MoveTo(f rame.left, frame.top);710 711 fLogFile = new BFile( log_path.String(), B_CREATE_FILE | B_WRITE_ONLY628 if (m.FindRect("frame", &fFrame) != B_OK) 629 fFrame.Set(82.0f, 30.0f, 400.0f, 350.0f); 630 if (m.FindRect("fSetwindowFrame", &fSetwindowFrame) != B_OK) 631 fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f); 632 if (m.FindBool("fIsZoomed", &fIsZoomed) != B_OK) 633 fIsZoomed = true; 634 if (m.FindFloat("fLastWidth", &fLastWidth) != B_OK) 635 fLastWidth = 318.0f; 636 if (m.FindFloat("fLastHeight", &fLastHeight) != B_OK) 637 fLastHeight = 320.0f; 638 639 fIsZoomed?ResizeTo(fLastWidth, fLastHeight):ResizeTo(318, 53); 640 MoveTo(fFrame.left, fFrame.top); 641 642 fLogFile = new BFile(fLogPath.String(), B_CREATE_FILE | B_WRITE_ONLY 712 643 | B_OPEN_AT_END); 713 644 if (fLogFile->InitCheck() != B_OK) { 714 log_file_flag = false;645 fLogFileFlag = false; 715 646 //log it to console, "log to file unavailable." 716 647 return B_OK; 717 648 } 718 649 719 SetDirLabel( web_directory.String());650 SetDirLabel(fWebDirectory.String()); 720 651 721 652 return B_OK; 722 653 } … … PoorManWindow::SaveSettings() 730 661 BMessage m(MSG_PREF_FILE); 731 662 732 663 //site tab 733 m.AddString(" web_directory", web_directory);734 m.AddString(" index_file_name", index_file_name);735 m.AddBool(" dir_list_flag", dir_list_flag);664 m.AddString("fWebDirectory", fWebDirectory); 665 m.AddString("fIndexFileName", fIndexFileName); 666 m.AddBool("fDirListFlag", fDirListFlag); 736 667 737 668 //logging tab 738 m.AddBool(" log_console_flag", log_console_flag);739 m.AddBool(" log_file_flag", log_file_flag);740 m.AddString(" log_path", log_path);669 m.AddBool("fLogConsoleFlag", fLogConsoleFlag); 670 m.AddBool("fLogFileFlag", fLogFileFlag); 671 m.AddString("fLogPath", fLogPath); 741 672 742 673 //advance tab 743 m.AddInt16(" max_connections", max_connections);674 m.AddInt16("fMaxConnections", fMaxConnections); 744 675 745 676 //windows' position and size 746 m.AddRect("frame", f rame);747 m.AddRect(" setwindow_frame", setwindow_frame);748 m.AddBool(" is_zoomed", is_zoomed);749 m.AddFloat(" last_width", last_width);750 m.AddFloat(" last_height", last_height);677 m.AddRect("frame", fFrame); 678 m.AddRect("fSetwindowFrame", fSetwindowFrame); 679 m.AddBool("fIsZoomed", fIsZoomed); 680 m.AddFloat("fLastWidth", fLastWidth); 681 m.AddFloat("fLastHeight", fLastHeight); 751 682 752 683 if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK) 753 684 return B_ERROR; … … status_t 768 699 PoorManWindow::StartServer() 769 700 { 770 701 if (fServer == NULL) 771 fServer = new PoorManServer( 772 web_directory.String(), 773 max_connections, 774 dir_list_flag, 775 index_file_name.String()); 702 fServer = new PoorManServer(fWebDirectory.String(), fMaxConnections, 703 fDirListFlag, fIndexFileName.String()); 776 704 777 705 poorman_log(B_TRANSLATE("Starting up... ")); 778 706 if (fServer->Run() != B_OK) { 779 707 return B_ERROR; 780 708 } 781 709 782 status = true;710 fStatus = true; 783 711 UpdateStatusLabelAndMenuItem(); 784 712 poorman_log(B_TRANSLATE("done.\n"), false, INADDR_NONE, GREEN); 785 713 … … PoorManWindow::StopServer() 795 723 796 724 poorman_log(B_TRANSLATE("Shutting down.\n")); 797 725 fServer->Stop(); 798 status = false;726 fStatus = false; 799 727 UpdateStatusLabelAndMenuItem(); 800 728 return B_OK; 801 729 } … … PoorManWindow::StopServer() 804 732 void 805 733 PoorManWindow::SetLogPath(const char* str) 806 734 { 807 if (!strcmp( log_path, str))735 if (!strcmp(fLogPath, str)) 808 736 return; 809 737 810 738 BFile* temp = new BFile(str, B_CREATE_FILE | B_WRITE_ONLY | B_OPEN_AT_END); … … PoorManWindow::SetLogPath(const char* str) 823 751 return; 824 752 } 825 753 826 log_path.SetTo(str);754 fLogPath.SetTo(str); 827 755 } -
src/apps/poorman/PoorManWindow.h
diff --git a/src/apps/poorman/PoorManWindow.h b/src/apps/poorman/PoorManWindow.h index bdbca27..a2ddc51 100644
a b class PoorManServer; 33 33 class PoorManWindow: public BWindow 34 34 { 35 35 public: 36 PoorManWindow(BRect frame);37 virtual~PoorManWindow();38 virtual void MessageReceived(BMessage* message);36 PoorManWindow(BRect frame); 37 virtual ~PoorManWindow(); 38 virtual void MessageReceived(BMessage* message); 39 39 40 virtual voidFrameMoved(BPoint origin);41 virtual voidFrameResized(float width, float height);42 virtual boolQuitRequested();43 virtual voidZoom(BPoint origin, float width, float height);40 virtual void FrameMoved(BPoint origin); 41 virtual void FrameResized(float width, float height); 42 virtual bool QuitRequested(); 43 virtual void Zoom(BPoint origin, float width, float height); 44 44 45 45 // ------------------------------------------- 46 46 // Public PoorMan Window Methods 47 void SetDirLabel(const char* name);48 voidSetHits(uint32 num);49 uint32 GetHits() { return hits; }50 status_t SaveConsole(BMessage* message, bool);47 void SetDirLabel(const char* name); 48 void SetHits(uint32 num); 49 uint32 GetHits() { return fHits; } 50 status_t SaveConsole(BMessage* message, bool); 51 51 52 status_tSaveSettings();53 status_tReadSettings();54 voidDefaultSettings();52 status_t SaveSettings(); 53 status_t ReadSettings(); 54 void DefaultSettings(); 55 55 56 status_tStartServer();57 status_tStopServer();56 status_t StartServer(); 57 status_t StopServer(); 58 58 59 PoorManServer* GetServer()const{return fServer;}59 PoorManServer* GetServer() const { return fServer;} 60 60 // ------------------------------------------- 61 61 // Preferences and Settings 62 62 // Site Tab 63 bool DirListFlag() { return dir_list_flag; } 64 void SetDirListFlag(bool flag) { dir_list_flag = flag; } 65 const char * IndexFileName() { return index_file_name.String(); } 66 void SetIndexFileName(const char * str) { index_file_name.SetTo(str); } 67 const char * WebDir() { return web_directory.String(); } 68 void SetWebDir(const char * str) { web_directory.SetTo(str); } 63 bool DirListFlag() 64 { return fDirListFlag; } 65 void SetDirListFlag(bool flag) 66 { fDirListFlag = flag; } 67 const char* IndexFileName() 68 { return fIndexFileName.String(); } 69 void SetIndexFileName(const char* str) 70 { fIndexFileName.SetTo(str); } 71 const char* WebDir() 72 { return fWebDirectory.String(); } 73 void SetWebDir(const char* str) 74 { fWebDirectory.SetTo(str); } 69 75 // Logging Tab 70 bool LogConsoleFlag() { return log_console_flag; } 71 void SetLogConsoleFlag(bool flag) { log_console_flag = flag; } 72 bool LogFileFlag() { return log_file_flag; } 73 void SetLogFileFlag(bool flag) { log_file_flag = flag; } 74 const char * LogPath() { return log_path.String(); } 75 void SetLogPath(const char * str); 76 bool LogConsoleFlag() 77 { return fLogConsoleFlag; } 78 void SetLogConsoleFlag(bool flag) 79 { fLogConsoleFlag = flag; } 80 bool LogFileFlag() 81 { return fLogFileFlag; } 82 void SetLogFileFlag(bool flag) 83 { fLogFileFlag = flag; } 84 const char* LogPath() 85 { return fLogPath.String(); } 86 void SetLogPath(const char* str); 76 87 // Advanced Tab 77 int16 MaxConnections() { return max_connections; } 78 void SetMaxConnections(int16 num) { max_connections = num; } 79 88 int16 MaxConnections() 89 { return fMaxConnections; } 90 void SetMaxConnections(int16 num) 91 { fMaxConnections = num; } 80 92 81 93 private: 82 94 // ------------------------------------------- 83 95 // PoorMan Window Methods 84 voidUpdateStatusLabelAndMenuItem();85 voidUpdateHitsLabel();96 void UpdateStatusLabelAndMenuItem(); 97 void UpdateHitsLabel(); 86 98 87 99 private: 88 100 // ------------------------------------------- 89 // PoorMan Window90 PoorManView * mainView;91 92 // -------------------------------------------93 101 // Build Menu Methods 94 BMenu *BuildFileMenu() const;95 BMenu *BuildEditMenu() const;96 BMenu *BuildControlsMenu() const;102 BMenu* BuildFileMenu() const; 103 BMenu* BuildEditMenu() const; 104 BMenu* BuildControlsMenu() const; 97 105 98 106 // -------------------------------------------- 99 107 // MenuBar & Menu items 100 BMenuBar *FileMenuBar;101 BMenu *FileMenu;102 BMenu *EditMenu;103 BMenu *ControlsMenu;108 BMenuBar* fFileMenuBar; 109 BMenu* fFileMenu; 110 BMenu* fEditMenu; 111 BMenu* fControlsMenu; 104 112 105 113 // -------------------------------------------- 106 114 // Status, Hits, Directory 107 BStringView * statusView;108 BStringView * hitsView;109 BStringView * dirView;115 BStringView* fStatusView; 116 BStringView* fHitsView; 117 BStringView* fDirView; 110 118 111 bool status;112 uint32 hits;113 char hitsLabel[25];119 bool fStatus; 120 uint32 fHits; 121 char fHitsLabel[25]; 114 122 115 123 // -------------------------------------------- 116 124 // Logging View 117 BScrollView * scrollView;118 BTextView * loggingView;125 BScrollView* fScrollView; 126 BTextView* fLoggingView; 119 127 // use asctime() for format of [Date/Time]: 120 128 121 129 122 130 // ------------------------------------------- 123 131 // PoorMan Preference Window 124 PoorManPreferencesWindow * prefWindow;132 PoorManPreferencesWindow * fPrefWindow; 125 133 126 134 // site tab 127 BString web_directory;128 BString index_file_name;129 bool dir_list_flag;135 BString fWebDirectory; 136 BString fIndexFileName; 137 bool fDirListFlag; 130 138 131 139 // logging tab 132 bool log_console_flag;133 bool log_file_flag;134 BString log_path;140 bool fLogConsoleFlag; 141 bool fLogFileFlag; 142 BString fLogPath; 135 143 136 144 // advanced tab 137 int16 max_connections;145 int16 fMaxConnections; 138 146 139 bool is_zoomed;140 float last_width;141 float last_height;142 BRect frame;143 BRect setwindow_frame;147 bool fIsZoomed; 148 float fLastWidth; 149 float fLastHeight; 150 BRect fFrame; 151 BRect fSetwindowFrame; 144 152 145 153 // File Panels 146 BFilePanel * saveConsoleFilePanel;147 BFilePanel * saveConsoleSelectionFilePanel;154 BFilePanel* fSaveConsoleFilePanel; 155 BFilePanel* fSaveConsoleSelectionFilePanel; 148 156 149 BFile* fLogFile; 150 BFont* fLogViewFont; 157 BFile* fLogFile; 151 158 152 PoorManServer*fServer;159 PoorManServer* fServer; 153 160 154 pthread_rwlock_t fLogFileLock;161 pthread_rwlock_t fLogFileLock; 155 162 }; 156 163 157 164 #endif -
src/apps/poorman/StatusSlider.cpp
diff --git a/src/apps/poorman/StatusSlider.cpp b/src/apps/poorman/StatusSlider.cpp index deaa1b0..694cda0 100644
a b 11 11 #include <stdio.h> 12 12 13 13 14 StatusSlider::StatusSlider (BRect frame, 15 const char *name, 16 const char *label, 17 char *statusPrefix, 18 BMessage *message, 19 int32 minValue, 20 int32 maxValue) 21 22 : BSlider(frame, 23 name, 24 label, 25 message, 26 minValue, 27 maxValue 28 ), 29 StatusPrefix(statusPrefix) 14 StatusSlider::StatusSlider(const char* name, const char* label, 15 char* statusPrefix, BMessage* message, int32 minValue, int32 maxValue) 16 : 17 BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL), 18 fStatusPrefix(statusPrefix) 30 19 { 31 temp = str;20 fTemp = fStr; 32 21 } 33 22 34 23 const char* 35 24 StatusSlider::UpdateText() const 36 25 { 37 38 sprintf(temp, "%ld %s", Value(), StatusPrefix); 39 40 return temp; 26 sprintf(fTemp, "%ld %s", Value(), fStatusPrefix); 27 28 return fTemp; 41 29 } -
src/apps/poorman/StatusSlider.h
diff --git a/src/apps/poorman/StatusSlider.h b/src/apps/poorman/StatusSlider.h index b9003d7..e7d0d27 100644
a b 13 13 #include <Slider.h> 14 14 15 15 16 class StatusSlider: public BSlider 17 { 16 class StatusSlider: public BSlider { 18 17 public: 19 StatusSlider(BRect frame, 20 const char *name, 21 const char *label, 22 char *statusPrefix, 23 BMessage *message, 24 int32 minValue, 25 int32 maxValue); 26 virtual const char* UpdateText() const; 18 StatusSlider(const char* name, 19 const char* label, 20 char* statusPrefix, 21 BMessage* message, 22 int32 minValue, 23 int32 maxValue); 24 25 virtual const char* UpdateText() const; 26 27 27 private: 28 char *StatusPrefix;29 char * temp;30 char str[128];28 char* fStatusPrefix; 29 char* fTemp; 30 char fStr[128]; 31 31 }; 32 32 33 33 #endif