summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/mainwindow/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
index f83e370..0a3312c 100644
--- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
@@ -10,2 +10,3 @@
#include <opie2/odebug.h>
+#include <opie2/oprocess.h>
#include <qpe/applnk.h>
@@ -26,2 +27,3 @@
#include <qmessagebox.h>
+#include <qtextstream.h>
@@ -46,2 +48,8 @@
+// is this always right?
+#define _HOSTFILE "/etc/hostname"
+#define _IRDANAME "/proc/sys/net/irda/devname"
+
+using namespace Opie::Core;
+
MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME)
@@ -124,2 +132,3 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi
makeChannel();
+ initHostname();
}
@@ -716 +725,51 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
}
+
+void MainWindowImp::setHostname()
+{
+ QFile f(_HOSTFILE);
+
+ OProcess*h = new OProcess;
+ _procTemp="";
+ *h << "hostname" << m_Nameinput->text();
+ connect(h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int)));
+ h->start(OProcess::Block,OProcess::Stderr);
+ odebug << "Got " << _procTemp << " - " << h->exitStatus() << oendl;
+ _procTemp="";
+ delete h;
+
+ if (f.open(IO_Truncate|IO_WriteOnly))
+ {
+ QTextStream s(&f);
+ s << m_Nameinput->text();
+ }
+ f.close();
+ f.setName(_IRDANAME);
+ if (f.open(IO_WriteOnly))
+ {
+ QTextStream s(&f);
+ s << m_Nameinput->text();
+ }
+}
+
+void MainWindowImp::initHostname()
+{
+ OProcess h;
+ _procTemp="";
+
+ h << "hostname";
+ connect(&h,SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int)));
+ h.start(OProcess::Block,OProcess::AllOutput);
+ odebug << "Got " << _procTemp <<oendl;
+ m_Nameinput->setText(_procTemp);
+ _procTemp="";
+}
+
+void MainWindowImp::slotHostname(Opie::Core::OProcess *proc, char *buffer, int buflen)
+{
+ if (buflen < 1 || buffer==0) return;
+ char*_t = new char[buflen+1];
+ ::memset(_t,0,buflen+1);
+ ::memcpy(_t,buffer,buflen);
+ _procTemp+=_t;
+ delete[]_t;
+}