Diffstat (limited to 'noncore/settings/networksettings/mainwindow/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | 59 |
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 | |||
@@ -1,58 +1,66 @@ | |||
1 | 1 | ||
2 | #include "mainwindowimp.h" | 2 | #include "mainwindowimp.h" |
3 | #include "addconnectionimp.h" | 3 | #include "addconnectionimp.h" |
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
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> |
17 | 18 | ||
18 | /* QT */ | 19 | /* QT */ |
19 | #include <qpushbutton.h> | 20 | #include <qpushbutton.h> |
20 | #include <qlistbox.h> | 21 | #include <qlistbox.h> |
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> |
33 | #endif | 35 | #endif |
34 | #include <qdir.h> | 36 | #include <qdir.h> |
35 | #include <qfile.h> | 37 | #include <qfile.h> |
36 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
37 | #include <qregexp.h> | 39 | #include <qregexp.h> |
38 | 40 | ||
39 | /* STD */ | 41 | /* STD */ |
40 | #include <net/if.h> | 42 | #include <net/if.h> |
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 | |||
53 | using namespace Opie::Core; | ||
54 | |||
47 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) | 55 | MainWindowImp::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())); |
53 | 61 | ||
54 | //remove tab with no function | 62 | //remove tab with no function |
55 | tabWidget->removePage( tab ); | 63 | tabWidget->removePage( tab ); |
56 | 64 | ||
57 | // Load connections. | 65 | // Load connections. |
58 | // /usr/local/kde/lib/libinterfaces.la | 66 | // /usr/local/kde/lib/libinterfaces.la |
@@ -113,24 +121,25 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
113 | { // until end of file... | 121 | { // until end of file... |
114 | QString line = stream.readLine(); // line of text excluding '\n' | 122 | QString line = stream.readLine(); // line of text excluding '\n' |
115 | if(line.contains("SCHEME")) | 123 | if(line.contains("SCHEME")) |
116 | { | 124 | { |
117 | line = line.mid(7, line.length()); | 125 | line = line.mid(7, line.length()); |
118 | currentProfileLabel->setText(line); | 126 | currentProfileLabel->setText(line); |
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 | */ |
130 | MainWindowImp::~MainWindowImp() | 139 | MainWindowImp::~MainWindowImp() |
131 | { | 140 | { |
132 | // Save profiles. | 141 | // Save profiles. |
133 | Config cfg("NetworkSetup"); | 142 | Config cfg("NetworkSetup"); |
134 | cfg.setGroup("General"); | 143 | cfg.setGroup("General"); |
135 | cfg.writeEntry("Profiles", profiles.join(" ")); | 144 | cfg.writeEntry("Profiles", profiles.join(" ")); |
136 | 145 | ||
@@ -705,12 +714,62 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | |||
705 | odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl; | 714 | odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl; |
706 | if(it.key()->type() == dest) | 715 | if(it.key()->type() == dest) |
707 | { | 716 | { |
708 | it.key()->receive( param, arg ); | 717 | it.key()->receive( param, arg ); |
709 | found = true; | 718 | found = true; |
710 | } | 719 | } |
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 | |||
727 | void 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 | |||
754 | void 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 | |||
767 | void 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 | } | ||