summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
index 0a3312c..3222e50 100644
--- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
@@ -28,2 +28,3 @@
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qregexp.h>
29 30
@@ -728,13 +729,22 @@ void MainWindowImp::setHostname()
728{ 729{
729 QFile f(_HOSTFILE); 730 static QRegExp filter("[^A-Za-z0-9_\\-\\.]");
731 if (filter.match(m_Nameinput->text())!=-1) {
732 odebug << "Wrong hostname" << oendl;
733 QMessageBox::critical(0, tr("Sorry"), tr("This is a wrong name.<br>Please use A-Z, a-z, _, - or a single dot."));
734 return;
735 }
730 736
731 OProcess*h = new OProcess; 737 OProcess h;
732 _procTemp=""; 738 _procTemp="";
733 *h << "hostname" << m_Nameinput->text(); 739 h << "hostname" << m_Nameinput->text();
734 connect(h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); 740 connect(&h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int)));
735 h->start(OProcess::Block,OProcess::Stderr); 741 h.start(OProcess::Block,OProcess::Stderr);
736 odebug << "Got " << _procTemp << " - " << h->exitStatus() << oendl; 742 odebug << "Got " << _procTemp << " - " << h.exitStatus() << oendl;
743 if (h.exitStatus()!=0) {
744 QMessageBox::critical(0, tr("Sorry"), QString(tr("Could not set name.\n%1")).arg(_procTemp.stripWhiteSpace()));
745 return;
746 }
737 _procTemp=""; 747 _procTemp="";
738 delete h;
739 748
749 QFile f(_HOSTFILE);
740 if (f.open(IO_Truncate|IO_WriteOnly)) 750 if (f.open(IO_Truncate|IO_WriteOnly))
@@ -743,3 +753,7 @@ void MainWindowImp::setHostname()
743 s << m_Nameinput->text(); 753 s << m_Nameinput->text();
754 } else {
755 QMessageBox::critical(0, tr("Sorry"), tr("Could not save name."));
756 return;
744 } 757 }
758
745 f.close(); 759 f.close();
@@ -750,2 +764,4 @@ void MainWindowImp::setHostname()
750 s << m_Nameinput->text(); 764 s << m_Nameinput->text();
765 } else {
766 QMessageBox::critical(0, tr("Sorry"), tr("Could not set infrared name."));
751 } 767 }
@@ -762,3 +778,3 @@ void MainWindowImp::initHostname()
762 odebug << "Got " << _procTemp <<oendl; 778 odebug << "Got " << _procTemp <<oendl;
763 m_Nameinput->setText(_procTemp); 779 m_Nameinput->setText(_procTemp.stripWhiteSpace());
764 _procTemp=""; 780 _procTemp="";