2015-02-04 20:09:37 +03:00
|
|
|
/*
|
|
|
|
* 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>
|
2015-03-05 15:56:16 +03:00
|
|
|
#include <String.h>
|
2015-02-04 20:09:37 +03:00
|
|
|
#include <View.h>
|
|
|
|
|
|
|
|
|
2015-03-05 15:56:16 +03:00
|
|
|
class BNetworkAddress;
|
|
|
|
|
|
|
|
|
2015-02-04 20:09:37 +03:00
|
|
|
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;
|
2015-02-19 20:37:04 +03:00
|
|
|
class BNetworkSettings;
|
2015-02-04 20:09:37 +03:00
|
|
|
|
|
|
|
|
2015-03-05 15:56:16 +03:00
|
|
|
class BNetworkConfigurationListener {
|
|
|
|
public:
|
|
|
|
virtual void ConfigurationUpdated(
|
|
|
|
const BMessage& message) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-03-16 21:19:04 +03:00
|
|
|
class BNetworkSettingsListener {
|
|
|
|
public:
|
|
|
|
virtual void SettingsUpdated(uint32 type) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BNetworkSettingsItem : public BNetworkConfigurationListener,
|
|
|
|
BNetworkSettingsListener {
|
2015-02-04 20:09:37 +03:00
|
|
|
public:
|
|
|
|
BNetworkSettingsItem();
|
|
|
|
virtual ~BNetworkSettingsItem();
|
|
|
|
|
|
|
|
virtual BNetworkSettingsType
|
|
|
|
Type() const = 0;
|
2015-02-04 23:04:51 +03:00
|
|
|
virtual BListItem* ListItem() = 0;
|
|
|
|
virtual BView* View() = 0;
|
2015-02-04 20:09:37 +03:00
|
|
|
|
|
|
|
virtual status_t ProfileChanged(
|
|
|
|
const BNetworkProfile* newProfile);
|
|
|
|
const BNetworkProfile*
|
|
|
|
Profile() const;
|
|
|
|
|
|
|
|
virtual status_t Revert() = 0;
|
2015-02-05 11:02:26 +03:00
|
|
|
virtual bool IsRevertable() = 0;
|
2015-02-04 20:09:37 +03:00
|
|
|
|
2015-02-27 02:08:45 +03:00
|
|
|
virtual void SettingsUpdated(uint32 type);
|
|
|
|
virtual void ConfigurationUpdated(const BMessage& message);
|
|
|
|
|
2015-03-18 12:54:26 +03:00
|
|
|
virtual void NotifySettingsUpdated();
|
|
|
|
|
2015-02-04 20:09:37 +03:00
|
|
|
private:
|
|
|
|
const BNetworkProfile*
|
|
|
|
fProfile;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BNetworkSettingsInterfaceItem : public BNetworkSettingsItem {
|
|
|
|
public:
|
|
|
|
BNetworkSettingsInterfaceItem(
|
|
|
|
const char* interface);
|
2015-02-13 23:38:59 +03:00
|
|
|
virtual ~BNetworkSettingsInterfaceItem();
|
2015-02-04 20:09:37 +03:00
|
|
|
|
|
|
|
virtual BNetworkSettingsType
|
|
|
|
Type() const;
|
|
|
|
const char* Interface() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char* fInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-03-05 15:56:16 +03:00
|
|
|
class BNetworkInterfaceListItem : public BListItem,
|
|
|
|
public BNetworkConfigurationListener {
|
|
|
|
public:
|
|
|
|
BNetworkInterfaceListItem(int family,
|
|
|
|
const char* interface, const char* label,
|
|
|
|
BNetworkSettings& settings);
|
|
|
|
~BNetworkInterfaceListItem();
|
|
|
|
|
2015-03-11 00:35:20 +03:00
|
|
|
const char* Label() const;
|
|
|
|
|
2015-03-05 15:56:16 +03:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-02-04 20:09:37 +03:00
|
|
|
class BNetworkSettingsAddOn {
|
|
|
|
public:
|
2015-02-19 20:37:04 +03:00
|
|
|
BNetworkSettingsAddOn(image_id image,
|
|
|
|
BNetworkSettings& settings);
|
2015-02-04 20:09:37 +03:00
|
|
|
virtual ~BNetworkSettingsAddOn();
|
|
|
|
|
|
|
|
virtual BNetworkSettingsInterfaceItem*
|
|
|
|
CreateNextInterfaceItem(uint32& cookie,
|
|
|
|
const char* interface);
|
|
|
|
virtual BNetworkSettingsItem*
|
|
|
|
CreateNextItem(uint32& cookie);
|
|
|
|
|
|
|
|
image_id Image();
|
|
|
|
BResources* Resources();
|
2015-02-19 20:37:04 +03:00
|
|
|
BNetworkSettings& Settings();
|
2015-02-04 20:09:37 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
image_id fImage;
|
|
|
|
BResources* fResources;
|
2015-02-19 20:37:04 +03:00
|
|
|
BNetworkSettings& fSettings;
|
2015-02-04 20:09:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Your add-on needs to export this hook in order to be picked up
|
|
|
|
extern "C" BNetworkSettingsAddOn* instantiate_network_settings_add_on(
|
2015-02-19 20:37:04 +03:00
|
|
|
image_id image, BNetworkSettings& settings);
|
2015-02-04 20:09:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace BNetworkKit
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _NETWORK_SETTINGS_ADD_ON_H
|