network preflet: Make InterfaceListItem dumber
* Allows us to use InterfaceListItem for non-physical interface things (like a VPN connection)
This commit is contained in:
@@ -24,6 +24,7 @@ enum BNetworkSettingsType {
|
|||||||
B_NETWORK_SETTINGS_TYPE_INTERFACE = 'intf',
|
B_NETWORK_SETTINGS_TYPE_INTERFACE = 'intf',
|
||||||
B_NETWORK_SETTINGS_TYPE_SERVICE = 'serv',
|
B_NETWORK_SETTINGS_TYPE_SERVICE = 'serv',
|
||||||
B_NETWORK_SETTINGS_TYPE_DIAL_UP = 'dial',
|
B_NETWORK_SETTINGS_TYPE_DIAL_UP = 'dial',
|
||||||
|
B_NETWORK_SETTINGS_TYPE_VPN = 'vpnc',
|
||||||
B_NETWORK_SETTINGS_TYPE_OTHER = 'othr'
|
B_NETWORK_SETTINGS_TYPE_OTHER = 'othr'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <IconUtils.h>
|
#include <IconUtils.h>
|
||||||
#include <NetworkDevice.h>
|
|
||||||
#include <OutlineListView.h>
|
#include <OutlineListView.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@@ -32,9 +31,11 @@
|
|||||||
#define B_TRANSLATION_CONTEXT "InterfaceListItem"
|
#define B_TRANSLATION_CONTEXT "InterfaceListItem"
|
||||||
|
|
||||||
|
|
||||||
InterfaceListItem::InterfaceListItem(const char* name)
|
InterfaceListItem::InterfaceListItem(const char* name,
|
||||||
|
BNetworkInterfaceType type)
|
||||||
:
|
:
|
||||||
BListItem(0, false),
|
BListItem(0, false),
|
||||||
|
fType(type),
|
||||||
fIcon(NULL),
|
fIcon(NULL),
|
||||||
fFirstLineOffset(0),
|
fFirstLineOffset(0),
|
||||||
fLineOffset(0),
|
fLineOffset(0),
|
||||||
@@ -166,16 +167,15 @@ InterfaceListItem::ConfigurationUpdated(const BMessage& message)
|
|||||||
void
|
void
|
||||||
InterfaceListItem::_Init()
|
InterfaceListItem::_Init()
|
||||||
{
|
{
|
||||||
const char* mediaTypeName = NULL;
|
switch(fType) {
|
||||||
|
default:
|
||||||
BNetworkDevice device(Name());
|
case B_NETWORK_INTERFACE_TYPE_WIFI:
|
||||||
if (device.IsWireless())
|
_PopulateBitmaps("wifi");
|
||||||
mediaTypeName = "wifi";
|
break;
|
||||||
else if (device.IsEthernet())
|
case B_NETWORK_INTERFACE_TYPE_ETHERNET:
|
||||||
mediaTypeName = "ether";
|
_PopulateBitmaps("ether");
|
||||||
|
break;
|
||||||
_PopulateBitmaps(mediaTypeName);
|
}
|
||||||
// Load the interface icons
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,13 +257,19 @@ InterfaceListItem::_UpdateState()
|
|||||||
fHasLink = fInterface.HasLink();
|
fHasLink = fInterface.HasLink();
|
||||||
fConnecting = (fInterface.Flags() & IFF_CONFIGURING) != 0;
|
fConnecting = (fInterface.Flags() & IFF_CONFIGURING) != 0;
|
||||||
|
|
||||||
BNetworkDevice device(Name());
|
switch (fType) {
|
||||||
if (device.IsWireless())
|
case B_NETWORK_INTERFACE_TYPE_WIFI:
|
||||||
fSubtitle = B_TRANSLATE("Wireless device");
|
fSubtitle = B_TRANSLATE("Wireless device");
|
||||||
else if (device.IsEthernet())
|
break;
|
||||||
|
case B_NETWORK_INTERFACE_TYPE_ETHERNET:
|
||||||
fSubtitle = B_TRANSLATE("Ethernet device");
|
fSubtitle = B_TRANSLATE("Ethernet device");
|
||||||
else
|
break;
|
||||||
|
case B_NETWORK_INTERFACE_TYPE_VPN:
|
||||||
|
fSubtitle = B_TRANSLATE("VPN connection");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
fSubtitle = "";
|
fSubtitle = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,22 @@
|
|||||||
#include <NetworkSettingsAddOn.h>
|
#include <NetworkSettingsAddOn.h>
|
||||||
|
|
||||||
|
|
||||||
|
enum BNetworkInterfaceType {
|
||||||
|
B_NETWORK_INTERFACE_TYPE_WIFI = 'wifi',
|
||||||
|
B_NETWORK_INTERFACE_TYPE_ETHERNET = 'ethr',
|
||||||
|
B_NETWORK_INTERFACE_TYPE_VPN = 'nvpn',
|
||||||
|
B_NETWORK_INTERFACE_TYPE_OTHER = 'othe',
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
|
|
||||||
|
|
||||||
class InterfaceListItem : public BListItem,
|
class InterfaceListItem : public BListItem,
|
||||||
public BNetworkKit::BNetworkConfigurationListener {
|
public BNetworkKit::BNetworkConfigurationListener {
|
||||||
public:
|
public:
|
||||||
InterfaceListItem(const char* name);
|
InterfaceListItem(const char* name,
|
||||||
|
BNetworkInterfaceType type);
|
||||||
~InterfaceListItem();
|
~InterfaceListItem();
|
||||||
|
|
||||||
void DrawItem(BView* owner,
|
void DrawItem(BView* owner,
|
||||||
@@ -42,6 +51,8 @@ private:
|
|||||||
const char* _StateText() const;
|
const char* _StateText() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BNetworkInterfaceType fType;
|
||||||
|
|
||||||
BBitmap* fIcon;
|
BBitmap* fIcon;
|
||||||
BBitmap* fIconOffline;
|
BBitmap* fIconOffline;
|
||||||
BBitmap* fIconPending;
|
BBitmap* fIconPending;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <Deskbar.h>
|
#include <Deskbar.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
#include <NetworkDevice.h>
|
||||||
#include <NetworkInterface.h>
|
#include <NetworkInterface.h>
|
||||||
#include <NetworkNotifications.h>
|
#include <NetworkNotifications.h>
|
||||||
#include <NetworkRoster.h>
|
#include <NetworkRoster.h>
|
||||||
@@ -94,6 +95,7 @@ NetworkWindow::NetworkWindow()
|
|||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
fServicesItem(NULL),
|
fServicesItem(NULL),
|
||||||
fDialUpItem(NULL),
|
fDialUpItem(NULL),
|
||||||
|
fVPNItem(NULL),
|
||||||
fOtherItem(NULL)
|
fOtherItem(NULL)
|
||||||
{
|
{
|
||||||
// Profiles section
|
// Profiles section
|
||||||
@@ -336,7 +338,15 @@ NetworkWindow::_ScanInterfaces()
|
|||||||
if ((interface.Flags() & IFF_LOOPBACK) != 0)
|
if ((interface.Flags() & IFF_LOOPBACK) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
InterfaceListItem* item = new InterfaceListItem(interface.Name());
|
BNetworkDevice device(interface.Name());
|
||||||
|
BNetworkInterfaceType type = B_NETWORK_INTERFACE_TYPE_OTHER;
|
||||||
|
|
||||||
|
if (device.IsWireless())
|
||||||
|
type = B_NETWORK_INTERFACE_TYPE_WIFI;
|
||||||
|
else if (device.IsEthernet())
|
||||||
|
type = B_NETWORK_INTERFACE_TYPE_ETHERNET;
|
||||||
|
|
||||||
|
InterfaceListItem* item = new InterfaceListItem(interface.Name(), type);
|
||||||
item->SetExpanded(true);
|
item->SetExpanded(true);
|
||||||
|
|
||||||
fInterfaceItemMap.insert(std::pair<BString, InterfaceListItem*>(
|
fInterfaceItemMap.insert(std::pair<BString, InterfaceListItem*>(
|
||||||
@@ -440,6 +450,7 @@ NetworkWindow::_ScanAddOns()
|
|||||||
|
|
||||||
_SortItemsUnder(fServicesItem);
|
_SortItemsUnder(fServicesItem);
|
||||||
_SortItemsUnder(fDialUpItem);
|
_SortItemsUnder(fDialUpItem);
|
||||||
|
_SortItemsUnder(fVPNItem);
|
||||||
_SortItemsUnder(fOtherItem);
|
_SortItemsUnder(fOtherItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,6 +492,11 @@ NetworkWindow::_ListItemFor(BNetworkSettingsType type)
|
|||||||
fDialUpItem = _CreateItem(B_TRANSLATE("Dial Up"));
|
fDialUpItem = _CreateItem(B_TRANSLATE("Dial Up"));
|
||||||
return fDialUpItem;
|
return fDialUpItem;
|
||||||
|
|
||||||
|
case B_NETWORK_SETTINGS_TYPE_VPN:
|
||||||
|
if (fVPNItem == NULL)
|
||||||
|
fVPNItem = _CreateItem(B_TRANSLATE("VPN"));
|
||||||
|
return fVPNItem;
|
||||||
|
|
||||||
case B_NETWORK_SETTINGS_TYPE_OTHER:
|
case B_NETWORK_SETTINGS_TYPE_OTHER:
|
||||||
if (fOtherItem == NULL)
|
if (fOtherItem == NULL)
|
||||||
fOtherItem = _CreateItem(B_TRANSLATE("Other"));
|
fOtherItem = _CreateItem(B_TRANSLATE("Other"));
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ private:
|
|||||||
ItemMap fInterfaceItemMap;
|
ItemMap fInterfaceItemMap;
|
||||||
BListItem* fServicesItem;
|
BListItem* fServicesItem;
|
||||||
BListItem* fDialUpItem;
|
BListItem* fDialUpItem;
|
||||||
|
BListItem* fVPNItem;
|
||||||
BListItem* fOtherItem;
|
BListItem* fOtherItem;
|
||||||
|
|
||||||
SettingsMap fSettingsMap;
|
SettingsMap fSettingsMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user