author | benmeyer <benmeyer> | 2002-10-18 14:28:42 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-18 14:28:42 (UTC) |
commit | 88b3a159060ed7057bfee4cc1ccfcf81a63a4780 (patch) (unidiff) | |
tree | 3dd78d403f337c73bb3ca9d75ef0a29f2adae9b6 /noncore/settings/networksettings/interfacesetupimp.cpp | |
parent | 461113126af82cd6343eedab36ecabb4253780ee (diff) | |
download | opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.zip opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.gz opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.bz2 |
More profile stuff works
Diffstat (limited to 'noncore/settings/networksettings/interfacesetupimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfacesetupimp.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/noncore/settings/networksettings/interfacesetupimp.cpp b/noncore/settings/networksettings/interfacesetupimp.cpp index 951aeee..c16d821 100644 --- a/noncore/settings/networksettings/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfacesetupimp.cpp | |||
@@ -13,33 +13,31 @@ | |||
13 | 13 | ||
14 | #include <assert.h> | 14 | #include <assert.h> |
15 | 15 | ||
16 | #define DNSSCRIPT "interfacednsscript" | 16 | #define DNSSCRIPT "interfacednsscript" |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Constuctor. Set up the connection and load the first profile. | 19 | * Constuctor. Set up the connection and load the first profile. |
20 | */ | 20 | */ |
21 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ | 21 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ |
22 | assert(i); | 22 | assert(i); |
23 | interface = i; | 23 | interface = i; |
24 | interfaces = new Interfaces(); | 24 | interfaces = new Interfaces(); |
25 | changeProfile(profileCombo->currentText()); | ||
26 | bool error = false; | 25 | bool error = false; |
27 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 26 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
28 | staticGroupBox->hide(); | 27 | staticGroupBox->hide(); |
29 | dhcpCheckBox->hide(); | 28 | dhcpCheckBox->hide(); |
30 | leaseTime->hide(); | 29 | leaseTime->hide(); |
31 | leaseHoursLabel->hide(); | 30 | leaseHoursLabel->hide(); |
32 | } | 31 | } |
33 | connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &))); | ||
34 | } | 32 | } |
35 | 33 | ||
36 | /** | 34 | /** |
37 | * Save the current settings, then write out the interfaces file and close. | 35 | * Save the current settings, then write out the interfaces file and close. |
38 | */ | 36 | */ |
39 | void InterfaceSetupImp::accept(){ | 37 | void InterfaceSetupImp::accept(){ |
40 | if(!saveSettings()) | 38 | if(!saveSettings()) |
41 | return; | 39 | return; |
42 | interfaces->write(); | 40 | interfaces->write(); |
43 | close(true); | 41 | close(true); |
44 | } | 42 | } |
45 | 43 | ||
@@ -81,53 +79,52 @@ bool InterfaceSetupImp::saveSettings(){ | |||
81 | interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns); | 79 | interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns); |
82 | } | 80 | } |
83 | 81 | ||
84 | // IP Information | 82 | // IP Information |
85 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 83 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
86 | return true; | 84 | return true; |
87 | } | 85 | } |
88 | 86 | ||
89 | /** | 87 | /** |
90 | * The Profile has changed. | 88 | * The Profile has changed. |
91 | * @profile the new profile. | 89 | * @profile the new profile. |
92 | */ | 90 | */ |
93 | void InterfaceSetupImp::changeProfile(const QString &profile){ | 91 | void InterfaceSetupImp::setProfile(const QString &profile){ |
94 | QString newInterfaceName; | 92 | QString newInterfaceName = interface->getInterfaceName() + profile; |
95 | if(profile.lower() == "all") | ||
96 | newInterfaceName = interface->getInterfaceName(); | ||
97 | else | ||
98 | newInterfaceName = interface->getInterfaceName() + "_" + profile; | ||
99 | if(newInterfaceName == currentInterfaceName) | ||
100 | return; | ||
101 | else{ | ||
102 | saveSettings(); | ||
103 | currentInterfaceName = newInterfaceName; | ||
104 | } | ||
105 | bool error = interfaces->setInterface(currentInterfaceName); | ||
106 | 93 | ||
107 | // See if we have to make a interface. | 94 | // See if we have to make a interface. |
108 | if(error){ | 95 | if(!interfaces->setInterface(newInterfaceName)){ |
109 | qDebug("InterfaceSetupImp: Adding a new interface from profile change."); | 96 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
110 | interfaces->addInterface(currentInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 97 | if(!interfaces->setInterface(newInterfaceName)){ |
111 | error = interfaces->setInterface(currentInterfaceName); | ||
112 | if(error){ | ||
113 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); | 98 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); |
114 | return; | 99 | return; |
115 | } | 100 | } |
101 | // Add making for this new interface if need too | ||
102 | if(profile != ""){ | ||
103 | if(!interfaces->setMapping(interface->getInterfaceName())){ | ||
104 | interfaces->addMapping(interface->getInterfaceName()); | ||
105 | if(!interfaces->setMapping(interface->getInterfaceName())){ | ||
106 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | ||
107 | return; | ||
108 | } | ||
109 | } | ||
110 | interfaces->setScript("getprofile.sh"); | ||
111 | interfaces->setMap("map", newInterfaceName); | ||
112 | } | ||
116 | } | 113 | } |
117 | 114 | ||
118 | //qDebug( currentInterfaceName.latin1() ); | ||
119 | // We must have a valid interface to get this far so read some settings. | 115 | // We must have a valid interface to get this far so read some settings. |
120 | 116 | ||
121 | // DHCP | 117 | // DHCP |
118 | bool error = false; | ||
122 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 119 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
123 | dhcpCheckBox->setChecked(true); | 120 | dhcpCheckBox->setChecked(true); |
124 | else | 121 | else |
125 | dhcpCheckBox->setChecked(false); | 122 | dhcpCheckBox->setChecked(false); |
126 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); | 123 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); |
127 | if(error) | 124 | if(error) |
128 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 125 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
129 | if(error) | 126 | if(error) |
130 | leaseTime->setValue(24); | 127 | leaseTime->setValue(24); |
131 | 128 | ||
132 | // IP Information | 129 | // IP Information |
133 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 130 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |