Network: added interface list item.

* Added BNetworkInterfaceListItem that can be used by interface protocol
  add-ons to represent their functionality in the list view.
* It will automatically update itself on changes, and will show the
  specified label, and address, if any, as well as indicate whether or
  not the family has been disabled (which doesn't work perfectly yet,
  as IFF_AUTO_CONFIGURED is on the interface level).
* Therefore, the interface list item will no longer show the address,
  but the type of the device instead.
* Introduced the BNetworkConfigurationListener interface that is used
  to broadcast network updates to.
This commit is contained in:
Axel Dörfler
2015-03-27 13:22:28 +01:00
parent b00dcbcad2
commit 5274e9b004
8 changed files with 232 additions and 65 deletions
@@ -10,9 +10,13 @@
#include <image.h>
#include <ListItem.h>
#include <Resources.h>
#include <String.h>
#include <View.h>
class BNetworkAddress;
namespace BNetworkKit {
@@ -31,7 +35,14 @@ class BNetworkProfile;
class BNetworkSettings;
class BNetworkSettingsItem {
class BNetworkConfigurationListener {
public:
virtual void ConfigurationUpdated(
const BMessage& message) = 0;
};
class BNetworkSettingsItem : public BNetworkConfigurationListener {
public:
BNetworkSettingsItem();
virtual ~BNetworkSettingsItem();
@@ -73,6 +84,36 @@ private:
};
class BNetworkInterfaceListItem : public BListItem,
public BNetworkConfigurationListener {
public:
BNetworkInterfaceListItem(int family,
const char* interface, const char* label,
BNetworkSettings& settings);
~BNetworkInterfaceListItem();
virtual void DrawItem(BView* owner,
BRect bounds, bool complete);
virtual void Update(BView* owner, const BFont* font);
virtual void ConfigurationUpdated(const BMessage& message);
private:
BFont _AddressFont();
void _UpdateState();
private:
BNetworkSettings& fSettings;
int fFamily;
const char* fInterface;
const char* fLabel;
BString fAddress;
bool fDisabled;
float fLineOffset;
float fSpacing;
};
class BNetworkSettingsAddOn {
public:
BNetworkSettingsAddOn(image_id image,