From 8557931349204aafaa9b649d010b244a730347fb Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 27 Mar 2013 23:36:54 -0400 Subject: [PATCH 01/27] Add sanity check. - The info list can in fact be NULL so we need to guard against that. This wouldn't currently get hit though, since the cases where the list isn't passed in are those where we only want a minimal frame anyways, so variable/return value creation wouldn't even be attempted. --- src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index b467cd1188..026b98320a 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -673,7 +673,7 @@ DwarfImageDebugInfo::CreateFrame(Image* image, instructionPointer, functionInstance->Address() - fRelocationDelta, subprogramEntry->Variables(), subprogramEntry->Blocks()); - if (!returnValueInfos->IsEmpty()) { + if (returnValueInfos != NULL && !returnValueInfos->IsEmpty()) { _CreateReturnValues(returnValueInfos, image, frame, *stackFrameDebugInfo); } From c844f6e030b98b1c9098c7b15ae7d7ff2c73b6d0 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 28 Mar 2013 20:54:33 -0400 Subject: [PATCH 02/27] Style fixes. --- src/apps/debugger/model/ReturnValueInfo.cpp | 1 + src/apps/debugger/model/ReturnValueInfo.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/apps/debugger/model/ReturnValueInfo.cpp b/src/apps/debugger/model/ReturnValueInfo.cpp index e44da3541f..3ae7bb27a0 100644 --- a/src/apps/debugger/model/ReturnValueInfo.cpp +++ b/src/apps/debugger/model/ReturnValueInfo.cpp @@ -3,6 +3,7 @@ * Distributed under the terms of the MIT License. */ + #include "ReturnValueInfo.h" #include "CpuState.h" diff --git a/src/apps/debugger/model/ReturnValueInfo.h b/src/apps/debugger/model/ReturnValueInfo.h index 693da13199..4cf5d9867f 100644 --- a/src/apps/debugger/model/ReturnValueInfo.h +++ b/src/apps/debugger/model/ReturnValueInfo.h @@ -5,6 +5,7 @@ #ifndef RETURN_VALUE_INFO_H #define RETURN_VALUE_INFO_H + #include "ObjectList.h" #include "Referenceable.h" #include "Types.h" From e13f5676a08f505497aafbd491f398760b237e87 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 27 Mar 2013 20:42:41 -0400 Subject: [PATCH 03/27] Cache app icons in BarInfo to make them load faster. This turns an IO bound problem into a CPU bound problem. In my testing this speeds up icon resizing dramatically although the CPU is quickly pegged at 100% trying to redraw the Deskbar if you whip the icon size slider back and forth with a dozen or so apps open and soon the CPU can't keep up and Deskbar lags behind. --- src/apps/deskbar/BarApp.cpp | 60 +++++++++++++++++++---------- src/apps/deskbar/BarApp.h | 8 ++-- src/apps/deskbar/ExpandoMenuBar.cpp | 7 ---- src/apps/deskbar/TeamMenu.cpp | 6 --- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 4189654acd..8ed106714c 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -719,6 +719,12 @@ TBarApp::Unsubscribe(const BMessenger &subscriber) void TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref) { + if ((flags & B_BACKGROUND_APP) != 0 + || strcasecmp(sig, kDeskbarSignature) == 0) { + // it's a background app or Deskbar itself, don't add it + return; + } + BAutolock autolock(sSubscriberLock); if (!autolock.IsLocked()) return; @@ -761,15 +767,9 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref) } BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig), - new BBitmap(IconRect(), kIconColorSpace), strdup(name.String())); - - if ((barInfo->flags & B_BACKGROUND_APP) == 0 - && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) { - FetchAppIcon(barInfo->sig, barInfo->icon); - } - + NULL, strdup(name.String())); + FetchAppIcon(barInfo); barInfo->teams->AddItem((void*)(addr_t)team); - sBarTeamInfoList.AddItem(barInfo); if (fSettings.expandNewTeams) @@ -839,9 +839,7 @@ TBarApp::ResizeTeamIcons() BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i); if ((barInfo->flags & B_BACKGROUND_APP) == 0 && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) { - delete barInfo->icon; - barInfo->icon = new BBitmap(IconRect(), kIconColorSpace); - FetchAppIcon(barInfo->sig, barInfo->icon); + FetchAppIcon(barInfo); } } } @@ -886,26 +884,40 @@ TBarApp::QuitPreferencesWindow() void -TBarApp::FetchAppIcon(const char* signature, BBitmap* icon) +TBarApp::FetchAppIcon(BarTeamInfo* barInfo) { - app_info appInfo; - icon_size size = icon->Bounds().IntegerHeight() >= 31 - ? B_LARGE_ICON : B_MINI_ICON; + int32 width = IconSize(); + int32 index = (width - kMinimumIconSize) / kIconSizeInterval; - if (be_roster->GetAppInfo(signature, &appInfo) == B_OK) { + // first look in the icon cache + barInfo->icon = barInfo->iconCache[index]; + if (barInfo->icon != NULL) + return; + + // icon wasn't in cache, get it from be_roster and cache it + app_info appInfo; + icon_size size = width >= 31 ? B_LARGE_ICON : B_MINI_ICON; + BBitmap* icon = new BBitmap(IconRect(), kIconColorSpace); + if (be_roster->GetAppInfo(barInfo->sig, &appInfo) == B_OK) { // fetch the app icon BFile file(&appInfo.ref, B_READ_ONLY); BAppFileInfo appMime(&file); - if (appMime.GetIcon(icon, size) == B_OK) + if (appMime.GetIcon(icon, size) == B_OK) { + delete barInfo->iconCache[index]; + barInfo->iconCache[index] = barInfo->icon = icon; return; + } } // couldn't find the app icon - // fetch the generic 3 boxes icon + // fetch the generic 3 boxes icon and cache it BMimeType defaultAppMime; defaultAppMime.SetTo(B_APP_MIME_TYPE); - if (defaultAppMime.GetIcon(icon, size) == B_OK) + if (defaultAppMime.GetIcon(icon, size) == B_OK) { + delete barInfo->iconCache[index]; + barInfo->iconCache[index] = barInfo->icon = icon; return; + } // couldn't find generic 3 boxes icon // fill with transparent @@ -923,6 +935,9 @@ TBarApp::FetchAppIcon(const char* signature, BBitmap* icon) for (int32 i = 0; i < icon->BitsLength(); i++) iconBits[i] = B_TRANSPARENT_MAGIC_CMAP8; } + + delete barInfo->iconCache[index]; + barInfo->iconCache[index] = NULL; } @@ -945,6 +960,8 @@ BarTeamInfo::BarTeamInfo(BList* teams, uint32 flags, char* sig, BBitmap* icon, icon(icon), name(name) { + for (int32 i = 0; i < kIconCacheCount; i++) + iconCache[i] = NULL; } @@ -955,6 +972,8 @@ BarTeamInfo::BarTeamInfo(const BarTeamInfo &info) icon(new BBitmap(*info.icon)), name(strdup(info.name)) { + for (int32 i = 0; i < kIconCacheCount; i++) + iconCache[i] = NULL; } @@ -962,6 +981,7 @@ BarTeamInfo::~BarTeamInfo() { delete teams; free(sig); - delete icon; free(name); + for (int32 i = 0; i < kIconCacheCount; i++) + delete iconCache[i]; } diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index 3dcd05e1ca..89627a36e7 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -71,15 +71,17 @@ const uint32 kSuspendSystem = 304; const int32 kMinimumIconSize = 16; const int32 kMaximumIconSize = 96; const int32 kIconSizeInterval = 8; +const int32 kIconCacheCount = (kMaximumIconSize - kMinimumIconSize) + / kIconSizeInterval + 1; // update preferences message constant const uint32 kUpdatePreferences = 'Pref'; /* --------------------------------------------- */ +class BBitmap; class BFile; class BList; -class BBitmap; class PreferencesWindow; class TBarView; class TBarWindow; @@ -96,6 +98,7 @@ public: char* sig; BBitmap* icon; char* name; + BBitmap* iconCache[kIconCacheCount]; }; class TBarApp : public BApplication { @@ -133,8 +136,7 @@ private: void QuitPreferencesWindow(); void ResizeTeamIcons(); - void FetchAppIcon(const char* signature, - BBitmap* icon); + void FetchAppIcon(BarTeamInfo* barInfo); BRect IconRect(); diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 3bfa307fb4..8c60fbe1bc 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -520,14 +520,7 @@ TExpandoMenuBar::BuildItems() barInfo->name, barInfo->sig, itemWidth, itemHeight, fDrawLabel, fVertical)); } - - barInfo->teams = NULL; - barInfo->icon = NULL; - barInfo->name = NULL; - barInfo->sig = NULL; } - - delete barInfo; } if (CountItems() == 0) { diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp index 1d30258873..7f5a7beef5 100644 --- a/src/apps/deskbar/TeamMenu.cpp +++ b/src/apps/deskbar/TeamMenu.cpp @@ -108,13 +108,7 @@ TTeamMenu::AttachedToWindow() menu->SetTrackingHook(barview->MenuTrackingHook, barview->GetTrackingHookData()); } - - barInfo->teams = NULL; - barInfo->icon = NULL; - barInfo->name = NULL; - barInfo->sig = NULL; } - delete barInfo; } if (CountItems() == 0) { From e0fcd6291689c1a02f86e60262c8f1d3c0f23dca Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Wed, 27 Mar 2013 08:58:21 +0100 Subject: [PATCH 04/27] Code style fixes. No functional changes. Fix for some code style issues pointed out by Axel. Thanks. --- src/apps/terminal/BasicTerminalBuffer.h | 1 + src/apps/terminal/TermParse.cpp | 8 ++++---- src/apps/terminal/VTPrsTbl.c | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/apps/terminal/BasicTerminalBuffer.h b/src/apps/terminal/BasicTerminalBuffer.h index 60802bd3a1..2dca366872 100644 --- a/src/apps/terminal/BasicTerminalBuffer.h +++ b/src/apps/terminal/BasicTerminalBuffer.h @@ -286,6 +286,7 @@ BasicTerminalBuffer::InsertChar(const char* c) return InsertChar(UTF8Char(c), 1); } + void BasicTerminalBuffer::InsertChar(const char* c, int32 length) { diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp index 21a060d04e..ece385aa1e 100644 --- a/src/apps/terminal/TermParse.cpp +++ b/src/apps/terminal/TermParse.cpp @@ -383,11 +383,11 @@ TermParse::EscParse() int row; int column; - /* default encoding system is UTF8 */ + // default encoding system is UTF8 int *groundtable = gUTF8GroundTable; int *parsestate = gUTF8GroundTable; - /* handle alternative character sets G0 - G4 */ + // handle alternative character sets G0 - G4 const char** graphSets[4] = { NULL, NULL, NULL, NULL }; int curGL = 0; int curGR = 0; @@ -422,12 +422,12 @@ TermParse::EscParse() if (curGraphSet != NULL) { int offset = c - (c < 128 ? 0x20 : 0xA0); if (offset >= 0 && offset < 96 - && (curGraphSet[offset] != 0)) { + && curGraphSet[offset] != 0) { fBuffer->InsertChar(curGraphSet[offset]); break; } } - fBuffer->InsertChar((char)(c)); + fBuffer->InsertChar((char)c); break; } case CASE_PRINT_GR: diff --git a/src/apps/terminal/VTPrsTbl.c b/src/apps/terminal/VTPrsTbl.c index 2651100a13..8e464107a4 100644 --- a/src/apps/terminal/VTPrsTbl.c +++ b/src/apps/terminal/VTPrsTbl.c @@ -9,6 +9,7 @@ * Siarzhuk Zharski, zharik@gmx.li */ + #include #include "VTparse.h" From 19bfeaa78642fedb092eeaea7bab826753f39bd5 Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Sun, 24 Mar 2013 10:00:27 +0100 Subject: [PATCH 05/27] Support %e (cur.encoding) for Terminal titles Optional parameter %e to indicate current tab view encoding in the window title. It is not shown in case tab view encoding is default UTF-8. Inspired by Sergei Reznikov. Thanks. --- src/apps/terminal/Shell.cpp | 4 +++- src/apps/terminal/Shell.h | 5 +++++ src/apps/terminal/ShellInfo.cpp | 22 +++++++++++++++++++- src/apps/terminal/ShellInfo.h | 9 ++++++++ src/apps/terminal/ShellParameters.cpp | 6 ++++-- src/apps/terminal/ShellParameters.h | 6 +++--- src/apps/terminal/TermConst.cpp | 1 + src/apps/terminal/TermView.cpp | 12 ++++------- src/apps/terminal/TermView.h | 2 +- src/apps/terminal/TitlePlaceholderMapper.cpp | 15 ++++++++++--- 10 files changed, 63 insertions(+), 19 deletions(-) diff --git a/src/apps/terminal/Shell.cpp b/src/apps/terminal/Shell.cpp index be93b97114..11793568ba 100644 --- a/src/apps/terminal/Shell.cpp +++ b/src/apps/terminal/Shell.cpp @@ -412,6 +412,8 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters) } else fShellInfo.SetDefaultShell(false); + fShellInfo.SetEncoding(parameters.Encoding()); + signal(SIGTTOU, SIG_IGN); // get a pseudo-tty @@ -548,7 +550,7 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters) */ setenv("TERM", kTerminalType, true); setenv("TTY", ttyName, true); - setenv("TTYPE", parameters.Encoding(), true); + setenv("TTYPE", fShellInfo.EncodingName(), true); // set the current working directory, if one is given if (parameters.CurrentDirectory().Length() > 0) diff --git a/src/apps/terminal/Shell.h b/src/apps/terminal/Shell.h index bc01fc9e42..df14406e82 100644 --- a/src/apps/terminal/Shell.h +++ b/src/apps/terminal/Shell.h @@ -49,6 +49,11 @@ public: const ShellInfo& Info() const { return fShellInfo; } + int Encoding() const + { return fShellInfo.Encoding(); } + void SetEncoding(int encoding) + { fShellInfo.SetEncoding(encoding); } + bool HasActiveProcesses() const; bool GetActiveProcessInfo( ActiveProcessInfo& _info) const; diff --git a/src/apps/terminal/ShellInfo.cpp b/src/apps/terminal/ShellInfo.cpp index c4dcf97bee..c3b64051b0 100644 --- a/src/apps/terminal/ShellInfo.cpp +++ b/src/apps/terminal/ShellInfo.cpp @@ -6,10 +6,30 @@ #include "ShellInfo.h" +#include +#include + +#include "TermConst.h" + +using namespace BPrivate ; // BCharacterSet stuff + ShellInfo::ShellInfo() : fProcessID(-1), - fIsDefaultShell(true) + fIsDefaultShell(true), + fEncoding(M_UTF8), + fEncodingName("UTF-8") { } + + +void +ShellInfo::SetEncoding(int encoding) +{ + fEncoding = encoding; + + const BCharacterSet* charset + = BCharacterSetRoster::GetCharacterSetByConversionID(fEncoding); + fEncodingName = charset ? charset->GetName() : "UTF-8"; +} diff --git a/src/apps/terminal/ShellInfo.h b/src/apps/terminal/ShellInfo.h index 540868527d..63d9eed898 100644 --- a/src/apps/terminal/ShellInfo.h +++ b/src/apps/terminal/ShellInfo.h @@ -7,6 +7,7 @@ #include +#include class ShellInfo { @@ -23,9 +24,17 @@ public: void SetDefaultShell(bool isDefault) { fIsDefaultShell = isDefault; } + int Encoding() const + { return fEncoding; } + const BString& EncodingName() const + { return fEncodingName; } + void SetEncoding(int encoding); + private: pid_t fProcessID; bool fIsDefaultShell; + int fEncoding; + BString fEncodingName; }; diff --git a/src/apps/terminal/ShellParameters.cpp b/src/apps/terminal/ShellParameters.cpp index e5cb02af99..136abcc856 100644 --- a/src/apps/terminal/ShellParameters.cpp +++ b/src/apps/terminal/ShellParameters.cpp @@ -6,6 +6,8 @@ #include "ShellParameters.h" +#include "TermConst.h" + ShellParameters::ShellParameters(int argc, const char* const* argv, const BString& currentDirectory) @@ -13,7 +15,7 @@ ShellParameters::ShellParameters(int argc, const char* const* argv, fArguments(argv), fArgumentCount(argc), fCurrentDirectory(currentDirectory), - fEncoding("UTF8") + fEncoding(M_UTF8) { } @@ -34,7 +36,7 @@ ShellParameters::SetCurrentDirectory(const BString& currentDirectory) void -ShellParameters::SetEncoding(const BString& encoding) +ShellParameters::SetEncoding(int encoding) { fEncoding = encoding; } diff --git a/src/apps/terminal/ShellParameters.h b/src/apps/terminal/ShellParameters.h index 8074cb19e3..ccbd2c3f0f 100644 --- a/src/apps/terminal/ShellParameters.h +++ b/src/apps/terminal/ShellParameters.h @@ -27,15 +27,15 @@ public: const BString& CurrentDirectory() const { return fCurrentDirectory; } - void SetEncoding(const BString& encoding); - const BString& Encoding() const + void SetEncoding(int encoding); + int Encoding() const { return fEncoding; } private: const char* const* fArguments; int fArgumentCount; BString fCurrentDirectory; - BString fEncoding; + int fEncoding; }; diff --git a/src/apps/terminal/TermConst.cpp b/src/apps/terminal/TermConst.cpp index e3d5efa1c6..1b88bc0493 100644 --- a/src/apps/terminal/TermConst.cpp +++ b/src/apps/terminal/TermConst.cpp @@ -26,6 +26,7 @@ const char* const kTooTipSetWindowTitlePlaceholders = B_TRANSLATE( "\t\t\tcurrent tab. Optionally the maximum number of path components\n" "\t\t\tcan be specified. E.g. '%2d' for at most two components.\n" "\t%T\t-\tThe Terminal application name for the current locale.\n" + "\t%e\t-\tThe encoding of the current tab. Not shown for UTF-8.\n" "\t%i\t-\tThe index of the window.\n" "\t%p\t-\tThe name of the active process in the current tab.\n" "\t%t\t-\tThe title of the current tab.\n" diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index e6e3d4be01..17d2d428c7 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include #include #include @@ -67,8 +65,6 @@ #include "VTkeymap.h" -using namespace BPrivate ; // BCharacterSet stuff - // defined in VTKeyTbl.c extern int function_keycode_table[]; extern char *function_key_char_table[]; @@ -364,10 +360,7 @@ TermView::_InitObject(const ShellParameters& shellParameters) // set the shell parameters' encoding ShellParameters modifiedShellParameters(shellParameters); - - const BCharacterSet* charset - = BCharacterSetRoster::GetCharacterSetByConversionID(fEncoding); - modifiedShellParameters.SetEncoding(charset ? charset->GetName() : "UTF-8"); + modifiedShellParameters.SetEncoding(fEncoding); error = fShell->Open(fRows, fColumns, modifiedShellParameters); @@ -700,6 +693,9 @@ TermView::SetEncoding(int encoding) { fEncoding = encoding; + if (fShell != NULL) + fShell->SetEncoding(fEncoding); + BAutolock _(fTextBuffer); fTextBuffer->SetEncoding(fEncoding); } diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h index 2766f25686..9e0721511a 100644 --- a/src/apps/terminal/TermView.h +++ b/src/apps/terminal/TermView.h @@ -60,7 +60,7 @@ public: bool IsShellBusy() const; bool GetActiveProcessInfo( ActiveProcessInfo& _info) const; - bool GetShellInfo(ShellInfo& _info) const; + bool GetShellInfo(ShellInfo& _info) const; const char* TerminalName() const; diff --git a/src/apps/terminal/TitlePlaceholderMapper.cpp b/src/apps/terminal/TitlePlaceholderMapper.cpp index 9cac1b51c8..29e9b4b6ee 100644 --- a/src/apps/terminal/TitlePlaceholderMapper.cpp +++ b/src/apps/terminal/TitlePlaceholderMapper.cpp @@ -4,9 +4,11 @@ */ +#include "TitlePlaceholderMapper.h" + #include -#include "TitlePlaceholderMapper.h" +#include "TermConst.h" // #pragma mark - TitlePlaceholderMapper @@ -36,8 +38,8 @@ TitlePlaceholderMapper::MapPlaceholder(char placeholder, int64 number, if (numberGiven && number > 0) { int32 index = directory.Length(); while (number > 0 && index > 0) { - index = directory.FindLast('/', index - 1); - number--; + index = directory.FindLast('/', index - 1); + number--; } if (number == 0 && index >= 0 && index + 1 < directory.Length()) @@ -48,6 +50,13 @@ TitlePlaceholderMapper::MapPlaceholder(char placeholder, int64 number, return true; } + case 'e': + if (fShellInfo.Encoding() != M_UTF8) { + _string.Truncate(0); + _string << "[" << fShellInfo.EncodingName() << "]"; + } + return true; + case 'p': // process name -- use "--", if the shell is active and it is the // default shell From 15aa77139011a57c47c11ba7fe1fee3c45ec2173 Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Thu, 28 Mar 2013 16:53:09 +0100 Subject: [PATCH 06/27] Keep color control enabled after color scheme change Fixes #9532 --- src/apps/terminal/AppearPrefView.cpp | 39 ++++++++++------------------ src/apps/terminal/AppearPrefView.h | 4 +-- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/apps/terminal/AppearPrefView.cpp b/src/apps/terminal/AppearPrefView.cpp index fa58dae14e..75a0e7127a 100644 --- a/src/apps/terminal/AppearPrefView.cpp +++ b/src/apps/terminal/AppearPrefView.cpp @@ -104,7 +104,6 @@ AppearancePrefView::AppearancePrefView(const char* name, kColorTable[0]); fColorField = new BMenuField(B_TRANSLATE("Color:"), colorsPopUp); - fColorField->SetEnabled(false); fTabTitle = new BTextControl("tabTitle", B_TRANSLATE("Tab title:"), "", NULL); @@ -151,7 +150,6 @@ AppearancePrefView::AppearancePrefView(const char* name, fTabTitle->SetText(PrefHandler::Default()->getString(PREF_TAB_TITLE)); fWindowTitle->SetText(PrefHandler::Default()->getString(PREF_WINDOW_TITLE)); - fColorControl->SetEnabled(false); fColorControl->SetValue( PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR)); @@ -219,16 +217,11 @@ AppearancePrefView::AttachedToWindow() fontSizeMenu->SetTargetForItems(this); } - fColorControl->SetTarget(this); - fColorField->Menu()->SetTargetForItems(this); - fColorSchemeField->Menu()->SetTargetForItems(this); + fColorControl->SetTarget(this); + fColorField->Menu()->SetTargetForItems(this); + fColorSchemeField->Menu()->SetTargetForItems(this); - _SetCurrentColorScheme(fColorSchemeField); - bool enableCustomColors = - strcmp(fColorSchemeField->Menu()->FindMarked()->Label(), - gCustomColorScheme.name) == 0; - - _EnableCustomColors(enableCustomColors); + _SetCurrentColorScheme(); } @@ -279,6 +272,15 @@ AppearancePrefView::MessageReceived(BMessage* msg) break; rgb_color oldColor = PrefHandler::Default()->getRGB(label); if (oldColor != fColorControl->ValueAsColor()) { + BMenuItem* item = fColorSchemeField->Menu()->FindMarked(); + if (strcmp(item->Label(), gCustomColorScheme.name) != 0) { + item->SetMarked(false); + item = fColorSchemeField->Menu()->FindItem( + gCustomColorScheme.name); + if (item) + item->SetMarked(true); + } + PrefHandler::Default()->setRGB(label, fColorControl->ValueAsColor()); modified = true; @@ -291,11 +293,6 @@ AppearancePrefView::MessageReceived(BMessage* msg) color_scheme* newScheme = NULL; if (msg->FindPointer("color_scheme", (void**)&newScheme) == B_OK) { - if (newScheme == &gCustomColorScheme) - _EnableCustomColors(true); - else - _EnableCustomColors(false); - _ChangeColorScheme(newScheme); modified = true; } @@ -365,14 +362,6 @@ AppearancePrefView::MessageReceived(BMessage* msg) } -void -AppearancePrefView::_EnableCustomColors(bool enable) -{ - fColorField->SetEnabled(enable); - fColorControl->SetEnabled(enable); -} - - void AppearancePrefView::_ChangeColorScheme(color_scheme* scheme) { @@ -388,7 +377,7 @@ AppearancePrefView::_ChangeColorScheme(color_scheme* scheme) void -AppearancePrefView::_SetCurrentColorScheme(BMenuField* field) +AppearancePrefView::_SetCurrentColorScheme() { PrefHandler* pref = PrefHandler::Default(); diff --git a/src/apps/terminal/AppearPrefView.h b/src/apps/terminal/AppearPrefView.h index 7f9f170fd6..975c11a318 100644 --- a/src/apps/terminal/AppearPrefView.h +++ b/src/apps/terminal/AppearPrefView.h @@ -54,10 +54,8 @@ public: float* _height); private: - void _EnableCustomColors(bool enable); - void _ChangeColorScheme(color_scheme* scheme); - void _SetCurrentColorScheme(BMenuField* field); + void _SetCurrentColorScheme(); static BMenu* _MakeFontMenu(uint32 command, const char* defaultFamily, From 18004d3ac01f07153a6891c451f2e7e2f1ae8d3f Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 29 Mar 2013 23:45:59 +0100 Subject: [PATCH 07/27] Avoid trying to set the media to Ethernet for WLAN devices. It didn't really harm, but would always try to find a corresponding media, fail and print an error. --- src/libs/compat/freebsd_network/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/compat/freebsd_network/device.c b/src/libs/compat/freebsd_network/device.c index 2e7fb3113e..ec2cf94e91 100644 --- a/src/libs/compat/freebsd_network/device.c +++ b/src/libs/compat/freebsd_network/device.c @@ -53,11 +53,11 @@ compat_open(const char *name, uint32 flags, void **cookie) if (!HAIKU_DRIVER_REQUIRES(FBSD_WLAN)) { ifp->if_flags &= ~IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); - } - memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_media = IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0); - ifp->if_ioctl(ifp, SIOCSIFMEDIA, (caddr_t)&ifr); + memset(&ifr, 0, sizeof(ifr)); + ifr.ifr_media = IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0); + ifp->if_ioctl(ifp, SIOCSIFMEDIA, (caddr_t)&ifr); + } ifp->if_flags |= IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); From 4e186e6a31e32ed6a0becde0bc3187400cbceb26 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 29 Mar 2013 23:47:21 +0100 Subject: [PATCH 08/27] Add IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} compat requests. They can be supplied as request type codes to SIOCS80211 are added to allow overcoming a difference between how Haiku and FreeBSD handle network drivers. In FreeBSD a device can be set into the down state but is still fully configurable using the ioctl interface. The Haiku network stack on the other hand opens and closes the driver on the transition form up to down and vice versa. This difference can become problematic with ported software that depends on the original behaviour. Therefore IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} provide a way to achieve the behaviour of setting and clearing IFF_UP without opening or closing the driver itself. The wpa_supplicant will use this in its BSD driver instead of actually setting the interface down and then failing all other ioctls. --- .../freebsd_wlan/net80211/ieee80211_haiku.cpp | 45 ++++++++++++++----- .../freebsd_wlan/net80211/ieee80211_ioctl.h | 16 +++++++ 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp index d4910cdef5..b1f936febb 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp @@ -191,6 +191,34 @@ stop_wlan(device_t device) } +status_t +wlan_open(void* cookie) +{ + dprintf("wlan_open(%p)\n", cookie); + struct ifnet* ifp = (struct ifnet*)cookie; + + ifp->if_init(ifp->if_softc); + + ifp->if_flags |= IFF_UP; + ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); + + return B_OK; +} + + +status_t +wlan_close(void* cookie) +{ + dprintf("wlan_close(%p)\n", cookie); + struct ifnet* ifp = (struct ifnet*)cookie; + + ifp->if_flags &= ~IFF_UP; + ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); + + return release_sem_etc(ifp->scan_done_sem, 1, B_RELEASE_ALL); +} + + status_t wlan_control(void* cookie, uint32 op, void* arg, size_t length) { @@ -344,6 +372,11 @@ wlan_control(void* cookie, uint32 op, void* arg, size_t length) if (user_memcpy(&request, arg, sizeof(struct ieee80211req)) != B_OK) return B_BAD_ADDRESS; + if (request.i_type == IEEE80211_IOC_HAIKU_COMPAT_WLAN_UP) + return wlan_open(cookie); + else if (request.i_type == IEEE80211_IOC_HAIKU_COMPAT_WLAN_DOWN) + return wlan_close(cookie); + TRACE("wlan_control: %ld, %d\n", op, request.i_type); status_t status = ifp->if_ioctl(ifp, op, (caddr_t)&request); if (status != B_OK) @@ -367,18 +400,6 @@ wlan_control(void* cookie, uint32 op, void* arg, size_t length) } -status_t -wlan_close(void* cookie) -{ - struct ifnet* ifp = (struct ifnet*)cookie; - - ifp->if_flags &= ~IFF_UP; - ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); - - return release_sem_etc(ifp->scan_done_sem, 1, B_RELEASE_ALL); -} - - status_t wlan_if_l2com_alloc(void* data) { diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h b/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h index f1a1dcd69a..551d1877a4 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h @@ -719,6 +719,22 @@ struct ieee80211req { #define IEEE80211_IOC_TDMA_SLOTLEN 203 /* TDMA: slot length (usecs) */ #define IEEE80211_IOC_TDMA_BINTERVAL 204 /* TDMA: beacon intvl (slots) */ +#ifdef __HAIKU__ +/* + These are here to allow overcoming a difference between Haiku and + FreeBSD drivers. In FreeBSD a device can be set into the down state + but is still fully configurable using the ioctl interface. The Haiku + network stack on the other hand opens and closes the driver on the + transition form up to down and vice versa. This difference can become + problematic with ported software that depends on the original behaviour. + Therefore IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} provide a way to + achieve the behaviour of setting and clearing IFF_UP without opening + or closing the driver itself. +*/ +#define IEEE80211_IOC_HAIKU_COMPAT_WLAN_UP 0x6000 +#define IEEE80211_IOC_HAIKU_COMPAT_WLAN_DOWN 0x6001 +#endif /* __HAIKU__ */ + /* * Parameters for controlling a scan requested with * IEEE80211_IOC_SCAN_REQ. From c07e2b1fe4a2dc46ab64dca162647e985f9cbfdb Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 29 Mar 2013 21:04:20 -0400 Subject: [PATCH 09/27] Add optional cpu state to Variable. - Used to preserve the CPU state for variables representing return values, since they may potentially be retrieved from registers, and these might be overwritten later in the same statement. --- src/apps/debugger/model/Variable.cpp | 10 ++++++++-- src/apps/debugger/model/Variable.h | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/model/Variable.cpp b/src/apps/debugger/model/Variable.cpp index 8e01442930..08653abcc6 100644 --- a/src/apps/debugger/model/Variable.cpp +++ b/src/apps/debugger/model/Variable.cpp @@ -6,22 +6,26 @@ #include "Variable.h" +#include "CpuState.h" #include "ObjectID.h" #include "Type.h" #include "ValueLocation.h" Variable::Variable(ObjectID* id, const BString& name, Type* type, - ValueLocation* location) + ValueLocation* location, CpuState* state) : fID(id), fName(name), fType(type), - fLocation(location) + fLocation(location), + fCpuState(state) { fID->AcquireReference(); fType->AcquireReference(); fLocation->AcquireReference(); + if (fCpuState != NULL) + fCpuState->AcquireReference(); } @@ -30,4 +34,6 @@ Variable::~Variable() fID->ReleaseReference(); fType->ReleaseReference(); fLocation->ReleaseReference(); + if (fCpuState != NULL) + fCpuState->ReleaseReference(); } diff --git a/src/apps/debugger/model/Variable.h b/src/apps/debugger/model/Variable.h index 9462c9a5d3..33fad51d78 100644 --- a/src/apps/debugger/model/Variable.h +++ b/src/apps/debugger/model/Variable.h @@ -11,6 +11,7 @@ #include +class CpuState; class ObjectID; class Type; class ValueLocation; @@ -19,19 +20,22 @@ class ValueLocation; class Variable : public BReferenceable { public: Variable(ObjectID* id, const BString& name, - Type* type, ValueLocation* location); + Type* type, ValueLocation* location, + CpuState* state = NULL); ~Variable(); ObjectID* ID() const { return fID; } const BString& Name() const { return fName; } Type* GetType() const { return fType; } ValueLocation* Location() const { return fLocation; } + CpuState* GetCpuState() const { return fCpuState; } private: ObjectID* fID; BString fName; Type* fType; ValueLocation* fLocation; + CpuState* fCpuState; }; From 47ffc32bc0b45e6ca96cd57ac67d0f44e0fcf87d Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 29 Mar 2013 21:05:27 -0400 Subject: [PATCH 10/27] Minor refactoring. - Factor out a _HasExitedFrame() function. - Reorder how/where return values are added a bit. --- .../debugger/controllers/ThreadHandler.cpp | 100 +++++++++++------- src/apps/debugger/controllers/ThreadHandler.h | 4 + 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/apps/debugger/controllers/ThreadHandler.cpp b/src/apps/debugger/controllers/ThreadHandler.cpp index b40aa35efa..c728dba3fd 100644 --- a/src/apps/debugger/controllers/ThreadHandler.cpp +++ b/src/apps/debugger/controllers/ThreadHandler.cpp @@ -52,6 +52,7 @@ ThreadHandler::ThreadHandler(Thread* thread, Worker* worker, fStepMode(STEP_NONE), fStepStatement(NULL), fBreakpointAddress(0), + fSteppedOverFunctionAddress(0), fPreviousInstructionPointer(0), fPreviousFrameAddress(0), fSingleStepping(false) @@ -487,17 +488,8 @@ ThreadHandler::_DoStepOver(CpuState* cpuState) if (_InstallTemporaryBreakpoint(info.Address() + info.Size()) != B_OK) return false; - ReturnValueInfo* returnInfo = new(std::nothrow) ReturnValueInfo( - info.TargetAddress(), cpuState); - if (returnInfo == NULL) - return false; + fSteppedOverFunctionAddress = info.TargetAddress(); - BReference returnInfoReference(returnInfo, true); - - if (fThread->AddReturnValueInfo(returnInfo) != B_OK) - return false; - - returnInfoReference.Detach(); _RunThread(cpuState->InstructionPointer()); return true; } @@ -597,6 +589,25 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState) } } + if (fPreviousFrameAddress != 0) { + TRACE_CONTROL("STEP_OVER: called function address %#" B_PRIx64 + ", previous frame address: %#" B_PRIx64 ", frame address: %#" + B_PRIx64 ", adding return info\n", fSteppedOverFunctionAddress, + fPreviousFrameAddress, stackTrace->FrameAt(0)->FrameAddress()); + ReturnValueInfo* returnInfo = new(std::nothrow) ReturnValueInfo( + fSteppedOverFunctionAddress, cpuState); + if (returnInfo == NULL) + return false; + + BReference returnInfoReference(returnInfo, true); + + if (fThread->AddReturnValueInfo(returnInfo) != B_OK) + return false; + + returnInfoReference.Detach(); + fSteppedOverFunctionAddress = 0; + } + // If we're still in the statement, we continue single-stepping, // otherwise we're done. if (fStepStatement->ContainsAddress( @@ -618,6 +629,23 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState) // That's the return address, so we're done in theory, // unless we're a recursive function. Check if we've actually // exited the previous stack frame or not + if (!_HasExitedFrame(cpuState->StackFramePointer())) { + status_t error = _InstallTemporaryBreakpoint( + cpuState->InstructionPointer()); + if (error != B_OK) + _StepFallback(); + else + _RunThread(cpuState->InstructionPointer()); + return true; + } + + if (fPreviousFrameAddress == 0) + return false; + + TRACE_CONTROL("ThreadHandler::_HandleBreakpointHitStep() - " + "frame pointer 0x%#" B_PRIx64 ", previous: 0x%#" B_PRIx64 + " - step out adding return value\n", cpuState + ->StackFramePointer(), fPreviousFrameAddress); ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo( cpuState->InstructionPointer(), cpuState); if (info == NULL) @@ -627,21 +655,6 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState) return false; infoReference.Detach(); - target_addr_t framePointer = cpuState->StackFramePointer(); - bool hasExitedFrame = fDebuggerInterface->GetArchitecture() - ->StackGrowthDirection() == STACK_GROWTH_DIRECTION_POSITIVE - ? framePointer < fPreviousFrameAddress - : framePointer > fPreviousFrameAddress; - - if (!hasExitedFrame) { - status_t error = _InstallTemporaryBreakpoint( - cpuState->InstructionPointer()); - if (error != B_OK) - _StepFallback(); - else - _RunThread(cpuState->InstructionPointer()); - return true; - } fPreviousFrameAddress = 0; } @@ -709,19 +722,24 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState) } } - if (stackTrace != NULL && stackTrace->FrameAt(0) - ->FrameAddress() != fPreviousFrameAddress) { - ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo( - cpuState->InstructionPointer(), cpuState); - if (info == NULL) - return false; - BReference infoReference(info, true); - if (fThread->AddReturnValueInfo(info) != B_OK) - return false; - infoReference.Detach(); + if (stackTrace != NULL) { + if (_HasExitedFrame(stackTrace->FrameAt(0) + ->FrameAddress())) { + TRACE_CONTROL("ThreadHandler::_HandleSingleStepStep() " + " - adding return value for STEP_OVER\n"); + ReturnValueInfo* info = new(std::nothrow) + ReturnValueInfo(cpuState->InstructionPointer(), + cpuState); + if (info == NULL) + return false; + BReference infoReference(info, true); + if (fThread->AddReturnValueInfo(info) != B_OK) + return false; + + infoReference.Detach(); + } } - return false; } return _DoStepOver(cpuState); @@ -733,3 +751,13 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState) return false; } } + + +bool +ThreadHandler::_HasExitedFrame(target_addr_t framePointer) const +{ + return fDebuggerInterface->GetArchitecture()->StackGrowthDirection() + == STACK_GROWTH_DIRECTION_POSITIVE + ? framePointer < fPreviousFrameAddress + : framePointer > fPreviousFrameAddress; +} diff --git a/src/apps/debugger/controllers/ThreadHandler.h b/src/apps/debugger/controllers/ThreadHandler.h index 1d4ad339b1..4fd078565a 100644 --- a/src/apps/debugger/controllers/ThreadHandler.h +++ b/src/apps/debugger/controllers/ThreadHandler.h @@ -91,6 +91,9 @@ private: bool _HandleBreakpointHitStep(CpuState* cpuState); bool _HandleSingleStepStep(CpuState* cpuState); + bool _HasExitedFrame(target_addr_t framePointer) + const; + private: Thread* fThread; Worker* fWorker; @@ -99,6 +102,7 @@ private: uint32 fStepMode; Statement* fStepStatement; target_addr_t fBreakpointAddress; + target_addr_t fSteppedOverFunctionAddress; target_addr_t fPreviousInstructionPointer; target_addr_t fPreviousFrameAddress; bool fSingleStepping; From 2c6fab1de6779fecadc6777425b05dd1c263b591 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 29 Mar 2013 21:06:59 -0400 Subject: [PATCH 11/27] Handle return value CPU states. - DwarfStackFrameDebugInfo::CreateReturnValue() now takes a cpu state parameter. This is attached to the associated Variable object. - ResolveValueNodeJob() now checks if the value node child it's dealing with is that of a variable. If so it pulls that CpuState for the ValueLoader's purposes rather than the current state. This gets return values for multiple function calls in the same statement working. --- .../debugger/debug_info/DwarfImageDebugInfo.cpp | 2 +- .../debug_info/DwarfStackFrameDebugInfo.cpp | 6 ++++-- .../debugger/debug_info/DwarfStackFrameDebugInfo.h | 2 ++ src/apps/debugger/jobs/ResolveValueNodeJob.cpp | 13 +++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 026b98320a..b9dad3117d 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -1166,7 +1166,7 @@ DwarfImageDebugInfo::_CreateReturnValues(ReturnValueInfoList* returnValueInfos, BReference idReference( targetFunction->GetFunctionID(), true); result = factory.CreateReturnValue(idReference, returnType, - location, variable); + location, subroutineState, variable); if (result != B_OK) return result; diff --git a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp index 42cef634e4..b2fe7b30ec 100644 --- a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp @@ -11,6 +11,7 @@ #include "Architecture.h" #include "CompilationUnit.h" +#include "CpuState.h" #include "DebugInfoEntries.h" #include "Dwarf.h" #include "DwarfFile.h" @@ -279,7 +280,8 @@ DwarfStackFrameDebugInfo::CreateLocalVariable(FunctionID* functionID, status_t DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID, - DIEType* returnType, ValueLocation* location, Variable*& _variable) + DIEType* returnType, ValueLocation* location, CpuState* state, + Variable*& _variable) { if (returnType == NULL) return B_BAD_VALUE; @@ -300,7 +302,7 @@ DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID, name.SetToFormat("%s returned", functionID->FunctionName().String()); Variable* variable = new(std::nothrow) Variable(id, name, - type, location); + type, location, state); if (variable == NULL) return B_NO_MEMORY; diff --git a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h index 3e691308f3..86ef5b7bff 100644 --- a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h @@ -14,6 +14,7 @@ class CompilationUnit; +class CpuState; class DIEFormalParameter; class DIESubprogram; class DIEType; @@ -60,6 +61,7 @@ public: status_t CreateReturnValue(FunctionID* functionID, DIEType* returnType, ValueLocation* location, + CpuState* state, Variable*& _variable); // returns reference diff --git a/src/apps/debugger/jobs/ResolveValueNodeJob.cpp b/src/apps/debugger/jobs/ResolveValueNodeJob.cpp index c810ad5c3e..13712e3a6f 100644 --- a/src/apps/debugger/jobs/ResolveValueNodeJob.cpp +++ b/src/apps/debugger/jobs/ResolveValueNodeJob.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2012-2013, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -18,6 +18,8 @@ #include "ValueLocation.h" #include "ValueNode.h" #include "ValueNodeContainer.h" +#include "Variable.h" +#include "VariableValueNodeChild.h" ResolveValueNodeValueJob::ResolveValueNodeValueJob( @@ -144,9 +146,16 @@ ResolveValueNodeValueJob::_ResolveNodeValue() } } + CpuState* variableCpuState = NULL; + VariableValueNodeChild* variableChild = dynamic_cast< + VariableValueNodeChild*>(nodeChild); + if (variableChild != NULL) + variableCpuState = variableChild->GetVariable()->GetCpuState(); + // resolve the node location and value ValueLoader valueLoader(fArchitecture, fDebuggerInterface, - fTypeInformation, fCpuState); + fTypeInformation, variableCpuState != NULL ? variableCpuState + : fCpuState); ValueLocation* location; Value* value; status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader, From d5c2d47e5d8e0fb577bf06a6bcb3168a541be87b Mon Sep 17 00:00:00 2001 From: John Scipione Date: Mon, 18 Feb 2013 22:11:16 -0500 Subject: [PATCH 12/27] Update NetworkSetup preflet and Interfaces add-on. Many updates including: * Add translation strings * MAC address in Interface Settings Window * Lots of layout kit improvements, works font sizes 8pt to 18pt. * Add right-click context menu to interfaces list view. * Make the Interfaces list view size a bit bigger. * Wired/Wireless settings use BStringViews instead of BTextViews since they aren't editable. * First interface is selected by default --- .../InterfacesAddOn/InterfaceAddressView.cpp | 145 +++++++--- .../InterfacesAddOn/InterfaceAddressView.h | 30 +- .../InterfacesAddOn/InterfaceHardwareView.cpp | 74 +++-- .../InterfacesAddOn/InterfaceHardwareView.h | 26 +- .../InterfacesAddOn/InterfaceWindow.cpp | 56 ++-- .../preflet/InterfacesAddOn/InterfaceWindow.h | 43 +-- .../InterfacesAddOn/InterfacesAddOn.cpp | 73 ++--- .../preflet/InterfacesAddOn/InterfacesAddOn.h | 15 +- .../InterfacesAddOn/InterfacesListView.cpp | 270 +++++++++++++----- .../InterfacesAddOn/InterfacesListView.h | 38 ++- .../kits/net/preflet/InterfacesAddOn/Jamfile | 10 + .../InterfacesAddOn/NetworkSettings.cpp | 23 +- .../preflet/InterfacesAddOn/NetworkSettings.h | 25 +- src/tests/kits/net/preflet/Jamfile | 6 +- .../kits/net/preflet/NetworkSetupWindow.cpp | 84 +++--- 15 files changed, 586 insertions(+), 332 deletions(-) diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp index c90469d228..83857bd586 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp @@ -1,18 +1,33 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ #include "InterfaceAddressView.h" #include "NetworkSettings.h" +#include +#include #include #include +#include +#include +#include +#include #include +#include + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "IntefaceAddressView" + + +// #pragma mark - InterfaceAddressView InterfaceAddressView::InterfaceAddressView(BRect frame, int family, @@ -27,26 +42,31 @@ InterfaceAddressView::InterfaceAddressView(BRect frame, int family, // Create our controls fModePopUpMenu = new BPopUpMenu("modes"); - fModePopUpMenu->AddItem(new BMenuItem("Automatic", + fModePopUpMenu->AddItem(new BMenuItem(B_TRANSLATE("DHCP"), new BMessage(M_MODE_AUTO))); - fModePopUpMenu->AddItem(new BMenuItem("Static", + fModePopUpMenu->AddItem(new BMenuItem(B_TRANSLATE("Static"), new BMessage(M_MODE_STATIC))); fModePopUpMenu->AddSeparatorItem(); - fModePopUpMenu->AddItem(new BMenuItem("None", - new BMessage(M_MODE_NONE))); + fModePopUpMenu->AddItem(new BMenuItem(B_TRANSLATE("Off"), + new BMessage(M_MODE_OFF))); - fModeField = new BMenuField("Mode:", fModePopUpMenu); - fModeField->SetToolTip(BString("The method for obtaining an IP address")); + fModeField = new BMenuField(B_TRANSLATE("Mode:"), fModePopUpMenu); + fModeField->SetToolTip(BString(B_TRANSLATE("The method for obtaining an IP address"))); - fAddressField = new BTextControl("IP Address:", NULL, NULL); - fAddressField->SetToolTip(BString("Your internet protocol address")); - fNetmaskField = new BTextControl("Netmask:", NULL, NULL); - fNetmaskField->SetToolTip(BString("Your netmask (subnet)")); - fGatewayField = new BTextControl("Gateway:", NULL, NULL); - fGatewayField->SetToolTip(BString("Your gateway (router)")); + float minimumWidth = be_control_look->DefaultItemSpacing() * 16; - RevertFields(); - // Do the initial field population + fAddressField = new BTextControl(B_TRANSLATE("IP Address:"), NULL, NULL); + fAddressField->SetToolTip(BString(B_TRANSLATE("Your IP address"))); + fAddressField->TextView()->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET)); + fNetmaskField = new BTextControl(B_TRANSLATE("Netmask:"), NULL, NULL); + fNetmaskField->SetToolTip(BString(B_TRANSLATE("Your netmask"))); + fNetmaskField->TextView()->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET)); + fGatewayField = new BTextControl(B_TRANSLATE("Gateway:"), NULL, NULL); + fGatewayField->SetToolTip(BString(B_TRANSLATE("Your gateway"))); + fGatewayField->TextView()->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET)); + + Revert(); + // Populate the fields BLayoutBuilder::Group<>(this) .AddGrid() @@ -67,6 +87,9 @@ InterfaceAddressView::~InterfaceAddressView() } +// #pragma mark - InterfaceAddressView virtual methods + + void InterfaceAddressView::AttachedToWindow() { @@ -80,71 +103,109 @@ InterfaceAddressView::MessageReceived(BMessage* message) switch (message->what) { case M_MODE_AUTO: _EnableFields(false); + _ShowFields(true); break; + case M_MODE_STATIC: _EnableFields(true); + _ShowFields(true); break; - case M_MODE_NONE: - _EnableFields(false); + + case M_MODE_OFF: fAddressField->SetText(""); fNetmaskField->SetText(""); fGatewayField->SetText(""); + _EnableFields(false); + _ShowFields(false); break; + default: BView::MessageReceived(message); } } +// #pragma mark - InterfaceAddressView private methods + + void -InterfaceAddressView::_EnableFields(bool enabled) +InterfaceAddressView::_EnableFields(bool enable) { - fAddressField->SetEnabled(enabled); - fNetmaskField->SetEnabled(enabled); - fGatewayField->SetEnabled(enabled); + fAddressField->SetEnabled(enable); + fNetmaskField->SetEnabled(enable); + fGatewayField->SetEnabled(enable); } +void +InterfaceAddressView::_ShowFields(bool show) +{ + if (show) { + if (fAddressField->IsHidden()) + fAddressField->Show(); + if (fNetmaskField->IsHidden()) + fNetmaskField->Show(); + if (fGatewayField->IsHidden()) + fGatewayField->Show(); + } else { + if (!fAddressField->IsHidden()) + fAddressField->Hide(); + if (!fNetmaskField->IsHidden()) + fNetmaskField->Hide(); + if (!fGatewayField->IsHidden()) + fGatewayField->Hide(); + } +} + + +// #pragma mark - InterfaceAddressView public methods + + status_t -InterfaceAddressView::RevertFields() +InterfaceAddressView::Revert() { // Populate address fields with current settings - const char* currMode = fSettings->AutoConfigure(fFamily) - ? "Automatic" : "Static"; - - _EnableFields(!fSettings->AutoConfigure(fFamily)); - // if Autoconfigured, disable address fields until changed - - if (fSettings->IPAddr(fFamily).IsEmpty() - && !fSettings->AutoConfigure(fFamily)) - { - currMode = "None"; + int32 mode; + if (fSettings->AutoConfigure(fFamily)) { + mode = M_MODE_AUTO; _EnableFields(false); + _ShowFields(true); + } else if (fSettings->IPAddr(fFamily).IsEmpty()) { + mode = M_MODE_OFF; + _EnableFields(false); + _ShowFields(false); + } else { + mode = M_MODE_STATIC; + _EnableFields(true); + _ShowFields(true); } - BMenuItem* item = fModePopUpMenu->FindItem(currMode); - if (item) + BMenuItem* item = fModePopUpMenu->FindItem(mode); + if (item != NULL) item->SetMarked(true); - fAddressField->SetText(fSettings->IP(fFamily)); - fNetmaskField->SetText(fSettings->Netmask(fFamily)); - fGatewayField->SetText(fSettings->Gateway(fFamily)); + if (!fSettings->IPAddr(fFamily).IsEmpty()) { + fAddressField->SetText(fSettings->IP(fFamily)); + fNetmaskField->SetText(fSettings->Netmask(fFamily)); + fGatewayField->SetText(fSettings->Gateway(fFamily)); + } return B_OK; } status_t -InterfaceAddressView::SaveFields() +InterfaceAddressView::Save() { + BMenuItem* item = fModePopUpMenu->FindMarked(); + if (item == NULL) + return B_ERROR; + fSettings->SetIP(fFamily, fAddressField->Text()); fSettings->SetNetmask(fFamily, fNetmaskField->Text()); fSettings->SetGateway(fFamily, fGatewayField->Text()); - - BMenuItem* item = fModePopUpMenu->FindItem("Automatic"); - fSettings->SetAutoConfigure(fFamily, item->IsMarked()); + fSettings->SetAutoConfigure(fFamily, item->Command() == M_MODE_AUTO); return B_OK; } - diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h index 5fbf274659..8d700e84c8 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h @@ -1,9 +1,10 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ #ifndef INTERFACE_ADDRESS_VIEW_H #define INTERFACE_ADDRESS_VIEW_H @@ -11,33 +12,37 @@ #include "NetworkSettings.h" -#include -#include -#include -#include #include enum { M_MODE_AUTO = 'iato', M_MODE_STATIC = 'istc', - M_MODE_NONE = 'inon' + M_MODE_OFF = 'ioff' }; +class BMenuField; +class BMessage; +class BPopUpMenu; +class BRect; +class BTextControl; + class InterfaceAddressView : public BGroupView { public: InterfaceAddressView(BRect frame, int family, NetworkSettings* settings); virtual ~InterfaceAddressView(); - virtual void MessageReceived(BMessage* message); - virtual void AttachedToWindow(); - status_t RevertFields(); - status_t SaveFields(); + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage* message); + + status_t Revert(); + status_t Save(); private: - void _EnableFields(bool enabled); + void _EnableFields(bool enable); + void _ShowFields(bool show); NetworkSettings* fSettings; int fFamily; @@ -50,5 +55,4 @@ private: }; -#endif /* INTERFACE_ADDRESS_VIEW_H */ - +#endif // INTERFACE_ADDRESS_VIEW_H diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.cpp index 7584ebb5d6..c5d9e6453e 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.cpp @@ -1,17 +1,33 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ #include "InterfaceHardwareView.h" #include "NetworkSettings.h" +#include +#include #include +#include #include +#include +#include +#include +#include +#include + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "IntefaceHardwareView" + + +// #pragma mark - InterfaceHardwareView InterfaceHardwareView::InterfaceHardwareView(BRect frame, @@ -24,22 +40,34 @@ InterfaceHardwareView::InterfaceHardwareView(BRect frame, // TODO : Small graph of throughput? - // TODO : Use strings instead of TextControls - fStatusField = new BTextControl("Status:", NULL, NULL); - fStatusField->SetEnabled(false); - fMACField = new BTextControl("MAC Address:", NULL, NULL); - fMACField->SetEnabled(false); - fSpeedField = new BTextControl("Link Speed:", NULL, NULL); - fSpeedField->SetEnabled(false); + float minimumWidth = be_control_look->DefaultItemSpacing() * 16; - RevertFields(); - // Do the initial field population + BStringView* status = new BStringView("status label", B_TRANSLATE("Status:")); + status->SetAlignment(B_ALIGN_RIGHT); + fStatusField = new BStringView("status field", ""); + fStatusField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET)); + BStringView* macAddress = new BStringView("mac address label", + B_TRANSLATE("MAC address:")); + macAddress->SetAlignment(B_ALIGN_RIGHT); + fMacAddressField = new BStringView("mac address field", ""); + fMacAddressField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET)); + BStringView* linkSpeed = new BStringView("link speed label", + B_TRANSLATE("Link speed:")); + linkSpeed->SetAlignment(B_ALIGN_RIGHT); + fLinkSpeedField = new BStringView("link speed field", ""); + fLinkSpeedField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET)); + + Revert(); + // Populate the fields BLayoutBuilder::Group<>(this) .AddGrid() - .AddTextControl(fStatusField, 0, 0, B_ALIGN_RIGHT) - .AddTextControl(fMACField, 0, 1, B_ALIGN_RIGHT) - .AddTextControl(fSpeedField, 0, 2, B_ALIGN_RIGHT) + .Add(status, 0, 0) + .Add(fStatusField, 1, 0) + .Add(macAddress, 0, 1) + .Add(fMacAddressField, 1, 1) + .Add(linkSpeed, 0, 2) + .Add(fLinkSpeedField, 1, 2) .End() .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, @@ -53,6 +81,9 @@ InterfaceHardwareView::~InterfaceHardwareView() } +// #pragma mark - InterfaceHardwareView virtual methods + + void InterfaceHardwareView::AttachedToWindow() { @@ -70,26 +101,29 @@ InterfaceHardwareView::MessageReceived(BMessage* message) } +// #pragma mark - InterfaceHardwareView public methods + + status_t -InterfaceHardwareView::RevertFields() +InterfaceHardwareView::Revert() { // Populate fields with current settings if (fSettings->HasLink()) - fStatusField->SetText("connected"); + fStatusField->SetText(B_TRANSLATE("connected")); else - fStatusField->SetText("disconnected"); + fStatusField->SetText(B_TRANSLATE("disconnected")); + + fMacAddressField->SetText(fSettings->HardwareAddress()); // TODO : Find how to get link speed - fSpeedField->SetText("100 Mb/s"); + fLinkSpeedField->SetText("100 Mb/s"); return B_OK; } status_t -InterfaceHardwareView::SaveFields() +InterfaceHardwareView::Save() { - return B_OK; } - diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.h index a6c3e6a6a1..7e023b754c 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceHardwareView.h @@ -1,9 +1,10 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ #ifndef INTERFACE_HARDWARE_VIEW_H #define INTERFACE_HARDWARE_VIEW_H @@ -11,35 +12,34 @@ #include "NetworkSettings.h" -#include -#include -#include -#include -#include #include +class BMessage; +class BRect; +class BStringView; + class InterfaceHardwareView : public BGroupView { public: InterfaceHardwareView(BRect frame, NetworkSettings* settings); virtual ~InterfaceHardwareView(); + virtual void MessageReceived(BMessage* message); virtual void AttachedToWindow(); - status_t RevertFields(); - status_t SaveFields(); - + status_t Revert(); + status_t Save(); private: void _EnableFields(bool enabled); NetworkSettings* fSettings; - BTextControl* fStatusField; - BTextControl* fMACField; - BTextControl* fSpeedField; + BStringView* fStatusField; + BStringView* fMacAddressField; + BStringView* fLinkSpeedField; }; -#endif /* INTERFACE_HARDWARE_VIEW_H */ +#endif // INTERFACE_HARDWARE_VIEW_H diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp index ece7e8bdee..424c8b60ae 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp @@ -1,55 +1,59 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ #include "InterfaceWindow.h" #include - -#include +#include +#include +#include +#include +#include #undef B_TRANSLATION_CONTEXT -#define B_TRANSLATION_CONTEXT "NetworkSetupWindow" +#define B_TRANSLATION_CONTEXT "InterfaceWindow" InterfaceWindow::InterfaceWindow(NetworkSettings* settings) : BWindow(BRect(50, 50, 370, 350), "Interface Settings", - B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, - B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE, - B_CURRENT_WORKSPACE) + B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, + B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE + | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE) { fNetworkSettings = settings; fTabView = new BTabView("settings_tabs"); - - fApplyButton = new BButton("save", B_TRANSLATE("Save"), - new BMessage(MSG_IP_SAVE)); + fTabView->SetTabWidth(B_WIDTH_FROM_LABEL); fRevertButton = new BButton("revert", B_TRANSLATE("Revert"), new BMessage(MSG_IP_REVERT)); - fTabView->SetResizingMode(B_FOLLOW_ALL); - // ensure tab container matches window size + fApplyButton = new BButton("save", B_TRANSLATE("Save"), + new BMessage(MSG_IP_SAVE)); + SetDefaultButton(fApplyButton); _PopulateTabs(); SetLayout(new BGroupLayout(B_VERTICAL)); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING) .Add(fTabView) - .AddGroup(B_HORIZONTAL, 5) - .AddGlue() + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(fRevertButton) + .AddGlue() .Add(fApplyButton) .End() - .SetInsets(10, 10, 10, 10) + .SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING, + B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) ); } @@ -65,21 +69,20 @@ InterfaceWindow::MessageReceived(BMessage* message) protocols* supportedFamilies = fNetworkSettings->ProtocolVersions(); switch (message->what) { + case MSG_IP_REVERT: - for (int index = 0; index < MAX_PROTOCOLS; index++) - { + for (int index = 0; index < MAX_PROTOCOLS; index++) { if (supportedFamilies[index].present) { int inet_id = supportedFamilies[index].inet_id; - fTabIPView[inet_id]->RevertFields(); + fTabIPView[inet_id]->Revert(); } } break; case MSG_IP_SAVE: - for (int index = 0; index < MAX_PROTOCOLS; index++) - { + for (int index = 0; index < MAX_PROTOCOLS; index++) { if (supportedFamilies[index].present) { int inet_id = supportedFamilies[index].inet_id; - fTabIPView[inet_id]->SaveFields(); + fTabIPView[inet_id]->Save(); } } this->Quit(); @@ -97,15 +100,15 @@ InterfaceWindow::_PopulateTabs() BRect frame = fTabView->Bounds(); protocols* supportedFamilies = fNetworkSettings->ProtocolVersions(); - BTab* hardwaretab = new BTab; + BTab* hardwareTab = new BTab; fTabHardwareView = new InterfaceHardwareView(frame, fNetworkSettings); - fTabView->AddTab(fTabHardwareView, hardwaretab); + fTabView->AddTab(fTabHardwareView, hardwareTab); if (fNetworkSettings->IsEthernet()) - hardwaretab->SetLabel("Wired"); + hardwareTab->SetLabel(B_TRANSLATE("Wired")); else - hardwaretab->SetLabel("Wirless"); + hardwareTab->SetLabel(B_TRANSLATE("Wirless")); for (int index = 0; index < MAX_PROTOCOLS; index++) { @@ -128,4 +131,3 @@ InterfaceWindow::QuitRequested() { return true; } - diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.h index d0e06e16ba..ddce7e500c 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.h @@ -1,9 +1,10 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ #ifndef INTERFACE_WINDOW_H #define INTERFACE_WINDOW_H @@ -13,15 +14,10 @@ #include "InterfaceAddressView.h" #include "InterfaceHardwareView.h" -#include -#include -#include -#include -#include -#include - #include +#include + enum { MSG_IP_SAVE = 'ipap', @@ -32,25 +28,30 @@ enum { typedef std::map IPViewMap; +class BButton; +class BTabView; + class InterfaceWindow : public BWindow { public: - InterfaceWindow(NetworkSettings* settings); - virtual ~InterfaceWindow(); - virtual bool QuitRequested(); - virtual void MessageReceived(BMessage* mesage); + InterfaceWindow(NetworkSettings* settings); + virtual ~InterfaceWindow(); + + virtual void MessageReceived(BMessage* mesage); + virtual bool QuitRequested(); private: - status_t _PopulateTabs(); + status_t _PopulateTabs(); - NetworkSettings* fNetworkSettings; - BButton* fApplyButton; - BButton* fRevertButton; - BTabView* fTabView; + NetworkSettings* fNetworkSettings; - IPViewMap fTabIPView; - InterfaceHardwareView* fTabHardwareView; + BButton* fRevertButton; + BButton* fApplyButton; + + BTabView* fTabView; + + IPViewMap fTabIPView; + InterfaceHardwareView* fTabHardwareView; }; -#endif /* INTERFACE_WINDOW_H */ - +#endif // INTERFACE_WINDOW_H diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp index acaacd6405..df11a7d3e9 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp @@ -1,30 +1,38 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Andre Alves Garzia, andre@andregarzia.com - * Stephan Assmuß + * Stephan Aßmus * Axel Dörfler + * Andre Alves Garzia, andre@andregarzia.com + * Alexander von Gluck, kallisti5@unixzen.com * Philippe Houdoin * Fredrik Modéen - * Hugo Santos * Philippe Saint-Pierre - * Alexander von Gluck, kallisti5@unixzen.com + * Hugo Santos + * John Scipione, jscipione@gmail.com */ #include "InterfacesAddOn.h" #include "InterfaceWindow.h" -#include - #include +#include +#include +#include #include #include +#include +#include #include +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "InterfacesAddOn" + + NetworkSetupAddOn* get_nth_addon(image_id image, int index) { @@ -60,42 +68,40 @@ InterfacesAddOn::Name() BView* InterfacesAddOn::CreateView(BRect *bounds) { - BRect intViewRect = *bounds; - // Construct the ListView - fListview = new InterfacesListView(intViewRect, - "interfaces", B_FOLLOW_ALL_SIDES); - fListview->SetSelectionMessage(new BMessage(kMsgInterfaceSelected)); - fListview->SetInvocationMessage(new BMessage(kMsgInterfaceConfigure)); + fListView = new InterfacesListView("interfaces"); + fListView->SetSelectionMessage(new BMessage(kMsgInterfaceSelected)); + fListView->SetInvocationMessage(new BMessage(kMsgInterfaceConfigure)); - BScrollView* scrollView = new BScrollView(NULL, fListview, - B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, false, true); + BScrollView* scrollView = new BScrollView("scrollView", fListView, + B_WILL_DRAW | B_FRAME_EVENTS, false, true); // Construct the BButtons - fConfigure = new BButton(intViewRect, "configure", - "Configure" B_UTF8_ELLIPSIS, new BMessage(kMsgInterfaceConfigure)); + fConfigure = new BButton("configure", B_TRANSLATE("Configure" B_UTF8_ELLIPSIS), + new BMessage(kMsgInterfaceConfigure)); fConfigure->SetEnabled(false); - fOnOff = new BButton(intViewRect, "onoff", "Disable", + fOnOff = new BButton("onoff", B_TRANSLATE("Disable"), new BMessage(kMsgInterfaceToggle)); fOnOff->SetEnabled(false); - fRenegotiate = new BButton(intViewRect, "heal", - "Renegotiate", new BMessage(kMsgInterfaceRenegotiate)); + fRenegotiate = new BButton("heal", B_TRANSLATE("Renegotiate"), + new BMessage(kMsgInterfaceRenegotiate)); fRenegotiate->SetEnabled(false); // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) + AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING) .Add(scrollView) - .AddGroup(B_HORIZONTAL, 5) + .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(fConfigure) .Add(fOnOff) .AddGlue() .Add(fRenegotiate) .End() - .SetInsets(10, 10, 10, 10) + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) ); *bounds = Bounds(); @@ -106,7 +112,7 @@ InterfacesAddOn::CreateView(BRect *bounds) void InterfacesAddOn::AttachedToWindow() { - fListview->SetTarget(this); + fListView->SetTarget(this); fConfigure->SetTarget(this); fOnOff->SetTarget(this); fRenegotiate->SetTarget(this); @@ -117,18 +123,17 @@ status_t InterfacesAddOn::Save() { // TODO : Profile? - return fListview->SaveItems(); + return fListView->SaveItems(); } void InterfacesAddOn::MessageReceived(BMessage* msg) { - int nr = fListview->CurrentSelection(); + int nr = fListView->CurrentSelection(); InterfaceListItem *item = NULL; - if (nr != -1) { - item = dynamic_cast(fListview->ItemAt(nr)); - } + if (nr != -1) + item = dynamic_cast(fListView->ItemAt(nr)); switch (msg->what) { case kMsgInterfaceSelected: @@ -136,7 +141,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg) fConfigure->SetEnabled(item != NULL); fOnOff->SetEnabled(item != NULL); fRenegotiate->SetEnabled(item != NULL); - if (!item) + if (item == NULL) break; fConfigure->SetEnabled(!item->IsDisabled()); fRenegotiate->SetEnabled(!item->IsDisabled()); @@ -146,7 +151,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg) case kMsgInterfaceConfigure: { - if (!item) + if (item == NULL) break; InterfaceWindow* sw = new InterfaceWindow(item->GetSettings()); @@ -156,20 +161,20 @@ InterfacesAddOn::MessageReceived(BMessage* msg) case kMsgInterfaceToggle: { - if (!item) + if (item == NULL) break; item->SetDisabled(!item->IsDisabled()); fConfigure->SetEnabled(!item->IsDisabled()); fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable"); fRenegotiate->SetEnabled(!item->IsDisabled()); - fListview->Invalidate(); + fListView->Invalidate(); break; } case kMsgInterfaceRenegotiate: { - if (!item) + if (item == NULL) break; NetworkSettings* ns = item->GetSettings(); diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h index dc73ba80d8..b70635112f 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h @@ -1,20 +1,18 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: + * Alexander von Gluck, * Philippe Houdoin * Fredrik Modéen - * Alexander von Gluck, + * John Scipione, jscipione@gmail.com */ #ifndef INTERFACES_ADDON_H #define INTERFACES_ADDON_H #include -#include -#include -#include #include "NetworkSetupAddOn.h" #include "InterfacesListView.h" @@ -26,6 +24,9 @@ static const uint32 kMsgInterfaceToggle = 'onof'; static const uint32 kMsgInterfaceRenegotiate = 'redo'; +class BButton; +class BView; + class InterfacesAddOn : public NetworkSetupAddOn, public BBox { public: @@ -41,12 +42,12 @@ public: void MessageReceived(BMessage* msg); private: - InterfacesListView* fListview; + InterfacesListView* fListView; BButton* fConfigure; BButton* fOnOff; BButton* fRenegotiate; }; -#endif /*INTERFACES_ADDON_H*/ +#endif // INTERFACES_ADDON_H diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp index cf64a38342..9d94011380 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp @@ -1,11 +1,12 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com * Philippe Houdoin * Fredrik Modéen - * Alexander von Gluck IV, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ @@ -19,24 +20,39 @@ #include #include #include +#include #include #include +#include +#include #include #include -#include +#include #include #include #include +#include +#include #include +#include +#include #include #include -#include "NetworkSettings.h" +#include "InterfacesAddOn.h" +#include "InterfaceWindow.h" -// #pragma mark - +#define ICON_SIZE 37 + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "InterfacesListView" + + +// #pragma mark - our_image function status_t @@ -53,7 +69,7 @@ our_image(image_info& image) } -// #pragma mark - +// #pragma mark - InterfaceListItem InterfaceListItem::InterfaceListItem(const char* name) @@ -73,22 +89,7 @@ InterfaceListItem::~InterfaceListItem() } -void -InterfaceListItem::Update(BView* owner, const BFont* font) -{ - BListItem::Update(owner, font); - font_height height; - font->GetHeight(&height); - - float lineHeight = ceilf(height.ascent) + ceilf(height.descent) - + ceilf(height.leading); - - fFirstlineOffset = 2 + ceilf(height.ascent + height.leading / 2); - fSecondlineOffset = fFirstlineOffset + lineHeight; - fThirdlineOffset = fFirstlineOffset + (lineHeight * 2); - - SetHeight(3 * lineHeight + 4); -} +// #pragma mark - InterfaceListItem public methods void @@ -96,22 +97,22 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete) { BListView* list = dynamic_cast(owner); - if (!list) + if (list == NULL) return; owner->PushState(); BRect bounds = list->ItemFrame(list->IndexOf(this)); - rgb_color black = {0, 0, 0, 255}; + rgb_color highColor = list->HighColor(); + rgb_color lowColor = list->LowColor(); if (IsSelected() || complete) { if (IsSelected()) { - list->SetHighColor(tint_color(list->ViewColor(), - B_HIGHLIGHT_BACKGROUND_TINT)); - } else { - list->SetHighColor(list->LowColor()); - } + list->SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR)); + list->SetLowColor(list->HighColor()); + } else + list->SetHighColor(lowColor); list->FillRect(bounds); } @@ -139,18 +140,18 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete) // Set the initial bounds of item contents BPoint iconPt = bounds.LeftTop(); BPoint namePt = bounds.LeftTop(); - BPoint v4addrPt = bounds.LeftTop(); - BPoint v6addrPt = bounds.LeftTop(); + BPoint line2Pt = bounds.LeftTop(); + BPoint line3Pt = bounds.LeftTop(); BPoint statePt = bounds.RightTop(); iconPt += BPoint(4, 4); statePt += BPoint(0, fFirstlineOffset); namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset); - v4addrPt += BPoint(ICON_SIZE + 12, fSecondlineOffset); - v6addrPt += BPoint(ICON_SIZE + 12, fThirdlineOffset); + line2Pt += BPoint(ICON_SIZE + 12, fSecondlineOffset); + line3Pt += BPoint(ICON_SIZE + 12, fThirdlineOffset); - statePt - -= BPoint(be_plain_font->StringWidth(interfaceState.String()), 0); + statePt -= BPoint( + be_plain_font->StringWidth(interfaceState.String()) + 4.0f, 0); if (fSettings->IsDisabled()) { list->SetDrawingMode(B_OP_ALPHA); @@ -162,46 +163,75 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete) list->DrawBitmapAsync(fIcon, iconPt); list->DrawBitmapAsync(stateIcon, iconPt); - if (fSettings->IsDisabled()) - list->SetHighColor(tint_color(black, B_LIGHTEN_1_TINT)); - else - list->SetHighColor(black); + if (fSettings->IsDisabled()) { + rgb_color textColor; + if (IsSelected()) + textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR); + else + textColor = ui_color(B_LIST_ITEM_TEXT_COLOR); + + if (textColor.red + textColor.green + textColor.blue > 128 * 3) + list->SetHighColor(tint_color(textColor, B_DARKEN_1_TINT)); + else + list->SetHighColor(tint_color(textColor, B_LIGHTEN_1_TINT)); + } else { + if (IsSelected()) + list->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR)); + else + list->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR)); + } list->SetFont(be_bold_font); list->DrawString(Name(), namePt); list->SetFont(be_plain_font); - list->DrawString(interfaceState, statePt); - + if (!fSettings->IsDisabled()) { // Render IPv4 Address - BString v4str("IPv4: "); - + BString ipv4Str(B_TRANSLATE_COMMENT("IP:", "IPv4 address label")); if (fSettings->IPAddr(AF_INET).IsEmpty()) - v4str << "none"; - else { - v4str << fSettings->IP(AF_INET); - } - - if (fSettings->AutoConfigure(AF_INET)) - v4str << " (DHCP)"; + ipv4Str << " " << B_TRANSLATE("None"); else - v4str << " (static)"; + ipv4Str << " " << BString(fSettings->IP(AF_INET)); - list->DrawString(v4str.String(), v4addrPt); + list->DrawString(ipv4Str, line2Pt); + } + + // Render IPv6 Address (if present) + if (!fSettings->IsDisabled() + && !fSettings->IPAddr(AF_INET6).IsEmpty()) { + BString ipv6Str(B_TRANSLATE_COMMENT("IPv6:", "IPv6 address label")); + ipv6Str << " " << BString(fSettings->IP(AF_INET6)); - // Render IPv6 Address (if present) - if (!fSettings->IPAddr(AF_INET6).IsEmpty()) { - BString v6str("IPv6: "); - v6str << fSettings->IP(AF_INET6); - list->DrawString(v6str, v6addrPt); - } + list->DrawString(ipv6Str, line3Pt); } owner->PopState(); } +void +InterfaceListItem::Update(BView* owner, const BFont* font) +{ + BListItem::Update(owner, font); + font_height height; + font->GetHeight(&height); + + float lineHeight = ceilf(height.ascent) + ceilf(height.descent) + + ceilf(height.leading); + + fFirstlineOffset = 2 + ceilf(height.ascent + height.leading / 2); + fSecondlineOffset = fFirstlineOffset + lineHeight; + fThirdlineOffset = fFirstlineOffset + (lineHeight * 2); + + SetHeight(max(3 * lineHeight + 4, fIcon->Bounds().Height() + 8)); + // either to the text height or icon height, whichever is taller +} + + +// #pragma mark - InterfaceListItem private methods + + void InterfaceListItem::_Init() { @@ -299,17 +329,17 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType) { 0, B_RGBA32); BIconUtils::GetVectorIcon(onlineHVIF, iconSize, fIconOnline); } - - } -// #pragma mark - +// #pragma mark - InterfaceListView -InterfacesListView::InterfacesListView(BRect rect, const char* name, uint32 resizingMode) - : BListView(rect, name, B_SINGLE_SELECTION_LIST, resizingMode) +InterfacesListView::InterfacesListView(const char* name) + : + BListView(name) { + fContextMenu = new BPopUpMenu("context menu", false, false); } @@ -318,6 +348,9 @@ InterfacesListView::~InterfacesListView() } +// #pragma mark - InterfaceListView protected methods + + void InterfacesListView::AttachedToWindow() { @@ -327,12 +360,16 @@ InterfacesListView::AttachedToWindow() start_watching_network( B_WATCH_NETWORK_INTERFACE_CHANGES | B_WATCH_NETWORK_LINK_CHANGES, this); + + Select(0); + // Select the first item in the list } void InterfacesListView::FrameResized(float width, float height) { + BListView::FrameResized(width, height); Invalidate(); } @@ -345,9 +382,9 @@ InterfacesListView::DetachedFromWindow() stop_watching_network(this); // free all items, they will be retrieved again in AttachedToWindow() - for (int32 i = CountItems(); i-- > 0;) { + for (int32 i = CountItems(); i-- > 0;) delete ItemAt(i); - } + MakeEmpty(); } @@ -366,7 +403,77 @@ InterfacesListView::MessageReceived(BMessage* message) } -InterfaceListItem * +void +InterfacesListView::MouseDown(BPoint where) +{ + int32 buttons = 0; + Window()->CurrentMessage()->FindInt32("buttons", &buttons); + + if ((B_SECONDARY_MOUSE_BUTTON & buttons) == 0) { + // If not secondary mouse button do the default + BListView::MouseDown(where); + return; + } + + InterfaceListItem* item = FindItem(where); + if (item == NULL) + return; + + // Remove all items from the menu + for (int32 i = fContextMenu->CountItems(); i >= 0; --i) { + BMenuItem* menuItem = fContextMenu->RemoveItem(i); + delete menuItem; + } + + // Now add the ones we want + if (item->GetSettings()->IsDisabled()) { + fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Enable"), + new BMessage(kMsgInterfaceToggle))); + } else { + fContextMenu->AddItem(new BMenuItem( + B_TRANSLATE("Configure" B_UTF8_ELLIPSIS), + new BMessage(kMsgInterfaceConfigure))); + if (item->GetSettings()->AutoConfigure(AF_INET) + || item->GetSettings()->AutoConfigure(AF_INET6)) { + fContextMenu->AddItem(new BMenuItem( + B_TRANSLATE("Renegotiate Address"), + new BMessage(kMsgInterfaceRenegotiate))); + } + fContextMenu->AddItem(new BSeparatorItem()); + fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Disable"), + new BMessage(kMsgInterfaceToggle))); + } + + fContextMenu->ResizeToPreferred(); + BMenuItem* selected = fContextMenu->Go(ConvertToScreen(where)); + if (selected == NULL) + return; + + switch (selected->Message()->what) { + case kMsgInterfaceConfigure: + { + InterfaceWindow* win = new InterfaceWindow(item->GetSettings()); + win->MoveTo(ConvertToScreen(where)); + win->Show(); + break; + } + + case kMsgInterfaceToggle: + item->SetDisabled(!item->IsDisabled()); + Invalidate(); + break; + + case kMsgInterfaceRenegotiate: + item->GetSettings()->RenegotiateAddresses(); + break; + } +} + + +// #pragma mark - InterfaceListView public methods + + +InterfaceListItem* InterfacesListView::FindItem(const char* name) { for (int32 i = CountItems(); i-- > 0;) { @@ -382,6 +489,22 @@ InterfacesListView::FindItem(const char* name) } +InterfaceListItem* +InterfacesListView::FindItem(BPoint where) +{ + for (int32 i = CountItems(); i-- > 0;) { + InterfaceListItem* item = dynamic_cast(ItemAt(i)); + if (item == NULL) + continue; + + if (ItemFrame(i).Contains(where)) + return item; + } + + return NULL; +} + + status_t InterfacesListView::SaveItems() { @@ -403,6 +526,9 @@ InterfacesListView::SaveItems() } +// #pragma mark - InterfaceListView private methods + + status_t InterfacesListView::_InitList() { @@ -411,9 +537,8 @@ InterfacesListView::_InitList() uint32 cookie = 0; while (roster.GetNextInterface(&cookie, interface) == B_OK) { - if (strncmp(interface.Name(), "loop", 4) && interface.Name()[0]) { + if (strncmp(interface.Name(), "loop", 4) && interface.Name()[0]) AddItem(new InterfaceListItem(interface.Name())); - } } return B_OK; @@ -447,29 +572,28 @@ InterfacesListView::_HandleNetworkMessage(BMessage* message) return; InterfaceListItem* item = FindItem(name); - if (!item) + if (item == NULL) printf("InterfaceListItem %s not found!\n", name); switch (opcode) { case B_NETWORK_INTERFACE_CHANGED: case B_NETWORK_DEVICE_LINK_CHANGED: - if (item) + if (item != NULL) InvalidateItem(IndexOf(item)); break; case B_NETWORK_INTERFACE_ADDED: - if (item) + if (item != NULL) InvalidateItem(IndexOf(item)); else AddItem(new InterfaceListItem(name)); break; case B_NETWORK_INTERFACE_REMOVED: - if (item) { + if (item != NULL) { RemoveItem(item); delete item; } break; } } - diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h index 8bf8ded916..5ea4f0804c 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h @@ -1,35 +1,30 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: + * Alexander von Gluck, kallisti5@unixzen.com * Philippe Houdoin * Fredrik Modéen - * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com */ #ifndef INTERFACES_LIST_VIEW_H #define INTERFACES_LIST_VIEW_H -#include -#include -#include -#include - -#include #include #include -#include -#include -#include -#include -#include #include "NetworkSettings.h" -#define ICON_SIZE 37 - +class BBitmap; +class BMenuItem; +class BNetworkInterface; +class BPoint; +class BPopUpMenu; +class BSeparatorItem; +class BString; class InterfaceListItem : public BListItem { public: @@ -71,13 +66,11 @@ private: class InterfacesListView : public BListView { public: - InterfacesListView(BRect rect, const char* name, - uint32 resizingMode - = B_FOLLOW_LEFT | B_FOLLOW_TOP); - + InterfacesListView(const char* name); virtual ~InterfacesListView(); InterfaceListItem* FindItem(const char* name); + InterfaceListItem* FindItem(BPoint where); status_t SaveItems(); protected: @@ -86,11 +79,16 @@ protected: virtual void FrameResized(float width, float height); virtual void MessageReceived(BMessage* message); + virtual void MouseDown(BPoint where); private: + // Context menu + BPopUpMenu* fContextMenu; + status_t _InitList(); status_t _UpdateList(); void _HandleNetworkMessage(BMessage* message); }; -#endif /*INTERFACES_LIST_VIEW_H*/ + +#endif // INTERFACES_LIST_VIEW_H diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/Jamfile b/src/tests/kits/net/preflet/InterfacesAddOn/Jamfile index d3e28d5f68..10e61e55d9 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/Jamfile +++ b/src/tests/kits/net/preflet/InterfacesAddOn/Jamfile @@ -34,3 +34,13 @@ Addon Interfaces : $(HAIKU_LOCALE_LIBS) libicon.a libagg.a ; + +DoCatalogs Interfaces : + x-vnd.Haiku-InterfacesAddOn + : + InterfacesAddOn.cpp + InterfacesListView.cpp + InterfaceWindow.cpp + InterfaceAddressView.cpp + InterfaceHardwareView.cpp +; diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.cpp index 7b6a866e90..ce7da8d209 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.cpp @@ -1,12 +1,13 @@ /* - * Copyright 2004-2011 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Andre Alves Garzia, andre@andregarzia.com * Axel Dörfler, axeld@pinc-software.de. - * Vegard Wærp, vegarwa@online.no + * Andre Alves Garzia, andre@andregarzia.com * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com + * Vegard Wærp, vegarwa@online.no */ @@ -18,20 +19,17 @@ #include #include #include -#include -#include #include #include #include +#include #include #include #include #include #include -#include - NetworkSettings::NetworkSettings(const char* name) : @@ -353,3 +351,14 @@ NetworkSettings::RenegotiateAddresses() return B_OK; } + + +const char* +NetworkSettings::HardwareAddress() +{ + BNetworkAddress macAddress; + if (fNetworkInterface->GetHardwareAddress(macAddress) == B_OK) + return macAddress.ToString(); + + return NULL; +} diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.h b/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.h index 2df798993e..d2b476a332 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/NetworkSettings.h @@ -1,22 +1,22 @@ /* - * Copyright 2004-2010 Haiku, Inc. All rights reserved. + * Copyright 2004-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Andre Alves Garzia, andre@andregarzia.com - * Vegard Wærp, vegarwa@online.no * Alexander von Gluck, kallisti5@unixzen.com + * John Scipione, jscipione@gmail.com + * Vegard Wærp, vegarwa@online.no */ #ifndef SETTINGS_H #define SETTINGS_H +#include + +#include #include #include -#include -#include - -#include #define MAX_PROTOCOLS 7 @@ -39,6 +39,8 @@ typedef struct _protocols { } protocols; +class BString; + class NetworkSettings { public: NetworkSettings(const char* name); @@ -48,11 +50,11 @@ public: { return fProtocols; } void SetIP(int family, const char* ip) - { fAddress[family].SetTo(ip); } + { fAddress[family].SetTo(family, ip); } void SetNetmask(int family, const char* mask) - { fNetmask[family].SetTo(mask); } + { fNetmask[family].SetTo(family, mask); } void SetGateway(int family, const char* ip) - { fGateway[family].SetTo(ip); } + { fGateway[family].SetTo(family, ip); } void SetAutoConfigure(int family, bool autoConf) { fAutoConfigure[family] = autoConf; } @@ -64,7 +66,6 @@ public: // void SetDomain(const BString& domain) // { fDomain = domain; } - bool AutoConfigure(int family) { return fAutoConfigure[family]; } BNetworkAddress IPAddr(int family) @@ -91,6 +92,8 @@ public: bool HasLink() { return fNetworkDevice->HasLink(); } + const char* HardwareAddress(); + const BString& WirelessNetwork() { return fWirelessNetwork; } BObjectList& NameServers() { return fNameServers; } @@ -128,4 +131,4 @@ private: }; -#endif /* SETTINGS_H */ +#endif // SETTINGS_H diff --git a/src/tests/kits/net/preflet/Jamfile b/src/tests/kits/net/preflet/Jamfile index 601ce31e6e..c5a5a1df5f 100644 --- a/src/tests/kits/net/preflet/Jamfile +++ b/src/tests/kits/net/preflet/Jamfile @@ -10,7 +10,7 @@ Preference NetworkSetup : ; SubInclude HAIKU_TOP src tests kits net preflet InterfacesAddOn ; -SubInclude HAIKU_TOP src tests kits net preflet ServicesAddOn ; -SubInclude HAIKU_TOP src tests kits net preflet DummyAddOn ; -SubInclude HAIKU_TOP src tests kits net preflet MultipleAddOns ; +#SubInclude HAIKU_TOP src tests kits net preflet ServicesAddOn ; +#SubInclude HAIKU_TOP src tests kits net preflet DummyAddOn ; +#SubInclude HAIKU_TOP src tests kits net preflet MultipleAddOns ; # SubInclude HAIKU_TOP src tests kits net preflet DialUpAddOn ; diff --git a/src/tests/kits/net/preflet/NetworkSetupWindow.cpp b/src/tests/kits/net/preflet/NetworkSetupWindow.cpp index 70f566dc8a..3344faee31 100644 --- a/src/tests/kits/net/preflet/NetworkSetupWindow.cpp +++ b/src/tests/kits/net/preflet/NetworkSetupWindow.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -50,46 +51,43 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title) fPanel = new BTabView("showview_box"); - // ---- Bottom globals buttons section - BBox *bottomDivider = new BBox(B_EMPTY_STRING); - bottomDivider->SetBorder(B_PLAIN_BORDER); - fApplyButton = new BButton("apply", B_TRANSLATE("Apply"), new BMessage(kMsgApply)); + SetDefaultButton(fApplyButton); fRevertButton = new BButton("revert", B_TRANSLATE("Revert"), new BMessage(kMsgRevert)); // fRevertButton->SetEnabled(false); // Enable boxes resizing modes - fPanel->SetResizingMode(B_FOLLOW_ALL); + //fPanel->SetResizingMode(B_FOLLOW_ALL); // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .AddGroup(B_HORIZONTAL, 5) + AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING) + .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(profilesMenuField) .AddGlue() .End() .Add(fPanel) - .Add(bottomDivider) - .AddGroup(B_HORIZONTAL, 5) - .AddGlue() + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(fRevertButton) + .AddGlue() .Add(fApplyButton) .End() - .SetInsets(10, 10, 10, 10) + .SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING, + B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) ); _BuildShowTabView(kMsgAddonShow); - bottomDivider->SetExplicitMaxSize(BSize(B_SIZE_UNSET, 1)); fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(), fMinAddonViewRect.Height())); fAddonView = NULL; + CenterOnScreen(); } @@ -243,7 +241,11 @@ NetworkSetupWindow::_BuildShowTabView(int32 msg_what) if (!search_paths) return; - fMinAddonViewRect.Set(0, 0, 375, 225); // Minimum size + float minimumWidth = be_control_look->DefaultItemSpacing() * 37; + float minimumHight = be_control_look->DefaultItemSpacing() * 25; + + fMinAddonViewRect.Set(0, 0, minimumWidth, minimumHight); + // Minimum size search_paths = strdup(search_paths); char* next_path_token; @@ -287,37 +289,37 @@ NetworkSetupWindow::_BuildShowTabView(int32 msg_what) int tabCount = 0; - if (status == B_OK) { - while ((fNetworkAddOnMap[fAddonCount] - = get_nth_addon(addon_id, tabCount)) != NULL) { - printf("Adding Tab: %d\n", fAddonCount); - BMessage* msg = new BMessage(msg_what); - - BRect r(0, 0, 0, 0); - BView* addon_view - = fNetworkAddOnMap[fAddonCount]->CreateView(&r); - fMinAddonViewRect = fMinAddonViewRect | r; - - msg->AddInt32("image_id", addon_id); - msg->AddString("addon_path", addon_path.Path()); - msg->AddPointer("addon", fNetworkAddOnMap[fAddonCount]); - msg->AddPointer("addon_view", addon_view); - - BTab *tab = new BTab; - fPanel->AddTab(addon_view, tab); - tab->SetLabel(fNetworkAddOnMap[fAddonCount]->Name()); - fAddonCount++; - // Number of tab addons total - tabCount++; - // Tabs for *this* addon - } + if (status != B_OK) { + // No "addon instantiate function" symbol found in this addon + printf("No symbol \"get_nth_addon\" found in %s addon: not a " + "network setup addon!\n", addon_path.Path()); + unload_add_on(addon_id); continue; } - // No "addon instantiate function" symbol found in this addon - printf("No symbol \"get_nth_addon\" found in %s addon: not a " - "network setup addon!\n", addon_path.Path()); - unload_add_on(addon_id); + while ((fNetworkAddOnMap[fAddonCount] + = get_nth_addon(addon_id, tabCount)) != NULL) { + printf("Adding Tab: %d\n", fAddonCount); + BMessage* msg = new BMessage(msg_what); + + BRect r(0, 0, 0, 0); + BView* addon_view + = fNetworkAddOnMap[fAddonCount]->CreateView(&r); + fMinAddonViewRect = fMinAddonViewRect | r; + + msg->AddInt32("image_id", addon_id); + msg->AddString("addon_path", addon_path.Path()); + msg->AddPointer("addon", fNetworkAddOnMap[fAddonCount]); + msg->AddPointer("addon_view", addon_view); + + BTab* tab = new BTab; + fPanel->AddTab(addon_view, tab); + tab->SetLabel(fNetworkAddOnMap[fAddonCount]->Name()); + fAddonCount++; + // Number of tab addons total + tabCount++; + // Tabs for *this* addon + } } } From 88e692e89f817ea357caaac03048350b08e0466c Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 29 Mar 2013 22:32:22 -0400 Subject: [PATCH 13/27] Ignore calls whose purpose is to calculate the GOT address. - Fixes several false positives where we'd show a return value for the current function. --- src/apps/debugger/controllers/ThreadHandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/controllers/ThreadHandler.cpp b/src/apps/debugger/controllers/ThreadHandler.cpp index c728dba3fd..72e519b70b 100644 --- a/src/apps/debugger/controllers/ThreadHandler.cpp +++ b/src/apps/debugger/controllers/ThreadHandler.cpp @@ -589,7 +589,8 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState) } } - if (fPreviousFrameAddress != 0) { + if (fPreviousFrameAddress != 0 && fSteppedOverFunctionAddress + != cpuState->InstructionPointer()) { TRACE_CONTROL("STEP_OVER: called function address %#" B_PRIx64 ", previous frame address: %#" B_PRIx64 ", frame address: %#" B_PRIx64 ", adding return info\n", fSteppedOverFunctionAddress, From 4e4c94e31496bb40ae0bf301229325b29fcafd4e Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Sat, 30 Mar 2013 06:26:11 +0100 Subject: [PATCH 14/27] Update translations from Pootle --- .../media/media-add-ons/multi_audio/ru.catkeys | 16 +++++++++++++++- data/catalogs/apps/deskbar/hu.catkeys | 6 +++++- data/catalogs/apps/deskbar/ja.catkeys | 7 ++++++- data/catalogs/apps/deskbar/ru.catkeys | 6 +++++- data/catalogs/apps/deskbar/sv.catkeys | 7 ++++++- data/catalogs/apps/drivesetup/ru.catkeys | 3 ++- data/catalogs/kits/ru.catkeys | 12 +++++++++++- 7 files changed, 50 insertions(+), 7 deletions(-) diff --git a/data/catalogs/add-ons/media/media-add-ons/multi_audio/ru.catkeys b/data/catalogs/add-ons/media/media-add-ons/multi_audio/ru.catkeys index c3e408bb9f..b177e91330 100644 --- a/data/catalogs/add-ons/media/media-add-ons/multi_audio/ru.catkeys +++ b/data/catalogs/add-ons/media/media-add-ons/multi_audio/ru.catkeys @@ -1,4 +1,4 @@ -1 russian x-vnd.Haiku-hmulti_audio.media_addon 1236066687 +1 russian x-vnd.Haiku-hmulti_audio.media_addon 451057402 Master MultiAudio Главный SPDIF MultiAudio SPDIF Gain MultiAudio Громкость @@ -18,3 +18,17 @@ Output treble MultiAudio Выход высоких Mono mix MultiAudio Моно микширование General MultiAudio Общие Input & Output MultiAudio Вход и Выход +Enhanced Setup MultiAudio Расщиренные настройки +Stereo mix MultiAudio Стерео микширование +Output 3D depth MultiAudio Выход 3D глубины +Volume MultiAudio Громкость +Output MultiAudio Выход +Video MultiAudio Видео +Line MultiAudio Линия +Mic MultiAudio Микрофон + frequency: MultiAudio частота: +Enable MultiAudio Включить +Mute MultiAudio Приглушить +Wave MultiAudio Волна +Setup MultiAudio Настройки +Level MultiAudio Уровень diff --git a/data/catalogs/apps/deskbar/hu.catkeys b/data/catalogs/apps/deskbar/hu.catkeys index af1bbfdf0f..1dd25d03c2 100644 --- a/data/catalogs/apps/deskbar/hu.catkeys +++ b/data/catalogs/apps/deskbar/hu.catkeys @@ -1,16 +1,19 @@ -1 hungarian x-vnd.Be-TSKB 1042823442 +1 hungarian x-vnd.Be-TSKB 2335730970 Power off DeskbarMenu Kikapcsolás +Sort applications by name PreferencesWindow Rendezés a program neve szerint Suspend DeskbarMenu Felfüggesztés Hide clock TimeView Óra elrejtése Applications PreferencesWindow Programok Time preferences… TimeView Idő beállítása… About Haiku DeskbarMenu Haiku névjegye +Edit in Tracker… PreferencesWindow Szerkesztés a Nyomkövetőben… Recent documents: PreferencesWindow Legutóbb használt fájlok: Recent applications DeskbarMenu Legutóbbi programok Applications B_USER_DESKBAR_DIRECTORY/Applications Programok Find… DeskbarMenu Keresés… Show clock Tray Óra megjelenítése Window PreferencesWindow Ablak +Defaults PreferencesWindow Eredeti Menu PreferencesWindow Menü Recent documents DeskbarMenu Legutóbb használt fájlok Auto-hide PreferencesWindow Automatikus elrejtés @@ -28,6 +31,7 @@ Restart Tracker DeskbarMenu Nyomkövető újraindítása Close all WindowMenu Összes bezárása Deskbar preferences PreferencesWindow Asztalsáv-beállítások Mount DeskbarMenu Csatolás +Revert PreferencesWindow Visszaállítás Small PreferencesWindow Kicsi Recent applications: PreferencesWindow Legutóbbi programok: Shutdown… DeskbarMenu Leállítás… diff --git a/data/catalogs/apps/deskbar/ja.catkeys b/data/catalogs/apps/deskbar/ja.catkeys index e797db0724..98561a6bdb 100644 --- a/data/catalogs/apps/deskbar/ja.catkeys +++ b/data/catalogs/apps/deskbar/ja.catkeys @@ -1,15 +1,19 @@ -1 japanese x-vnd.Be-TSKB 1398106986 +1 japanese x-vnd.Be-TSKB 2335730970 Power off DeskbarMenu 電源を切る +Sort applications by name PreferencesWindow アプリケーションを名前順に並び替える Suspend DeskbarMenu サスペンド Hide clock TimeView 時計を隠す +Applications PreferencesWindow アプリケーション Time preferences… TimeView 日付と時刻の設定… About Haiku DeskbarMenu Haiku について +Edit in Tracker… PreferencesWindow Tracker 中で編集… Recent documents: PreferencesWindow 最近使ったドキュメント Recent applications DeskbarMenu 最近使ったアプリケーション Applications B_USER_DESKBAR_DIRECTORY/Applications アプリケーション Find… DeskbarMenu 検索… Show clock Tray 時計を表示 Window PreferencesWindow ウィンドウ +Defaults PreferencesWindow デフォルト値 Menu PreferencesWindow メニュー Recent documents DeskbarMenu 最近使ったドキュメント Auto-hide PreferencesWindow 自動的に隠す @@ -27,6 +31,7 @@ Restart Tracker DeskbarMenu Tracker を再起動 Close all WindowMenu すべて閉じる Deskbar preferences PreferencesWindow Deskbar の設定 Mount DeskbarMenu マウント +Revert PreferencesWindow 取り消し Small PreferencesWindow 小 Recent applications: PreferencesWindow 最近使ったアプリケーション Shutdown… DeskbarMenu シャットダウン… diff --git a/data/catalogs/apps/deskbar/ru.catkeys b/data/catalogs/apps/deskbar/ru.catkeys index f24ba7c0e7..6a478a0e57 100644 --- a/data/catalogs/apps/deskbar/ru.catkeys +++ b/data/catalogs/apps/deskbar/ru.catkeys @@ -1,16 +1,19 @@ -1 russian x-vnd.Be-TSKB 1042823442 +1 russian x-vnd.Be-TSKB 2335730970 Power off DeskbarMenu Выключить компьютер +Sort applications by name PreferencesWindow Сортировать приложения по имени Suspend DeskbarMenu Приостановить Hide clock TimeView Скрыть часы Applications PreferencesWindow Приложения Time preferences… TimeView Настроить часы… About Haiku DeskbarMenu О системе Haiku +Edit in Tracker… PreferencesWindow Изменить меню… Recent documents: PreferencesWindow Недавние документы: Recent applications DeskbarMenu Недавние приложения Applications B_USER_DESKBAR_DIRECTORY/Applications Приложения Find… DeskbarMenu Найти… Show clock Tray Показать часы Window PreferencesWindow Окно +Defaults PreferencesWindow По умолчанию Menu PreferencesWindow Меню Recent documents DeskbarMenu Недавние документы Auto-hide PreferencesWindow Скрывать автоматически @@ -28,6 +31,7 @@ Restart Tracker DeskbarMenu Перезапустить Tracker Close all WindowMenu Закрыть все Deskbar preferences PreferencesWindow Настройки Deskbar Mount DeskbarMenu Подключить +Revert PreferencesWindow Вернуть Small PreferencesWindow Маленькие Recent applications: PreferencesWindow Недавние приложения: Shutdown… DeskbarMenu Завершение работы… diff --git a/data/catalogs/apps/deskbar/sv.catkeys b/data/catalogs/apps/deskbar/sv.catkeys index e4a3eb0386..1f35d4fc99 100644 --- a/data/catalogs/apps/deskbar/sv.catkeys +++ b/data/catalogs/apps/deskbar/sv.catkeys @@ -1,15 +1,19 @@ -1 swedish x-vnd.Be-TSKB 1398106986 +1 swedish x-vnd.Be-TSKB 2335730970 Power off DeskbarMenu Stäng av +Sort applications by name PreferencesWindow Sortera program efter namn Suspend DeskbarMenu Vänteläge Hide clock TimeView Dölj klockan +Applications PreferencesWindow Program Time preferences… TimeView Tidspreferenser About Haiku DeskbarMenu Om Haiku +Edit in Tracker… PreferencesWindow Editera i Tracker… Recent documents: PreferencesWindow Senaste dokument: Recent applications DeskbarMenu Senaste program Applications B_USER_DESKBAR_DIRECTORY/Applications Program Find… DeskbarMenu Sök... Show clock Tray Visa klockan Window PreferencesWindow Fönster +Defaults PreferencesWindow Standardvärden Menu PreferencesWindow Meny Recent documents DeskbarMenu Senaste dokument Auto-hide PreferencesWindow Dölj automatiskt @@ -27,6 +31,7 @@ Restart Tracker DeskbarMenu Starta om Tracker Close all WindowMenu Stäng alla Deskbar preferences PreferencesWindow Deskbar inställningar Mount DeskbarMenu Montera +Revert PreferencesWindow Återgå Small PreferencesWindow Liten Recent applications: PreferencesWindow Senaste program: Shutdown… DeskbarMenu Stäng av… diff --git a/data/catalogs/apps/drivesetup/ru.catkeys b/data/catalogs/apps/drivesetup/ru.catkeys index 39ec84e490..db908bf518 100644 --- a/data/catalogs/apps/drivesetup/ru.catkeys +++ b/data/catalogs/apps/drivesetup/ru.catkeys @@ -1,4 +1,4 @@ -1 russian x-vnd.Haiku-DriveSetup 4139684894 +1 russian x-vnd.Haiku-DriveSetup 2015202924 DriveSetup System name Разметка диска Cancel AbstractParametersPanel Отмена Delete MainWindow Удалить @@ -49,6 +49,7 @@ Failed to format the partition %s!\n MainWindow Не удалось иници Mount MainWindow Подключить Partition type PartitionList Тип раздела Are you sure you want to format a raw disk? (most people initialize the disk with a partitioning system first) You will be asked again before changes are written to the disk. MainWindow Вы уверены, что хотите инициализировать весь диск? (обычно на диске создают систему разделов)\nПовторный запрос будет выдан непосредственно перед записью изменений на диск. +Change parameters… MainWindow Изменить параметры… Device PartitionList Устройство Disk MainWindow Диск Are you sure you want to initialize the selected disk? All data will be lost. You will be asked again before changes are written to the disk.\n MainWindow Вы уверены, что хотите инициализировать выбранный диск? Все данные на этом диске будут потеряны.\nПовторный запрос будет выдан непосредственно перед записью изменений на диск.\n diff --git a/data/catalogs/kits/ru.catkeys b/data/catalogs/kits/ru.catkeys index d2c7e67b70..4b0075d919 100644 --- a/data/catalogs/kits/ru.catkeys +++ b/data/catalogs/kits/ru.catkeys @@ -1,21 +1,29 @@ -1 russian x-vnd.Haiku-libbe 864109244 +1 russian x-vnd.Haiku-libbe 672385853 +gamma AboutWindow гамма +beta AboutWindow бета %3.2f GiB StringForSize %3.2f ГБ Written by: AboutWindow Разработан: About %app% AboutMenuItem О программе… Cut TextView Вырезать +Version AboutWindow Версия Cannot create the replicant for \"%description\".\n%error ZombieReplicantView Невозможно удалить репликант \"%description\".\n%error +About AboutWindow О программе Copy TextView Копировать %3.2f KiB StringForSize %3.2f КБ %d bytes StringForSize %d байт +alpha AboutWindow альфа Error PrintJob Ошибка No Pages to print! PrintJob Нет страниц для печати +All Rights Reserved. AboutWindow Все права защищены. OK Dragger ОК OK PrintJob ОК Green: ColorControl Зеленый: +Version history: AboutWindow История версий: Remove replicant Dragger Удалить репликант OK ZombieReplicantView ОК Print Server is not responding. PrintJob Сервер печати не отвечает. Paste TextView Вставить +Special Thanks: AboutWindow Особые благодарности: %.2f TiB StringForSize %.2f ТБ Cannot locate the application for the replicant. No application signature supplied.\n%error ZombieReplicantView Не удалось найти приложение этого репликанта. Не указана сигнатура приложения.\n%error Redo TextView Повторить @@ -26,6 +34,8 @@ Undo TextView Отменить Red: ColorControl Красный: %3.2f MiB StringForSize %3.2f МБ About %app… Dragger О программе… +development AboutWindow в разработке Error ZombieReplicantView Ошибка Blue: ColorControl Синий: +gold master AboutWindow золотая Can't delete this replicant from its original application. Life goes on. Dragger Не удалось удалить этот репликант из его изначальное приложения. Жизнь продолжается. From a3a541eebd0b2ffe2e2ba30acf1c87d5ed9cf98f Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 30 Mar 2013 20:17:39 +0100 Subject: [PATCH 15/27] Make a copy of the network config message and store that one. Using the original message and storing that into the settings resulted in a not yet fully understood deadlock. Presumably related to missing and/or stray replies. --- src/servers/net/NetServer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index 2e9c045f09..27da836cdd 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -351,9 +351,10 @@ NetServer::MessageReceived(BMessage* message) case kMsgAddPersistentNetwork: { - status_t result = _ConvertNetworkToSettings(*message); + BMessage network = *message; + status_t result = _ConvertNetworkToSettings(network); if (result == B_OK) - result = fSettings.AddNetwork(*message); + result = fSettings.AddNetwork(network); BMessage reply(B_REPLY); reply.AddInt32("status", result); From f84890787563f38410d44ca77e39a001b32722af Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Mar 2013 00:43:32 +0100 Subject: [PATCH 16/27] Implement storing persistent network configurations. The API to add persistent networks was added back in r42807 and r42816 but storing them was still missing. --- src/servers/net/Settings.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/servers/net/Settings.cpp b/src/servers/net/Settings.cpp index 36dafc21c9..a52c2b1ced 100644 --- a/src/servers/net/Settings.cpp +++ b/src/servers/net/Settings.cpp @@ -10,6 +10,7 @@ #include "Settings.h" #include +#include #include #include #include @@ -410,13 +411,18 @@ Settings::_ConvertToDriverSettings(const char* name, BString settings; status = _ConvertToDriverSettings(settingsTemplate, settings, message); - if (status == B_OK) { - settings.RemoveFirst("\n"); - // TODO: actually write the settings.String() out into the file - printf("settings:\n%s\n", settings.String()); - } + if (status != B_OK) + return status; - return status; + settings.RemoveFirst("\n"); + BFile settingsFile(path.Path(), B_WRITE_ONLY | B_ERASE_FILE + | B_CREATE_FILE); + + ssize_t written = settingsFile.Write(settings.String(), settings.Length()); + if (written < 0) + return written; + + return written == settings.Length() ? B_OK : B_ERROR; } From 93c2c2aa6ba9738915ab4cfa4f1f00a738bf1886 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Mar 2013 03:01:08 +0200 Subject: [PATCH 17/27] Update wpa_supplicant to version 2.0 and bring in improvements. * Updated to version 2.0 of vendor code. * Reliability improvements in controlling the underlying devices. * Implement leaving networks. * Better timeout handling. * Usability enhancements like cancel on escape, ok button being the default and the password field having focus on start. * Storing of the password using BKeyStore. --- build/jam/OptionalPackages | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index 319a793d40..737a9e9b4d 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -2349,13 +2349,13 @@ if [ IsOptionalHaikuImagePackageAdded wpa_supplicant ] { Echo "No optional package wpa_supplicant available for $(TARGET_ARCH)" ; } else if $(HAIKU_GCC_VERSION[1]) >= 4 { InstallOptionalHaikuImagePackage - wpa_supplicant-0.7.3-x86-gcc4-2012-04-03.zip - : $(baseURL)/wpa_supplicant-0.7.3-x86-gcc4-2012-04-03.zip + wpa_supplicant-2.0-x86-gcc4-2013-03-31.zip + : $(baseURL)/wpa_supplicant-2.0-x86-gcc4-2013-03-31.zip : : : false ; } else { InstallOptionalHaikuImagePackage - wpa_supplicant-0.7.3-x86-gcc2-2012-04-03.zip - : $(baseURL)/wpa_supplicant-0.7.3-x86-gcc2-2012-04-03.zip + wpa_supplicant-2.0-x86-gcc2-2013-03-31.zip + : $(baseURL)/wpa_supplicant-2.0-x86-gcc2-2013-03-31.zip : : : false ; } } From fa21184f24d35e0c1e3dddae0a2981d05861e494 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Mar 2013 03:22:21 +0200 Subject: [PATCH 18/27] Implement leaving networks on the net_server side. We always try to reach the wpa_supplicant first. If it isn't running we check if this might have been a network we've connected directly and then just disassociate using an MLME disassociation request. --- src/servers/net/NetServer.cpp | 44 +++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index 27da836cdd..f98cf009c4 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -1160,8 +1160,48 @@ NetServer::_JoinNetwork(const BMessage& message, const char* name) status_t NetServer::_LeaveNetwork(const BMessage& message) { - // TODO: not yet implemented - return B_NOT_SUPPORTED; + const char* deviceName; + if (message.FindString("device", &deviceName) != B_OK) + return B_BAD_VALUE; + + int32 reason; + if (message.FindInt32("reason", &reason) != B_OK) + reason = IEEE80211_REASON_AUTH_LEAVE; + + // We always try to send the leave request to the wpa_supplicant. + + BMessage leave(kMsgWPALeaveNetwork); + status_t status = leave.AddString("device", deviceName); + if (status == B_OK) + status = leave.AddInt32("reason", reason); + if (status != B_OK) + return status; + + BMessenger wpaSupplicant(kWPASupplicantSignature); + status = wpaSupplicant.SendMessage(&leave); + if (status == B_OK) + return B_OK; + + // The wpa_supplicant doesn't seem to be running, check if this was an open + // network we connected ourselves. + BNetworkDevice device(deviceName); + wireless_network network; + + uint32 cookie = 0; + if (device.GetNextAssociatedNetwork(cookie, network) != B_OK + || network.authentication_mode != B_NETWORK_AUTHENTICATION_NONE) { + // We didn't join ourselves, we can't do much. + return status; + } + + // We joined ourselves, so we can just disassociate again. + ieee80211req_mlme mlmeRequest; + memset(&mlmeRequest, 0, sizeof(mlmeRequest)); + mlmeRequest.im_op = IEEE80211_MLME_DISASSOC; + mlmeRequest.im_reason = reason; + + return set_80211(deviceName, IEEE80211_IOC_MLME, &mlmeRequest, + sizeof(mlmeRequest)); } From 32057ce92279831f060782646fa67ea7161019f9 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Mar 2013 18:30:39 +0200 Subject: [PATCH 19/27] If a keyring is empty, store a no data flag instead of failing. Any fully empty keyring (no keys and no applications) would fail to add the empty flat buffer and thus prevent the whole keystore database from being stored. This could easily happen when you used separate keyrings but the master keyring was left unused for example. Adding a flag that tells that there is no data allows us to distinguish between a case where the stored data is missing due to a problem versus an actually empty buffer. --- src/servers/keystore/Keyring.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/servers/keystore/Keyring.cpp b/src/servers/keystore/Keyring.cpp index 8392716909..fbf11b4a0b 100644 --- a/src/servers/keystore/Keyring.cpp +++ b/src/servers/keystore/Keyring.cpp @@ -42,6 +42,11 @@ Keyring::ReadFromMessage(const BMessage& message) if (result != B_OK) return result; + if (message.GetBool("noData", false)) { + fFlatBuffer.SetSize(0); + return B_OK; + } + ssize_t size; const void* data; result = message.FindData("data", B_RAW_TYPE, &data, &size); @@ -69,8 +74,12 @@ Keyring::WriteToMessage(BMessage& message) if (result != B_OK) return result; - result = message.AddData("data", B_RAW_TYPE, fFlatBuffer.Buffer(), - fFlatBuffer.BufferLength()); + if (fFlatBuffer.BufferLength() == 0) + result = message.AddBool("noData", true); + else { + result = message.AddData("data", B_RAW_TYPE, fFlatBuffer.Buffer(), + fFlatBuffer.BufferLength()); + } if (result != B_OK) return result; From 6de478363ee34b8d265dc2b763c031dda9e6fec8 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Mar 2013 20:16:04 +0200 Subject: [PATCH 20/27] Add BMessenger::SetTo() to reinitialize a BMessenger. This allows to reuse BMessenger objects for different targets, or to recheck validity after initial creation. With that one can use the same BMessenger after launching an application that was previously not found valid for example. --- headers/os/app/Messenger.h | 5 ++ src/kits/app/Messenger.cpp | 120 ++++++++++++++++++++++++++++--------- 2 files changed, 98 insertions(+), 27 deletions(-) diff --git a/headers/os/app/Messenger.h b/headers/os/app/Messenger.h index 3c68fee9ed..1285014d82 100644 --- a/headers/os/app/Messenger.h +++ b/headers/os/app/Messenger.h @@ -48,6 +48,9 @@ public: // Operators and misc + status_t SetTo(const char *signature, team_id team = -1); + status_t SetTo(const BHandler *handler, const BLooper *looper = NULL); + BMessenger &operator=(const BMessenger &from); bool operator==(const BMessenger &other) const; @@ -63,6 +66,8 @@ private: void _SetTo(team_id team, port_id port, int32 token); void _InitData(const char *signature, team_id team, status_t *result); + void _InitData(const BHandler *handler, const BLooper *looper, + status_t *result); private: port_id fPort; diff --git a/src/kits/app/Messenger.cpp b/src/kits/app/Messenger.cpp index 230136fa49..3e284a3743 100644 --- a/src/kits/app/Messenger.cpp +++ b/src/kits/app/Messenger.cpp @@ -98,33 +98,7 @@ BMessenger::BMessenger(const BHandler* handler, const BLooper* looper, fHandlerToken(B_NULL_TOKEN), fTeam(-1) { - status_t error = (handler || looper ? B_OK : B_BAD_VALUE); - if (error == B_OK) { - if (handler) { - // BHandler is given, check/retrieve the looper. - if (looper) { - if (handler->Looper() != looper) - error = B_MISMATCHED_VALUES; - } else { - looper = handler->Looper(); - if (looper == NULL) - error = B_MISMATCHED_VALUES; - } - } - // set port, token,... - if (error == B_OK) { - AutoLocker locker(gLooperList); - if (locker.IsLocked() && gLooperList.IsLooperValid(looper)) { - fPort = looper->fMsgPort; - fHandlerToken = (handler - ? _get_object_token_(handler) : B_PREFERRED_TOKEN); - fTeam = looper->Team(); - } else - error = B_BAD_VALUE; - } - } - if (_result) - *_result = error; + _InitData(handler, looper, _result); } @@ -427,6 +401,50 @@ BMessenger::SendMessage(BMessage *message, BMessage *reply, // #pragma mark - Operators and misc +/*! \brief Reinitializes a BMessenger to target the already running application + identified by the supplied signature and/or team ID. + + When only a signature is given, and multiple instances of the application + are running it is undeterminate which one is chosen as the target. In case + only a team ID is passed, the target application is identified uniquely. + If both are supplied, the application identified by the team ID must have + a matching signature, otherwise the initilization fails. + + \param signature The target application's signature. May be \c NULL. + \param team The target application's team ID. May be < 0. + \return The result of the reinitialization. +*/ +status_t +BMessenger::SetTo(const char *signature, team_id team) +{ + status_t result = B_OK; + _InitData(signature, team, &result); + return result; +} + + +/*! \brief Reinitializes a BMessenger to target the local BHandler and/or + BLooper. + + When a \c NULL handler is supplied, the preferred handler in the given + looper is targeted. If no looper is supplied the looper the given handler + belongs to is used -- that means in particular, that the handler must + already belong to a looper. If both are supplied the handler must actually + belong to looper. + + \param handler The target handler. May be \c NULL. + \param looper The target looper. May be \c NULL. + \return The result of the reinitialization. +*/ +status_t +BMessenger::SetTo(const BHandler* handler, const BLooper* looper) +{ + status_t result = B_OK; + _InitData(handler, looper, &result); + return result; +} + + /*! \brief Makes this BMessenger a copy of the supplied one. \param from the messenger to be copied. @@ -564,6 +582,54 @@ BMessenger::_InitData(const char* signature, team_id team, status_t* _result) } +/*! \brief Initializes the BMessenger to target the local BHandler and/or + BLooper. + + When a \c NULL handler is supplied, the preferred handler in the given + looper is targeted. If no looper is supplied the looper the given handler + belongs to is used -- that means in particular, that the handler must + already belong to a looper. If both are supplied the handler must actually + belong to looper. + + \param handler The target handler. May be \c NULL. + \param looper The target looper. May be \c NULL. + \param result An optional pointer to a pre-allocated status_t into which + the result of the initialization is written. +*/ +void +BMessenger::_InitData(const BHandler* handler, const BLooper* looper, + status_t* _result) +{ + status_t error = (handler || looper ? B_OK : B_BAD_VALUE); + if (error == B_OK) { + if (handler) { + // BHandler is given, check/retrieve the looper. + if (looper) { + if (handler->Looper() != looper) + error = B_MISMATCHED_VALUES; + } else { + looper = handler->Looper(); + if (looper == NULL) + error = B_MISMATCHED_VALUES; + } + } + // set port, token,... + if (error == B_OK) { + AutoLocker locker(gLooperList); + if (locker.IsLocked() && gLooperList.IsLooperValid(looper)) { + fPort = looper->fMsgPort; + fHandlerToken = (handler + ? _get_object_token_(handler) : B_PREFERRED_TOKEN); + fTeam = looper->Team(); + } else + error = B_BAD_VALUE; + } + } + if (_result) + *_result = error; +} + + /*! \brief Returns whether the first one of two BMessengers is less than the second one. From 4e66f871e58574af7ba13b6af259d4dedf58095e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Mar 2013 20:23:45 +0200 Subject: [PATCH 21/27] Launch the keystore_server on demand from BKeyStore. This allows leaving the keystore_server closed as long as it isn't used and still avoids having to launch it manually. --- src/kits/app/KeyStore.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/kits/app/KeyStore.cpp b/src/kits/app/KeyStore.cpp index c72b87a7a5..58fe5d0da5 100644 --- a/src/kits/app/KeyStore.cpp +++ b/src/kits/app/KeyStore.cpp @@ -9,6 +9,7 @@ #include #include +#include using namespace BPrivate; @@ -416,8 +417,17 @@ BKeyStore::_SendKeyMessage(BMessage& message, BMessage* reply) const reply = &localReply; BMessenger messenger(kKeyStoreServerSignature); - if (!messenger.IsValid()) - return B_ERROR; + if (!messenger.IsValid()) { + // Try to start the keystore server. + status_t result = be_roster->Launch(kKeyStoreServerSignature); + if (result != B_OK && result != B_ALREADY_RUNNING) + return B_ERROR; + + // Then re-target the messenger and check again. + messenger.SetTo(kKeyStoreServerSignature); + if (!messenger.IsValid()) + return B_ERROR; + } if (messenger.SendMessage(&message, reply) != B_OK) return B_ERROR; From 8163a8e0efcfe7279bf6890250fa98e44cbbcedf Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Mar 2013 20:25:27 +0200 Subject: [PATCH 22/27] Use a BMessenger to check for wpa_supplicant availabiltiy. * Only launch it on join requests if it isn't yet valid anyway. * Don't do any work on leave requests if it isn't running at all. --- src/servers/net/NetServer.cpp | 40 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index f98cf009c4..69ef3c84c1 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -1129,14 +1129,21 @@ NetServer::_JoinNetwork(const BMessage& message, const char* name) // Join via wpa_supplicant - status_t status = be_roster->Launch(kWPASupplicantSignature); - if (status != B_OK && status != B_ALREADY_RUNNING) - return status; + BMessenger wpaSupplicant(kWPASupplicantSignature); + if (!wpaSupplicant.IsValid()) { + status_t status = be_roster->Launch(kWPASupplicantSignature); + if (status != B_OK && status != B_ALREADY_RUNNING) + return status; + + wpaSupplicant.SetTo(kWPASupplicantSignature); + if (!wpaSupplicant.IsValid()) + return B_ERROR; + } // TODO: listen to notifications from the supplicant! BMessage join(kMsgWPAJoinNetwork); - status = join.AddString("device", deviceName); + status_t status = join.AddString("device", deviceName); if (status == B_OK) status = join.AddString("name", network.name); if (status == B_OK) @@ -1148,7 +1155,6 @@ NetServer::_JoinNetwork(const BMessage& message, const char* name) if (status != B_OK) return status; - BMessenger wpaSupplicant(kWPASupplicantSignature); status = wpaSupplicant.SendMessage(&join); if (status != B_OK) return status; @@ -1170,17 +1176,19 @@ NetServer::_LeaveNetwork(const BMessage& message) // We always try to send the leave request to the wpa_supplicant. - BMessage leave(kMsgWPALeaveNetwork); - status_t status = leave.AddString("device", deviceName); - if (status == B_OK) - status = leave.AddInt32("reason", reason); - if (status != B_OK) - return status; - BMessenger wpaSupplicant(kWPASupplicantSignature); - status = wpaSupplicant.SendMessage(&leave); - if (status == B_OK) - return B_OK; + if (wpaSupplicant.IsValid()) { + BMessage leave(kMsgWPALeaveNetwork); + status_t status = leave.AddString("device", deviceName); + if (status == B_OK) + status = leave.AddInt32("reason", reason); + if (status != B_OK) + return status; + + status = wpaSupplicant.SendMessage(&leave); + if (status == B_OK) + return B_OK; + } // The wpa_supplicant doesn't seem to be running, check if this was an open // network we connected ourselves. @@ -1191,7 +1199,7 @@ NetServer::_LeaveNetwork(const BMessage& message) if (device.GetNextAssociatedNetwork(cookie, network) != B_OK || network.authentication_mode != B_NETWORK_AUTHENTICATION_NONE) { // We didn't join ourselves, we can't do much. - return status; + return B_ERROR; } // We joined ourselves, so we can just disassociate again. From 2ac5770dc73bf3c68886663ddbb9e7935d1cf782 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 1 Apr 2013 01:59:29 +0200 Subject: [PATCH 23/27] Don't automatically join a network if we already have a link. The _ConfigureInterface() method is used as a backend for all configuration tasks. That includes setting addresses manually or by DHCP and changing flags, mtu or metric. Therefore we can't join networks every time it is invoked. Instead we check for an existing link first and only try to join if there is none yet. --- src/servers/net/NetServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index 69ef3c84c1..a067fbf453 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -533,7 +533,7 @@ NetServer::_ConfigureInterface(BMessage& message) } BNetworkDevice device(name); - if (device.IsWireless()) { + if (device.IsWireless() && !device.HasLink()) { const char* networkName; if (message.FindString("network", &networkName) == B_OK) { // join configured network From 0ef15eb6b9510c80ff004a99e3cbd6f7c5d52053 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 1 Apr 2013 19:26:21 +0200 Subject: [PATCH 24/27] Rename _ConfigureInterfaces() to *FromSettings(). This makes it more obvious what the function does. --- src/servers/net/NetServer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index a067fbf453..6a33f5151f 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -80,7 +80,7 @@ private: status_t _ConfigureDevice(const char* path); void _ConfigureDevices(const char* path, BMessage* suggestedInterface = NULL); - void _ConfigureInterfaces( + void _ConfigureInterfacesFromSettings( BMessage* _missingDevice = NULL); void _ConfigureIPv6LinkLocal(const char* name); @@ -268,7 +268,7 @@ NetServer::MessageReceived(BMessage* message) case kMsgInterfaceSettingsUpdated: { - _ConfigureInterfaces(); + _ConfigureInterfacesFromSettings(); break; } @@ -787,7 +787,7 @@ NetServer::_ConfigureDevices(const char* startPath, void -NetServer::_ConfigureInterfaces(BMessage* _missingDevice) +NetServer::_ConfigureInterfacesFromSettings(BMessage* _missingDevice) { BMessage interface; uint32 cookie = 0; @@ -837,7 +837,7 @@ NetServer::_BringUpInterfaces() // First, we look into the settings, and try to bring everything up from there BMessage missingDevice; - _ConfigureInterfaces(&missingDevice); + _ConfigureInterfacesFromSettings(&missingDevice); // check configuration From 50944289c6f40c9961bf2a69d0986dd8aca11704 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 1 Apr 2013 19:38:21 +0200 Subject: [PATCH 25/27] Use the wpa_supplicant to join open networks if it is running. We need to make sure that the wpa_supplicant knows about our intention even when joining an open network, as it otherwise might interfere. Since leaving a network is not synchronous and the wpa_supplicant is already running in that case anyway, this seems easier and more reliable. If the wpa_supplicant is not already running we still join ourselves. --- src/servers/net/NetServer.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index 6a33f5151f..e24e70dada 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -1113,24 +1113,26 @@ NetServer::_JoinNetwork(const BMessage& message, const char* name) } } - if (!askForConfig - && network.authentication_mode == B_NETWORK_AUTHENTICATION_NONE) { - // we join the network ourselves - status_t status = set_80211(deviceName, IEEE80211_IOC_SSID, - network.name, strlen(network.name)); - if (status != B_OK) { - fprintf(stderr, "%s: joining SSID failed: %s\n", name, - strerror(status)); - return status; - } - - return B_OK; - } - - // Join via wpa_supplicant + // We always try to join via the wpa_supplicant. Even if we could join + // ourselves, we need to make sure that the wpa_supplicant knows about + // our intention, as otherwise it would interfere with it. BMessenger wpaSupplicant(kWPASupplicantSignature); if (!wpaSupplicant.IsValid()) { + // The wpa_supplicant isn't running yet, we may join ourselves. + if (!askForConfig + && network.authentication_mode == B_NETWORK_AUTHENTICATION_NONE) { + // We can join this network ourselves. + status_t status = set_80211(deviceName, IEEE80211_IOC_SSID, + network.name, strlen(network.name)); + if (status != B_OK) { + fprintf(stderr, "%s: joining SSID failed: %s\n", name, + strerror(status)); + return status; + } + } + + // We need the supplicant, try to launch it. status_t status = be_roster->Launch(kWPASupplicantSignature); if (status != B_OK && status != B_ALREADY_RUNNING) return status; From 6e77a76ef949934aa78e71ee52bc34eecd96d987 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Tue, 2 Apr 2013 01:07:09 +0200 Subject: [PATCH 26/27] Use the SSID supplied in the MLME request not the desired SSID. The wpa_supplicant (rightfully) supplies the SSID with this request. However, with the code that is in place it gets ignored and the desired SSID, as set by IEEE80211_IOC_SSID is used instead. This still works if the wpa_supplicant is the only client in use and IEEE80211_IOC_SSID is never used, as then the mlme.im_macaddr is used as the only identifying element. If we used IEEE80211_IOC_SSID before though, for example because we joined an open network from the net_server directly, there will always be a mismatch between the desired SSID and the one the wpa_supplicant tries to associate with using this MLME request. No association is then possible. As there is no obvious reason why the request supplied SSID shouldn't be used, we simply do so. --- .../freebsd_wlan/net80211/ieee80211_ioctl.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.c b/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.c index 15c6c17a7f..269ab45790 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.c +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.c @@ -1549,8 +1549,25 @@ ieee80211_ioctl_setmlme(struct ieee80211vap *vap, struct ieee80211req *ireq) return error; if (vap->iv_opmode == IEEE80211_M_STA && mlme.im_op == IEEE80211_MLME_ASSOC) +#ifndef __HAIKU__ return setmlme_assoc_sta(vap, mlme.im_macaddr, vap->iv_des_ssid[0].len, vap->iv_des_ssid[0].ssid); +#else + /* The wpa_supplicant (rightfully) supplies the SSID with this request. + However, with the code above it gets ignored and the desired SSID, + as set by IEEE80211_IOC_SSID is used instead. This still works if + the wpa_supplicant is the only client in use and IEEE80211_IOC_SSID + is never used, as then the mlme.im_macaddr is used as the only + identifying element. If we used IEEE80211_IOC_SSID before though, + for example because we joined an open network from the net_server + directly, there will always be a mismatch between the desired SSID + and the one the wpa_supplicant tries to associate with using this + MLME request. No association is then possible. As there is no + obvious reason why the request supplied SSID shouldn't be used, we + simply do so. */ + return setmlme_assoc_sta(vap, mlme.im_macaddr, + mlme.im_ssid_len, mlme.im_ssid); +#endif else if (mlme.im_op == IEEE80211_MLME_ASSOC) return setmlme_assoc_adhoc(vap, mlme.im_macaddr, mlme.im_ssid_len, mlme.im_ssid); From 1b3dd41a357d759e93ca7512ee429250523cdf82 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Tue, 2 Apr 2013 02:30:04 +0200 Subject: [PATCH 27/27] Never join a network if not explicitly configured. The scanning still occurs so that the network list is populated. But if no SSID has been explicitly configured, we now always set the IEEE80211_SCAN_NOJOIN flag that prevents automatically joining open networks at the end of the scan. --- src/libs/compat/freebsd_wlan/net80211/ieee80211_scan.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_scan.c b/src/libs/compat/freebsd_wlan/net80211/ieee80211_scan.c index 68a0ea4542..9fbeb91f31 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_scan.c +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_scan.c @@ -411,6 +411,15 @@ start_scan_locked(const struct ieee80211_scanner *scan, , flags & IEEE80211_SCAN_ONCE ? ", once" : "" ); +#ifdef __HAIKU__ + /* We never want to join if not explicitly looking for an SSID */ + if (nssid == 0 && (flags & IEEE80211_SCAN_NOJOIN) == 0) { + IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, + "%s: setting nojoin due to no configured ssid\n", __func__); + flags |= IEEE80211_SCAN_NOJOIN; + } +#endif + scan_update_locked(vap, scan); if (ss->ss_ops != NULL) { if ((flags & IEEE80211_SCAN_NOSSID) == 0)