1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 5 #include <dirent.h> 6 #include <sys/stat.h> 7 8 #include <String.h> 9 #include <ListView.h> 10 #include <ListItem.h> 11 #include <ScrollView.h> 12 #include <Box.h> 13 #include <Button.h> 14 #include <Bitmap.h> 15 #include <Alert.h> 16 17 #include <NetworkSettings.h> 18 #include <NetworkSettingsAddOn.h> 19 #include "InterfaceListItem.h" 20 21 #include "DialUpView.h" 22 23 24 using namespace BNetworkKit; 25 26 27 class AddOn : public BNetworkSettingsAddOn { 28 public: 29 AddOn(image_id addon_image, BNetworkSettings& settings); 30 virtual ~AddOn(); 31 32 virtual BNetworkSettingsItem* 33 CreateNextItem(uint32& cookie); 34 }; 35 36 37 class DialUpInterfaceItem : public BNetworkSettingsItem { 38 public: 39 DialUpInterfaceItem(BNetworkSettings& settings); 40 virtual ~DialUpInterfaceItem(); 41 42 virtual BNetworkSettingsType 43 Type() const; 44 45 virtual BListItem* ListItem(); 46 virtual BView* View(); 47 48 virtual status_t Revert(); 49 virtual bool IsRevertable(); 50 51 private: 52 BNetworkSettings& fSettings; 53 BListItem* fItem; 54 BView* fView; 55 }; 56 57 58 // #pragma mark - 59 60 61 DialUpInterfaceItem::DialUpInterfaceItem(BNetworkSettings& settings) 62 : 63 fSettings(settings), 64 fItem(new InterfaceListItem("Dialup", 65 B_NETWORK_INTERFACE_TYPE_DIAL_UP)), 66 fView(NULL) 67 { 68 } 69 70 71 DialUpInterfaceItem::~DialUpInterfaceItem() 72 { 73 if (fView->Parent() == NULL) 74 delete fView; 75 76 delete fItem; 77 } 78 79 80 BNetworkSettingsType 81 DialUpInterfaceItem::Type() const 82 { 83 return B_NETWORK_SETTINGS_TYPE_DIAL_UP; 84 } 85 86 87 BListItem* 88 DialUpInterfaceItem::ListItem() 89 { 90 return fItem; 91 } 92 93 94 BView* 95 DialUpInterfaceItem::View() 96 { 97 if (fView == NULL) 98 fView = new DialUpView(BRect(0, 0, 100, 100)/*, fSettings*/); 99 100 return fView; 101 } 102 103 104 status_t 105 DialUpInterfaceItem::Revert() 106 { 107 return B_OK; 108 } 109 110 bool 111 DialUpInterfaceItem::IsRevertable() 112 { 113 // TODO 114 return false; 115 } 116 117 118 // #pragma mark - 119 120 121 AddOn::AddOn(image_id image, BNetworkSettings& settings) 122 : BNetworkSettingsAddOn(image, settings) 123 { 124 } 125 126 127 AddOn::~AddOn() 128 { 129 } 130 131 132 BNetworkSettingsItem* 133 AddOn::CreateNextItem(uint32& cookie) 134 { 135 if (cookie++ == 0) 136 return new DialUpInterfaceItem(Settings()); 137 138 return NULL; 139 } 140 141 142 // #pragma mark - 143 144 145 extern "C" 146 BNetworkSettingsAddOn* 147 instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings) 148 { 149 return new AddOn(image, settings); 150 } 151