summaryrefslogtreecommitdiff
path: root/noncore
authorbenmeyer <benmeyer>2002-10-18 15:40:50 (UTC)
committer benmeyer <benmeyer>2002-10-18 15:40:50 (UTC)
commitc16dcab3fe45ae7193cbdfb2f62bf7e5482d449b (patch) (unidiff)
tree39e69706b24b032364ad4483d2f33688e7054390 /noncore
parent0910b94b5b6618c84b3eb6c457c9137d63a7277f (diff)
downloadopie-c16dcab3fe45ae7193cbdfb2f62bf7e5482d449b.zip
opie-c16dcab3fe45ae7193cbdfb2f62bf7e5482d449b.tar.gz
opie-c16dcab3fe45ae7193cbdfb2f62bf7e5482d449b.tar.bz2
Profiles copy
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interfaces.cpp50
-rw-r--r--noncore/net/networksetup/interfaces.h1
-rw-r--r--noncore/net/networksetup/interfacesetupimp.cpp21
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp24
-rw-r--r--noncore/settings/networksettings/interfaces.cpp50
-rw-r--r--noncore/settings/networksettings/interfaces.h1
-rw-r--r--noncore/settings/networksettings/interfacesetupimp.cpp21
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp24
8 files changed, 148 insertions, 44 deletions
diff --git a/noncore/net/networksetup/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp
index eef42df..0927258 100644
--- a/noncore/net/networksetup/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces.cpp
@@ -167,6 +167,32 @@ bool Interfaces::addInterface(QString interface, QString family, QString method)
167} 167}
168 168
169/** 169/**
170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface.
172 * @return bool true if successfull
173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){
175 if(!setInterface(interface)) return false;
176
177 QStringList::Iterator it = currentIface;
178 it++;
179
180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface;
184 newIface++;
185
186 for ( it; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break;
189 newIface = interfaces.insert(newIface, *it);
190 }
191
192 return true;
193}
194
195/**
170 * Remove the currently selected interface and all of its options. 196 * Remove the currently selected interface and all of its options.
171 * @return bool if successfull or not. 197 * @return bool if successfull or not.
172 */ 198 */
@@ -401,12 +427,26 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator
401 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 427 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
402 QString line = (*it).simplifyWhiteSpace(); 428 QString line = (*it).simplifyWhiteSpace();
403 if(line.contains(stanza) && line.contains(option)){ 429 if(line.contains(stanza) && line.contains(option)){
404 if(found == true){ 430 uint point = line.find(option);
405 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 431 bool valid = true;
432 if(point > 0){
433 // There are more chars in the line. check +1
434 if(line.at(point-1) != ' ')
435 valid = false;
436 }
437 point += option.length();
438 if(point < line.length()-1){
439 // There are more chars in the line. check -1
440 if(line.at(point) != ' ')
441 valid = false;
442 }
443 if(valid){
444 if(found == true){
445 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
446 }
447 found = true;
448 iterator = it;
406 } 449 }
407 qDebug("Found");
408 found = true;
409 iterator = it;
410 } 450 }
411 } 451 }
412 return found; 452 return found;
diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h
index e617c17..7cf04f0 100644
--- a/noncore/net/networksetup/interfaces.h
+++ b/noncore/net/networksetup/interfaces.h
@@ -30,6 +30,7 @@ public:
30 30
31 bool removeInterface(); 31 bool removeInterface();
32 bool addInterface(QString interface, QString family, QString method); 32 bool addInterface(QString interface, QString family, QString method);
33 bool copyInterface(QString oldInterface, QString newInterface);
33 bool setInterface(QString interface); 34 bool setInterface(QString interface);
34 bool isInterfaceSet(); 35 bool isInterfaceSet();
35 QString getInterfaceName(bool &error); 36 QString getInterfaceName(bool &error);
diff --git a/noncore/net/networksetup/interfacesetupimp.cpp b/noncore/net/networksetup/interfacesetupimp.cpp
index c16d821..bdbdfde 100644
--- a/noncore/net/networksetup/interfacesetupimp.cpp
+++ b/noncore/net/networksetup/interfacesetupimp.cpp
@@ -89,17 +89,15 @@ bool InterfaceSetupImp::saveSettings(){
89 * @profile the new profile. 89 * @profile the new profile.
90 */ 90 */
91void InterfaceSetupImp::setProfile(const QString &profile){ 91void InterfaceSetupImp::setProfile(const QString &profile){
92 QString newInterfaceName = interface->getInterfaceName() + profile; 92 QString newInterfaceName = interface->getInterfaceName();
93 93 if(profile.length() > 0)
94 newInterfaceName += "_" + profile;
95 qDebug( newInterfaceName.latin1());
94 // See if we have to make a interface. 96 // See if we have to make a interface.
95 if(!interfaces->setInterface(newInterfaceName)){ 97 if(!interfaces->setInterface(newInterfaceName)){
96 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
97 if(!interfaces->setInterface(newInterfaceName)){
98 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
99 return;
100 }
101 // Add making for this new interface if need too 98 // Add making for this new interface if need too
102 if(profile != ""){ 99 if(profile != ""){
100 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
103 if(!interfaces->setMapping(interface->getInterfaceName())){ 101 if(!interfaces->setMapping(interface->getInterfaceName())){
104 interfaces->addMapping(interface->getInterfaceName()); 102 interfaces->addMapping(interface->getInterfaceName());
105 if(!interfaces->setMapping(interface->getInterfaceName())){ 103 if(!interfaces->setMapping(interface->getInterfaceName())){
@@ -107,8 +105,15 @@ void InterfaceSetupImp::setProfile(const QString &profile){
107 return; 105 return;
108 } 106 }
109 } 107 }
110 interfaces->setScript("getprofile.sh");
111 interfaces->setMap("map", newInterfaceName); 108 interfaces->setMap("map", newInterfaceName);
109 interfaces->setScript("getprofile.sh");
110 }
111 else{
112 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
113 if(!interfaces->setInterface(newInterfaceName)){
114 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
115 return;
116 }
112 } 117 }
113 } 118 }
114 119
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 3c0af6a..9f07f0d 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -228,13 +228,13 @@ void MainWindowImp::configureClicked(){
228 228
229 Interface *i = interfaceItems[item]; 229 Interface *i = interfaceItems[item];
230 if(i->getModuleOwner()){ 230 if(i->getModuleOwner()){
231 i->getModuleOwner()->setProfile(currentProfileLabel->text()); 231 i->getModuleOwner()->setProfile(currentProfile);
232 QTabWidget *tabWidget = NULL; 232 QTabWidget *tabWidget = NULL;
233 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 233 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
234 if(moduleConfigure != NULL){ 234 if(moduleConfigure != NULL){
235 if(tabWidget != NULL){ 235 if(tabWidget != NULL){
236 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 236 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
237 configure->setProfile(currentProfileLabel->text()); 237 configure->setProfile(currentProfile);
238 tabWidget->insertTab(configure, "TCP/IP"); 238 tabWidget->insertTab(configure, "TCP/IP");
239 239
240 } 240 }
@@ -245,7 +245,7 @@ void MainWindowImp::configureClicked(){
245 } 245 }
246 246
247 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 247 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
248 configure->setProfile(currentProfileLabel->text()); 248 configure->setProfile(currentProfile);
249 configure->showMaximized(); 249 configure->showMaximized();
250 configure->show(); 250 configure->show();
251} 251}
@@ -377,12 +377,14 @@ void MainWindowImp::jobDone(KProcess *process){
377 found = true; 377 found = true;
378 } 378 }
379 if(!found){ 379 if(!found){
380 Interface *i = new Interface(this, *ni, false); 380 if(!(*ni).contains("_")){
381 i->setAttached(false); 381 Interface *i = new Interface(this, *ni, false);
382 i->setHardwareName("Disconnected"); 382 i->setAttached(false);
383 interfaceNames.insert(i->getInterfaceName(), i); 383 i->setHardwareName("Disconnected");
384 updateInterface(i); 384 interfaceNames.insert(i->getInterfaceName(), i);
385 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 385 updateInterface(i);
386 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
387 }
386 } 388 }
387 } 389 }
388 } 390 }
@@ -489,6 +491,9 @@ void MainWindowImp::removeProfile(){
489 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 491 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
490 profilesList->insertItem((*it)); 492 profilesList->insertItem((*it));
491 } 493 }
494
495 // Remove any interface settings and mappings.
496 //TODO
492} 497}
493 498
494/** 499/**
@@ -503,6 +508,7 @@ void MainWindowImp::changeProfile(){
503 QString newProfile = profilesList->text(profilesList->currentItem()); 508 QString newProfile = profilesList->text(profilesList->currentItem());
504 if(newProfile != currentProfileLabel->text()){ 509 if(newProfile != currentProfileLabel->text()){
505 currentProfileLabel->setText(newProfile); 510 currentProfileLabel->setText(newProfile);
511 QFile::remove(SCHEME);
506 QFile file(SCHEME); 512 QFile file(SCHEME);
507 if ( file.open(IO_ReadWrite) ) { 513 if ( file.open(IO_ReadWrite) ) {
508 QTextStream stream( &file ); 514 QTextStream stream( &file );
diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp
index eef42df..0927258 100644
--- a/noncore/settings/networksettings/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces.cpp
@@ -167,6 +167,32 @@ bool Interfaces::addInterface(QString interface, QString family, QString method)
167} 167}
168 168
169/** 169/**
170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface.
172 * @return bool true if successfull
173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){
175 if(!setInterface(interface)) return false;
176
177 QStringList::Iterator it = currentIface;
178 it++;
179
180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface;
184 newIface++;
185
186 for ( it; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break;
189 newIface = interfaces.insert(newIface, *it);
190 }
191
192 return true;
193}
194
195/**
170 * Remove the currently selected interface and all of its options. 196 * Remove the currently selected interface and all of its options.
171 * @return bool if successfull or not. 197 * @return bool if successfull or not.
172 */ 198 */
@@ -401,12 +427,26 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator
401 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 427 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
402 QString line = (*it).simplifyWhiteSpace(); 428 QString line = (*it).simplifyWhiteSpace();
403 if(line.contains(stanza) && line.contains(option)){ 429 if(line.contains(stanza) && line.contains(option)){
404 if(found == true){ 430 uint point = line.find(option);
405 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 431 bool valid = true;
432 if(point > 0){
433 // There are more chars in the line. check +1
434 if(line.at(point-1) != ' ')
435 valid = false;
436 }
437 point += option.length();
438 if(point < line.length()-1){
439 // There are more chars in the line. check -1
440 if(line.at(point) != ' ')
441 valid = false;
442 }
443 if(valid){
444 if(found == true){
445 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
446 }
447 found = true;
448 iterator = it;
406 } 449 }
407 qDebug("Found");
408 found = true;
409 iterator = it;
410 } 450 }
411 } 451 }
412 return found; 452 return found;
diff --git a/noncore/settings/networksettings/interfaces.h b/noncore/settings/networksettings/interfaces.h
index e617c17..7cf04f0 100644
--- a/noncore/settings/networksettings/interfaces.h
+++ b/noncore/settings/networksettings/interfaces.h
@@ -30,6 +30,7 @@ public:
30 30
31 bool removeInterface(); 31 bool removeInterface();
32 bool addInterface(QString interface, QString family, QString method); 32 bool addInterface(QString interface, QString family, QString method);
33 bool copyInterface(QString oldInterface, QString newInterface);
33 bool setInterface(QString interface); 34 bool setInterface(QString interface);
34 bool isInterfaceSet(); 35 bool isInterfaceSet();
35 QString getInterfaceName(bool &error); 36 QString getInterfaceName(bool &error);
diff --git a/noncore/settings/networksettings/interfacesetupimp.cpp b/noncore/settings/networksettings/interfacesetupimp.cpp
index c16d821..bdbdfde 100644
--- a/noncore/settings/networksettings/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfacesetupimp.cpp
@@ -89,17 +89,15 @@ bool InterfaceSetupImp::saveSettings(){
89 * @profile the new profile. 89 * @profile the new profile.
90 */ 90 */
91void InterfaceSetupImp::setProfile(const QString &profile){ 91void InterfaceSetupImp::setProfile(const QString &profile){
92 QString newInterfaceName = interface->getInterfaceName() + profile; 92 QString newInterfaceName = interface->getInterfaceName();
93 93 if(profile.length() > 0)
94 newInterfaceName += "_" + profile;
95 qDebug( newInterfaceName.latin1());
94 // See if we have to make a interface. 96 // See if we have to make a interface.
95 if(!interfaces->setInterface(newInterfaceName)){ 97 if(!interfaces->setInterface(newInterfaceName)){
96 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
97 if(!interfaces->setInterface(newInterfaceName)){
98 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
99 return;
100 }
101 // Add making for this new interface if need too 98 // Add making for this new interface if need too
102 if(profile != ""){ 99 if(profile != ""){
100 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
103 if(!interfaces->setMapping(interface->getInterfaceName())){ 101 if(!interfaces->setMapping(interface->getInterfaceName())){
104 interfaces->addMapping(interface->getInterfaceName()); 102 interfaces->addMapping(interface->getInterfaceName());
105 if(!interfaces->setMapping(interface->getInterfaceName())){ 103 if(!interfaces->setMapping(interface->getInterfaceName())){
@@ -107,8 +105,15 @@ void InterfaceSetupImp::setProfile(const QString &profile){
107 return; 105 return;
108 } 106 }
109 } 107 }
110 interfaces->setScript("getprofile.sh");
111 interfaces->setMap("map", newInterfaceName); 108 interfaces->setMap("map", newInterfaceName);
109 interfaces->setScript("getprofile.sh");
110 }
111 else{
112 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
113 if(!interfaces->setInterface(newInterfaceName)){
114 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
115 return;
116 }
112 } 117 }
113 } 118 }
114 119
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 3c0af6a..9f07f0d 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -228,13 +228,13 @@ void MainWindowImp::configureClicked(){
228 228
229 Interface *i = interfaceItems[item]; 229 Interface *i = interfaceItems[item];
230 if(i->getModuleOwner()){ 230 if(i->getModuleOwner()){
231 i->getModuleOwner()->setProfile(currentProfileLabel->text()); 231 i->getModuleOwner()->setProfile(currentProfile);
232 QTabWidget *tabWidget = NULL; 232 QTabWidget *tabWidget = NULL;
233 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 233 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
234 if(moduleConfigure != NULL){ 234 if(moduleConfigure != NULL){
235 if(tabWidget != NULL){ 235 if(tabWidget != NULL){
236 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 236 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
237 configure->setProfile(currentProfileLabel->text()); 237 configure->setProfile(currentProfile);
238 tabWidget->insertTab(configure, "TCP/IP"); 238 tabWidget->insertTab(configure, "TCP/IP");
239 239
240 } 240 }
@@ -245,7 +245,7 @@ void MainWindowImp::configureClicked(){
245 } 245 }
246 246
247 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 247 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
248 configure->setProfile(currentProfileLabel->text()); 248 configure->setProfile(currentProfile);
249 configure->showMaximized(); 249 configure->showMaximized();
250 configure->show(); 250 configure->show();
251} 251}
@@ -377,12 +377,14 @@ void MainWindowImp::jobDone(KProcess *process){
377 found = true; 377 found = true;
378 } 378 }
379 if(!found){ 379 if(!found){
380 Interface *i = new Interface(this, *ni, false); 380 if(!(*ni).contains("_")){
381 i->setAttached(false); 381 Interface *i = new Interface(this, *ni, false);
382 i->setHardwareName("Disconnected"); 382 i->setAttached(false);
383 interfaceNames.insert(i->getInterfaceName(), i); 383 i->setHardwareName("Disconnected");
384 updateInterface(i); 384 interfaceNames.insert(i->getInterfaceName(), i);
385 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 385 updateInterface(i);
386 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
387 }
386 } 388 }
387 } 389 }
388 } 390 }
@@ -489,6 +491,9 @@ void MainWindowImp::removeProfile(){
489 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 491 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
490 profilesList->insertItem((*it)); 492 profilesList->insertItem((*it));
491 } 493 }
494
495 // Remove any interface settings and mappings.
496 //TODO
492} 497}
493 498
494/** 499/**
@@ -503,6 +508,7 @@ void MainWindowImp::changeProfile(){
503 QString newProfile = profilesList->text(profilesList->currentItem()); 508 QString newProfile = profilesList->text(profilesList->currentItem());
504 if(newProfile != currentProfileLabel->text()){ 509 if(newProfile != currentProfileLabel->text()){
505 currentProfileLabel->setText(newProfile); 510 currentProfileLabel->setText(newProfile);
511 QFile::remove(SCHEME);
506 QFile file(SCHEME); 512 QFile file(SCHEME);
507 if ( file.open(IO_ReadWrite) ) { 513 if ( file.open(IO_ReadWrite) ) {
508 QTextStream stream( &file ); 514 QTextStream stream( &file );