summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/mainwindow/mainwindowimp.cpp') (more/less context) (show 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
@@ -5,12 +5,13 @@
5#include "interfacesetupimp.h" 5#include "interfacesetupimp.h"
6#include "interfaces.h" 6#include "interfaces.h"
7#include "module.h" 7#include "module.h"
8 8
9/* OPIE */ 9/* OPIE */
10#include <opie2/odebug.h> 10#include <opie2/odebug.h>
11#include <opie2/oprocess.h>
11#include <qpe/applnk.h> 12#include <qpe/applnk.h>
12#include <qpe/qcopenvelope_qws.h> 13#include <qpe/qcopenvelope_qws.h>
13#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
14#include <qpe/config.h> 15#include <qpe/config.h>
15#include <qpe/qlibrary.h> 16#include <qpe/qlibrary.h>
16#include <qpe/resource.h> 17#include <qpe/resource.h>
@@ -21,12 +22,13 @@
21#include <qlineedit.h> 22#include <qlineedit.h>
22#include <qlistview.h> 23#include <qlistview.h>
23#include <qheader.h> 24#include <qheader.h>
24#include <qlabel.h> 25#include <qlabel.h>
25#include <qtabwidget.h> // in order to disable the profiles tab 26#include <qtabwidget.h> // in order to disable the profiles tab
26#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtextstream.h>
27 29
28 30
29#if QT_VERSION < 0x030000 31#if QT_VERSION < 0x030000
30#include <qlist.h> 32#include <qlist.h>
31#else 33#else
32#include <qptrlist.h> 34#include <qptrlist.h>
@@ -41,12 +43,18 @@
41#include <sys/ioctl.h> 43#include <sys/ioctl.h>
42#include <sys/socket.h> 44#include <sys/socket.h>
43 45
44#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 46#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
45#define _PROCNETDEV "/proc/net/dev" 47#define _PROCNETDEV "/proc/net/dev"
46 48
49// is this always right?
50#define _HOSTFILE "/etc/hostname"
51#define _IRDANAME "/proc/sys/net/irda/devname"
52
53using namespace Opie::Core;
54
47MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) 55MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME)
48{ 56{
49 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 57 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
50 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 58 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
51 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 59 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
52 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 60 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
@@ -119,12 +127,13 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi
119 break; 127 break;
120 } 128 }
121 } 129 }
122 file.close(); 130 file.close();
123 } 131 }
124 makeChannel(); 132 makeChannel();
133 initHostname();
125} 134}
126 135
127/** 136/**
128 * Deconstructor. Save profiles. Delete loaded libraries. 137 * Deconstructor. Save profiles. Delete loaded libraries.
129 */ 138 */
130MainWindowImp::~MainWindowImp() 139MainWindowImp::~MainWindowImp()
@@ -711,6 +720,56 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
711 } 720 }
712 721
713 722
714 if (found) QPEApplication::setKeepRunning(); 723 if (found) QPEApplication::setKeepRunning();
715 else odebug << "Huh what do ya want" << oendl; 724 else odebug << "Huh what do ya want" << oendl;
716} 725}
726
727void MainWindowImp::setHostname()
728{
729 QFile f(_HOSTFILE);
730
731 OProcess*h = new OProcess;
732 _procTemp="";
733 *h << "hostname" << m_Nameinput->text();
734 connect(h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int)));
735 h->start(OProcess::Block,OProcess::Stderr);
736 odebug << "Got " << _procTemp << " - " << h->exitStatus() << oendl;
737 _procTemp="";
738 delete h;
739
740 if (f.open(IO_Truncate|IO_WriteOnly))
741 {
742 QTextStream s(&f);
743 s << m_Nameinput->text();
744 }
745 f.close();
746 f.setName(_IRDANAME);
747 if (f.open(IO_WriteOnly))
748 {
749 QTextStream s(&f);
750 s << m_Nameinput->text();
751 }
752}
753
754void MainWindowImp::initHostname()
755{
756 OProcess h;
757 _procTemp="";
758
759 h << "hostname";
760 connect(&h,SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int)));
761 h.start(OProcess::Block,OProcess::AllOutput);
762 odebug << "Got " << _procTemp <<oendl;
763 m_Nameinput->setText(_procTemp);
764 _procTemp="";
765}
766
767void MainWindowImp::slotHostname(Opie::Core::OProcess *proc, char *buffer, int buflen)
768{
769 if (buflen < 1 || buffer==0) return;
770 char*_t = new char[buflen+1];
771 ::memset(_t,0,buflen+1);
772 ::memcpy(_t,buffer,buflen);
773 _procTemp+=_t;
774 delete[]_t;
775}