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,678 +1,678 @@
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;
182 ifc.ifc_len = sizeof(ifrs); 182 ifc.ifc_len = sizeof(ifrs);
183 ifc.ifc_req = ifrs; 183 ifc.ifc_req = ifrs;
184 result = ioctl(sockfd, SIOCGIFCONF, &ifc); 184 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
185 185
186 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { 186 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) {
187 struct ifreq *pifr = &ifrs[i]; 187 struct ifreq *pifr = &ifrs[i];
188 188
189 ifaces += pifr->ifr_name; 189 ifaces += pifr->ifr_name;
190 } 190 }
191 } else { 191 } else {
192 procFile.open(IO_ReadOnly); 192 procFile.open(IO_ReadOnly);
193 QString line; 193 QString line;
194 QTextStream procTs(&procFile); 194 QTextStream procTs(&procFile);
195 int loc = -1; 195 int loc = -1;
196 196
197 procTs.readLine(); // eat a line 197 procTs.readLine(); // eat a line
198 procTs.readLine(); // eat a line 198 procTs.readLine(); // eat a line
199 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 199 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
200 if((loc = line.find(":")) != -1) { 200 if((loc = line.find(":")) != -1) {
201 ifaces += line.left(loc); 201 ifaces += line.left(loc);
202 } 202 }
203 } 203 }
204 } 204 }
205 205
206 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 206 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
207 int flags = 0; 207 int flags = 0;
208 if ( m_handledIfaces.contains( (*it) ) ) { 208 if ( m_handledIfaces.contains( (*it) ) ) {
209 qDebug(" %s is handled by a module", (*it).latin1() ); 209 qDebug(" %s is handled by a module", (*it).latin1() );
210 continue; 210 continue;
211 } 211 }
212// int family; 212// int family;
213 i = NULL; 213 i = NULL;
214 214
215 strcpy(ifr.ifr_name, (*it).latin1()); 215 strcpy(ifr.ifr_name, (*it).latin1());
216 216
217 struct ifreq ifcopy; 217 struct ifreq ifcopy;
218 ifcopy = ifr; 218 ifcopy = ifr;
219 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 219 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
220 flags = ifcopy.ifr_flags; 220 flags = ifcopy.ifr_flags;
221 i = new Interface(this, ifr.ifr_name, false); 221 i = new Interface(this, ifr.ifr_name, false);
222 i->setAttached(true); 222 i->setAttached(true);
223 if ((flags & IFF_UP) == IFF_UP) 223 if ((flags & IFF_UP) == IFF_UP)
224 i->setStatus(true); 224 i->setStatus(true);
225 else 225 else
226 i->setStatus(false); 226 i->setStatus(false);
227 227
228 if ((flags & IFF_BROADCAST) == IFF_BROADCAST) 228 if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
229 i->setHardwareName("Ethernet"); 229 i->setHardwareName("Ethernet");
230 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) 230 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
231 i->setHardwareName("Point to Point"); 231 i->setHardwareName("Point to Point");
232 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) 232 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
233 i->setHardwareName("Multicast"); 233 i->setHardwareName("Multicast");
234 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 234 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
235 i->setHardwareName("Loopback"); 235 i->setHardwareName("Loopback");
236 else 236 else
237 i->setHardwareName("Unknown"); 237 i->setHardwareName("Unknown");
238 238
239 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); 239 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
240 interfaceNames.insert(i->getInterfaceName(), i); 240 interfaceNames.insert(i->getInterfaceName(), i);
241 updateInterface(i); 241 updateInterface(i);
242 connect(i, SIGNAL(updateInterface(Interface *)), 242 connect(i, SIGNAL(updateInterface(Interface *)),
243 this, SLOT(updateInterface(Interface *))); 243 this, SLOT(updateInterface(Interface *)));
244 } 244 }
245 // now lets ask the plugins too ;) 245 // now lets ask the plugins too ;)
246 QMap<Module*, QLibrary*>::Iterator it; 246 QMap<Module*, QLibrary*>::Iterator it;
247 QList<Interface> ilist; 247 QList<Interface> ilist;
248 for( it = libraries.begin(); it != libraries.end(); ++it ){ 248 for( it = libraries.begin(); it != libraries.end(); ++it ){
249 if(it.key()){ 249 if(it.key()){
250 ilist = it.key()->getInterfaces(); 250 ilist = it.key()->getInterfaces();
251 for( i = ilist.first(); i != 0; i = ilist.next() ){ 251 for( i = ilist.first(); i != 0; i = ilist.next() ){
252 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); 252 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
253 interfaceNames.insert(i->getInterfaceName(), i); 253 interfaceNames.insert(i->getInterfaceName(), i);
254 updateInterface(i); 254 updateInterface(i);
255 connect(i, SIGNAL(updateInterface(Interface *)), 255 connect(i, SIGNAL(updateInterface(Interface *)),
256 this, SLOT(updateInterface(Interface *))); 256 this, SLOT(updateInterface(Interface *)));
257 } 257 }
258 } 258 }
259 } 259 }
260} 260}
261 261
262/** 262/**
263 * Load all modules that are found in the path 263 * Load all modules that are found in the path
264 * @param path a directory that is scaned for any plugins that can be loaded 264 * @param path a directory that is scaned for any plugins that can be loaded
265 * and attempts to load them 265 * and attempts to load them
266 */ 266 */
267void MainWindowImp::loadModules(const QString &path){ 267void MainWindowImp::loadModules(const QString &path){
268#ifdef DEBUG 268#ifdef DEBUG
269 qDebug("MainWindowImp::loadModules: %s", path.latin1()); 269 qDebug("MainWindowImp::loadModules: %s", path.latin1());
270#endif 270#endif
271 QDir d(path); 271 QDir d(path);
272 if(!d.exists()) 272 if(!d.exists())
273 return; 273 return;
274 274
275 // Don't want sym links 275 // Don't want sym links
276 d.setFilter( QDir::Files | QDir::NoSymLinks ); 276 d.setFilter( QDir::Files | QDir::NoSymLinks );
277 const QFileInfoList *list = d.entryInfoList(); 277 const QFileInfoList *list = d.entryInfoList();
278 QFileInfoListIterator it( *list ); 278 QFileInfoListIterator it( *list );
279 QFileInfo *fi; 279 QFileInfo *fi;
280 while ( (fi=it.current()) ) { 280 while ( (fi=it.current()) ) {
281#ifdef QWS 281#ifdef QWS
282 if(fi->fileName().contains(".so")){ 282 if(fi->fileName().contains(".so")){
283#else 283#else
284 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ 284 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){
285#endif 285#endif
286 loadPlugin(path + "/" + fi->fileName()); 286 loadPlugin(path + "/" + fi->fileName());
287 qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); 287 qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1());
288 } 288 }
289 ++it; 289 ++it;
290 } 290 }
291} 291}
292 292
293/** 293/**
294 * Attempt to load a function and resolve a function. 294 * Attempt to load a function and resolve a function.
295 * @param pluginFileName - the name of the file in which to attempt to load 295 * @param pluginFileName - the name of the file in which to attempt to load
296 * @param resolveString - function pointer to resolve 296 * @param resolveString - function pointer to resolve
297 * @return pointer to the function with name resolveString or NULL 297 * @return pointer to the function with name resolveString or NULL
298 */ 298 */
299Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ 299Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
300#ifdef DEBUG 300#ifdef DEBUG
301 qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); 301 qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1());
302#endif 302#endif
303#ifdef QWS 303#ifdef QWS
304 QLibrary *lib = new QLibrary(pluginFileName); 304 QLibrary *lib = new QLibrary(pluginFileName);
305 void *functionPointer = lib->resolve(resolveString); 305 void *functionPointer = lib->resolve(resolveString);
306 if( !functionPointer ){ 306 if( !functionPointer ){
307#ifdef DEBUG 307#ifdef DEBUG
308 qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); 308 qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1());
309#endif 309#endif
310 delete lib; 310 delete lib;
311 return NULL; 311 return NULL;
312 } 312 }
313 // Try to get an object. 313 // Try to get an object.
314 Module *object = ((Module* (*)()) functionPointer)(); 314 Module *object = ((Module* (*)()) functionPointer)();
315 if(object == NULL){ 315 if(object == NULL){
316#ifdef DEBUG 316#ifdef DEBUG
317 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 317 qDebug("MainWindowImp: Couldn't create object, but did load library!");
318#endif 318#endif
319 delete lib; 319 delete lib;
320 return NULL; 320 return NULL;
321 } 321 }
322 322
323 m_handledIfaces += object->handledInterfaceNames(); 323 m_handledIfaces += object->handledInterfaceNames();
324 // Store for deletion later 324 // Store for deletion later
325 libraries.insert(object, lib); 325 libraries.insert(object, lib);
326 return object; 326 return object;
327 327
328#else 328#else
329 QLibrary *lib = loader->library(pluginFileName); 329 QLibrary *lib = loader->library(pluginFileName);
330 if( !lib || !lib->hasSymbol(resolveString) ){ 330 if( !lib || !lib->hasSymbol(resolveString) ){
331 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 331 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
332 return NULL; 332 return NULL;
333 } 333 }
334 // Try to get an object. 334 // Try to get an object.
335 Module *object = ((Module* (*)()) lib->symbol(resolveString))(); 335 Module *object = ((Module* (*)()) lib->symbol(resolveString))();
336 if(object == NULL){ 336 if(object == NULL){
337#ifdef DEBUG 337#ifdef DEBUG
338 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 338 qDebug("MainWindowImp: Couldn't create object, but did load library!");
339#endif 339#endif
340 return NULL; 340 return NULL;
341 } 341 }
342#ifdef DEBUG 342#ifdef DEBUG
343 qDebug("MainWindowImp::loadPlugin:: Found object, storing."); 343 qDebug("MainWindowImp::loadPlugin:: Found object, storing.");
344#endif 344#endif
345 // Store for deletion later 345 // Store for deletion later
346 libraries.insert(object, lib); 346 libraries.insert(object, lib);
347 return object; 347 return object;
348#endif 348#endif
349} 349}
350 350
351/** 351/**
352 * The Add button was clicked. Bring up the add dialog and if OK is hit 352 * The Add button was clicked. Bring up the add dialog and if OK is hit
353 * load the plugin and append it to the list 353 * load the plugin and append it to the list
354 */ 354 */
355void MainWindowImp::addClicked(){ 355void MainWindowImp::addClicked(){
356 QMap<Module*, QLibrary*>::Iterator it; 356 QMap<Module*, QLibrary*>::Iterator it;
357 QMap<QString, QString> list; 357 QMap<QString, QString> list;
358 QMap<QString, Module*> newInterfaceOwners; 358 QMap<QString, Module*> newInterfaceOwners;
359 359
360 for( it = libraries.begin(); it != libraries.end(); ++it ){ 360 for( it = libraries.begin(); it != libraries.end(); ++it ){
361 if(it.key()){ 361 if(it.key()){
362 (it.key())->possibleNewInterfaces(list); 362 (it.key())->possibleNewInterfaces(list);
363 } 363 }
364 } 364 }
365 // See if the list has anything that we can add. 365 // See if the list has anything that we can add.
366 if(list.count() == 0){ 366 if(list.count() == 0){
367 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); 367 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
368 return; 368 return;
369 } 369 }
370 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 370 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
371 addNewConnection.addConnections(list); 371 addNewConnection.addConnections(list);
372 addNewConnection.showMaximized(); 372 addNewConnection.showMaximized();
373 if(QDialog::Accepted == addNewConnection.exec()){ 373 if(QDialog::Accepted == addNewConnection.exec()){
374 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 374 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
375 if(!item) 375 if(!item)
376 return; 376 return;
377 377
378 for( it = libraries.begin(); it != libraries.end(); ++it ){ 378 for( it = libraries.begin(); it != libraries.end(); ++it ){
379 if(it.key()){ 379 if(it.key()){
380 Interface *i = (it.key())->addNewInterface(item->text(0)); 380 Interface *i = (it.key())->addNewInterface(item->text(0));
381 if(i){ 381 if(i){
382 qDebug("iface name %s",i->getInterfaceName().latin1()); 382 qDebug("iface name %s",i->getInterfaceName().latin1());
383 interfaceNames.insert(i->getInterfaceName(), i); 383 interfaceNames.insert(i->getInterfaceName(), i);
384 updateInterface(i); 384 updateInterface(i);
385 } 385 }
386 } 386 }
387 } 387 }
388 } 388 }
389} 389}
390 390
391/** 391/**
392 * Prompt the user to see if they really want to do this. 392 * Prompt the user to see if they really want to do this.
393 * If they do then remove from the list and unload. 393 * If they do then remove from the list and unload.
394 */ 394 */
395void MainWindowImp::removeClicked(){ 395void MainWindowImp::removeClicked(){
396 QListViewItem *item = connectionList->currentItem(); 396 QListViewItem *item = connectionList->currentItem();
397 if(!item) { 397 if(!item) {
398 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 398 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
399 return; 399 return;
400 } 400 }
401 401
402 Interface *i = interfaceItems[item]; 402 Interface *i = interfaceItems[item];
403 if(i->getModuleOwner() == NULL){ 403 if(i->getModuleOwner() == NULL){
404 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); 404 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
405 } 405 }
406 else{ 406 else{
407 if(!i->getModuleOwner()->remove(i)) 407 if(!i->getModuleOwner()->remove(i))
408 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); 408 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok);
409 else{ 409 else{
410 delete item; 410 delete item;
411// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); 411// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
412 } 412 }
413 } 413 }
414} 414}
415 415
416/** 416/**
417 * Pull up the configure about the currently selected interface. 417 * Pull up the configure about the currently selected interface.
418 * Report an error if no interface is selected. 418 * Report an error if no interface is selected.
419 * If the interface has a module owner then request its configure. 419 * If the interface has a module owner then request its configure.
420 */ 420 */
421void MainWindowImp::configureClicked(){ 421void MainWindowImp::configureClicked(){
422 QListViewItem *item = connectionList->currentItem(); 422 QListViewItem *item = connectionList->currentItem();
423 if(!item){ 423 if(!item){
424 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); 424 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok);
425 return; 425 return;
426 } 426 }
427 427
428 QString currentProfileText = currentProfileLabel->text(); 428 QString currentProfileText = currentProfileLabel->text();
429 if(currentProfileText.upper() == "ALL"); 429 if(currentProfileText.upper() == "ALL");
430 currentProfileText = ""; 430 currentProfileText = "";
431 431
432 Interface *i = interfaceItems[item]; 432 Interface *i = interfaceItems[item];
433 433
434 if(i->getModuleOwner()){ 434 if(i->getModuleOwner()){
435 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 435 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
436 if(moduleConfigure != NULL){ 436 if(moduleConfigure != NULL){
437 i->getModuleOwner()->setProfile(currentProfileText); 437 i->getModuleOwner()->setProfile(currentProfileText);
438 moduleConfigure->showMaximized(); 438 moduleConfigure->showMaximized();
439 return; 439 return;
440 } 440 }
441 } 441 }
442 442
443 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); 443 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp );
444 configure->setProfile(currentProfileText); 444 configure->setProfile(currentProfileText);
445 configure->showMaximized(); 445 configure->showMaximized();
446} 446}
447 447
448/** 448/**
449 * Pull up the information about the currently selected interface. 449 * Pull up the information about the currently selected interface.
450 * Report an error if no interface is selected. 450 * Report an error if no interface is selected.
451 * If the interface has a module owner then request its configure. 451 * If the interface has a module owner then request its configure.
452 */ 452 */
453void MainWindowImp::informationClicked(){ 453void MainWindowImp::informationClicked(){
454 QListViewItem *item = connectionList->currentItem(); 454 QListViewItem *item = connectionList->currentItem();
455 if(!item){ 455 if(!item){
456 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 456 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
457 return; 457 return;
458 } 458 }
459 459
460 Interface *i = interfaceItems[item]; 460 Interface *i = interfaceItems[item];
461// if(!i->isAttached()){ 461// if(!i->isAttached()){
462// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 462// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
463// return; 463// return;
464// } 464// }
465 465
466 if(i->getModuleOwner()){ 466 if(i->getModuleOwner()){
467 QWidget *moduleInformation = i->getModuleOwner()->information(i); 467 QWidget *moduleInformation = i->getModuleOwner()->information(i);
468 if(moduleInformation != NULL){ 468 if(moduleInformation != NULL){
469 moduleInformation->showMaximized(); 469 moduleInformation->showMaximized();
470#ifdef DEBUG 470#ifdef DEBUG
471 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); 471 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed.");
472#endif 472#endif
473 return; 473 return;
474 } 474 }
475 } 475 }
476 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); 476 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp);
477 information->showMaximized(); 477 information->showMaximized();
478} 478}
479 479
480/** 480/**
481 * Update this interface. If no QListViewItem exists create one. 481 * Update this interface. If no QListViewItem exists create one.
482 * @param Interface* pointer to the interface that needs to be updated. 482 * @param Interface* pointer to the interface that needs to be updated.
483 */ 483 */
484void MainWindowImp::updateInterface(Interface *i){ 484void MainWindowImp::updateInterface(Interface *i){
485 if(!advancedUserMode){ 485 if(!advancedUserMode){
486 if(i->getInterfaceName() == "lo") 486 if(i->getInterfaceName() == "lo")
487 return; 487 return;
488 } 488 }
489 489
490 QListViewItem *item = NULL; 490 QListViewItem *item = NULL;
491 491
492 // Find the interface, making it if needed. 492 // Find the interface, making it if needed.
493 if(items.find(i) == items.end()){ 493 if(items.find(i) == items.end()){
494 item = new QListViewItem(connectionList, "", "", ""); 494 item = new QListViewItem(connectionList, "", "", "");
495 // See if you can't find a module owner for this interface 495 // See if you can't find a module owner for this interface
496 QMap<Module*, QLibrary*>::Iterator it; 496 QMap<Module*, QLibrary*>::Iterator it;
497 for( it = libraries.begin(); it != libraries.end(); ++it ){ 497 for( it = libraries.begin(); it != libraries.end(); ++it ){
498 if(it.key()->isOwner(i)) 498 if(it.key()->isOwner(i))
499 i->setModuleOwner(it.key()); 499 i->setModuleOwner(it.key());
500 } 500 }
501 items.insert(i, item); 501 items.insert(i, item);
502 interfaceItems.insert(item, i); 502 interfaceItems.insert(item, i);
503 } 503 }
504 else 504 else
505 item = items[i]; 505 item = items[i];
506 506
507 // Update the icons and information 507 // Update the icons and information
508#ifdef QWS 508#ifdef QWS
509 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 509 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
510#else 510#else
511 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); 511 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
512#endif 512#endif
513 513
514 QString typeName = "lan"; 514 QString typeName = "lan";
515 if(i->getInterfaceName() == "lo") 515 if(i->getInterfaceName() == "lo")
516 typeName = "lo"; 516 typeName = "lo";
517 if(i->getInterfaceName().contains("irda")) 517 if(i->getInterfaceName().contains("irda"))
518 typeName = "irda"; 518 typeName = "irda";
519 if(i->getInterfaceName().contains("wlan")) 519 if(i->getInterfaceName().contains("wlan"))
520 typeName = "wlan"; 520 typeName = "wlan";
521 if(i->getInterfaceName().contains("usb")) 521 if(i->getInterfaceName().contains("usb"))
522 typeName = "usb"; 522 typeName = "usb";
523 523
524 if(!i->isAttached()) 524 if(!i->isAttached())
525 typeName = "connect_no"; 525 typeName = "connect_no";
526 // Actually try to use the Module 526 // Actually try to use the Module
527 if(i->getModuleOwner() != NULL) 527 if(i->getModuleOwner() != NULL)
528 typeName = i->getModuleOwner()->getPixmapName(i); 528 typeName = i->getModuleOwner()->getPixmapName(i);
529 529
530#ifdef QWS 530#ifdef QWS
531 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); 531 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
532#else 532#else
533 item->setPixmap(1, (SmallIcon(typeName))); 533 item->setPixmap(1, (SmallIcon(typeName)));
534#endif 534#endif
535 item->setText(2, i->getHardwareName()); 535 item->setText(2, i->getHardwareName());
536 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 536 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
537 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 537 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
538} 538}
539 539
540void MainWindowImp::newProfileChanged(const QString& newText){ 540void MainWindowImp::newProfileChanged(const QString& newText){
541 if(newText.length() > 0) 541 if(newText.length() > 0)
542 newProfileButton->setEnabled(true); 542 newProfileButton->setEnabled(true);
543 else 543 else
544 newProfileButton->setEnabled(false); 544 newProfileButton->setEnabled(false);
545} 545}
546 546
547/** 547/**
548 * Adds a new profile to the list of profiles. 548 * Adds a new profile to the list of profiles.
549 * Don't add profiles that already exists. 549 * Don't add profiles that already exists.
550 * Appends to the list and QStringList 550 * Appends to the list and QStringList
551 */ 551 */
552void MainWindowImp::addProfile(){ 552void MainWindowImp::addProfile(){
553 QString newProfileName = newProfile->text(); 553 QString newProfileName = newProfile->text();
554 if(profiles.grep(newProfileName).count() > 0){ 554 if(profiles.grep(newProfileName).count() > 0){
555 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); 555 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
556 return; 556 return;
557 } 557 }
558 profiles.append(newProfileName); 558 profiles.append(newProfileName);
559 profilesList->insertItem(newProfileName); 559 profilesList->insertItem(newProfileName);
560} 560}
561 561
562/** 562/**
563 * Removes the currently selected profile in the combo. 563 * Removes the currently selected profile in the combo.
564 * Doesn't delete if there are less then 2 profiles. 564 * Doesn't delete if there are less then 2 profiles.
565 */ 565 */
566void MainWindowImp::removeProfile(){ 566void MainWindowImp::removeProfile(){
567 if(profilesList->count() <= 1){ 567 if(profilesList->count() <= 1){
568 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); 568 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
569 return; 569 return;
570 } 570 }
571 QString profileToRemove = profilesList->currentText(); 571 QString profileToRemove = profilesList->currentText();
572 if(profileToRemove == "All"){ 572 if(profileToRemove == "All"){
573 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); 573 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
574 return; 574 return;
575 } 575 }
576 // Can't remove the curent profile 576 // Can't remove the curent profile
577 if(profileToRemove == currentProfileLabel->text()){ 577 if(profileToRemove == currentProfileLabel->text()){
578 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); 578 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
579 return; 579 return;
580 580
581 } 581 }
582 582
583 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 583 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
584 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 584 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
585 profilesList->clear(); 585 profilesList->clear();
586 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 586 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
587 profilesList->insertItem((*it)); 587 profilesList->insertItem((*it));
588 588
589 // Remove any interface settings and mappings. 589 // Remove any interface settings and mappings.
590 Interfaces interfaces; 590 Interfaces interfaces;
591 // Go through them one by one 591 // Go through them one by one
592 QMap<Interface*, QListViewItem*>::Iterator it; 592 QMap<Interface*, QListViewItem*>::Iterator it;
593 for( it = items.begin(); it != items.end(); ++it ){ 593 for( it = items.begin(); it != items.end(); ++it ){
594 QString interfaceName = it.key()->getInterfaceName(); 594 QString interfaceName = it.key()->getInterfaceName();
595 qDebug(interfaceName.latin1()); 595 qDebug(interfaceName.latin1());
596 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 596 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
597 interfaces.removeInterface(); 597 interfaces.removeInterface();
598 if(interfaces.setMapping(interfaceName)){ 598 if(interfaces.setMapping(interfaceName)){
599 if(profilesList->count() == 1) 599 if(profilesList->count() == 1)
600 interfaces.removeMapping(); 600 interfaces.removeMapping();
601 else{ 601 else{
602 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 602 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
603 } 603 }
604 } 604 }
605 interfaces.write(); 605 interfaces.write();
606 break; 606 break;
607 } 607 }
608 } 608 }
609 } 609 }
610} 610}
611 611
612/** 612/**
613 * A new profile has been selected, change. 613 * A new profile has been selected, change.
614 * @param newProfile the new profile. 614 * @param newProfile the new profile.
615 */ 615 */
616void MainWindowImp::changeProfile(){ 616void MainWindowImp::changeProfile(){
617 if(profilesList->currentItem() == -1){ 617 if(profilesList->currentItem() == -1){
618 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); 618 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
619 return; 619 return;
620 } 620 }
621 QString newProfile = profilesList->text(profilesList->currentItem()); 621 QString newProfile = profilesList->text(profilesList->currentItem());
622 if(newProfile != currentProfileLabel->text()){ 622 if(newProfile != currentProfileLabel->text()){
623 currentProfileLabel->setText(newProfile); 623 currentProfileLabel->setText(newProfile);
624 QFile::remove(scheme); 624 QFile::remove(scheme);
625 QFile file(scheme); 625 QFile file(scheme);
626 if ( file.open(IO_ReadWrite) ) { 626 if ( file.open(IO_ReadWrite) ) {
627 QTextStream stream( &file ); 627 QTextStream stream( &file );
628 stream << QString("SCHEME=%1").arg(newProfile); 628 stream << QString("SCHEME=%1").arg(newProfile);
629 file.close(); 629 file.close();
630 } 630 }
631 // restart all up devices? 631 // restart all up devices?
632 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 632 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
633 // Go through them one by one 633 // Go through them one by one
634 QMap<Interface*, QListViewItem*>::Iterator it; 634 QMap<Interface*, QListViewItem*>::Iterator it;
635 for( it = items.begin(); it != items.end(); ++it ){ 635 for( it = items.begin(); it != items.end(); ++it ){
636 if(it.key()->getStatus() == true) 636 if(it.key()->getStatus() == true)
637 it.key()->restart(); 637 it.key()->restart();
638 } 638 }
639 } 639 }
640 } 640 }
641 // TODO change the profile in the modules 641 // TODO change the profile in the modules
642} 642}
643 643
644 644
645void MainWindowImp::makeChannel() 645void MainWindowImp::makeChannel()
646{ 646{
647 channel = new QCopChannel( "QPE/Application/networksettings", this ); 647 channel = new QCopChannel( "QPE/Application/networksettings", this );
648 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 648 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
649 this, SLOT(receive(const QCString&, const QByteArray&)) ); 649 this, SLOT(receive(const QCString&, const QByteArray&)) );
650} 650}
651 651
652void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) 652void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
653{ 653{
654 bool found = false; 654 bool found = false;
655 qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); 655 qDebug("MainWindowImp::receive QCop msg >"+msg+"<");
656 if (msg == "raise") { 656 if (msg == "raise") {
657 raise(); 657 raise();
658 return; 658 return;
659 } 659 }
660 660
661 QString dest = msg.left(msg.find("(")); 661 QString dest = msg.left(msg.find("("));
662 QCString param = msg.right(msg.length() - msg.find("(") - 1); 662 QCString param = msg.right(msg.length() - msg.find("(") - 1);
663 param = param.left( param.length() - 1 ); 663 param = param.left( param.length() - 1 );
664 qDebug("dest >%s< param >"+param+"<",dest.latin1()); 664 qDebug("dest >%s< param >"+param+"<",dest.latin1());
665 665
666 QMap<Module*, QLibrary*>::Iterator it; 666 QMap<Module*, QLibrary*>::Iterator it;
667 for( it = libraries.begin(); it != libraries.end(); ++it ){ 667 for( it = libraries.begin(); it != libraries.end(); ++it ){
668 qDebug("plugin >%s<", it.key()->type().latin1() ); 668 qDebug("plugin >%s<", it.key()->type().latin1() );
669 if(it.key()->type() == dest){ 669 if(it.key()->type() == dest){
670 it.key()->receive( param, arg ); 670 it.key()->receive( param, arg );
671 found = true; 671 found = true;
672 } 672 }
673 } 673 }
674 674
675 675
676 if (found) QPEApplication::setKeepRunning(); 676 if (found) QPEApplication::setKeepRunning();
677 else qDebug("Huh what do ya want"); 677 else qDebug("Huh what do ya want");
678} 678}
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