summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindow.ui104
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.cpp59
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.h13
3 files changed, 174 insertions, 2 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindow.ui b/noncore/settings/networksettings/mainwindow/mainwindow.ui
index a730dd5..185b345 100644
--- a/noncore/settings/networksettings/mainwindow/mainwindow.ui
+++ b/noncore/settings/networksettings/mainwindow/mainwindow.ui
@@ -10,9 +10,9 @@
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>240</width>
+ <width>340</width>
<height>289</height>
</rect>
</property>
<property stdset="1">
@@ -40,8 +40,11 @@
</property>
<property>
<name>layoutMargin</name>
</property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
@@ -431,11 +434,110 @@
</hbox>
</widget>
</grid>
</widget>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>devicenametab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Device name</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>m_NameHead</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&lt;b&gt;Name of the device&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>m_Nameinput</cstring>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>m_setButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Set value</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>m_Infolabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>The name here is that one your device identifying with on
+console or infrared.</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer5</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
</widget>
</vbox>
</widget>
+<connections>
+ <connection>
+ <sender>m_setButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>setHostname()</slot>
+ </connection>
+ <slot access="protected">setHostname()</slot>
+</connections>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>connectionList</tabstop>
<tabstop>informationConnectionButton</tabstop>
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
@@ -7,8 +7,9 @@
#include "module.h"
/* OPIE */
#include <opie2/odebug.h>
+#include <opie2/oprocess.h>
#include <qpe/applnk.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
@@ -23,8 +24,9 @@
#include <qheader.h>
#include <qlabel.h>
#include <qtabwidget.h> // in order to disable the profiles tab
#include <qmessagebox.h>
+#include <qtextstream.h>
#if QT_VERSION < 0x030000
#include <qlist.h>
@@ -43,8 +45,14 @@
#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
#define _PROCNETDEV "/proc/net/dev"
+// 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)
{
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
@@ -121,8 +129,9 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi
}
file.close();
}
makeChannel();
+ initHostname();
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
@@ -713,4 +722,54 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
if (found) QPEApplication::setKeepRunning();
else odebug << "Huh what do ya want" << oendl;
}
+
+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;
+}
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.h b/noncore/settings/networksettings/mainwindow/mainwindowimp.h
index f211d6e..da1bb8f 100644
--- a/noncore/settings/networksettings/mainwindow/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.h
@@ -17,8 +17,13 @@ class KLibrary;
class KLibLoader;
#define QLibrary KLibrary
#endif
+namespace Opie {
+namespace Core {
+ class OProcess;
+}
+}
class MainWindowImp : public MainWindow {
Q_OBJECT
@@ -45,14 +50,19 @@ private slots:
void newProfileChanged(const QString& newText);
void receive (const QCString &, const QByteArray &);
+protected slots:
+ virtual void setHostname();
+ virtual void slotHostname(Opie::Core::OProcess *proc, char *buffer, int buflen);
+
private:
void makeChannel();
void loadModules(const QString &path);
+ void initHostname();
Module* loadPlugin(const QString &pluginFileName,
- const QString &resolveString = "create_plugin");
+ const QString &resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
@@ -65,8 +75,9 @@ private:
QStringList profiles;
bool advancedUserMode;
QString scheme;
+ QString _procTemp;
#ifndef QWS
KLibLoader *loader;
#endif
};