177db25ddSAxel Dörfler /* 277db25ddSAxel Dörfler * Copyright 2004-2015 Haiku Inc. All rights reserved. 377db25ddSAxel Dörfler * Distributed under the terms of the MIT License. 477db25ddSAxel Dörfler * 577db25ddSAxel Dörfler */ 677db25ddSAxel Dörfler #ifndef _NETWORK_SETTINGS_ADD_ON_H 777db25ddSAxel Dörfler #define _NETWORK_SETTINGS_ADD_ON_H 877db25ddSAxel Dörfler 977db25ddSAxel Dörfler 1077db25ddSAxel Dörfler #include <image.h> 1177db25ddSAxel Dörfler #include <ListItem.h> 1277db25ddSAxel Dörfler #include <Resources.h> 135274e9b0SAxel Dörfler #include <String.h> 1477db25ddSAxel Dörfler #include <View.h> 1577db25ddSAxel Dörfler 1677db25ddSAxel Dörfler 175274e9b0SAxel Dörfler class BNetworkAddress; 185274e9b0SAxel Dörfler 195274e9b0SAxel Dörfler 2077db25ddSAxel Dörfler namespace BNetworkKit { 2177db25ddSAxel Dörfler 2277db25ddSAxel Dörfler 2377db25ddSAxel Dörfler enum BNetworkSettingsType { 2477db25ddSAxel Dörfler B_NETWORK_SETTINGS_TYPE_INTERFACE = 'intf', 2577db25ddSAxel Dörfler B_NETWORK_SETTINGS_TYPE_SERVICE = 'serv', 2677db25ddSAxel Dörfler B_NETWORK_SETTINGS_TYPE_DIAL_UP = 'dial', 27*6516aed5SAlexander von Gluck IV B_NETWORK_SETTINGS_TYPE_VPN = 'vpnc', 2877db25ddSAxel Dörfler B_NETWORK_SETTINGS_TYPE_OTHER = 'othr' 2977db25ddSAxel Dörfler }; 3077db25ddSAxel Dörfler 3177db25ddSAxel Dörfler class BNetworkProfile; 322864e4daSAxel Dörfler class BNetworkSettings; 3377db25ddSAxel Dörfler 3477db25ddSAxel Dörfler 355274e9b0SAxel Dörfler class BNetworkConfigurationListener { 365274e9b0SAxel Dörfler public: 375274e9b0SAxel Dörfler virtual void ConfigurationUpdated( 385274e9b0SAxel Dörfler const BMessage& message) = 0; 395274e9b0SAxel Dörfler }; 405274e9b0SAxel Dörfler 415274e9b0SAxel Dörfler 42d26777c4SAxel Dörfler class BNetworkSettingsListener { 43d26777c4SAxel Dörfler public: 44d26777c4SAxel Dörfler virtual void SettingsUpdated(uint32 type) = 0; 45d26777c4SAxel Dörfler }; 46d26777c4SAxel Dörfler 47d26777c4SAxel Dörfler 48d26777c4SAxel Dörfler class BNetworkSettingsItem : public BNetworkConfigurationListener, 49d26777c4SAxel Dörfler BNetworkSettingsListener { 5077db25ddSAxel Dörfler public: 5177db25ddSAxel Dörfler BNetworkSettingsItem(); 5277db25ddSAxel Dörfler virtual ~BNetworkSettingsItem(); 5377db25ddSAxel Dörfler 5477db25ddSAxel Dörfler virtual BNetworkSettingsType 5577db25ddSAxel Dörfler Type() const = 0; 56021ff1caSAxel Dörfler virtual BListItem* ListItem() = 0; 57021ff1caSAxel Dörfler virtual BView* View() = 0; 5877db25ddSAxel Dörfler 5977db25ddSAxel Dörfler virtual status_t ProfileChanged( 6077db25ddSAxel Dörfler const BNetworkProfile* newProfile); 6177db25ddSAxel Dörfler const BNetworkProfile* 6277db25ddSAxel Dörfler Profile() const; 6377db25ddSAxel Dörfler 6477db25ddSAxel Dörfler virtual status_t Revert() = 0; 65f6c7cf44SAxel Dörfler virtual bool IsRevertable() = 0; 6677db25ddSAxel Dörfler 6707addd7eSAxel Dörfler virtual void SettingsUpdated(uint32 type); 6807addd7eSAxel Dörfler virtual void ConfigurationUpdated(const BMessage& message); 6907addd7eSAxel Dörfler 703d7aaa30SAxel Dörfler virtual void NotifySettingsUpdated(); 713d7aaa30SAxel Dörfler 7277db25ddSAxel Dörfler private: 7377db25ddSAxel Dörfler const BNetworkProfile* 7477db25ddSAxel Dörfler fProfile; 7577db25ddSAxel Dörfler }; 7677db25ddSAxel Dörfler 7777db25ddSAxel Dörfler 7877db25ddSAxel Dörfler class BNetworkSettingsInterfaceItem : public BNetworkSettingsItem { 7977db25ddSAxel Dörfler public: 8077db25ddSAxel Dörfler BNetworkSettingsInterfaceItem( 8177db25ddSAxel Dörfler const char* interface); 823401ff7cSAxel Dörfler virtual ~BNetworkSettingsInterfaceItem(); 8377db25ddSAxel Dörfler 8477db25ddSAxel Dörfler virtual BNetworkSettingsType 8577db25ddSAxel Dörfler Type() const; 8677db25ddSAxel Dörfler const char* Interface() const; 8777db25ddSAxel Dörfler 8877db25ddSAxel Dörfler private: 8977db25ddSAxel Dörfler const char* fInterface; 9077db25ddSAxel Dörfler }; 9177db25ddSAxel Dörfler 9277db25ddSAxel Dörfler 935274e9b0SAxel Dörfler class BNetworkInterfaceListItem : public BListItem, 945274e9b0SAxel Dörfler public BNetworkConfigurationListener { 955274e9b0SAxel Dörfler public: 965274e9b0SAxel Dörfler BNetworkInterfaceListItem(int family, 975274e9b0SAxel Dörfler const char* interface, const char* label, 985274e9b0SAxel Dörfler BNetworkSettings& settings); 995274e9b0SAxel Dörfler ~BNetworkInterfaceListItem(); 1005274e9b0SAxel Dörfler 101d1f0b8dbSAxel Dörfler const char* Label() const; 102d1f0b8dbSAxel Dörfler 1035274e9b0SAxel Dörfler virtual void DrawItem(BView* owner, 1045274e9b0SAxel Dörfler BRect bounds, bool complete); 1055274e9b0SAxel Dörfler virtual void Update(BView* owner, const BFont* font); 1065274e9b0SAxel Dörfler 1075274e9b0SAxel Dörfler virtual void ConfigurationUpdated(const BMessage& message); 1085274e9b0SAxel Dörfler 1095274e9b0SAxel Dörfler private: 1105274e9b0SAxel Dörfler BFont _AddressFont(); 1115274e9b0SAxel Dörfler void _UpdateState(); 1125274e9b0SAxel Dörfler 1135274e9b0SAxel Dörfler private: 1145274e9b0SAxel Dörfler BNetworkSettings& fSettings; 1155274e9b0SAxel Dörfler int fFamily; 1165274e9b0SAxel Dörfler const char* fInterface; 1175274e9b0SAxel Dörfler const char* fLabel; 1185274e9b0SAxel Dörfler BString fAddress; 1195274e9b0SAxel Dörfler bool fDisabled; 1205274e9b0SAxel Dörfler float fLineOffset; 1215274e9b0SAxel Dörfler float fSpacing; 1225274e9b0SAxel Dörfler }; 1235274e9b0SAxel Dörfler 1245274e9b0SAxel Dörfler 12577db25ddSAxel Dörfler class BNetworkSettingsAddOn { 12677db25ddSAxel Dörfler public: 1272864e4daSAxel Dörfler BNetworkSettingsAddOn(image_id image, 1282864e4daSAxel Dörfler BNetworkSettings& settings); 12977db25ddSAxel Dörfler virtual ~BNetworkSettingsAddOn(); 13077db25ddSAxel Dörfler 13177db25ddSAxel Dörfler virtual BNetworkSettingsInterfaceItem* 13277db25ddSAxel Dörfler CreateNextInterfaceItem(uint32& cookie, 13377db25ddSAxel Dörfler const char* interface); 13477db25ddSAxel Dörfler virtual BNetworkSettingsItem* 13577db25ddSAxel Dörfler CreateNextItem(uint32& cookie); 13677db25ddSAxel Dörfler 13777db25ddSAxel Dörfler image_id Image(); 13877db25ddSAxel Dörfler BResources* Resources(); 1392864e4daSAxel Dörfler BNetworkSettings& Settings(); 14077db25ddSAxel Dörfler 14177db25ddSAxel Dörfler private: 14277db25ddSAxel Dörfler image_id fImage; 14377db25ddSAxel Dörfler BResources* fResources; 1442864e4daSAxel Dörfler BNetworkSettings& fSettings; 14577db25ddSAxel Dörfler }; 14677db25ddSAxel Dörfler 14777db25ddSAxel Dörfler 14877db25ddSAxel Dörfler // Your add-on needs to export this hook in order to be picked up 14977db25ddSAxel Dörfler extern "C" BNetworkSettingsAddOn* instantiate_network_settings_add_on( 1502864e4daSAxel Dörfler image_id image, BNetworkSettings& settings); 15177db25ddSAxel Dörfler 15277db25ddSAxel Dörfler 15377db25ddSAxel Dörfler } // namespace BNetworkKit 15477db25ddSAxel Dörfler 15577db25ddSAxel Dörfler 15677db25ddSAxel Dörfler #endif // _NETWORK_SETTINGS_ADD_ON_H 157