summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-29 01:35:34 (UTC)
committer mickeyl <mickeyl>2003-12-29 01:35:34 (UTC)
commitdae677b6e29e2a0efb7128bcc4b0d87bf2b535dd (patch) (unidiff)
tree15fa32456809982685cdce110b54bf1658efd0e5
parent29fa04fc898c53cfdc9b148d79fcff54d9173707 (diff)
downloadopie-dae677b6e29e2a0efb7128bcc4b0d87bf2b535dd.zip
opie-dae677b6e29e2a0efb7128bcc4b0d87bf2b535dd.tar.gz
opie-dae677b6e29e2a0efb7128bcc4b0d87bf2b535dd.tar.bz2
waited too long for tille to do something - merged it on my own... :(
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/main.cpp11
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp2
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h3
-rw-r--r--noncore/settings/networksettings/networksettings.pro10
-rw-r--r--noncore/settings/networksettings/opie-networksettings.control2
5 files changed, 9 insertions, 19 deletions
diff --git a/noncore/settings/networksettings/main.cpp b/noncore/settings/networksettings/main.cpp
index 1b74d62..5d275ac 100644
--- a/noncore/settings/networksettings/main.cpp
+++ b/noncore/settings/networksettings/main.cpp
@@ -1,13 +1,6 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include <qpe/qpeapplication.h> 2#include <opie/oapplicationfactory.h>
3 3
4int main(int argc, char **argv) 4OPIE_EXPORT_APP( OApplicationFactory<MainWindowImp> )
5{
6 QPEApplication app(argc, argv);
7 MainWindowImp window;
8 app.showMainWidget(&window);
9 return app.exec();
10}
11 5
12// main.cpp
13 6
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index f74cf87..d9752ce 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,181 +1,181 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h" 5#include "interfaces.h"
6#include "module.h" 6#include "module.h"
7 7
8#include <qpushbutton.h> 8#include <qpushbutton.h>
9#include <qlistbox.h> 9#include <qlistbox.h>
10#include <qlineedit.h> 10#include <qlineedit.h>
11#include <qlistview.h> 11#include <qlistview.h>
12#include <qheader.h> 12#include <qheader.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qpe/qcopenvelope_qws.h> 14#include <qpe/qcopenvelope_qws.h>
15#include <qtabwidget.h> // in order to disable the profiles tab 15#include <qtabwidget.h> // in order to disable the profiles tab
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17 17
18#include <qmessagebox.h> 18#include <qmessagebox.h>
19 19
20#ifdef QWS 20#ifdef QWS
21 #include <qpe/config.h> 21 #include <qpe/config.h>
22 #include <qpe/qlibrary.h> 22 #include <qpe/qlibrary.h>
23 #include <qpe/resource.h> 23 #include <qpe/resource.h>
24 #include <qpe/qpeapplication.h> 24 #include <qpe/qpeapplication.h>
25#else 25#else
26 #include <klibloader.h> 26 #include <klibloader.h>
27 #define QLibrary KLibrary 27 #define QLibrary KLibrary
28 #include <kconfig.h> 28 #include <kconfig.h>
29 #define Config KConfig 29 #define Config KConfig
30 #include <kapplication.h> 30 #include <kapplication.h>
31 #include <kstandarddirs.h> 31 #include <kstandarddirs.h>
32 #include <kiconloader.h> 32 #include <kiconloader.h>
33 #define showMaximized show 33 #define showMaximized show
34#endif 34#endif
35 35
36#if QT_VERSION < 300 36#if QT_VERSION < 300
37#include <qlist.h> 37#include <qlist.h>
38#else 38#else
39#include <qptrlist.h> 39#include <qptrlist.h>
40#endif 40#endif
41#include <qdir.h> 41#include <qdir.h>
42#include <qfile.h> 42#include <qfile.h>
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qregexp.h> 44#include <qregexp.h>
45 45
46#include <net/if.h> 46#include <net/if.h>
47#include <sys/ioctl.h> 47#include <sys/ioctl.h>
48#include <sys/socket.h> 48#include <sys/socket.h>
49 49
50#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 50#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
51#define _PROCNETDEV "/proc/net/dev" 51#define _PROCNETDEV "/proc/net/dev"
52 52
53MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){ 53MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){
54 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 54 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
55 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 55 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
56 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 56 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
57 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 57 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
58 58
59 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 59 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
60 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 60 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
61 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 61 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
62 62
63 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 63 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
64 64
65 //FIXME: disable profiles for the moment: 65 //FIXME: disable profiles for the moment:
66 tabWidget->setTabEnabled( tab, false ); 66 tabWidget->setTabEnabled( tab, false );
67 67
68 // Load connections. 68 // Load connections.
69 // /usr/local/kde/lib/libinterfaces.la 69 // /usr/local/kde/lib/libinterfaces.la
70#ifdef QWS 70#ifdef QWS
71 loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); 71 loadModules(QPEApplication::qpeDir() + "plugins/networksettings");
72#else 72#else
73 loader = KLibLoader::self(); 73 loader = KLibLoader::self();
74 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); 74 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
75#endif 75#endif
76 getAllInterfaces(); 76 getAllInterfaces();
77 77
78 Interfaces i; 78 Interfaces i;
79 QStringList list = i.getInterfaceList(); 79 QStringList list = i.getInterfaceList();
80 QMap<QString, Interface*>::Iterator it; 80 QMap<QString, Interface*>::Iterator it;
81 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 81 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
82 /* 82 /*
83 * we skipped it in getAllInterfaces now 83 * we skipped it in getAllInterfaces now
84 * we need to ignore it as well 84 * we need to ignore it as well
85 */ 85 */
86 if (m_handledIfaces.contains( *ni) ) { 86 if (m_handledIfaces.contains( *ni) ) {
87 qDebug("Not up iface handled by module"); 87 qDebug("Not up iface handled by module");
88 continue; 88 continue;
89 } 89 }
90 bool found = false; 90 bool found = false;
91 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 91 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
92 if(it.key() == (*ni)) 92 if(it.key() == (*ni))
93 found = true; 93 found = true;
94 } 94 }
95 if(!found){ 95 if(!found){
96 if(!(*ni).contains("_")){ 96 if(!(*ni).contains("_")){
97 Interface *i = new Interface(this, *ni, false); 97 Interface *i = new Interface(this, *ni, false);
98 i->setAttached(false); 98 i->setAttached(false);
99 i->setHardwareName(tr("Disconnected")); 99 i->setHardwareName(tr("Disconnected"));
100 interfaceNames.insert(i->getInterfaceName(), i); 100 interfaceNames.insert(i->getInterfaceName(), i);
101 updateInterface(i); 101 updateInterface(i);
102 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 102 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
103 } 103 }
104 } 104 }
105 } 105 }
106 106
107 //getInterfaceList(); 107 //getInterfaceList();
108 connectionList->header()->hide(); 108 connectionList->header()->hide();
109 109
110 Config cfg("NetworkSetup"); 110 Config cfg("NetworkSetup");
111 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 111 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
112 for ( QStringList::Iterator it = profiles.begin(); 112 for ( QStringList::Iterator it = profiles.begin();
113 it != profiles.end(); ++it) 113 it != profiles.end(); ++it)
114 profilesList->insertItem((*it)); 114 profilesList->insertItem((*it));
115 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 115 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
116 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 116 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
117 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); 117 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
118 118
119 QFile file(scheme); 119 QFile file(scheme);
120 if ( file.open(IO_ReadOnly) ) { // file opened successfully 120 if ( file.open(IO_ReadOnly) ) { // file opened successfully
121 QTextStream stream( &file ); // use a text stream 121 QTextStream stream( &file ); // use a text stream
122 while ( !stream.eof() ) { // until end of file... 122 while ( !stream.eof() ) { // until end of file...
123 QString line = stream.readLine(); // line of text excluding '\n' 123 QString line = stream.readLine(); // line of text excluding '\n'
124 if(line.contains("SCHEME")){ 124 if(line.contains("SCHEME")){
125 line = line.mid(7, line.length()); 125 line = line.mid(7, line.length());
126 currentProfileLabel->setText(line); 126 currentProfileLabel->setText(line);
127 break; 127 break;
128 } 128 }
129 } 129 }
130 file.close(); 130 file.close();
131 } 131 }
132 makeChannel(); 132 makeChannel();
133} 133}
134 134
135/** 135/**
136 * Deconstructor. Save profiles. Delete loaded libraries. 136 * Deconstructor. Save profiles. Delete loaded libraries.
137 */ 137 */
138MainWindowImp::~MainWindowImp(){ 138MainWindowImp::~MainWindowImp(){
139 // Save profiles. 139 // Save profiles.
140 Config cfg("NetworkSetup"); 140 Config cfg("NetworkSetup");
141 cfg.setGroup("General"); 141 cfg.setGroup("General");
142 cfg.writeEntry("Profiles", profiles.join(" ")); 142 cfg.writeEntry("Profiles", profiles.join(" "));
143 143
144 // Delete all interfaces that don't have owners. 144 // Delete all interfaces that don't have owners.
145 QMap<Interface*, QListViewItem*>::Iterator iIt; 145 QMap<Interface*, QListViewItem*>::Iterator iIt;
146 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 146 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
147 if(iIt.key()->getModuleOwner() == NULL) 147 if(iIt.key()->getModuleOwner() == NULL)
148 delete iIt.key(); 148 delete iIt.key();
149 } 149 }
150 150
151#ifdef QWS 151#ifdef QWS
152 // Delete Modules and Libraries 152 // Delete Modules and Libraries
153 QMap<Module*, QLibrary*>::Iterator it; 153 QMap<Module*, QLibrary*>::Iterator it;
154 for( it = libraries.begin(); it != libraries.end(); ++it ){ 154 for( it = libraries.begin(); it != libraries.end(); ++it ){
155 delete it.key(); 155 delete it.key();
156 // I wonder why I can't delete the libraries 156 // I wonder why I can't delete the libraries
157 // What fucking shit this is. 157 // What fucking shit this is.
158 //delete it.data(); 158 //delete it.data();
159 } 159 }
160#else 160#else
161 // klibloader automaticly deletes the libraries for us... 161 // klibloader automaticly deletes the libraries for us...
162#endif 162#endif
163} 163}
164 164
165/** 165/**
166 * Query the kernel for all of the interfaces. 166 * Query the kernel for all of the interfaces.
167 */ 167 */
168void MainWindowImp::getAllInterfaces(){ 168void MainWindowImp::getAllInterfaces(){
169 int sockfd = socket(PF_INET, SOCK_DGRAM, 0); 169 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
170 if(sockfd == -1) 170 if(sockfd == -1)
171 return; 171 return;
172 172
173 struct ifreq ifr; 173 struct ifreq ifr;
174 QStringList ifaces; 174 QStringList ifaces;
175 QFile procFile(QString(_PROCNETDEV)); 175 QFile procFile(QString(_PROCNETDEV));
176 int result; 176 int result;
177 Interface *i; 177 Interface *i;
178 178
179 if (! procFile.exists()) { 179 if (! procFile.exists()) {
180 struct ifreq ifrs[100]; 180 struct ifreq ifrs[100];
181 struct ifconf ifc; 181 struct ifconf ifc;
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 451835b..f211d6e 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,74 +1,75 @@
1#ifndef MAINWINOWIMP_H 1#ifndef MAINWINOWIMP_H
2#define MAINWINOWIMP_H 2#define MAINWINOWIMP_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8class Module; 8class Module;
9class Interface; 9class Interface;
10class QLibrary; 10class QLibrary;
11class KProcess; 11class KProcess;
12class QCopChannel; 12class QCopChannel;
13#ifdef QWS 13#ifdef QWS
14class QLibrary; 14class QLibrary;
15#else 15#else
16class KLibrary; 16class KLibrary;
17class KLibLoader; 17class KLibLoader;
18#define QLibrary KLibrary 18#define QLibrary KLibrary
19#endif 19#endif
20 20
21 21
22class MainWindowImp : public MainWindow { 22class MainWindowImp : public MainWindow {
23 Q_OBJECT 23 Q_OBJECT
24 24
25public: 25public:
26 MainWindowImp(QWidget *parent=0, const char *name=0); 26 static QString appName() { return QString::fromLatin1("networksettings"); }
27 MainWindowImp(QWidget *parent=0, const char *name=0, WFlags fl = 0);
27 ~MainWindowImp(); 28 ~MainWindowImp();
28 29
29 QCopChannel *channel; 30 QCopChannel *channel;
30 31
31private slots: 32private slots:
32 void getAllInterfaces(); 33 void getAllInterfaces();
33 34
34 void addClicked(); 35 void addClicked();
35 void removeClicked(); 36 void removeClicked();
36 void configureClicked(); 37 void configureClicked();
37 void informationClicked(); 38 void informationClicked();
38 39
39 void addProfile(); 40 void addProfile();
40 void removeProfile(); 41 void removeProfile();
41 void changeProfile(); 42 void changeProfile();
42 43
43 void updateInterface(Interface *i); 44 void updateInterface(Interface *i);
44 void newProfileChanged(const QString& newText); 45 void newProfileChanged(const QString& newText);
45 46
46 void receive (const QCString &, const QByteArray &); 47 void receive (const QCString &, const QByteArray &);
47 48
48private: 49private:
49 void makeChannel(); 50 void makeChannel();
50 void loadModules(const QString &path); 51 void loadModules(const QString &path);
51 52
52 Module* loadPlugin(const QString &pluginFileName, 53 Module* loadPlugin(const QString &pluginFileName,
53 const QString &resolveString = "create_plugin"); 54 const QString &resolveString = "create_plugin");
54 55
55 // For our local list of names 56 // For our local list of names
56 QMap<QString, Interface*> interfaceNames; 57 QMap<QString, Interface*> interfaceNames;
57 58
58 QMap<Module*, QLibrary*> libraries; 59 QMap<Module*, QLibrary*> libraries;
59 QMap<Interface*, QListViewItem*> items; 60 QMap<Interface*, QListViewItem*> items;
60 QMap<QListViewItem*, Interface*> interfaceItems; 61 QMap<QListViewItem*, Interface*> interfaceItems;
61 QStringList m_handledIfaces; 62 QStringList m_handledIfaces;
62 63
63 QMap<KProcess*, QString> threads; 64 QMap<KProcess*, QString> threads;
64 QStringList profiles; 65 QStringList profiles;
65 66
66 bool advancedUserMode; 67 bool advancedUserMode;
67 QString scheme; 68 QString scheme;
68#ifndef QWS 69#ifndef QWS
69 KLibLoader *loader; 70 KLibLoader *loader;
70#endif 71#endif
71}; 72};
72 73
73#endif // MAINWINOWIMP_H 74#endif // MAINWINOWIMP_H
74 75
diff --git a/noncore/settings/networksettings/networksettings.pro b/noncore/settings/networksettings/networksettings.pro
index cdd133a..e8dbe5b 100644
--- a/noncore/settings/networksettings/networksettings.pro
+++ b/noncore/settings/networksettings/networksettings.pro
@@ -1,16 +1,12 @@
1DESTDIR = $(OPIEDIR)/bin 1CONFIG = qt warn_on debug quick-app
2TEMPLATE = app
3#
4CONFIG = qt warn_on debug
5#CONFIG = qt warn_on release
6HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h 2HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h
7SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp 3SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp
8INCLUDEPATH += $(OPIEDIR)/include interfaces/ 4INCLUDEPATH += $(OPIEDIR)/include interfaces/
9DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ 5DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/
10LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopie 6LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopie -lopiecore2 -lopienet2
11INTERFACES = mainwindow.ui addconnection.ui 7INTERFACES = mainwindow.ui addconnection.ui
12TARGET = networksettings 8TARGET = networksettings
13 9
14 10
15 11
16include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/opie-networksettings.control b/noncore/settings/networksettings/opie-networksettings.control
index 82aac2a..08a79c6 100644
--- a/noncore/settings/networksettings/opie-networksettings.control
+++ b/noncore/settings/networksettings/opie-networksettings.control
@@ -1,10 +1,10 @@
1Package: opie-networksettings 1Package: opie-networksettings
2Files: plugins/application/libnetworksettings.so* bin/networksettings apps/Settings/networksettings.desktop pics/networksettings/* pics/Network/PPPConnect.png $OPIEDIR/lib/libinterfaces.so* root/usr/bin/changedns bin/getprofile 2Files: plugins/application/libnetworksettings.so* bin/networksettings apps/Settings/networksettings.desktop pics/networksettings/* pics/Network/PPPConnect.png $OPIEDIR/lib/libinterfaces.so* root/usr/bin/changedns bin/getprofile
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Patrick S. Vogt <tille@handhelds.org> 5Maintainer: Patrick S. Vogt <tille@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal, libopiecore2, libopienet2
8Description: Network settings. 8Description: Network settings.
9Replaces: opie-networksetup 9Replaces: opie-networksetup
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION