[haiku-commits] BRANCH axeld-github.network-preferences [3643b2f0d720] src/preferences/network src/preferences/network/InterfacesAddOn src/bin/network/ifconfig headers/os/add-ons/network_settings

  • From: axeld-github.network-preferences <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 11 Feb 2015 20:46:50 +0100 (CET)

added 9 changesets to branch 'refs/remotes/axeld-github/network-preferences'
old head: b81e4e2ae149a73ff65e7fc9d1d0781eec4f42c1
new head: 3643b2f0d72040d18f1908f0e4064ddb23885751
overview: https://github.com/axeld/haiku/compare/b81e4e2ae149...3643b2f0d720

----------------------------------------------------------------------------

b7ebbbc1ffed: Network: WIP of redesign.
  
  * Fletched out new add-on API.
  * Moved InterfaceListItem from the interfaces add-on into the
    application.
  * Renamed NetworkSetup* to Network* respectively NetworkSettings*.

0ea36dcabf5b: Network: moved add-on headers to the correct position.
  
  * Ie. they've moved to headers/os/add-ons/network_settings now.

25d511e9ff68: Network: made list view B_FULL_UPDATE_ON_RESIZE.
  
  * To account for its right aligned contents.

cc9130b67ef1: Network: Removed unused includes.

272e85ca911a: Network: no need for public constants.

2224918f8605: WIP, amend me.

bf5cca4c50d6: ifconfig: moved media type stuff into its own file.
  
  * This can now be easily shared.

1de91d438370: BNetworkDevice.GetHardwareAddress() was broken.
  
  * Copy&paste error, apparently.

3643b2f0d720: Network: integrated former hardware view from add-on.
  
  * The interfaces logic is within the main application, so is the
    new interface view.
  * Disabling/renegotiating does not work yet.
  * Reveals a bug in some interface code; when you click on an ethernet
    device first, there is no place for the wireless menu. When you then
    press on a wireless device, it crashes in BMenuField code.
    In the other direction, there is then an empty space.
  * Fixed list item width reporting.

                                   [ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

25 files changed, 1684 insertions(+), 1016 deletions(-)
.../os/add-ons/network_settings/NetworkProfile.h |  56 +++
.../network_settings/NetworkSettingsAddOn.h      |  96 ++++
src/bin/network/ifconfig/Jamfile                 |   1 +
src/bin/network/ifconfig/MediaTypes.cpp          | 139 ++++++
src/bin/network/ifconfig/MediaTypes.h            |  23 +
src/bin/network/ifconfig/ifconfig.cpp            | 117 +----
src/kits/network/libnetapi/NetworkDevice.cpp     |   4 +-
.../InterfacesIcons.rdef => InterfaceIcons.rdef} |   0
src/preferences/network/InterfaceListItem.cpp    | 326 +++++++++++++
src/preferences/network/InterfaceListItem.h      |  61 +++
...terfaceHardwareView.cpp => InterfaceView.cpp} | 197 ++++----
.../InterfaceHardwareView.h => InterfaceView.h}  |  36 +-
src/preferences/network/Jamfile                  |  38 +-
.../network/{NetworkSetup.cpp => Network.cpp}    |   6 +-
.../network/{NetworkSetup.rdef => Network.rdef}  |   0
src/preferences/network/NetworkProfile.cpp       | 160 +++++++
src/preferences/network/NetworkSettingsAddOn.cpp | 123 +++++
src/preferences/network/NetworkSetupAddOn.cpp    | 102 ----
src/preferences/network/NetworkSetupAddOn.h      |  56 ---
src/preferences/network/NetworkSetupProfile.cpp  | 159 -------
src/preferences/network/NetworkSetupProfile.h    |  52 --
src/preferences/network/NetworkSetupWindow.cpp   | 340 --------------
src/preferences/network/NetworkSetupWindow.h     |  64 ---
src/preferences/network/NetworkWindow.cpp        | 470 +++++++++++++++++++
src/preferences/network/NetworkWindow.h          |  74 +++

############################################################################

Commit:      b7ebbbc1ffed0c9bd9477c135d4018c4e599a955
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb  4 17:09:37 2015 UTC

Network: WIP of redesign.

* Fletched out new add-on API.
* Moved InterfaceListItem from the interfaces add-on into the
  application.
* Renamed NetworkSetup* to Network* respectively NetworkSettings*.

----------------------------------------------------------------------------

diff --git a/src/preferences/network/InterfacesAddOn/InterfacesIcons.rdef 
b/src/preferences/network/InterfaceIcons.rdef
similarity index 100%
rename from src/preferences/network/InterfacesAddOn/InterfacesIcons.rdef
rename to src/preferences/network/InterfaceIcons.rdef
diff --git a/src/preferences/network/InterfaceListItem.cpp 
b/src/preferences/network/InterfaceListItem.cpp
new file mode 100644
index 0000000..efd0d9b
--- /dev/null
+++ b/src/preferences/network/InterfaceListItem.cpp
@@ -0,0 +1,303 @@
+/*
+ * Copyright 2004-2015 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Alexander von Gluck IV, kallisti5@xxxxxxxxxxx
+ *             Philippe Houdoin
+ *             Fredrik Modéen
+ *             John Scipione, jscipione@xxxxxxxxx
+ */
+
+
+#include "InterfaceListItem.h"
+
+#include <algorithm>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+#include <netinet/in.h>
+#include <net_notifications.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+
+#include <Application.h>
+#include <Bitmap.h>
+#include <Catalog.h>
+#include <File.h>
+#include <IconUtils.h>
+#include <MenuItem.h>
+#include <NetworkDevice.h>
+#include <NetworkInterface.h>
+#include <NetworkRoster.h>
+#include <OutlineListView.h>
+#include <Point.h>
+#include <PopUpMenu.h>
+#include <Resources.h>
+#include <String.h>
+#include <SeparatorItem.h>
+#include <Window.h>
+
+#include <AutoDeleter.h>
+
+
+#define ICON_SIZE 37
+
+
+#undef B_TRANSLATION_CONTEXT
+#define B_TRANSLATION_CONTEXT "InterfacesListView"
+
+
+InterfaceListItem::InterfaceListItem(const char* name)
+       :
+       BListItem(0, false),
+       fIcon(NULL)
+{
+       fInterface.SetTo(name);
+       _Init();
+}
+
+
+InterfaceListItem::~InterfaceListItem()
+{
+       delete fIcon;
+}
+
+
+// #pragma mark - InterfaceListItem public methods
+
+
+void
+InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
+{
+       BOutlineListView* list = dynamic_cast<BOutlineListView*>(owner);
+       if (list == NULL)
+               return;
+
+       owner->PushState();
+
+       BRect bounds = list->ItemFrame(list->IndexOf(this));
+
+       //rgb_color highColor = list->HighColor();
+       rgb_color lowColor = list->LowColor();
+
+       if (IsSelected() || complete) {
+               if (IsSelected()) {
+                       
list->SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
+                       list->SetLowColor(list->HighColor());
+               } else
+                       list->SetHighColor(lowColor);
+
+               list->FillRect(bounds);
+       }
+
+       BString interfaceState;
+       BBitmap* stateIcon(NULL);
+
+       // TODO: only update periodically
+       bool disabled = (fInterface.Flags() & IFF_UP) == 0;
+
+       if (disabled) {
+               interfaceState = "disabled";
+               stateIcon = fIconOffline;
+       } else if (!fInterface.HasLink()) {
+               interfaceState = "no link";
+               stateIcon = fIconOffline;
+       // TODO!
+//     } else if ((fSettings->IPAddr(AF_INET).IsEmpty()
+//             && fSettings->IPAddr(AF_INET6).IsEmpty())
+//             && (fSettings->AutoConfigure(AF_INET)
+//             || fSettings->AutoConfigure(AF_INET6))) {
+//             interfaceState = "connecting" B_UTF8_ELLIPSIS;
+//             stateIcon = fIconPending;
+       } else {
+               interfaceState = "connected";
+               stateIcon = fIconOnline;
+       }
+
+       // Set the initial bounds of item contents
+       BPoint iconPt = bounds.LeftTop();
+       BPoint namePt = 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);
+       line2Pt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
+       line3Pt += BPoint(ICON_SIZE + 12, fThirdlineOffset);
+
+       statePt -= BPoint(
+               be_plain_font->StringWidth(interfaceState.String()) + 4.0f, 0);
+
+       if (disabled) {
+               list->SetDrawingMode(B_OP_ALPHA);
+               list->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
+               list->SetHighColor(0, 0, 0, 32);
+       } else
+               list->SetDrawingMode(B_OP_OVER);
+
+       list->DrawBitmapAsync(fIcon, iconPt);
+       list->DrawBitmapAsync(stateIcon, iconPt);
+
+       if (disabled) {
+               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);
+
+       BString name = Name();
+       name.RemoveFirst("/dev/net/");
+
+       list->DrawString(name, namePt);
+       list->SetFont(be_plain_font);
+       list->DrawString(interfaceState, statePt);
+
+// TODO!
+/*     if (!disabled) {
+               // Render IPv4 Address
+               BString ipv4Str(B_TRANSLATE_COMMENT("IP:", "IPv4 address 
label"));
+               if (fSettings->IPAddr(AF_INET).IsEmpty())
+                       ipv4Str << " " << B_TRANSLATE("None");
+               else
+                       ipv4Str << " " << BString(fSettings->IP(AF_INET));
+
+               list->DrawString(ipv4Str, line2Pt);
+       }
+
+       // Render IPv6 Address (if present)
+       if (!disabled && !fSettings->IPAddr(AF_INET6).IsEmpty()) {
+               BString ipv6Str(B_TRANSLATE_COMMENT("IPv6:", "IPv6 address 
label"));
+               ipv6Str << " " << BString(fSettings->IP(AF_INET6));
+
+               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(std::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()
+{
+       const char* mediaTypeName = NULL;
+
+       BNetworkDevice device(Name());
+       if (device.IsWireless())
+               mediaTypeName = "wifi";
+       else if (device.IsEthernet())
+               mediaTypeName = "ether";
+
+       _PopulateBitmaps(mediaTypeName);
+               // Load the interface icons
+}
+
+
+void
+InterfaceListItem::_PopulateBitmaps(const char* mediaType)
+{
+       const uint8* interfaceHVIF;
+       const uint8* offlineHVIF;
+       const uint8* pendingHVIF;
+       const uint8* onlineHVIF;
+
+       BBitmap* interfaceBitmap = NULL;
+
+       BResources* resources = BApplication::AppResources();
+
+       size_t iconSize;
+
+       // Try specific interface icon?
+       interfaceHVIF = (const uint8*)resources->LoadResource(
+               B_VECTOR_ICON_TYPE, Name(), &iconSize);
+
+       if (interfaceHVIF == NULL && mediaType != NULL)
+               // Not found, try interface media type?
+               interfaceHVIF = (const uint8*)resources->LoadResource(
+                       B_VECTOR_ICON_TYPE, mediaType, &iconSize);
+       if (interfaceHVIF == NULL)
+               // Not found, try default interface icon?
+               interfaceHVIF = (const uint8*)resources->LoadResource(
+                       B_VECTOR_ICON_TYPE, "ether", &iconSize);
+
+       if (interfaceHVIF) {
+               // Now build the bitmap
+               interfaceBitmap = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE),
+                       0, B_RGBA32);
+               if (BIconUtils::GetVectorIcon(interfaceHVIF,
+                       iconSize, interfaceBitmap) == B_OK)
+                       fIcon = interfaceBitmap;
+               else
+                       delete interfaceBitmap;
+       }
+
+       // Load possible state icons
+       offlineHVIF = (const uint8*)resources->LoadResource(
+               B_VECTOR_ICON_TYPE, "offline", &iconSize);
+
+       if (offlineHVIF) {
+               fIconOffline = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE),
+                       0, B_RGBA32);
+               BIconUtils::GetVectorIcon(offlineHVIF, iconSize, fIconOffline);
+       }
+
+       pendingHVIF = (const uint8*)resources->LoadResource(
+               B_VECTOR_ICON_TYPE, "pending", &iconSize);
+
+       if (pendingHVIF) {
+               fIconPending = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE),
+                       0, B_RGBA32);
+               BIconUtils::GetVectorIcon(pendingHVIF, iconSize, fIconPending);
+       }
+
+       onlineHVIF = (const uint8*)resources->LoadResource(
+               B_VECTOR_ICON_TYPE, "online", &iconSize);
+
+       if (onlineHVIF) {
+               fIconOnline = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE),
+                       0, B_RGBA32);
+               BIconUtils::GetVectorIcon(onlineHVIF, iconSize, fIconOnline);
+       }
+}
diff --git a/src/preferences/network/InterfaceListItem.h 
b/src/preferences/network/InterfaceListItem.h
new file mode 100644
index 0000000..84d4286
--- /dev/null
+++ b/src/preferences/network/InterfaceListItem.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004-2015 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ *             Philippe Houdoin
+ *             Fredrik Modéen
+ *             John Scipione, jscipione@xxxxxxxxx
+ */
+#ifndef INTERFACE_LIST_ITEM_H
+#define INTERFACE_LIST_ITEM_H
+
+
+#include <ListItem.h>
+#include <NetworkInterface.h>
+
+
+class BBitmap;
+
+
+class InterfaceListItem : public BListItem {
+public:
+                                                               
InterfaceListItem(const char* name);
+                                                               
~InterfaceListItem();
+
+                       void                            DrawItem(BView* owner,
+                                                                       BRect 
bounds, bool complete);
+                       void                            Update(BView* owner, 
const BFont* font);
+
+       inline  const char*                     Name() { return 
fInterface.Name(); }
+
+private:
+                       void                            _Init();
+                       void                            _PopulateBitmaps(const 
char* mediaType);
+
+                       BBitmap*                        fIcon;
+                       BBitmap*                        fIconOffline;
+                       BBitmap*                        fIconPending;
+                       BBitmap*                        fIconOnline;
+
+                       BNetworkInterface       fInterface;
+                               // Hardware Interface
+
+                       float                           fFirstlineOffset;
+                       float                           fSecondlineOffset;
+                       float                           fThirdlineOffset;
+};
+
+
+#endif // INTERFACE_LIST_ITEM_H
diff --git a/src/preferences/network/Jamfile b/src/preferences/network/Jamfile
index a80e8e9..16c4a11 100644
--- a/src/preferences/network/Jamfile
+++ b/src/preferences/network/Jamfile
@@ -1,33 +1,37 @@
 SubDir HAIKU_TOP src preferences network ;
+
+UsePrivateHeaders net shared ;
+
 SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src apps networkstatus ] ;
 
 Preference Network :
-       NetworkSetup.cpp
-       NetworkSetupWindow.cpp
-       NetworkSetupProfile.cpp
-       NetworkSetupAddOn.cpp
+       Network.cpp
+       NetworkWindow.cpp
+       NetworkProfile.cpp
+       NetworkSettingsAddOn.cpp
+       InterfaceListItem.cpp
 
        # from NetworkStatus
        RadioView.cpp
        WirelessNetworkMenuItem.cpp
 
-       : be root [ TargetLibstdc++ ] localestub
-       : NetworkSetup.rdef
+       : be root bnetapi [ TargetLibstdc++ ] localestub
+       : Network.rdef InterfaceIcons.rdef
 ;
 
 DoCatalogs Network :
        x-vnd.Haiku-Network
        :
-       NetworkSetup.cpp
-       NetworkSetupWindow.cpp
-       NetworkSetupProfile.cpp
-       NetworkSetupAddOn.cpp
+       Network.cpp
+       NetworkWindow.cpp
+       NetworkProfile.cpp
+       NetworkSettingsAddOn.cpp
        RadioView.cpp
        WirelessNetworkMenuItem.cpp
 ;
 
-SubInclude HAIKU_TOP src preferences network InterfacesAddOn ;
-SubInclude HAIKU_TOP src preferences network ServicesAddOn ;
+#SubInclude HAIKU_TOP src preferences network InterfacesAddOn ;
+#SubInclude HAIKU_TOP src preferences network ServicesAddOn ;
 #SubInclude HAIKU_TOP src preferences network DummyAddOn ;
 #SubInclude HAIKU_TOP src preferences network MultipleAddOns ;
 #SubInclude HAIKU_TOP src preferences network DialUpAddOn ;
diff --git a/src/preferences/network/NetworkSetup.cpp 
b/src/preferences/network/Network.cpp
similarity index 87%
rename from src/preferences/network/NetworkSetup.cpp
rename to src/preferences/network/Network.cpp
index 4f91910..84a6b9f 100644
--- a/src/preferences/network/NetworkSetup.cpp
+++ b/src/preferences/network/Network.cpp
@@ -1,16 +1,16 @@
 /*
  * Copyright 2004-2015 Haiku Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
- *
  */
 
+
 #include <Alert.h>
 #include <Application.h>
 #include <Catalog.h>
 #include <Locale.h>
 #include <Window.h>
 
-#include "NetworkSetupWindow.h"
+#include "NetworkWindow.h"
 
 
 static const char* kSignature = "application/x-vnd.Haiku-Network";
@@ -35,7 +35,7 @@ Application::Application()
 void
 Application::ReadyToRun()
 {
-       NetworkSetupWindow* window = new NetworkSetupWindow();
+       NetworkWindow* window = new NetworkWindow();
        window->Show();
 }
 
diff --git a/src/preferences/network/NetworkSetup.rdef 
b/src/preferences/network/Network.rdef
similarity index 100%
rename from src/preferences/network/NetworkSetup.rdef
rename to src/preferences/network/Network.rdef
diff --git a/src/preferences/network/NetworkProfile.cpp 
b/src/preferences/network/NetworkProfile.cpp
new file mode 100644
index 0000000..338a96d
--- /dev/null
+++ b/src/preferences/network/NetworkProfile.cpp
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2004-2015 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "NetworkProfile.h"
+
+#include <stdlib.h>
+
+
+using namespace BNetworkKit;
+
+
+BNetworkProfile::BNetworkProfile()
+       :
+       fIsDefault(false),
+       fIsCurrent(false),
+       fName(NULL)
+{
+}
+
+
+BNetworkProfile::BNetworkProfile(const char* path)
+       :
+       fIsDefault(false),
+       fIsCurrent(false)
+{
+       SetTo(path);
+}
+
+
+BNetworkProfile::BNetworkProfile(const entry_ref& ref)
+       :
+       fIsDefault(false),
+       fIsCurrent(false)
+{
+       SetTo(ref);
+}
+
+
+BNetworkProfile::BNetworkProfile(const BEntry& entry)
+       :
+       fIsDefault(false),
+       fIsCurrent(false)
+{
+       SetTo(entry);
+}
+
+
+BNetworkProfile::~BNetworkProfile()
+{
+}
+
+
+status_t
+BNetworkProfile::SetTo(const char* path)
+{
+       status_t status = fEntry.SetTo(path, true);
+       if (status != B_OK)
+               return status;
+
+       fPath.Unset();
+       fName = NULL;
+       return B_OK;
+}
+
+
+status_t
+BNetworkProfile::SetTo(const entry_ref& ref)
+{
+       status_t status = fEntry.SetTo(&ref);
+       if (status != B_OK)
+               return status;
+
+       fPath.Unset();
+       fName = ref.name;
+       return B_OK;
+}
+
+
+status_t
+BNetworkProfile::SetTo(const BEntry& entry)
+{
+       fEntry = entry;
+       fPath.Unset();
+       fName = NULL;
+       return B_OK;
+}
+
+
+const char*
+BNetworkProfile::Name()
+{
+       if (fName == NULL) {
+               if (fEntry.GetPath(&fPath) == B_OK)
+                       fName = fPath.Leaf();
+       }
+
+       return fName;
+}
+
+
+status_t
+BNetworkProfile::SetName(const char* name)
+{
+       return B_OK;
+}
+
+
+bool
+BNetworkProfile::Exists()
+{
+       return fEntry.Exists();
+}
+
+
+status_t
+BNetworkProfile::Delete()
+{
+       return B_ERROR;
+}
+
+
+bool
+BNetworkProfile::IsDefault()
+{
+       return fIsDefault;
+}
+
+
+bool
+BNetworkProfile::IsCurrent()
+{
+       return fIsCurrent;
+}
+
+
+status_t
+BNetworkProfile::MakeCurrent()
+{
+       return B_ERROR;
+}
+
+
+// #pragma mark -
+
+
+BNetworkProfile*
+BNetworkProfile::Default()
+{
+       return NULL;
+}
+
+
+BNetworkProfile*
+BNetworkProfile::Current()
+{
+       return NULL;
+}
diff --git a/src/preferences/network/NetworkProfile.h 
b/src/preferences/network/NetworkProfile.h
new file mode 100644
index 0000000..da26f51
--- /dev/null
+++ b/src/preferences/network/NetworkProfile.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004-2015 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _NETWORK_PROFILE_H
+#define _NETWORK_PROFILE_H
+
+
+#include <Entry.h>
+#include <Path.h>
+
+
+namespace BNetworkKit {
+
+
+class BNetworkProfile {
+public:
+                                                               
BNetworkProfile();
+                                                               
BNetworkProfile(const char* path);
+                                                               
BNetworkProfile(const entry_ref& ref);
+                                                               
BNetworkProfile(const BEntry& entry);
+       virtual                                         ~BNetworkProfile();
+
+                       status_t                        SetTo(const char* path);
+                       status_t                        SetTo(const entry_ref& 
ref);
+                       status_t                        SetTo(const BEntry& 
entry);
+
+                       bool                            Exists();
+
+                       const char*                     Name();
+                       status_t                        SetName(const char* 
name);
+
+                       bool                            IsDefault();
+                       bool                            IsCurrent();
+
+                       status_t                        MakeCurrent();
+                       status_t                        Delete();
+
+       static  BNetworkProfile*        Default();
+       static  BNetworkProfile*        Current();
+
+private:
+                       BEntry                          fEntry;
+                       BPath                           fPath;
+                       bool                            fIsDefault;
+                       bool                            fIsCurrent;
+                       const char*                     fName;
+
+       static  BDirectory*                     fProfilesRoot;
+};
+
+
+}      // namespace BNetworkKit
+
+
+#endif // _NETWORK_PROFILE_H
diff --git a/src/preferences/network/NetworkSettingsAddOn.cpp 
b/src/preferences/network/NetworkSettingsAddOn.cpp
new file mode 100644
index 0000000..bb27fda
--- /dev/null
+++ b/src/preferences/network/NetworkSettingsAddOn.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004-2015 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "NetworkSettingsAddOn.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+using namespace BNetworkKit;
+
+
+BNetworkSettingsItem::BNetworkSettingsItem()
+       :
+       fProfile(NULL)
+{
+}
+
+
+BNetworkSettingsItem::~BNetworkSettingsItem()
+{
+}
+
+
+status_t
+BNetworkSettingsItem::ProfileChanged(const BNetworkProfile* newProfile)
+{
+       fProfile = newProfile;
+       return B_OK;
+}
+
+
+const BNetworkProfile*
+BNetworkSettingsItem::Profile() const
+{
+       return fProfile;
+}
+
+
+// #pragma mark -
+
+
+BNetworkSettingsInterfaceItem::BNetworkSettingsInterfaceItem(
+       const char* interface)
+       :
+       fInterface(interface)
+{
+}
+
+
+BNetworkSettingsType
+BNetworkSettingsInterfaceItem::Type() const
+{
+       return B_NETWORK_SETTINGS_TYPE_INTERFACE;
+}
+
+
+const char*
+BNetworkSettingsInterfaceItem::Interface() const
+{
+       return fInterface;
+}
+
+
+// #pragma mark -
+
+
+BNetworkSettingsAddOn::BNetworkSettingsAddOn(image_id image)
+       :
+       fImage(image),
+       fResources(NULL)
+{
+}
+
+
+BNetworkSettingsAddOn::~BNetworkSettingsAddOn()
+{
+       delete fResources;
+}
+
+
+BNetworkSettingsInterfaceItem*
+BNetworkSettingsAddOn::CreateNextInterfaceItem(uint32& cookie,
+       const char* interface)
+{
+       return NULL;
+}
+
+
+BNetworkSettingsItem*
+BNetworkSettingsAddOn::CreateNextItem(uint32& cookie)
+{
+       return NULL;
+}
+
+
+image_id
+BNetworkSettingsAddOn::Image()
+{
+       return fImage;
+}
+
+
+BResources*
+BNetworkSettingsAddOn::Resources()
+{
+       if (fResources == NULL) {
+               image_info info;
+               if (get_image_info(fImage, &info) != B_OK)
+                       return NULL;
+
+               BResources* resources = new BResources();
+               BFile file(info.name, B_READ_ONLY);
+               if (resources->SetTo(&file) == B_OK)
+                       fResources = resources;
+               else
+                       delete resources;
+       }
+       return fResources;
+}
diff --git a/src/preferences/network/NetworkSettingsAddOn.h 
b/src/preferences/network/NetworkSettingsAddOn.h
new file mode 100644
index 0000000..479f2ef
--- /dev/null
+++ b/src/preferences/network/NetworkSettingsAddOn.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2004-2015 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ */
+#ifndef _NETWORK_SETTINGS_ADD_ON_H
+#define _NETWORK_SETTINGS_ADD_ON_H
+
+
+#include <image.h>
+#include <ListItem.h>
+#include <Resources.h>
+#include <View.h>
+
+
+namespace BNetworkKit {
+
+
+enum BNetworkSettingsType {
+       B_NETWORK_SETTINGS_TYPE_INTERFACE = 'intf',
+       B_NETWORK_SETTINGS_TYPE_SERVICE = 'serv',
+       B_NETWORK_SETTINGS_TYPE_DIAL_UP = 'dial',
+       B_NETWORK_SETTINGS_TYPE_OTHER = 'othr'
+};
+
+class BNetworkProfile;
+
+
+class BNetworkSettingsItem {
+public:
+                                                               
BNetworkSettingsItem();
+       virtual                                         ~BNetworkSettingsItem();
+
+       virtual BNetworkSettingsType
+                                                               Type() const = 
0;
+       virtual BListItem*                      CreateListItem() = 0;
+
+       virtual status_t                        ProfileChanged(
+                                                                       const 
BNetworkProfile* newProfile);
+                       const BNetworkProfile*
+                                                               Profile() const;
+
+       virtual status_t                        Save() = 0;
+       virtual status_t                        Revert() = 0;
+
+private:
+                       const BNetworkProfile*
+                                                               fProfile;
+};
+
+
+class BNetworkSettingsInterfaceItem : public BNetworkSettingsItem {
+public:
+                                                               
BNetworkSettingsInterfaceItem(
+                                                                       const 
char* interface);
+
+       virtual BNetworkSettingsType
+                                                               Type() const;
+                       const char*                     Interface() const;
+
+private:
+                       const char*                     fInterface;
+};
+
+
+class BNetworkSettingsAddOn {
+public:
+                                                               
BNetworkSettingsAddOn(image_id image);
+       virtual                                         
~BNetworkSettingsAddOn();
+
+       virtual BNetworkSettingsInterfaceItem*
+                                                               
CreateNextInterfaceItem(uint32& cookie,
+                                                                       const 
char* interface);
+       virtual BNetworkSettingsItem*
+                                                               
CreateNextItem(uint32& cookie);
+
+                       image_id                        Image();
+                       BResources*                     Resources();
+
+private:
+                       image_id                        fImage;
+                       BResources*                     fResources;
+};
+
+
+// Your add-on needs to export this hook in order to be picked up
+extern "C" BNetworkSettingsAddOn* instantiate_network_settings_add_on(
+       image_id image);
+
+
+}      // namespace BNetworkKit
+
+
+#endif // _NETWORK_SETTINGS_ADD_ON_H
diff --git a/src/preferences/network/NetworkSetupAddOn.cpp 
b/src/preferences/network/NetworkSetupAddOn.cpp
deleted file mode 100644
index 703ee5a..0000000
--- a/src/preferences/network/NetworkSetupAddOn.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2004-2015 Haiku Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- */
-
-
-#include "NetworkSetupAddOn.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-
-NetworkSetupAddOn::NetworkSetupAddOn(image_id image)
-       :
-       fIsDirty(false),
-       fProfile(NULL),
-       fImage(image),
-       fResources(NULL)
-{
-}
-
-
-NetworkSetupAddOn::~NetworkSetupAddOn()
-{
-       delete fResources;
-}
-
-
-status_t
-NetworkSetupAddOn::Save()
-{
-       return B_OK;
-}
-
-
-status_t
-NetworkSetupAddOn::Revert()
-{
-       return B_OK;
-}
-
-
-status_t
-NetworkSetupAddOn::ProfileChanged(NetworkSetupProfile* newProfile)
-{
-       fProfile = newProfile;
-       return B_OK;
-}
-
-
-bool
-NetworkSetupAddOn::IsDirty()
-{
-       return fIsDirty;
-}
-
-
-void
-NetworkSetupAddOn::SetDirty(bool dirty)
-{
-       fIsDirty = dirty;
-}
-
-
-NetworkSetupProfile*
-NetworkSetupAddOn::Profile()
-{
-       return fProfile;
-}
-
-
-image_id
-NetworkSetupAddOn::ImageId()
-{
-       return fImage;
-}
-
-
-const char*
-NetworkSetupAddOn::Name()
-{
-       return "Dummy NetworkSetupAddon";
-}
-
-
-BResources*
-NetworkSetupAddOn::Resources()
-{
-       if (fResources == NULL) {
-               image_info info;
-               if (get_image_info(fImage, &info) != B_OK)
-                       return NULL;
-
-               BResources* resources = new BResources();
-               BFile file(info.name, B_READ_ONLY);
-               if (resources->SetTo(&file) == B_OK)
-                       fResources = resources;
-               else
-                       delete resources;
-       }
-       return fResources;
-}
diff --git a/src/preferences/network/NetworkSetupAddOn.h 
b/src/preferences/network/NetworkSetupAddOn.h
deleted file mode 100644
index e80b8b9..0000000
--- a/src/preferences/network/NetworkSetupAddOn.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2004-2015 Haiku Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- */
-#ifndef NETWORK_SETUP_ADD_ON_H
-#define NETWORK_SETUP_ADD_ON_H
-
-
-#include <image.h>
-#include <Resources.h>
-#include <View.h>
-
-
-class NetworkSetupProfile;
-
-class NetworkSetupAddOn {
-public:
-                                                               
NetworkSetupAddOn(image_id image);
-       virtual                                         ~NetworkSetupAddOn();
-
-       virtual BView*                          CreateView() = 0;
-       virtual status_t                        Save();
-       virtual status_t                        Revert();
-
-       virtual const char*                     Name();
-       virtual status_t                        
ProfileChanged(NetworkSetupProfile* newProfile);
-
-                       NetworkSetupProfile*
-                                                               Profile();
-                       bool                            IsDirty();
-                       void                            SetDirty(bool dirty = 
true);
-                       image_id                        ImageId();
-                       BResources*                     Resources();
-
-private:
-                       bool                            fIsDirty;
-                       NetworkSetupProfile*
-                                                               fProfile;
-                       image_id                        fImage;
-                       BResources*                     fResources;
-};
-
-
-extern "C" {
-
-#define NETWORK_SETUP_ADDON_INSTANCIATE_FUNC_NAME "get_nth_addon"
-typedef NetworkSetupAddOn* (*network_setup_addon_instantiate)(image_id image,
-       int index);
-
-extern NetworkSetupAddOn* get_nth_addon(image_id image, int index);
-
-}
-
-
-#endif // NETWORKSETUPADDON_H
diff --git a/src/preferences/network/NetworkSetupProfile.cpp 
b/src/preferences/network/NetworkSetupProfile.cpp
deleted file mode 100644
index e2f060d..0000000
--- a/src/preferences/network/NetworkSetupProfile.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2004-2015 Haiku Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- */
-
-
-#include "NetworkSetupProfile.h"
-
-#include <stdlib.h>
-
-
-NetworkSetupProfile::NetworkSetupProfile()
-       :
-       fRoot(new BEntry()),
-       fPath(new BPath()),
-       fIsDefault(false),
-       fIsCurrent(false),
-       fName(NULL)
-{
-}
-
-
-NetworkSetupProfile::NetworkSetupProfile(const char* path)
-       :
-       fRoot(NULL),
-       fPath(NULL),
-       fIsDefault(false),
-       fIsCurrent(false)
-{
-       SetTo(path);
-}
-
-
-NetworkSetupProfile::NetworkSetupProfile(const entry_ref* ref)
-       :
-       fRoot(NULL),
-       fPath(NULL),
-       fIsDefault(false),
-       fIsCurrent(false)
-{
-       SetTo(ref);
-}
-
-
-NetworkSetupProfile::NetworkSetupProfile(BEntry* entry)
-       :
-       fRoot(NULL),
-       fPath(NULL),
-       fIsDefault(false),
-       fIsCurrent(false)
-{
-       SetTo(entry);
-}
-
-
-NetworkSetupProfile::~NetworkSetupProfile()
-{
-       delete fRoot;
-       delete fPath;
-}
-
-
-status_t
-NetworkSetupProfile::SetTo(const char* path)
-{
-       SetTo(new BEntry(path));
-       return B_OK;
-}
-
-
-status_t
-NetworkSetupProfile::SetTo(const entry_ref* ref)
-{
-       SetTo(new BEntry(ref));
-       return B_OK;
-}
-
-
-status_t
-NetworkSetupProfile::SetTo(BEntry* entry)
-{
-       delete fRoot;
-       delete fPath;
-       fRoot = entry;
-       fPath = NULL;
-       fName = NULL;
-       return B_OK;
-}
-
-
-const char*
-NetworkSetupProfile::Name()
-{
-       if (fName == NULL) {
-               fRoot->GetPath(fPath);
-               fName = fPath->Leaf();
-       }
-
-       return fName;
-}
-
-
-status_t
-NetworkSetupProfile::SetName(const char* name)
-{
-       return B_OK;
-}
-
-
-bool
-NetworkSetupProfile::Exists()
-{
-       return fRoot->Exists();
-}
-
-
-status_t
-NetworkSetupProfile::Delete()
-{
-       return B_ERROR;
-}
-
-
-bool
-NetworkSetupProfile::IsDefault()
-{
-       return fIsDefault;
-}
-
-
-bool
-NetworkSetupProfile::IsCurrent()
-{
-       return fIsCurrent;
-}
-
-
-status_t
-NetworkSetupProfile::MakeCurrent()
-{
-       return B_ERROR;
-}
-
-
-// #pragma mark -
-
-
-NetworkSetupProfile*
-NetworkSetupProfile::Default()
-{
-       return NULL;
-}
-
-
-NetworkSetupProfile*
-NetworkSetupProfile::Current()
-{
-       return NULL;
-}
diff --git a/src/preferences/network/NetworkSetupProfile.h 
b/src/preferences/network/NetworkSetupProfile.h
deleted file mode 100644
index 7c4f94e..0000000
--- a/src/preferences/network/NetworkSetupProfile.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2004-2015 Haiku Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- */
-#ifndef NETWORK_SETUP_PROFILE_H
-#define NETWORK_SETUP_PROFILE_H
-
-
-#include <StorageKit.h>
-
-
-class NetworkSetupProfile {
-public:
-                                                               
NetworkSetupProfile();
-                                                               
NetworkSetupProfile(const char* path);
-                                                               
NetworkSetupProfile(const entry_ref* ref);
-                                                               
NetworkSetupProfile(BEntry* entry);
-
-       virtual                                         ~NetworkSetupProfile();
-
-                       status_t                        SetTo(const char* path);
-                       status_t                        SetTo(const entry_ref* 
ref);
-                       status_t                        SetTo(BEntry* entry);
-
-                       bool                            Exists();
-
-                       const char*                     Name();
-                       status_t                        SetName(const char* 
name);
-
-                       bool                            IsDefault();
-                       bool                            IsCurrent();
-
-                       status_t                        MakeCurrent();
-                       status_t                        Delete();
-
-       static  NetworkSetupProfile*
-                                                               Default();
-       static  NetworkSetupProfile*
-                                                               Current();
-
-private:
-                       BEntry*                         fRoot;
-                       BPath*                          fPath;
-                       bool                            fIsDefault;
-                       bool                            fIsCurrent;
-                       const char*                     fName;
-
-       static  BDirectory*                     fProfilesRoot;
-};
-
-
-#endif // NETWORK_SETUP_PROFILE_H
diff --git a/src/preferences/network/NetworkSetupWindow.cpp 
b/src/preferences/network/NetworkWindow.cpp
similarity index 53%
rename from src/preferences/network/NetworkSetupWindow.cpp
rename to src/preferences/network/NetworkWindow.cpp
index 8b5c421..52ad0e6 100644
--- a/src/preferences/network/NetworkSetupWindow.cpp
+++ b/src/preferences/network/NetworkWindow.cpp
@@ -8,8 +8,9 @@
  */
 
 
-#include "NetworkSetupWindow.h"
+#include "NetworkWindow.h"
 
+#include <net/if.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -21,30 +22,35 @@
 #include <CheckBox.h>
 #include <ControlLook.h>
 #include <Deskbar.h>
+#include <Directory.h>
 #include <LayoutBuilder.h>
-#include <Locale.h>
+#include <NetworkInterface.h>
+#include <NetworkRoster.h>
+#include <OutlineListView.h>
+#include <Path.h>
+#include <PathFinder.h>
 #include <Roster.h>
-#include <StorageKit.h>
-#include <SupportKit.h>
-#include <TabView.h>
+#include <ScrollView.h>
+#include <SymLink.h>
 
 #define ENABLE_PROFILES 0
 #if ENABLE_PROFILES
 #      include <PopUpMenu.h>
 #endif
 
+#include "InterfaceListItem.h"
+
 
 const char* kNetworkStatusSignature = "application/x-vnd.Haiku-NetworkStatus";
 
 #undef B_TRANSLATION_CONTEXT
-#define B_TRANSLATION_CONTEXT  "NetworkSetupWindow"
+#define B_TRANSLATION_CONTEXT  "NetworkWindow"
 
 
-NetworkSetupWindow::NetworkSetupWindow()
+NetworkWindow::NetworkWindow()
        :
        BWindow(BRect(100, 100, 300, 300), B_TRANSLATE("Network"), 
B_TITLED_WINDOW,
-               B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS),
-       fAddOnCount(0)
+               B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS)
 {
        // ---- Profiles section
 #if ENABLE_PROFILES
@@ -60,8 +66,6 @@ NetworkSetupWindow::NetworkSetupWindow()
 
        // ---- Settings section
 
-       fPanel = new BTabView("tabs", B_WIDTH_FROM_LABEL);
-
        fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
                new BMessage(kMsgApply));
        SetDefaultButton(fApplyButton);
@@ -73,8 +77,14 @@ NetworkSetupWindow::NetworkSetupWindow()
        BMessage* message = new BMessage(kMsgToggleReplicant);
        BCheckBox* replicantStatus = new BCheckBox("replicantStatus",
                B_TRANSLATE("Show network status in Deskbar"), message);
+       replicantStatus->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
        replicantStatus->SetValue(_IsReplicantInstalled());
 
+       fListView = new BOutlineListView("list");
+
+       BScrollView* scrollView = new BScrollView("ScrollView",
+               fListView, 0/*B_WILL_DRAW | B_FRAME_EVENTS*/, false, true);
+
        // Build the layout
        BLayoutBuilder::Group<>(this, B_VERTICAL)
                .SetInsets(B_USE_DEFAULT_SPACING)
@@ -86,9 +96,9 @@ NetworkSetupWindow::NetworkSetupWindow()
                .End()
 #endif
                .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
-                       .Add(fPanel)
-                       .Add(new BGroupView("panel"))
-               .End()
+                       .Add(scrollView)
+                       .AddGlue()
+                       .End()
                .Add(replicantStatus)
                .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
                        .Add(fRevertButton)
@@ -96,7 +106,8 @@ NetworkSetupWindow::NetworkSetupWindow()
                        .Add(fApplyButton)
                .End();
 
-       _BuildShowTabView();
+       _ScanInterfaces();
+       _ScanAddOns();
 
        fAddOnView = NULL;
 
@@ -104,13 +115,13 @@ NetworkSetupWindow::NetworkSetupWindow()
 }
 
 
-NetworkSetupWindow::~NetworkSetupWindow()
+NetworkWindow::~NetworkWindow()
 {
 }
 
 
 bool
-NetworkSetupWindow::QuitRequested()
+NetworkWindow::QuitRequested()
 {
        be_app->PostMessage(B_QUIT_REQUESTED);
        return true;
@@ -118,7 +129,7 @@ NetworkSetupWindow::QuitRequested()
 
 
 void
-NetworkSetupWindow::MessageReceived(BMessage* message)
+NetworkWindow::MessageReceived(BMessage* message)
 {
        switch (message->what) {
                case kMsgProfileNew:
@@ -139,26 +150,22 @@ NetworkSetupWindow::MessageReceived(BMessage* message)
 
                case kMsgRevert:
                {
-                       for (int index = 0; index < fAddOnCount; index++) {
-                               NetworkSetupAddOn* addOn = 
fNetworkAddOnMap[index];
-                               addOn->Revert();
-                       }
+                       for (int index = 0; index < fItems.CountItems(); 
index++)
+                               fItems.ItemAt(index)->Revert();
                        break;
                }
 
                case kMsgApply:
                {
-                       for (int index = 0; index < fAddOnCount; index++) {
-                               NetworkSetupAddOn* addOn = 
fNetworkAddOnMap[index];
-                               addOn->Save();
-                       }
+                       for (int index = 0; index < fItems.CountItems(); 
index++)
+                               fItems.ItemAt(index)->Save();
                        break;
                }
 
                case kMsgToggleReplicant:
                {
-                       _ShowReplicant(message->GetInt32("be:value", 
B_CONTROL_OFF)
-                               == B_CONTROL_ON);
+                       _ShowReplicant(
+                               message->GetInt32("be:value", B_CONTROL_OFF) == 
B_CONTROL_ON);
                        break;
                }
 
@@ -169,7 +176,7 @@ NetworkSetupWindow::MessageReceived(BMessage* message)
 
 
 void
-NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 what)
+NetworkWindow::_BuildProfilesMenu(BMenu* menu, int32 what)
 {
        char currentProfile[256] = { 0 };
 
@@ -227,90 +234,137 @@ NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, 
int32 what)
 
 
 void
-NetworkSetupWindow::_BuildShowTabView()
+NetworkWindow::_ScanInterfaces()
 {
-       BPath path;
-       BPath addOnPath;
-       BDirectory dir;
-       BEntry entry;
-
-       char* searchPaths = getenv("ADDON_PATH");
-       if (!searchPaths)
-               return;
-
-       searchPaths = strdup(searchPaths);
-       char* nextPathToken;
-       char* searchPath = strtok_r(searchPaths, ":", &nextPathToken);
-
-       while (searchPath) {
-               if (strncmp(searchPath, "%A/", 3) == 0) {
-                       app_info ai;
-                       be_app->GetAppInfo(&ai);
-                       entry.SetTo(&ai.ref);
-                       entry.GetPath(&path);
-                       path.GetParent(&path);
-                       path.Append(searchPath + 3);
-               } else {
-                       path.SetTo(searchPath);
-                       path.Append("Network Setup");
-               }
-
-               searchPath = strtok_r(NULL, ":", &nextPathToken);
+       // Try existing devices first
+       BNetworkRoster& roster = BNetworkRoster::Default();
+       BNetworkInterface interface;
+       uint32 cookie = 0;
 
-               dir.SetTo(path.Path());
-               if (dir.InitCheck() != B_OK)
+       while (roster.GetNextInterface(&cookie, interface) == B_OK) {
+               if ((interface.Flags() & IFF_LOOPBACK) != 0)
                        continue;
 
-               dir.Rewind();
-               while (dir.GetNextEntry(&entry) >= 0) {
-                       if (entry.IsDirectory())
+               InterfaceListItem* item = new 
InterfaceListItem(interface.Name());
+               fInterfaceItemMap.insert(std::pair<BString, BListItem*>(
+                       BString(interface.Name()), item));
+               fListView->AddItem(item);
+       }
+
+       // TODO: Then consider those from the settings (for example, for USB)
+}
+
+
+void
+NetworkWindow::_ScanAddOns()
+{
+       BStringList paths;
+       BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "Network 
Settings",
+               paths);
+
+       for (int32 i = 0; i < paths.CountStrings(); i++) {
+               BDirectory directory(paths.StringAt(i));
+               BEntry entry;
+               while (directory.GetNextEntry(&entry) == B_OK) {
+                       BPath path;
+                       if (entry.GetPath(&path) != B_OK)
                                continue;
 
-                       entry.GetPath(&addOnPath);
-                       image_id image = load_add_on(addOnPath.Path());
+                       image_id image = load_add_on(path.Path());
                        if (image < 0) {
-                               printf("Failed to load %s addon: %s.\n", 
addOnPath.Path(),
+                               printf("Failed to load %s addon: %s.\n", 
path.Path(),
                                        strerror(image));
                                continue;
                        }
 
-                       network_setup_addon_instantiate get_nth_addon;
-                       status_t status = get_image_symbol(image, 
"get_nth_addon",
-                               B_SYMBOL_TYPE_TEXT, (void **) &get_nth_addon);
-
-                       int tabCount = 0;
+                       BNetworkSettingsAddOn* (*instantiateAddOn)(image_id 
image);
 
+                       status_t status = get_image_symbol(image,
+                               "instantiate_network_settings_add_on",
+                               B_SYMBOL_TYPE_TEXT, (void**)&instantiateAddOn);
                        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", 
addOnPath.Path());
+                               // No "addon instantiate function" symbol found 
in this addon
+                               printf("No symbol 
\"instantiate_network_settings_add_on\" "
+                                       "found in %s addon: not a network setup 
addon!\n",
+                                       path.Path());
+                               unload_add_on(image);
+                               continue;
+                       }
+
+                       BNetworkSettingsAddOn* addOn = instantiateAddOn(image);
+                       if (addOn == NULL) {
                                unload_add_on(image);
                                continue;
                        }
 
-                       while ((fNetworkAddOnMap[fAddOnCount]
-                                       = get_nth_addon(image, tabCount)) != 
NULL) {
-                               printf("Adding Tab: %d\n", fAddOnCount);
-                               BView* view = 
fNetworkAddOnMap[fAddOnCount]->CreateView();
-
-                               // FIXME rework this: we don't want to use a 
tab view here,
-                               // instead add-ons should populate the 
"interfaces" list with
-                               // interfaces, services, etc.
-                               fPanel->AddTab(view);
-                               fAddOnCount++;
-                                       // Number of tab addons total
-                               tabCount++;
-                                       // Tabs for *this* addon
+                       fAddOns.AddItem(addOn);
+
+                       // Per interface items
+                       ItemMap::const_iterator iterator = 
fInterfaceItemMap.begin();
+                       for (; iterator != fInterfaceItemMap.end(); iterator++) 
{
+                               const BString& interface = iterator->first;
+                               BListItem* interfaceItem = iterator->second;
+
+                               uint32 cookie = 0;
+                               while (true) {
+                                       BNetworkSettingsItem* item = 
addOn->CreateNextInterfaceItem(
+                                               cookie, interface.String());
+                                       if (item == NULL)
+                                               break;
+
+                                       fItems.AddItem(item);
+                                       // TODO: sort
+                                       fListView->AddUnder(interfaceItem, 
item->CreateListItem());
+                               }
+                       }
+
+                       // Generic items
+                       uint32 cookie = 0;
+                       while (true) {
+                               BNetworkSettingsItem* item = 
addOn->CreateNextItem(cookie);
+                               if (item == NULL)
+                                       break;
+
+                               fItems.AddItem(item);
+                               // TODO: sort
+                               fListView->AddUnder(_ItemFor(item->Type()),
+                                       item->CreateListItem());
                        }
                }
        }
+}
+
 
-       free(searchPaths);
+BListItem*
+NetworkWindow::_ItemFor(BNetworkSettingsType type)
+{
+       switch (type) {
+               case B_NETWORK_SETTINGS_TYPE_SERVICE:
+                       if (fServicesItem == NULL)
+                               fServicesItem = new 
BStringItem(B_TRANSLATE("Services"));
+
+                       return fServicesItem;
+
+               case B_NETWORK_SETTINGS_TYPE_DIAL_UP:
+                       if (fDialUpItem == NULL)
+                               fDialUpItem = new BStringItem(B_TRANSLATE("Dial 
Up"));
+
+                       return fDialUpItem;
+
+               case B_NETWORK_SETTINGS_TYPE_OTHER:
+                       if (fOtherItem == NULL)
+                               fOtherItem = new 
BStringItem(B_TRANSLATE("Other"));
+
+                       return fOtherItem;
+
+               default:
+                       return NULL;
+       }
 }
 
 
 void
-NetworkSetupWindow::_ShowReplicant(bool show)
+NetworkWindow::_ShowReplicant(bool show)
 {
        if (show) {
                const char* argv[] = {"--deskbar", NULL};
@@ -333,7 +387,7 @@ NetworkSetupWindow::_ShowReplicant(bool show)
 
 
 bool
-NetworkSetupWindow::_IsReplicantInstalled()
+NetworkWindow::_IsReplicantInstalled()
 {
        BDeskbar deskbar;
        return deskbar.HasItem("NetworkStatus");
diff --git a/src/preferences/network/NetworkSetupWindow.h 
b/src/preferences/network/NetworkWindow.h
similarity index 55%
rename from src/preferences/network/NetworkSetupWindow.h
rename to src/preferences/network/NetworkWindow.h
index ca71db4..3980dce 100644
--- a/src/preferences/network/NetworkSetupWindow.h
+++ b/src/preferences/network/NetworkWindow.h
@@ -5,26 +5,27 @@
  *     Authors:
  *             Alexander von Gluck, <kallisti5@xxxxxxxxxxx>
  */
-#ifndef NETWORK_SETUP_WINDOW_H
-#define NETWORK_SETUP_WINDOW_H
+#ifndef NETWORK_WINDOW_H
+#define NETWORK_WINDOW_H
 
 
-#include "NetworkSetupAddOn.h"
-
 #include <map>
 
+#include <ObjectList.h>
 #include <Window.h>
 
+#include "NetworkSettingsAddOn.h"
+
+
+using namespace BNetworkKit;
 
-typedef std::map<int, NetworkSetupAddOn*> NetworkAddOnMap;
 
-class NetworkSetupWindow;
 class BTabView;
 class BButton;
 class BMenu;
 
 
-class NetworkSetupWindow : public BWindow {
+class NetworkWindow : public BWindow {
 public:
        static  const uint32            kMsgProfileSelected = 'prof';
        static  const uint32            kMsgProfileManage = 'mngp';
@@ -34,8 +35,8 @@ public:
        static  const uint32            kMsgToggleReplicant = 'trep';
 
 public:
-                                                               
NetworkSetupWindow();
-       virtual                                         ~NetworkSetupWindow();
+                                                               NetworkWindow();
+       virtual                                         ~NetworkWindow();
 
                        bool                            QuitRequested();
                        void                            
MessageReceived(BMessage* message);
@@ -44,21 +45,33 @@ private:
        typedef BWindow                         inherited;
 
                        void                            
_BuildProfilesMenu(BMenu* menu, int32 what);
-                       void                            _BuildShowTabView();
+                       void                            _ScanInterfaces();
+                       void                            _ScanAddOns();
+                       BListItem*                      
_ItemFor(BNetworkSettingsType type);
 
                        bool                            _IsReplicantInstalled();
                        void                            _ShowReplicant(bool 
show);
 
 private:
+       typedef BObjectList<BNetworkSettingsAddOn> AddOnList;
+       typedef BObjectList<BNetworkSettingsItem> ItemList;
+       typedef std::map<BString, BListItem*> ItemMap;
+
                        BButton*                        fRevertButton;
                        BButton*                        fApplyButton;
 
-                       NetworkAddOnMap         fNetworkAddOnMap;
+                       AddOnList                       fAddOns;
+
+                       BOutlineListView*       fListView;
+                       ItemMap                         fInterfaceItemMap;
+                       BListItem*                      fServicesItem;
+                       BListItem*                      fDialUpItem;
+                       BListItem*                      fOtherItem;
+
+                       ItemList                        fItems;
 
-                       BTabView*                       fPanel;
                        BView*                          fAddOnView;
-                       int                                     fAddOnCount;
 };
 
 
-#endif // NETWORK_SETUP_WINDOW_H
+#endif // NETWORK_WINDOW_H

############################################################################

Commit:      0ea36dcabf5b3df86ac4eafd6546dc94a3f9d917
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb  4 17:30:33 2015 UTC

Network: moved add-on headers to the correct position.

* Ie. they've moved to headers/os/add-ons/network_settings now.

----------------------------------------------------------------------------

diff --git a/src/preferences/network/NetworkProfile.h 
b/headers/os/add-ons/network_settings/NetworkProfile.h
similarity index 100%
rename from src/preferences/network/NetworkProfile.h
rename to headers/os/add-ons/network_settings/NetworkProfile.h
diff --git a/src/preferences/network/NetworkSettingsAddOn.h 
b/headers/os/add-ons/network_settings/NetworkSettingsAddOn.h
similarity index 100%
rename from src/preferences/network/NetworkSettingsAddOn.h
rename to headers/os/add-ons/network_settings/NetworkSettingsAddOn.h
diff --git a/src/preferences/network/Jamfile b/src/preferences/network/Jamfile
index 16c4a11..0b3ac4e 100644
--- a/src/preferences/network/Jamfile
+++ b/src/preferences/network/Jamfile
@@ -1,5 +1,6 @@
 SubDir HAIKU_TOP src preferences network ;
 
+UsePublicHeaders [ FDirName add-ons network_settings ] ;
 UsePrivateHeaders net shared ;
 
 SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src apps networkstatus ] ;
@@ -29,9 +30,3 @@ DoCatalogs Network :
        RadioView.cpp
        WirelessNetworkMenuItem.cpp
 ;
-
-#SubInclude HAIKU_TOP src preferences network InterfacesAddOn ;
-#SubInclude HAIKU_TOP src preferences network ServicesAddOn ;
-#SubInclude HAIKU_TOP src preferences network DummyAddOn ;
-#SubInclude HAIKU_TOP src preferences network MultipleAddOns ;
-#SubInclude HAIKU_TOP src preferences network DialUpAddOn ;
diff --git a/src/preferences/network/NetworkProfile.cpp 
b/src/preferences/network/NetworkProfile.cpp
index 338a96d..b92ddce 100644
--- a/src/preferences/network/NetworkProfile.cpp
+++ b/src/preferences/network/NetworkProfile.cpp
@@ -4,7 +4,7 @@
  */
 
 
-#include "NetworkProfile.h"
+#include <NetworkProfile.h>
 
 #include <stdlib.h>
 
diff --git a/src/preferences/network/NetworkSettingsAddOn.cpp 
b/src/preferences/network/NetworkSettingsAddOn.cpp
index bb27fda..5553641 100644
--- a/src/preferences/network/NetworkSettingsAddOn.cpp
+++ b/src/preferences/network/NetworkSettingsAddOn.cpp
@@ -4,7 +4,7 @@
  */
 
 
-#include "NetworkSettingsAddOn.h"
+#include <NetworkSettingsAddOn.h>
 
 #include <stdio.h>
 #include <stdlib.h>

############################################################################

Commit:      25d511e9ff6823720e11ed0c1b7f019efcb82d74
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb  4 17:31:26 2015 UTC

Network: made list view B_FULL_UPDATE_ON_RESIZE.

* To account for its right aligned contents.

----------------------------------------------------------------------------

diff --git a/src/preferences/network/NetworkWindow.cpp 
b/src/preferences/network/NetworkWindow.cpp
index 52ad0e6..9f52ba5 100644
--- a/src/preferences/network/NetworkWindow.cpp
+++ b/src/preferences/network/NetworkWindow.cpp
@@ -52,7 +52,7 @@ NetworkWindow::NetworkWindow()
        BWindow(BRect(100, 100, 300, 300), B_TRANSLATE("Network"), 
B_TITLED_WINDOW,
                B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS)
 {
-       // ---- Profiles section
+       // Profiles section
 #if ENABLE_PROFILES
        BPopUpMenu* profilesPopup = new BPopUpMenu("<none>");
        _BuildProfilesMenu(profilesPopup, kMsgProfileSelected);
@@ -64,7 +64,7 @@ NetworkWindow::NetworkWindow()
        profilesMenuField->SetEnabled(false);
 #endif
 
-       // ---- Settings section
+       // Settings section
 
        fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
                new BMessage(kMsgApply));
@@ -80,7 +80,8 @@ NetworkWindow::NetworkWindow()
        replicantStatus->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
        replicantStatus->SetValue(_IsReplicantInstalled());
 
-       fListView = new BOutlineListView("list");
+       fListView = new BOutlineListView("list", B_SINGLE_SELECTION_LIST,
+               B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | 
B_NAVIGABLE);
 
        BScrollView* scrollView = new BScrollView("ScrollView",
                fListView, 0/*B_WILL_DRAW | B_FRAME_EVENTS*/, false, true);

############################################################################

Commit:      cc9130b67ef17c808c0b0b5425d2d4a189d2a7f5
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb  4 17:32:24 2015 UTC

Network: Removed unused includes.

----------------------------------------------------------------------------

diff --git a/src/preferences/network/InterfaceListItem.cpp 
b/src/preferences/network/InterfaceListItem.cpp
index efd0d9b..ce04aab 100644
--- a/src/preferences/network/InterfaceListItem.cpp
+++ b/src/preferences/network/InterfaceListItem.cpp
@@ -14,36 +14,14 @@
 
 #include <algorithm>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-#include <netinet/in.h>
-#include <net_notifications.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-
 #include <Application.h>
 #include <Bitmap.h>
 #include <Catalog.h>
-#include <File.h>
 #include <IconUtils.h>
-#include <MenuItem.h>
 #include <NetworkDevice.h>
-#include <NetworkInterface.h>
-#include <NetworkRoster.h>
 #include <OutlineListView.h>
-#include <Point.h>
-#include <PopUpMenu.h>
 #include <Resources.h>
 #include <String.h>
-#include <SeparatorItem.h>
-#include <Window.h>
-
-#include <AutoDeleter.h>
 
 
 #define ICON_SIZE 37

############################################################################

Commit:      272e85ca911a8486d9285518241515312740d3f4
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb  4 20:04:51 2015 UTC

Network: no need for public constants.

----------------------------------------------------------------------------

diff --git a/headers/os/add-ons/network_settings/NetworkSettingsAddOn.h 
b/headers/os/add-ons/network_settings/NetworkSettingsAddOn.h
index 479f2ef..8cebdf7 100644
--- a/headers/os/add-ons/network_settings/NetworkSettingsAddOn.h
+++ b/headers/os/add-ons/network_settings/NetworkSettingsAddOn.h
@@ -33,7 +33,8 @@ public:
 
        virtual BNetworkSettingsType
                                                                Type() const = 
0;
-       virtual BListItem*                      CreateListItem() = 0;
+       virtual BListItem*                      ListItem() = 0;
+       virtual BView*                          View() = 0;
 
        virtual status_t                        ProfileChanged(
                                                                        const 
BNetworkProfile* newProfile);
diff --git a/src/preferences/network/NetworkWindow.cpp 
b/src/preferences/network/NetworkWindow.cpp
index 9f52ba5..a1e6417 100644
--- a/src/preferences/network/NetworkWindow.cpp
+++ b/src/preferences/network/NetworkWindow.cpp
@@ -3,8 +3,9 @@
  * Distributed under the terms of the MIT License.
  *
  *     Authors:
- *             Alexander von Gluck, <kallisti5@xxxxxxxxxxx>
  *             Adrien Destugues, <pulkomandy@xxxxxxxxxxxxx>
+ *             Axel Dörfler, <axeld@xxxxxxxxxxxxxxxx>
+ *             Alexander von Gluck, <kallisti5@xxxxxxxxxxx>
  */
 
 
@@ -43,6 +44,15 @@
 
 const char* kNetworkStatusSignature = "application/x-vnd.Haiku-NetworkStatus";
 
+static const uint32 kMsgProfileSelected = 'prof';
+static const uint32 kMsgProfileManage = 'mngp';
+static const uint32 kMsgProfileNew = 'newp';
+static const uint32 kMsgApply = 'aply';
+static const uint32 kMsgRevert = 'rvrt';
+static const uint32 kMsgToggleReplicant = 'trep';
+static const uint32 kMsgItemSelected = 'ItSl';
+
+
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT  "NetworkWindow"
 
@@ -75,16 +85,18 @@ NetworkWindow::NetworkWindow()
        // fRevertButton->SetEnabled(false);
 
        BMessage* message = new BMessage(kMsgToggleReplicant);
-       BCheckBox* replicantStatus = new BCheckBox("replicantStatus",
+       BCheckBox* showReplicantCheckBox = new 
BCheckBox("showReplicantCheckBox",
                B_TRANSLATE("Show network status in Deskbar"), message);
-       replicantStatus->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
-       replicantStatus->SetValue(_IsReplicantInstalled());
+       showReplicantCheckBox->SetExplicitMaxSize(
+               BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
+       showReplicantCheckBox->SetValue(_IsReplicantInstalled());
 
        fListView = new BOutlineListView("list", B_SINGLE_SELECTION_LIST,
                B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | 
B_NAVIGABLE);
+       fListView->SetSelectionMessage(new BMessage(kMsgItemSelected));
 
-       BScrollView* scrollView = new BScrollView("ScrollView",
-               fListView, 0/*B_WILL_DRAW | B_FRAME_EVENTS*/, false, true);
+       BScrollView* scrollView = new BScrollView("ScrollView", fListView,
+               0, false, true);
 
        // Build the layout
        BLayoutBuilder::Group<>(this, B_VERTICAL)
@@ -100,7 +112,7 @@ NetworkWindow::NetworkWindow()
                        .Add(scrollView)
                        .AddGlue()
                        .End()
-               .Add(replicantStatus)
+               .Add(showReplicantCheckBox)
                .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
                        .Add(fRevertButton)
                        .AddGlue()
@@ -149,6 +161,9 @@ NetworkWindow::MessageReceived(BMessage* message)
                        break;
                }
 
+               case kMsgItemSelected:
+                       break;
+
                case kMsgRevert:
                {
                        for (int index = 0; index < fItems.CountItems(); 
index++)
@@ -315,7 +330,7 @@ NetworkWindow::_ScanAddOns()
 
                                        fItems.AddItem(item);
                                        // TODO: sort
-                                       fListView->AddUnder(interfaceItem, 
item->CreateListItem());
+                                       fListView->AddUnder(interfaceItem, 
item->ListItem());
                                }
                        }
 
@@ -328,8 +343,7 @@ NetworkWindow::_ScanAddOns()
 
                                fItems.AddItem(item);
                                // TODO: sort
-                               fListView->AddUnder(_ItemFor(item->Type()),
-                                       item->CreateListItem());
+                               fListView->AddUnder(_ItemFor(item->Type()), 
item->ListItem());
                        }
                }
        }
diff --git a/src/preferences/network/NetworkWindow.h 
b/src/preferences/network/NetworkWindow.h
index 3980dce..073e500 100644
--- a/src/preferences/network/NetworkWindow.h
+++ b/src/preferences/network/NetworkWindow.h
@@ -3,6 +3,7 @@
  * Distributed under the terms of the MIT License.
  *
  *     Authors:
+ *             Axel Dörfler, <axeld@xxxxxxxxxxxxxxxx>
  *             Alexander von Gluck, <kallisti5@xxxxxxxxxxx>
  */
 #ifndef NETWORK_WINDOW_H
@@ -27,14 +28,6 @@ class BMenu;
 
 class NetworkWindow : public BWindow {
 public:
-       static  const uint32            kMsgProfileSelected = 'prof';
-       static  const uint32            kMsgProfileManage = 'mngp';
-       static  const uint32            kMsgProfileNew = 'newp';
-       static  const uint32            kMsgApply = 'aply';
-       static  const uint32            kMsgRevert = 'rvrt';
-       static  const uint32            kMsgToggleReplicant = 'trep';
-
-public:
                                                                NetworkWindow();
        virtual                                         ~NetworkWindow();
 

############################################################################

Commit:      2224918f8605fc71a341401d7e31539b5764f497
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Thu Feb  5 08:02:26 2015 UTC

WIP, amend me.

----------------------------------------------------------------------------

diff --git a/src/preferences/network/InterfaceListItem.cpp 
b/src/preferences/network/InterfaceListItem.cpp
index ce04aab..dec0b40 100644
--- a/src/preferences/network/InterfaceListItem.cpp
+++ b/src/preferences/network/InterfaceListItem.cpp
@@ -74,45 +74,26 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, 
bool complete)
                list->FillRect(bounds);
        }
 
-       BString interfaceState;
-       BBitmap* stateIcon(NULL);
-
        // TODO: only update periodically
-       bool disabled = (fInterface.Flags() & IFF_UP) == 0;
+       _UpdateState();
 
-       if (disabled) {
-               interfaceState = "disabled";
-               stateIcon = fIconOffline;
-       } else if (!fInterface.HasLink()) {
-               interfaceState = "no link";
-               stateIcon = fIconOffline;
-       // TODO!
-//     } else if ((fSettings->IPAddr(AF_INET).IsEmpty()
-//             && fSettings->IPAddr(AF_INET6).IsEmpty())
-//             && (fSettings->AutoConfigure(AF_INET)
-//             || fSettings->AutoConfigure(AF_INET6))) {
-//             interfaceState = "connecting" B_UTF8_ELLIPSIS;
-//             stateIcon = fIconPending;
-       } else {
-               interfaceState = "connected";
-               stateIcon = fIconOnline;
-       }
+       BBitmap* stateIcon = _StateIcon();
+       const char* stateText = _StateText();
 
        // Set the initial bounds of item contents
-       BPoint iconPt = bounds.LeftTop();
-       BPoint namePt = bounds.LeftTop();
-       BPoint line2Pt = bounds.LeftTop();
-       BPoint line3Pt = bounds.LeftTop();
-       BPoint statePt = bounds.RightTop();
+       BPoint iconPoint = bounds.LeftTop();
+       BPoint namePoint = bounds.LeftTop();
+       BPoint line2Point = bounds.LeftTop();
+       BPoint line3Point = bounds.LeftTop();
+       BPoint statePoint = bounds.RightTop();
 
-       iconPt += BPoint(4, 4);
-       statePt += BPoint(0, fFirstlineOffset);
-       namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset);
-       line2Pt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
-       line3Pt += BPoint(ICON_SIZE + 12, fThirdlineOffset);
+       iconPoint += BPoint(4, 4);
+       statePoint += BPoint(0, fFirstlineOffset);
+       namePoint += BPoint(ICON_SIZE + 12, fFirstlineOffset);
+       line2Point += BPoint(ICON_SIZE + 12, fSecondlineOffset);
+       line3Point += BPoint(ICON_SIZE + 12, fThirdlineOffset);
 
-       statePt -= BPoint(
-               be_plain_font->StringWidth(interfaceState.String()) + 4.0f, 0);
+       statePoint -= BPoint(be_plain_font->StringWidth(stateText) + 4.0f, 0);
 
        if (disabled) {
                list->SetDrawingMode(B_OP_ALPHA);
@@ -121,10 +102,10 @@ InterfaceListItem::DrawItem(BView* owner, BRect 
/*bounds*/, bool complete)
        } else
                list->SetDrawingMode(B_OP_OVER);
 
-       list->DrawBitmapAsync(fIcon, iconPt);
-       list->DrawBitmapAsync(stateIcon, iconPt);
+       list->DrawBitmapAsync(fIcon, iconPoint);
+       list->DrawBitmapAsync(stateIcon, iconPoint);
 
-       if (disabled) {
+       if (fDisabled) {
                rgb_color textColor;
                if (IsSelected())
                        textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR);
@@ -147,9 +128,9 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, 
bool complete)
        BString name = Name();
        name.RemoveFirst("/dev/net/");
 
-       list->DrawString(name, namePt);
+       list->DrawString(name, namePoint);
        list->SetFont(be_plain_font);
-       list->DrawString(interfaceState, statePt);
+       list->DrawString(stateText, statePoint);
 
 // TODO!
 /*     if (!disabled) {
@@ -160,7 +141,7 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, 
bool complete)
                else
                        ipv4Str << " " << BString(fSettings->IP(AF_INET));
 
-               list->DrawString(ipv4Str, line2Pt);
+               list->DrawString(ipv4Str, line2Point);
        }
 
        // Render IPv6 Address (if present)
@@ -168,7 +149,7 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, 
bool complete)
                BString ipv6Str(B_TRANSLATE_COMMENT("IPv6:", "IPv6 address 
label"));
                ipv6Str << " " << BString(fSettings->IP(AF_INET6));
 
-               list->DrawString(ipv6Str, line3Pt);
+               list->DrawString(ipv6Str, line3Point);
        }
 */
        owner->PopState();
@@ -189,6 +170,7 @@ InterfaceListItem::Update(BView* owner, const BFont* font)
        fSecondlineOffset = fFirstlineOffset + lineHeight;
        fThirdlineOffset = fFirstlineOffset + (lineHeight * 2);
 
+       SetWidth();
        SetHeight(std::max(3 * lineHeight + 4, fIcon->Bounds().Height() + 8));
                // either to the text height or icon height, whichever is taller
 }
@@ -279,3 +261,69 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType)
                BIconUtils::GetVectorIcon(onlineHVIF, iconSize, fIconOnline);
        }
 }
+
+
+void
+InterfaceListItem::_UpdateState()
+{
+       fDisabled = (fInterface.Flags() & IFF_UP) == 0;
+       fHasLink = fInterface.HasLink();
+       fConnecting = (fInterfaceFlags() & IFF_CONFIGURING) != 0;
+
+       int32 count = fInterface.CountAddresses();
+       int32 addressIndex = 0;
+       for (int32 index = 0; index < count; index++) {
+               if (addressIndex >= sizeof(fAddress) / sizeof(fAddress[0]))
+                       break;
+
+               BNetworkInterfaceAddress address;
+               if (fInterface.GetAddressAt(index, address) == B_OK)
+                       fAddress[addressIndex++] = address.Address().ToString();
+       }
+}
+
+
+BBitmap*
+InterfaceListItem::_StateIcon() const
+{
+       if (fDisabled) {
+               interfaceState = "disabled";
+               stateIcon = fIconOffline;
+       } else if (!fHasLink) {
+               interfaceState = "no link";
+               stateIcon = fIconOffline;
+       // TODO!
+//     } else if ((fSettings->IPAddr(AF_INET).IsEmpty()
+//             && fSettings->IPAddr(AF_INET6).IsEmpty())
+//             && (fSettings->AutoConfigure(AF_INET)
+//             || fSettings->AutoConfigure(AF_INET6))) {
+//             interfaceState = "connecting" B_UTF8_ELLIPSIS;
+//             stateIcon = fIconPending;
+       } else {
+               interfaceState = "connected";
+               stateIcon = fIconOnline;
+       }
+}
+
+
+const char*
+InterfaceListItem::_StateText() const
+{
+       if (fDisabled) {
+               interfaceState = "disabled";
+               stateIcon = fIconOffline;
+       } else if (!fInterface.HasLink()) {
+               interfaceState = "no link";
+               stateIcon = fIconOffline;
+       // TODO!
+//     } else if ((fSettings->IPAddr(AF_INET).IsEmpty()
+//             && fSettings->IPAddr(AF_INET6).IsEmpty())
+//             && (fSettings->AutoConfigure(AF_INET)
+//             || fSettings->AutoConfigure(AF_INET6))) {
+//             interfaceState = "connecting" B_UTF8_ELLIPSIS;
+//             stateIcon = fIconPending;
+       } else {
+               interfaceState = "connected";
+               stateIcon = fIconOnline;
+       }
+}
diff --git a/src/preferences/network/InterfaceListItem.h 
b/src/preferences/network/InterfaceListItem.h
index 84d4286..7e61288 100644
--- a/src/preferences/network/InterfaceListItem.h
+++ b/src/preferences/network/InterfaceListItem.h
@@ -33,7 +33,11 @@ public:
 private:
                        void                            _Init();
                        void                            _PopulateBitmaps(const 
char* mediaType);
+                       void                            _UpdateState();
+                       BBitmap*                        _StateIcon() const;
+                       const char*                     _StateText() const;
 
+private:
                        BBitmap*                        fIcon;
                        BBitmap*                        fIconOffline;
                        BBitmap*                        fIconPending;
@@ -45,6 +49,11 @@ private:
                        float                           fFirstlineOffset;
                        float                           fSecondlineOffset;
                        float                           fThirdlineOffset;
+
+                       bool                            fDisabled;
+                       bool                            fHasLink;
+                       bool                            fConnecting;
+                       BString                         fAddress[2];
 };
 
 
diff --git a/src/preferences/network/NetworkWindow.cpp 
b/src/preferences/network/NetworkWindow.cpp
index a1e6417..7de2c0c 100644
--- a/src/preferences/network/NetworkWindow.cpp
+++ b/src/preferences/network/NetworkWindow.cpp
@@ -124,6 +124,12 @@ NetworkWindow::NetworkWindow()
 
        fAddOnView = NULL;
 
+       // Set preferred size of the list view from its contents
+       float width;
+       float height;
+       fListView->GetPreferredSize(&width, &height);
+       fListView->SetExplicitPreferredSize(BSize(width, std::min(height, 
400.f)));
+
        CenterOnScreen();
 }
 

############################################################################

Commit:      bf5cca4c50d607b899de6457f8868150a5647808
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb 11 08:12:19 2015 UTC

ifconfig: moved media type stuff into its own file.

* This can now be easily shared.

----------------------------------------------------------------------------

diff --git a/src/bin/network/ifconfig/Jamfile b/src/bin/network/ifconfig/Jamfile
index a9dabe9..14fa7bb 100644
--- a/src/bin/network/ifconfig/Jamfile
+++ b/src/bin/network/ifconfig/Jamfile
@@ -4,5 +4,6 @@ UsePrivateHeaders net ;
 
 BinCommand ifconfig :
        ifconfig.cpp
+       MediaTypes.cpp
        : be network bnetapi
 ;
diff --git a/src/bin/network/ifconfig/MediaTypes.cpp 
b/src/bin/network/ifconfig/MediaTypes.cpp
new file mode 100644
index 0000000..19efc3e
--- /dev/null
+++ b/src/bin/network/ifconfig/MediaTypes.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2006-2015, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Oliver Tappe, zooey@xxxxxxxxxxxxxxx
+ *             Atis Elsts, the.kfx@xxxxxxxxx
+ */
+
+
+#include "MediaTypes.h"
+
+#include <net/if_media.h>
+
+
+struct media_type {
+       int                     type;
+       const char*     name;
+       const char* pretty;
+       struct {
+               int subtype;
+               const char* name;
+               const char* pretty;
+       } subtypes [6];
+       struct {
+               int option;
+               bool read_only;
+               const char* name;
+               const char* pretty;
+       } options [6];
+};
+
+
+const media_type kMediaTypes[] = {
+       {
+               0, // for generic options
+               "all",
+               "All",
+               {
+                       { IFM_AUTO, "auto", "Auto-select" },
+                       { -1, NULL, NULL }
+               },
+               {
+                       { IFM_FULL_DUPLEX, true, "fullduplex", "Full Duplex" },
+                       { IFM_HALF_DUPLEX, true, "halfduplex", "Half Duplex" },
+                       { IFM_LOOP, true, "loop", "Loop" },
+                       //{ IFM_ACTIVE, false, "active", "Active" },
+                       { -1, false, NULL, NULL }
+               }
+       },
+       {
+               IFM_ETHER,
+               "ether",
+               "Ethernet",
+               {
+                       //{ IFM_AUTO, "auto", "Auto-select" },
+                       //{ IFM_AUI, "AUI", "10 MBit, AUI" },
+                       //{ IFM_10_2, "10base2", "10 MBit, 10BASE-2" },
+                       { IFM_10_T, "10baseT", "10 MBit, 10BASE-T" },
+                       { IFM_100_TX, "100baseTX", "100 MBit, 100BASE-TX" },
+                       { IFM_1000_T, "1000baseT", "1 GBit, 1000BASE-T" },
+                       { IFM_1000_SX, "1000baseSX", "1 GBit, 1000BASE-SX" },
+                       { IFM_10G_T, "10GbaseT", "10 GBit, 10GBASE-T" },
+                       { -1, NULL, NULL }
+               },
+               {
+                       { -1, false, NULL, NULL }
+               }
+       },
+       { -1, NULL, NULL, {{ -1, NULL, NULL }}, {{ -1, false, NULL, NULL }} }
+};
+
+
+const char*
+get_media_type_name(size_t index)
+{
+       if (index < sizeof(kMediaTypes) / sizeof(kMediaTypes[0]))
+               return kMediaTypes[index].pretty;
+
+       return NULL;
+}
+
+
+const char*
+get_media_subtype_name(size_t typeIndex, size_t subIndex)
+{
+       if (typeIndex < sizeof(kMediaTypes) / sizeof(kMediaTypes[0])) {
+               if (kMediaTypes[typeIndex].subtypes[subIndex].subtype >= 0)
+                       return kMediaTypes[typeIndex].subtypes[subIndex].name;
+       }
+
+       return NULL;
+}
+
+
+bool
+media_parse_subtype(const char* string, int media, int* type)
+{
+       for (size_t i = 0; kMediaTypes[i].type >= 0; i++) {
+               // only check for generic or correct subtypes
+               if (kMediaTypes[i].type &&
+                       kMediaTypes[i].type != media)
+                       continue;
+               for (size_t j = 0; kMediaTypes[i].subtypes[j].subtype >= 0; 
j++) {
+                       if (strcmp(kMediaTypes[i].subtypes[j].name, string) == 
0) {
+                               // found a match
+                               *type = kMediaTypes[i].subtypes[j].subtype;
+                               return true;
+                       }
+               }
+       }
+       return false;
+}
+
+
+const char*
+media_type_to_string(int media)
+{
+       for (size_t i = 0; kMediaTypes[i].type >= 0; i++) {
+               // loopback doesn't really have a media anyway
+               if (IFM_TYPE(media) == 0)
+                       break;
+
+               // only check for generic or correct subtypes
+               if (kMediaTypes[i].type
+                       && kMediaTypes[i].type != IFM_TYPE(media))
+                       continue;
+
+               for (size_t j = 0; kMediaTypes[i].subtypes[j].subtype >= 0; 
j++) {
+                       if (kMediaTypes[i].subtypes[j].subtype == 
IFM_SUBTYPE(media)) {
+                               // found a match
+                               return kMediaTypes[i].subtypes[j].pretty;
+                       }
+               }
+       }
+
+       return NULL;
+}
diff --git a/src/bin/network/ifconfig/MediaTypes.h 
b/src/bin/network/ifconfig/MediaTypes.h
new file mode 100644
index 0000000..d5768e3
--- /dev/null
+++ b/src/bin/network/ifconfig/MediaTypes.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006-2015, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Oliver Tappe, zooey@xxxxxxxxxxxxxxx
+ *             Atis Elsts, the.kfx@xxxxxxxxx
+ */
+#ifndef MEDIA_TYPES_H
+#define MEDIA_TYPES_H
+
+
+#include <stddef.h>
+
+
+const char* get_media_type_name(size_t index);
+const char* get_media_subtype_name(size_t typeIndex, size_t subIndex);
+bool media_parse_subtype(const char* string, int media, int* type);
+const char* media_type_to_string(int media);
+
+
+#endif // MEDIA_TYPES_H
diff --git a/src/bin/network/ifconfig/ifconfig.cpp 
b/src/bin/network/ifconfig/ifconfig.cpp
index b9c481d..05ace35 100644
--- a/src/bin/network/ifconfig/ifconfig.cpp
+++ b/src/bin/network/ifconfig/ifconfig.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
+ * Copyright 2006-2015, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -25,6 +25,8 @@
 
 #include <NetServer.h>
 
+#include "MediaTypes.h"
+
 
 extern const char* __progname;
 const char* kProgramName = __progname;
@@ -35,6 +37,7 @@ enum preferred_output_format {
        PREFER_OUTPUT_PREFIX_LENGTH,
 };
 
+
 struct address_family {
        int                     family;
        const char*     name;
@@ -42,23 +45,6 @@ struct address_family {
        preferred_output_format preferred_format;
 };
 
-struct media_type {
-       int                     type;
-       const char*     name;

[ *** diff truncated: 140 lines dropped *** ]


############################################################################

Commit:      1de91d438370bda4004582583b63495bd5b84950
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb 11 16:01:53 2015 UTC

BNetworkDevice.GetHardwareAddress() was broken.

* Copy&paste error, apparently.

----------------------------------------------------------------------------

############################################################################

Commit:      3643b2f0d72040d18f1908f0e4064ddb23885751
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Wed Feb 11 17:24:38 2015 UTC

Network: integrated former hardware view from add-on.

* The interfaces logic is within the main application, so is the
  new interface view.
* Disabling/renegotiating does not work yet.
* Reveals a bug in some interface code; when you click on an ethernet
  device first, there is no place for the wireless menu. When you then
  press on a wireless device, it crashes in BMenuField code.
  In the other direction, there is then an empty space.
* Fixed list item width reporting.

----------------------------------------------------------------------------


Other related posts:

  • » [haiku-commits] BRANCH axeld-github.network-preferences [3643b2f0d720] src/preferences/network src/preferences/network/InterfacesAddOn src/bin/network/ifconfig headers/os/add-ons/network_settings - axeld-github . network-preferences