summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp44
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h140
-rw-r--r--noncore/settings/networksettings/module.h12
-rw-r--r--noncore/settings/networksettings/networksettings.pro5
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.h2
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp72
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.h3
7 files changed, 191 insertions, 87 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 4119490..0ef1e68 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,626 +1,666 @@
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 <qtabwidget.h> // in order to disable the profiles tab 15#include <qtabwidget.h> // in order to disable the profiles tab
15 16
16#include <qmessagebox.h> 17#include <qmessagebox.h>
17 18
18#ifdef QWS 19#ifdef QWS
19 #include <qpe/config.h> 20 #include <qpe/config.h>
20 #include <qpe/qlibrary.h> 21 #include <qpe/qlibrary.h>
21 #include <qpe/resource.h> 22 #include <qpe/resource.h>
22 #include <qpe/qpeapplication.h> 23 #include <qpe/qpeapplication.h>
23#else 24#else
24 #include <klibloader.h> 25 #include <klibloader.h>
25 #define QLibrary KLibrary 26 #define QLibrary KLibrary
26 #include <kconfig.h> 27 #include <kconfig.h>
27 #define Config KConfig 28 #define Config KConfig
28 #include <kapplication.h> 29 #include <kapplication.h>
29 #include <kstandarddirs.h> 30 #include <kstandarddirs.h>
30 #include <kiconloader.h> 31 #include <kiconloader.h>
31 #define showMaximized show 32 #define showMaximized show
32#endif 33#endif
33 34
34#if QT_VERSION < 300 35#if QT_VERSION < 300
35#include <qlist.h> 36#include <qlist.h>
36#else 37#else
37#include <qptrlist.h> 38#include <qptrlist.h>
38#endif 39#endif
39#include <qdir.h> 40#include <qdir.h>
40#include <qfile.h> 41#include <qfile.h>
41#include <qtextstream.h> 42#include <qtextstream.h>
42#include <qregexp.h> 43#include <qregexp.h>
43 44
44#include <net/if.h> 45#include <net/if.h>
45#include <sys/ioctl.h> 46#include <sys/ioctl.h>
46#include <sys/socket.h> 47#include <sys/socket.h>
47 48
48#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 49#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
49#define _PROCNETDEV "/proc/net/dev" 50#define _PROCNETDEV "/proc/net/dev"
50 51
51MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ 52MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){
52 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 53 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
53 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 54 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
54 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 55 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
55 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 56 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
56 57
57 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 58 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
58 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 59 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
59 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 60 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
60 61
61 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 62 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
62 63
63 //FIXME: disable profiles for the moment: 64 //FIXME: disable profiles for the moment:
64 tabWidget->setTabEnabled( tab, false ); 65// tabWidget->setTabEnabled( tab, false );
65 66
66 // Load connections. 67 // Load connections.
67 // /usr/local/kde/lib/libinterfaces.la 68 // /usr/local/kde/lib/libinterfaces.la
68#ifdef QWS 69#ifdef QWS
69 loadModules(QPEApplication::qpeDir() + "/plugins/networksettings"); 70 loadModules(QPEApplication::qpeDir() + "/plugins/networksettings");
70#else 71#else
71 loader = KLibLoader::self(); 72 loader = KLibLoader::self();
72 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); 73 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
73#endif 74#endif
74 getAllInterfaces(); 75 getAllInterfaces();
75 76
76 Interfaces i; 77 Interfaces i;
77 QStringList list = i.getInterfaceList(); 78 QStringList list = i.getInterfaceList();
78 QMap<QString, Interface*>::Iterator it; 79 QMap<QString, Interface*>::Iterator it;
79 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 80 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
80 bool found = false; 81 bool found = false;
81 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 82 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
82 if(it.key() == (*ni)) 83 if(it.key() == (*ni))
83 found = true; 84 found = true;
84 } 85 }
85 if(!found){ 86 if(!found){
86 if(!(*ni).contains("_")){ 87 if(!(*ni).contains("_")){
87 Interface *i = new Interface(this, *ni, false); 88 Interface *i = new Interface(this, *ni, false);
88 i->setAttached(false); 89 i->setAttached(false);
89 i->setHardwareName(tr("Disconnected")); 90 i->setHardwareName(tr("Disconnected"));
90 interfaceNames.insert(i->getInterfaceName(), i); 91 interfaceNames.insert(i->getInterfaceName(), i);
91 updateInterface(i); 92 updateInterface(i);
92 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 93 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
93 } 94 }
94 } 95 }
95 } 96 }
96 97
97 //getInterfaceList(); 98 //getInterfaceList();
98 connectionList->header()->hide(); 99 connectionList->header()->hide();
99 100
100 Config cfg("NetworkSetup"); 101 Config cfg("NetworkSetup");
101 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 102 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
102 for ( QStringList::Iterator it = profiles.begin(); 103 for ( QStringList::Iterator it = profiles.begin();
103 it != profiles.end(); ++it) 104 it != profiles.end(); ++it)
104 profilesList->insertItem((*it)); 105 profilesList->insertItem((*it));
105 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 106 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
106 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 107 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
107 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); 108 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
108 109
109 QFile file(scheme); 110 QFile file(scheme);
110 if ( file.open(IO_ReadOnly) ) { // file opened successfully 111 if ( file.open(IO_ReadOnly) ) { // file opened successfully
111 QTextStream stream( &file ); // use a text stream 112 QTextStream stream( &file ); // use a text stream
112 while ( !stream.eof() ) { // until end of file... 113 while ( !stream.eof() ) { // until end of file...
113 QString line = stream.readLine(); // line of text excluding '\n' 114 QString line = stream.readLine(); // line of text excluding '\n'
114 if(line.contains("SCHEME")){ 115 if(line.contains("SCHEME")){
115 line = line.mid(7, line.length()); 116 line = line.mid(7, line.length());
116 currentProfileLabel->setText(line); 117 currentProfileLabel->setText(line);
117 break; 118 break;
118 } 119 }
119 } 120 }
120 file.close(); 121 file.close();
121 } 122 }
123 makeChannel();
122} 124}
123 125
124/** 126/**
125 * Deconstructor. Save profiles. Delete loaded libraries. 127 * Deconstructor. Save profiles. Delete loaded libraries.
126 */ 128 */
127MainWindowImp::~MainWindowImp(){ 129MainWindowImp::~MainWindowImp(){
128 // Save profiles. 130 // Save profiles.
129 Config cfg("NetworkSetup"); 131 Config cfg("NetworkSetup");
130 cfg.setGroup("General"); 132 cfg.setGroup("General");
131 cfg.writeEntry("Profiles", profiles.join(" ")); 133 cfg.writeEntry("Profiles", profiles.join(" "));
132 134
133 // Delete all interfaces that don't have owners. 135 // Delete all interfaces that don't have owners.
134 QMap<Interface*, QListViewItem*>::Iterator iIt; 136 QMap<Interface*, QListViewItem*>::Iterator iIt;
135 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 137 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
136 if(iIt.key()->getModuleOwner() == NULL) 138 if(iIt.key()->getModuleOwner() == NULL)
137 delete iIt.key(); 139 delete iIt.key();
138 } 140 }
139 141
140#ifdef QWS 142#ifdef QWS
141 // Delete Modules and Libraries 143 // Delete Modules and Libraries
142 QMap<Module*, QLibrary*>::Iterator it; 144 QMap<Module*, QLibrary*>::Iterator it;
143 for( it = libraries.begin(); it != libraries.end(); ++it ){ 145 for( it = libraries.begin(); it != libraries.end(); ++it ){
144 delete it.key(); 146 delete it.key();
145 // I wonder why I can't delete the libraries 147 // I wonder why I can't delete the libraries
146 // What fucking shit this is. 148 // What fucking shit this is.
147 //delete it.data(); 149 //delete it.data();
148 } 150 }
149#else 151#else
150 // klibloader automaticly deletes the libraries for us... 152 // klibloader automaticly deletes the libraries for us...
151#endif 153#endif
152} 154}
153 155
154/** 156/**
155 * Query the kernel for all of the interfaces. 157 * Query the kernel for all of the interfaces.
156 */ 158 */
157void MainWindowImp::getAllInterfaces(){ 159void MainWindowImp::getAllInterfaces(){
158 int sockfd = socket(PF_INET, SOCK_DGRAM, 0); 160 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
159 if(sockfd == -1) 161 if(sockfd == -1)
160 return; 162 return;
161 163
162 struct ifreq ifr; 164 struct ifreq ifr;
163 QStringList ifaces; 165 QStringList ifaces;
164 QFile procFile(QString(_PROCNETDEV)); 166 QFile procFile(QString(_PROCNETDEV));
165 int result; 167 int result;
166 Interface *i; 168 Interface *i;
167 169
168 if (! procFile.exists()) { 170 if (! procFile.exists()) {
169 struct ifreq ifrs[100]; 171 struct ifreq ifrs[100];
170 struct ifconf ifc; 172 struct ifconf ifc;
171 ifc.ifc_len = sizeof(ifrs); 173 ifc.ifc_len = sizeof(ifrs);
172 ifc.ifc_req = ifrs; 174 ifc.ifc_req = ifrs;
173 result = ioctl(sockfd, SIOCGIFCONF, &ifc); 175 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
174 176
175 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { 177 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) {
176 struct ifreq *pifr = &ifrs[i]; 178 struct ifreq *pifr = &ifrs[i];
177 179
178 ifaces += pifr->ifr_name; 180 ifaces += pifr->ifr_name;
179 } 181 }
180 } else { 182 } else {
181 procFile.open(IO_ReadOnly); 183 procFile.open(IO_ReadOnly);
182 QString line; 184 QString line;
183 QTextStream procTs(&procFile); 185 QTextStream procTs(&procFile);
184 int loc = -1; 186 int loc = -1;
185 187
186 procTs.readLine(); // eat a line 188 procTs.readLine(); // eat a line
187 procTs.readLine(); // eat a line 189 procTs.readLine(); // eat a line
188 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 190 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
189 if((loc = line.find(":")) != -1) { 191 if((loc = line.find(":")) != -1) {
190 ifaces += line.left(loc); 192 ifaces += line.left(loc);
191 } 193 }
192 } 194 }
193 } 195 }
194 196
195 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 197 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
196 int flags = 0, family; 198 int flags = 0;
199// int family;
197 i = NULL; 200 i = NULL;
198 201
199 strcpy(ifr.ifr_name, (*it).latin1()); 202 strcpy(ifr.ifr_name, (*it).latin1());
200 203
201 struct ifreq ifcopy; 204 struct ifreq ifcopy;
202 ifcopy = ifr; 205 ifcopy = ifr;
203 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 206 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
204 flags = ifcopy.ifr_flags; 207 flags = ifcopy.ifr_flags;
205 i = new Interface(this, ifr.ifr_name, false); 208 i = new Interface(this, ifr.ifr_name, false);
206 i->setAttached(true); 209 i->setAttached(true);
207 if ((flags & IFF_UP) == IFF_UP) 210 if ((flags & IFF_UP) == IFF_UP)
208 i->setStatus(true); 211 i->setStatus(true);
209 else 212 else
210 i->setStatus(false); 213 i->setStatus(false);
211 214
212 if ((flags & IFF_BROADCAST) == IFF_BROADCAST) 215 if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
213 i->setHardwareName("Ethernet"); 216 i->setHardwareName("Ethernet");
214 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) 217 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
215 i->setHardwareName("Point to Point"); 218 i->setHardwareName("Point to Point");
216 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) 219 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
217 i->setHardwareName("Multicast"); 220 i->setHardwareName("Multicast");
218 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 221 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
219 i->setHardwareName("Loopback"); 222 i->setHardwareName("Loopback");
220 else 223 else
221 i->setHardwareName("Unknown"); 224 i->setHardwareName("Unknown");
222 225
223 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); 226 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
224 interfaceNames.insert(i->getInterfaceName(), i); 227 interfaceNames.insert(i->getInterfaceName(), i);
225 updateInterface(i); 228 updateInterface(i);
226 connect(i, SIGNAL(updateInterface(Interface *)), 229 connect(i, SIGNAL(updateInterface(Interface *)),
227 this, SLOT(updateInterface(Interface *))); 230 this, SLOT(updateInterface(Interface *)));
228 } 231 }
229 // now lets ask the plugins too ;) 232 // now lets ask the plugins too ;)
230 QMap<Module*, QLibrary*>::Iterator it; 233 QMap<Module*, QLibrary*>::Iterator it;
231 QList<Interface> ilist; 234 QList<Interface> ilist;
232 for( it = libraries.begin(); it != libraries.end(); ++it ){ 235 for( it = libraries.begin(); it != libraries.end(); ++it ){
233 if(it.key()){ 236 if(it.key()){
234 ilist = it.key()->getInterfaces(); 237 ilist = it.key()->getInterfaces();
235 for( i = ilist.first(); i != 0; i = ilist.next() ){ 238 for( i = ilist.first(); i != 0; i = ilist.next() ){
236 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); 239 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
237 interfaceNames.insert(i->getInterfaceName(), i); 240 interfaceNames.insert(i->getInterfaceName(), i);
238 updateInterface(i); 241 updateInterface(i);
239 connect(i, SIGNAL(updateInterface(Interface *)), 242 connect(i, SIGNAL(updateInterface(Interface *)),
240 this, SLOT(updateInterface(Interface *))); 243 this, SLOT(updateInterface(Interface *)));
241 } 244 }
242 } 245 }
243 } 246 }
244} 247}
245 248
246/** 249/**
247 * Load all modules that are found in the path 250 * Load all modules that are found in the path
248 * @param path a directory that is scaned for any plugins that can be loaded 251 * @param path a directory that is scaned for any plugins that can be loaded
249 * and attempts to load them 252 * and attempts to load them
250 */ 253 */
251void MainWindowImp::loadModules(const QString &path){ 254void MainWindowImp::loadModules(const QString &path){
252#ifdef DEBUG 255#ifdef DEBUG
253 qDebug("MainWindowImp::loadModules: %s", path.latin1()); 256 qDebug("MainWindowImp::loadModules: %s", path.latin1());
254#endif 257#endif
255 QDir d(path); 258 QDir d(path);
256 if(!d.exists()) 259 if(!d.exists())
257 return; 260 return;
258 261
259 // Don't want sym links 262 // Don't want sym links
260 d.setFilter( QDir::Files | QDir::NoSymLinks ); 263 d.setFilter( QDir::Files | QDir::NoSymLinks );
261 const QFileInfoList *list = d.entryInfoList(); 264 const QFileInfoList *list = d.entryInfoList();
262 QFileInfoListIterator it( *list ); 265 QFileInfoListIterator it( *list );
263 QFileInfo *fi; 266 QFileInfo *fi;
264 while ( (fi=it.current()) ) { 267 while ( (fi=it.current()) ) {
265#ifdef QWS 268#ifdef QWS
266 if(fi->fileName().contains(".so")){ 269 if(fi->fileName().contains(".so")){
267#else 270#else
268 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ 271 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){
269#endif 272#endif
270 loadPlugin(path + "/" + fi->fileName()); 273 loadPlugin(path + "/" + fi->fileName());
271 qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); 274 qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1());
272 } 275 }
273 ++it; 276 ++it;
274 } 277 }
275} 278}
276 279
277/** 280/**
278 * Attempt to load a function and resolve a function. 281 * Attempt to load a function and resolve a function.
279 * @param pluginFileName - the name of the file in which to attempt to load 282 * @param pluginFileName - the name of the file in which to attempt to load
280 * @param resolveString - function pointer to resolve 283 * @param resolveString - function pointer to resolve
281 * @return pointer to the function with name resolveString or NULL 284 * @return pointer to the function with name resolveString or NULL
282 */ 285 */
283Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ 286Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
284#ifdef DEBUG 287#ifdef DEBUG
285 qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); 288 qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1());
286#endif 289#endif
287#ifdef QWS 290#ifdef QWS
288 QLibrary *lib = new QLibrary(pluginFileName); 291 QLibrary *lib = new QLibrary(pluginFileName);
289 void *functionPointer = lib->resolve(resolveString); 292 void *functionPointer = lib->resolve(resolveString);
290 if( !functionPointer ){ 293 if( !functionPointer ){
291#ifdef DEBUG 294#ifdef DEBUG
292 qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); 295 qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1());
293#endif 296#endif
294 delete lib; 297 delete lib;
295 return NULL; 298 return NULL;
296 } 299 }
297 // Try to get an object. 300 // Try to get an object.
298 Module *object = ((Module* (*)()) functionPointer)(); 301 Module *object = ((Module* (*)()) functionPointer)();
299 if(object == NULL){ 302 if(object == NULL){
300#ifdef DEBUG 303#ifdef DEBUG
301 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 304 qDebug("MainWindowImp: Couldn't create object, but did load library!");
302#endif 305#endif
303 delete lib; 306 delete lib;
304 return NULL; 307 return NULL;
305 } 308 }
306 309
307 // Store for deletion later 310 // Store for deletion later
308 libraries.insert(object, lib); 311 libraries.insert(object, lib);
309 return object; 312 return object;
310 313
311#else 314#else
312 QLibrary *lib = loader->library(pluginFileName); 315 QLibrary *lib = loader->library(pluginFileName);
313 if( !lib || !lib->hasSymbol(resolveString) ){ 316 if( !lib || !lib->hasSymbol(resolveString) ){
314 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 317 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
315 return NULL; 318 return NULL;
316 } 319 }
317 // Try to get an object. 320 // Try to get an object.
318 Module *object = ((Module* (*)()) lib->symbol(resolveString))(); 321 Module *object = ((Module* (*)()) lib->symbol(resolveString))();
319 if(object == NULL){ 322 if(object == NULL){
320#ifdef DEBUG 323#ifdef DEBUG
321 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 324 qDebug("MainWindowImp: Couldn't create object, but did load library!");
322#endif 325#endif
323 return NULL; 326 return NULL;
324 } 327 }
325#ifdef DEBUG 328#ifdef DEBUG
326 qDebug("MainWindowImp::loadPlugin:: Found object, storing."); 329 qDebug("MainWindowImp::loadPlugin:: Found object, storing.");
327#endif 330#endif
328 // Store for deletion later 331 // Store for deletion later
329 libraries.insert(object, lib); 332 libraries.insert(object, lib);
330 return object; 333 return object;
331#endif 334#endif
332} 335}
333 336
334/** 337/**
335 * The Add button was clicked. Bring up the add dialog and if OK is hit 338 * The Add button was clicked. Bring up the add dialog and if OK is hit
336 * load the plugin and append it to the list 339 * load the plugin and append it to the list
337 */ 340 */
338void MainWindowImp::addClicked(){ 341void MainWindowImp::addClicked(){
339 QMap<Module*, QLibrary*>::Iterator it; 342 QMap<Module*, QLibrary*>::Iterator it;
340 QMap<QString, QString> list; 343 QMap<QString, QString> list;
341 QMap<QString, Module*> newInterfaceOwners; 344 QMap<QString, Module*> newInterfaceOwners;
342 345
343 for( it = libraries.begin(); it != libraries.end(); ++it ){ 346 for( it = libraries.begin(); it != libraries.end(); ++it ){
344 if(it.key()){ 347 if(it.key()){
345 (it.key())->possibleNewInterfaces(list); 348 (it.key())->possibleNewInterfaces(list);
346 } 349 }
347 } 350 }
348 // See if the list has anything that we can add. 351 // See if the list has anything that we can add.
349 if(list.count() == 0){ 352 if(list.count() == 0){
350 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); 353 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
351 return; 354 return;
352 } 355 }
353 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 356 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
354 addNewConnection.addConnections(list); 357 addNewConnection.addConnections(list);
355 addNewConnection.showMaximized(); 358 addNewConnection.showMaximized();
356 if(QDialog::Accepted == addNewConnection.exec()){ 359 if(QDialog::Accepted == addNewConnection.exec()){
357 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 360 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
358 if(!item) 361 if(!item)
359 return; 362 return;
360 363
361 for( it = libraries.begin(); it != libraries.end(); ++it ){ 364 for( it = libraries.begin(); it != libraries.end(); ++it ){
362 if(it.key()){ 365 if(it.key()){
363 Interface *i = (it.key())->addNewInterface(item->text(0)); 366 Interface *i = (it.key())->addNewInterface(item->text(0));
364 if(i){ 367 if(i){
365 qDebug("iface name %s",i->getInterfaceName().latin1()); 368 qDebug("iface name %s",i->getInterfaceName().latin1());
366 interfaceNames.insert(i->getInterfaceName(), i); 369 interfaceNames.insert(i->getInterfaceName(), i);
367 updateInterface(i); 370 updateInterface(i);
368 } 371 }
369 } 372 }
370 } 373 }
371 } 374 }
372} 375}
373 376
374/** 377/**
375 * Prompt the user to see if they really want to do this. 378 * Prompt the user to see if they really want to do this.
376 * If they do then remove from the list and unload. 379 * If they do then remove from the list and unload.
377 */ 380 */
378void MainWindowImp::removeClicked(){ 381void MainWindowImp::removeClicked(){
379 QListViewItem *item = connectionList->currentItem(); 382 QListViewItem *item = connectionList->currentItem();
380 if(!item) { 383 if(!item) {
381 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 384 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
382 return; 385 return;
383 } 386 }
384 387
385 Interface *i = interfaceItems[item]; 388 Interface *i = interfaceItems[item];
386 if(i->getModuleOwner() == NULL){ 389 if(i->getModuleOwner() == NULL){
387 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); 390 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
388 } 391 }
389 else{ 392 else{
390 if(!i->getModuleOwner()->remove(i)) 393 if(!i->getModuleOwner()->remove(i))
391 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); 394 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok);
392 else{ 395 else{
393 delete item; 396 delete item;
394// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); 397// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
395 } 398 }
396 } 399 }
397} 400}
398 401
399/** 402/**
400 * Pull up the configure about the currently selected interface. 403 * Pull up the configure about the currently selected interface.
401 * Report an error if no interface is selected. 404 * Report an error if no interface is selected.
402 * If the interface has a module owner then request its configure. 405 * If the interface has a module owner then request its configure.
403 */ 406 */
404void MainWindowImp::configureClicked(){ 407void MainWindowImp::configureClicked(){
405 QListViewItem *item = connectionList->currentItem(); 408 QListViewItem *item = connectionList->currentItem();
406 if(!item){ 409 if(!item){
407 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); 410 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok);
408 return; 411 return;
409 } 412 }
410 413
411 QString currentProfileText = currentProfileLabel->text(); 414 QString currentProfileText = currentProfileLabel->text();
412 if(currentProfileText.upper() == "ALL"); 415 if(currentProfileText.upper() == "ALL");
413 currentProfileText = ""; 416 currentProfileText = "";
414 417
415 Interface *i = interfaceItems[item]; 418 Interface *i = interfaceItems[item];
416 419
417 if(i->getModuleOwner()){ 420 if(i->getModuleOwner()){
418 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 421 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
419 if(moduleConfigure != NULL){ 422 if(moduleConfigure != NULL){
420 i->getModuleOwner()->setProfile(currentProfileText); 423 i->getModuleOwner()->setProfile(currentProfileText);
421 moduleConfigure->showMaximized(); 424 moduleConfigure->showMaximized();
422 return; 425 return;
423 } 426 }
424 } 427 }
425 428
426 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); 429 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose );
427 configure->setProfile(currentProfileText); 430 configure->setProfile(currentProfileText);
428 configure->showMaximized(); 431 configure->showMaximized();
429} 432}
430 433
431/** 434/**
432 * Pull up the information about the currently selected interface. 435 * Pull up the information about the currently selected interface.
433 * Report an error if no interface is selected. 436 * Report an error if no interface is selected.
434 * If the interface has a module owner then request its configure. 437 * If the interface has a module owner then request its configure.
435 */ 438 */
436void MainWindowImp::informationClicked(){ 439void MainWindowImp::informationClicked(){
437 QListViewItem *item = connectionList->currentItem(); 440 QListViewItem *item = connectionList->currentItem();
438 if(!item){ 441 if(!item){
439 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 442 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
440 return; 443 return;
441 } 444 }
442 445
443 Interface *i = interfaceItems[item]; 446 Interface *i = interfaceItems[item];
444// if(!i->isAttached()){ 447// if(!i->isAttached()){
445// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 448// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
446// return; 449// return;
447// } 450// }
448 451
449 if(i->getModuleOwner()){ 452 if(i->getModuleOwner()){
450 QWidget *moduleInformation = i->getModuleOwner()->information(i); 453 QWidget *moduleInformation = i->getModuleOwner()->information(i);
451 if(moduleInformation != NULL){ 454 if(moduleInformation != NULL){
452 moduleInformation->showMaximized(); 455 moduleInformation->showMaximized();
453#ifdef DEBUG 456#ifdef DEBUG
454 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); 457 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed.");
455#endif 458#endif
456 return; 459 return;
457 } 460 }
458 } 461 }
459 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); 462 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
460 information->showMaximized(); 463 information->showMaximized();
461} 464}
462 465
463/** 466/**
464 * Update this interface. If no QListViewItem exists create one. 467 * Update this interface. If no QListViewItem exists create one.
465 * @param Interface* pointer to the interface that needs to be updated. 468 * @param Interface* pointer to the interface that needs to be updated.
466 */ 469 */
467void MainWindowImp::updateInterface(Interface *i){ 470void MainWindowImp::updateInterface(Interface *i){
468 if(!advancedUserMode){ 471 if(!advancedUserMode){
469 if(i->getInterfaceName() == "lo") 472 if(i->getInterfaceName() == "lo")
470 return; 473 return;
471 } 474 }
472 475
473 QListViewItem *item = NULL; 476 QListViewItem *item = NULL;
474 477
475 // Find the interface, making it if needed. 478 // Find the interface, making it if needed.
476 if(items.find(i) == items.end()){ 479 if(items.find(i) == items.end()){
477 item = new QListViewItem(connectionList, "", "", ""); 480 item = new QListViewItem(connectionList, "", "", "");
478 // See if you can't find a module owner for this interface 481 // See if you can't find a module owner for this interface
479 QMap<Module*, QLibrary*>::Iterator it; 482 QMap<Module*, QLibrary*>::Iterator it;
480 for( it = libraries.begin(); it != libraries.end(); ++it ){ 483 for( it = libraries.begin(); it != libraries.end(); ++it ){
481 if(it.key()->isOwner(i)) 484 if(it.key()->isOwner(i))
482 i->setModuleOwner(it.key()); 485 i->setModuleOwner(it.key());
483 } 486 }
484 items.insert(i, item); 487 items.insert(i, item);
485 interfaceItems.insert(item, i); 488 interfaceItems.insert(item, i);
486 } 489 }
487 else 490 else
488 item = items[i]; 491 item = items[i];
489 492
490 // Update the icons and information 493 // Update the icons and information
491#ifdef QWS 494#ifdef QWS
492 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 495 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
493#else 496#else
494 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); 497 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
495#endif 498#endif
496 499
497 QString typeName = "lan"; 500 QString typeName = "lan";
498 if(i->getInterfaceName() == "lo") 501 if(i->getInterfaceName() == "lo")
499 typeName = "lo"; 502 typeName = "lo";
500 if(i->getInterfaceName().contains("irda")) 503 if(i->getInterfaceName().contains("irda"))
501 typeName = "irda"; 504 typeName = "irda";
502 if(i->getInterfaceName().contains("wlan")) 505 if(i->getInterfaceName().contains("wlan"))
503 typeName = "wlan"; 506 typeName = "wlan";
504 if(i->getInterfaceName().contains("usb")) 507 if(i->getInterfaceName().contains("usb"))
505 typeName = "usb"; 508 typeName = "usb";
506 509
507 if(!i->isAttached()) 510 if(!i->isAttached())
508 typeName = "connect_no"; 511 typeName = "connect_no";
509 // Actually try to use the Module 512 // Actually try to use the Module
510 if(i->getModuleOwner() != NULL) 513 if(i->getModuleOwner() != NULL)
511 typeName = i->getModuleOwner()->getPixmapName(i); 514 typeName = i->getModuleOwner()->getPixmapName(i);
512 515
513#ifdef QWS 516#ifdef QWS
514 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); 517 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
515#else 518#else
516 item->setPixmap(1, (SmallIcon(typeName))); 519 item->setPixmap(1, (SmallIcon(typeName)));
517#endif 520#endif
518 item->setText(2, i->getHardwareName()); 521 item->setText(2, i->getHardwareName());
519 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 522 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
520 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 523 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
521} 524}
522 525
523void MainWindowImp::newProfileChanged(const QString& newText){ 526void MainWindowImp::newProfileChanged(const QString& newText){
524 if(newText.length() > 0) 527 if(newText.length() > 0)
525 newProfileButton->setEnabled(true); 528 newProfileButton->setEnabled(true);
526 else 529 else
527 newProfileButton->setEnabled(false); 530 newProfileButton->setEnabled(false);
528} 531}
529 532
530/** 533/**
531 * Adds a new profile to the list of profiles. 534 * Adds a new profile to the list of profiles.
532 * Don't add profiles that already exists. 535 * Don't add profiles that already exists.
533 * Appends to the list and QStringList 536 * Appends to the list and QStringList
534 */ 537 */
535void MainWindowImp::addProfile(){ 538void MainWindowImp::addProfile(){
536 QString newProfileName = newProfile->text(); 539 QString newProfileName = newProfile->text();
537 if(profiles.grep(newProfileName).count() > 0){ 540 if(profiles.grep(newProfileName).count() > 0){
538 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); 541 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
539 return; 542 return;
540 } 543 }
541 profiles.append(newProfileName); 544 profiles.append(newProfileName);
542 profilesList->insertItem(newProfileName); 545 profilesList->insertItem(newProfileName);
543} 546}
544 547
545/** 548/**
546 * Removes the currently selected profile in the combo. 549 * Removes the currently selected profile in the combo.
547 * Doesn't delete if there are less then 2 profiles. 550 * Doesn't delete if there are less then 2 profiles.
548 */ 551 */
549void MainWindowImp::removeProfile(){ 552void MainWindowImp::removeProfile(){
550 if(profilesList->count() <= 1){ 553 if(profilesList->count() <= 1){
551 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); 554 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
552 return; 555 return;
553 } 556 }
554 QString profileToRemove = profilesList->currentText(); 557 QString profileToRemove = profilesList->currentText();
555 if(profileToRemove == "All"){ 558 if(profileToRemove == "All"){
556 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); 559 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
557 return; 560 return;
558 } 561 }
559 // Can't remove the curent profile 562 // Can't remove the curent profile
560 if(profileToRemove == currentProfileLabel->text()){ 563 if(profileToRemove == currentProfileLabel->text()){
561 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); 564 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
562 return; 565 return;
563 566
564 } 567 }
565 568
566 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 569 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
567 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 570 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
568 profilesList->clear(); 571 profilesList->clear();
569 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 572 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
570 profilesList->insertItem((*it)); 573 profilesList->insertItem((*it));
571 574
572 // Remove any interface settings and mappings. 575 // Remove any interface settings and mappings.
573 Interfaces interfaces; 576 Interfaces interfaces;
574 // Go through them one by one 577 // Go through them one by one
575 QMap<Interface*, QListViewItem*>::Iterator it; 578 QMap<Interface*, QListViewItem*>::Iterator it;
576 for( it = items.begin(); it != items.end(); ++it ){ 579 for( it = items.begin(); it != items.end(); ++it ){
577 QString interfaceName = it.key()->getInterfaceName(); 580 QString interfaceName = it.key()->getInterfaceName();
578 qDebug(interfaceName.latin1()); 581 qDebug(interfaceName.latin1());
579 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 582 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
580 interfaces.removeInterface(); 583 interfaces.removeInterface();
581 if(interfaces.setMapping(interfaceName)){ 584 if(interfaces.setMapping(interfaceName)){
582 if(profilesList->count() == 1) 585 if(profilesList->count() == 1)
583 interfaces.removeMapping(); 586 interfaces.removeMapping();
584 else{ 587 else{
585 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 588 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
586 } 589 }
587 } 590 }
588 interfaces.write(); 591 interfaces.write();
589 break; 592 break;
590 } 593 }
591 } 594 }
592 } 595 }
593} 596}
594 597
595/** 598/**
596 * A new profile has been selected, change. 599 * A new profile has been selected, change.
597 * @param newProfile the new profile. 600 * @param newProfile the new profile.
598 */ 601 */
599void MainWindowImp::changeProfile(){ 602void MainWindowImp::changeProfile(){
600 if(profilesList->currentItem() == -1){ 603 if(profilesList->currentItem() == -1){
601 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); 604 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
602 return; 605 return;
603 } 606 }
604 QString newProfile = profilesList->text(profilesList->currentItem()); 607 QString newProfile = profilesList->text(profilesList->currentItem());
605 if(newProfile != currentProfileLabel->text()){ 608 if(newProfile != currentProfileLabel->text()){
606 currentProfileLabel->setText(newProfile); 609 currentProfileLabel->setText(newProfile);
607 QFile::remove(scheme); 610 QFile::remove(scheme);
608 QFile file(scheme); 611 QFile file(scheme);
609 if ( file.open(IO_ReadWrite) ) { 612 if ( file.open(IO_ReadWrite) ) {
610 QTextStream stream( &file ); 613 QTextStream stream( &file );
611 stream << QString("SCHEME=%1").arg(newProfile); 614 stream << QString("SCHEME=%1").arg(newProfile);
612 file.close(); 615 file.close();
613 } 616 }
614 // restart all up devices? 617 // restart all up devices?
615 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 618 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
616 // Go through them one by one 619 // Go through them one by one
617 QMap<Interface*, QListViewItem*>::Iterator it; 620 QMap<Interface*, QListViewItem*>::Iterator it;
618 for( it = items.begin(); it != items.end(); ++it ){ 621 for( it = items.begin(); it != items.end(); ++it ){
619 if(it.key()->getStatus() == true) 622 if(it.key()->getStatus() == true)
620 it.key()->restart(); 623 it.key()->restart();
621 } 624 }
622 } 625 }
623 } 626 }
624 // TODO change the profile in the modules 627 // TODO change the profile in the modules
625} 628}
626 629
630
631void MainWindowImp::makeChannel()
632{
633 channel = new QCopChannel( "QPE/Application/networksettings", this );
634 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
635 this, SLOT(receive(const QCString&, const QByteArray&)) );
636}
637
638void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
639{
640 bool found = false;
641 qDebug("MainWindowImp::receive QCop msg >"+msg+"<");
642
643 QString dest = msg.left(msg.find("("));
644 QCString param = msg.right(msg.length() - msg.find("(") - 1);
645 param = param.left( param.length() - 1 );
646 qDebug("dest >%s< param >"+param+"<",dest.latin1());
647
648// if (param.contains("QString,QString,QString")) {
649// QDataStream stream(arg,IO_ReadOnly);
650// QString arg1, arg2, arg3;
651// stream >> arg1 >> arg2 >> arg3 ;
652// qDebug("args: >%s< >%s< >%s<",arg1.latin1(),arg2.latin1(),arg3.latin1());
653// }
654
655 QMap<Module*, QLibrary*>::Iterator it;
656 for( it = libraries.begin(); it != libraries.end(); ++it ){
657 qDebug("plugin >%s<", it.key()->type().latin1() );
658 if(it.key()->type() == dest){
659 it.key()->receive( param, arg );
660 found = true;
661 }
662 }
663
664
665 if (!found) qDebug("Huh what do ya want");
666}
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index c045fe6..a553f75 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,67 +1,73 @@
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;
12#ifdef QWS 12class QCopChannel;
13class QLibrary; 13#ifdef QWS
14#else 14class QLibrary;
15class KLibrary; 15#else
16class KLibLoader; 16class KLibrary;
17#define QLibrary KLibrary 17class KLibLoader;
18#endif 18#define QLibrary KLibrary
19 19#endif
20 20
21class MainWindowImp : public MainWindow { 21
22 Q_OBJECT 22class MainWindowImp : public MainWindow {
23 23 Q_OBJECT
24public: 24
25 MainWindowImp(QWidget *parent=0, const char *name=0); 25public:
26 ~MainWindowImp(); 26 MainWindowImp(QWidget *parent=0, const char *name=0);
27 27 ~MainWindowImp();
28private slots: 28
29 void getAllInterfaces(); 29 QCopChannel *channel;
30 30
31 void addClicked(); 31private slots:
32 void removeClicked(); 32 void getAllInterfaces();
33 void configureClicked(); 33
34 void informationClicked(); 34 void addClicked();
35 35 void removeClicked();
36 void addProfile(); 36 void configureClicked();
37 void removeProfile(); 37 void informationClicked();
38 void changeProfile(); 38
39 39 void addProfile();
40 void updateInterface(Interface *i); 40 void removeProfile();
41 void newProfileChanged(const QString& newText); 41 void changeProfile();
42 42
43private: 43 void updateInterface(Interface *i);
44 void loadModules(const QString &path); 44 void newProfileChanged(const QString& newText);
45 45
46 Module* loadPlugin(const QString &pluginFileName, 46 void receive (const QCString &, const QByteArray &);
47 const QString &resolveString = "create_plugin"); 47
48 48private:
49 // For our local list of names 49 void makeChannel();
50 QMap<QString, Interface*> interfaceNames; 50 void loadModules(const QString &path);
51 51
52 QMap<Module*, QLibrary*> libraries; 52 Module* loadPlugin(const QString &pluginFileName,
53 QMap<Interface*, QListViewItem*> items; 53 const QString &resolveString = "create_plugin");
54 QMap<QListViewItem*, Interface*> interfaceItems; 54
55 55 // For our local list of names
56 QMap<KProcess*, QString> threads; 56 QMap<QString, Interface*> interfaceNames;
57 QStringList profiles; 57
58 58 QMap<Module*, QLibrary*> libraries;
59 bool advancedUserMode; 59 QMap<Interface*, QListViewItem*> items;
60 QString scheme; 60 QMap<QListViewItem*, Interface*> interfaceItems;
61#ifndef QWS 61
62 KLibLoader *loader; 62 QMap<KProcess*, QString> threads;
63#endif 63 QStringList profiles;
64}; 64
65 65 bool advancedUserMode;
66#endif // MAINWINOWIMP_H 66 QString scheme;
67 67#ifndef QWS
68 KLibLoader *loader;
69#endif
70};
71
72#endif // MAINWINOWIMP_H
73
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h
index 46a3c77..db74394 100644
--- a/noncore/settings/networksettings/module.h
+++ b/noncore/settings/networksettings/module.h
@@ -1,90 +1,102 @@
1#ifndef NETCONF_MODULE_H 1#ifndef NETCONF_MODULE_H
2#define NETCONF_MODULE_H 2#define NETCONF_MODULE_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#if QT_VERSION < 300 5#if QT_VERSION < 300
6#include <qlist.h> 6#include <qlist.h>
7#else 7#else
8#include <qptrlist.h> 8#include <qptrlist.h>
9#endif 9#endif
10#include <qmap.h> 10#include <qmap.h>
11#include "interface.h" 11#include "interface.h"
12 12
13class QWidget; 13class QWidget;
14class QTabWidget; 14class QTabWidget;
15 15
16class Module : QObject{ 16class Module : QObject{
17 17
18signals: 18signals:
19 void updateInterface(Interface *i); 19 void updateInterface(Interface *i);
20
20 21
21public: 22public:
22 Module(){}; 23 Module(){};
23 24
24 /** 25 /**
26 * The type of the plugin
27 * and the name of the dcop call
28 */
29 virtual const QString type() = 0;
30
31 /**
25 * The current profile has been changed and the module should do any 32 * The current profile has been changed and the module should do any
26 * neccesary changes also. 33 * neccesary changes also.
27 * @param newProfile what the profile should be changed to. 34 * @param newProfile what the profile should be changed to.
28 */ 35 */
29 virtual void setProfile(const QString &newProfile) = 0; 36 virtual void setProfile(const QString &newProfile) = 0;
30 37
31 /** 38 /**
32 * get the icon name for this device. 39 * get the icon name for this device.
33 * @param Interface* can be used in determining the icon. 40 * @param Interface* can be used in determining the icon.
34 * @return QString the icon name (minus .png, .gif etc) 41 * @return QString the icon name (minus .png, .gif etc)
35 */ 42 */
36 virtual QString getPixmapName(Interface *) = 0; 43 virtual QString getPixmapName(Interface *) = 0;
37 44
38 /** 45 /**
39 * Check to see if the interface i is owned by this module. 46 * Check to see if the interface i is owned by this module.
40 * @param Interface* interface to check against 47 * @param Interface* interface to check against
41 * @return bool true if i is owned by this module, false otherwise. 48 * @return bool true if i is owned by this module, false otherwise.
42 */ 49 */
43 virtual bool isOwner(Interface *){ return false; }; 50 virtual bool isOwner(Interface *){ return false; };
44 51
45 /** 52 /**
46 * Create and return the WLANConfigure Module 53 * Create and return the WLANConfigure Module
47 * @param Interface *i the interface to configure. 54 * @param Interface *i the interface to configure.
48 * @return QWidget* pointer to this modules configure. 55 * @return QWidget* pointer to this modules configure.
49 */ 56 */
50 virtual QWidget *configure(Interface *){ return NULL; } ; 57 virtual QWidget *configure(Interface *){ return NULL; } ;
51 58
52 /** 59 /**
53 * Create, and return the Information Module 60 * Create, and return the Information Module
54 * @param Interface *i the interface to get info on. 61 * @param Interface *i the interface to get info on.
55 * @return QWidget* pointer to this modules info. 62 * @return QWidget* pointer to this modules info.
56 */ 63 */
57 virtual QWidget *information(Interface *){ return NULL; }; 64 virtual QWidget *information(Interface *){ return NULL; };
58 65
59 /** 66 /**
60 * Get all active (up or down) interfaces 67 * Get all active (up or down) interfaces
61 * @return QList<Interface> A list of interfaces that exsist that havn't 68 * @return QList<Interface> A list of interfaces that exsist that havn't
62 * been called by isOwner() 69 * been called by isOwner()
63 */ 70 */
64 virtual QList<Interface> getInterfaces() = 0; 71 virtual QList<Interface> getInterfaces() = 0;
65 72
66 /** 73 /**
67 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), 74 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
68 * modem ppp) 75 * modem ppp)
69 */ 76 */
70 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; 77 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
71 78
72 /** 79 /**
73 * Attempts to create a new interface from name 80 * Attempts to create a new interface from name
74 * @return Interface* NULL if it was unable to be created. 81 * @return Interface* NULL if it was unable to be created.
75 * @param name the type of interface to create 82 * @param name the type of interface to create
76 */ 83 */
77 virtual Interface *addNewInterface(const QString &name) = 0; 84 virtual Interface *addNewInterface(const QString &name) = 0;
78 85
79 /** 86 /**
80 * Attempts to remove the interface, doesn't delete i 87 * Attempts to remove the interface, doesn't delete i
81 * @return bool true if successfull, false otherwise. 88 * @return bool true if successfull, false otherwise.
82 */ 89 */
83 virtual bool remove(Interface* i) = 0; 90 virtual bool remove(Interface* i) = 0;
84 91
92 /**
93 * get dcop calls
94 */
95 virtual void receive(const QCString &msg, const QByteArray &arg) = 0;
96
85}; 97};
86 98
87#endif 99#endif
88 100
89// module.h 101// module.h
90 102
diff --git a/noncore/settings/networksettings/networksettings.pro b/noncore/settings/networksettings/networksettings.pro
index 875c68e..cdd133a 100644
--- a/noncore/settings/networksettings/networksettings.pro
+++ b/noncore/settings/networksettings/networksettings.pro
@@ -1,15 +1,16 @@
1DESTDIR = $(OPIEDIR)/bin 1DESTDIR = $(OPIEDIR)/bin
2TEMPLATE = app 2TEMPLATE = app
3#CONFIG = qt warn_on debug 3#
4CONFIG = qt warn_on release 4CONFIG = qt warn_on debug
5#CONFIG = qt warn_on release
5HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h 6HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h
6SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp 7SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp
7INCLUDEPATH += $(OPIEDIR)/include interfaces/ 8INCLUDEPATH += $(OPIEDIR)/include interfaces/
8DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ 9DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/
9LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopie 10LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopie
10INTERFACES = mainwindow.ui addconnection.ui 11INTERFACES = mainwindow.ui addconnection.ui
11TARGET = networksettings 12TARGET = networksettings
12 13
13 14
14 15
15include ( $(OPIEDIR)/include.pro ) 16include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppmodule.h b/noncore/settings/networksettings/ppp/pppmodule.h
index 6464f87..de649e4 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.h
+++ b/noncore/settings/networksettings/ppp/pppmodule.h
@@ -1,41 +1,43 @@
1#ifndef PPP_MODULE_H 1#ifndef PPP_MODULE_H
2#define PPP_MODULE_H 2#define PPP_MODULE_H
3 3
4#include "module.h" 4#include "module.h"
5 5
6class PPPModule : Module { 6class PPPModule : Module {
7 7
8signals: 8signals:
9 void updateInterface(Interface *i); 9 void updateInterface(Interface *i);
10 10
11public: 11public:
12 PPPModule(); 12 PPPModule();
13 ~PPPModule(); 13 ~PPPModule();
14 14
15 virtual const QString type() {return "ppp";};
15 virtual void setProfile(const QString &newProfile); 16 virtual void setProfile(const QString &newProfile);
16 virtual bool isOwner(Interface *); 17 virtual bool isOwner(Interface *);
17 virtual QWidget *configure(Interface *i); 18 virtual QWidget *configure(Interface *i);
18 virtual QWidget *information(Interface *i); 19 virtual QWidget *information(Interface *i);
19 virtual QList<Interface> getInterfaces(); 20 virtual QList<Interface> getInterfaces();
20 virtual void possibleNewInterfaces(QMap<QString, QString> &); 21 virtual void possibleNewInterfaces(QMap<QString, QString> &);
21 virtual Interface *addNewInterface(const QString &name); 22 virtual Interface *addNewInterface(const QString &name);
22 virtual bool remove(Interface* i); 23 virtual bool remove(Interface* i);
23 virtual QString getPixmapName(Interface* i); 24 virtual QString getPixmapName(Interface* i);
25 virtual void receive(const QCString &msg, const QByteArray &arg) {};
24 26
25private: 27private:
26 QList<Interface> list; 28 QList<Interface> list;
27 QString profile; 29 QString profile;
28 30
29}; 31};
30 32
31extern "C" 33extern "C"
32{ 34{
33 void* create_plugin() { 35 void* create_plugin() {
34 return new PPPModule(); 36 return new PPPModule();
35 } 37 }
36}; 38};
37 39
38#endif 40#endif
39 41
40// pppmodule.h 42// pppmodule.h
41 43
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 3979e60..3c988d5 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,113 +1,153 @@
1#include "wlanmodule.h" 1#include "wlanmodule.h"
2#include "wlanimp.h" 2#include "wlanimp.h"
3#include "infoimp.h" 3#include "infoimp.h"
4#include "wextensions.h" 4#include "wextensions.h"
5#include "interfaceinformationimp.h" 5#include "interfaceinformationimp.h"
6 6
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qprogressbar.h> 8#include <qprogressbar.h>
9#include <qtabwidget.h> 9#include <qtabwidget.h>
10 10
11/** 11/**
12 * Constructor, find all of the possible interfaces 12 * Constructor, find all of the possible interfaces
13 */ 13 */
14WLANModule::WLANModule() : Module() { 14WLANModule::WLANModule() : Module() {
15} 15}
16 16
17/** 17/**
18 * Delete any interfaces that we own. 18 * Delete any interfaces that we own.
19 */ 19 */
20WLANModule::~WLANModule(){ 20WLANModule::~WLANModule(){
21 Interface *i; 21 Interface *i;
22 for ( i=list.first(); i != 0; i=list.next() ) 22 for ( i=list.first(); i != 0; i=list.next() )
23 delete i; 23 delete i;
24} 24}
25 25
26/** 26/**
27 * Change the current profile 27 * Change the current profile
28 */ 28 */
29void WLANModule::setProfile(const QString &newProfile){ 29void WLANModule::setProfile(const QString &newProfile){
30 profile = newProfile; 30 profile = newProfile;
31} 31}
32 32
33/** 33/**
34 * get the icon name for this device. 34 * get the icon name for this device.
35 * @param Interface* can be used in determining the icon. 35 * @param Interface* can be used in determining the icon.
36 * @return QString the icon name (minus .png, .gif etc) 36 * @return QString the icon name (minus .png, .gif etc)
37 */ 37 */
38QString WLANModule::getPixmapName(Interface* ){ 38QString WLANModule::getPixmapName(Interface* ){
39 return "wlan"; 39 return "wlan";
40} 40}
41 41
42/** 42/**
43 * Check to see if the interface i is owned by this module. 43 * Check to see if the interface i is owned by this module.
44 * @param Interface* interface to check against 44 * @param Interface* interface to check against
45 * @return bool true if i is owned by this module, false otherwise. 45 * @return bool true if i is owned by this module, false otherwise.
46 */ 46 */
47bool WLANModule::isOwner(Interface *i){ 47bool WLANModule::isOwner(Interface *i){
48 WExtensions we(i->getInterfaceName()); 48 WExtensions we(i->getInterfaceName());
49 if(!we.doesHaveWirelessExtensions()) 49 if(!we.doesHaveWirelessExtensions())
50 return false; 50 return false;
51 51
52 i->setHardwareName("802.11b"); 52 i->setHardwareName("802.11b");
53 list.append(i); 53 list.append(i);
54 return true; 54 return true;
55} 55}
56 56
57/** 57/**
58 * Create, and return the WLANConfigure Module 58 * Create, and return the WLANConfigure Module
59 * @return QWidget* pointer to this modules configure. 59 * @return QWidget* pointer to this modules configure.
60 */ 60 */
61QWidget *WLANModule::configure(Interface *i){ 61QWidget *WLANModule::configure(Interface *i){
62 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); 62 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose);
63 wlanconfig->setProfile(profile); 63 wlanconfig->setProfile(profile);
64 return wlanconfig; 64 return wlanconfig;
65} 65}
66 66
67/** 67/**
68 * Create, and return the Information Module 68 * Create, and return the Information Module
69 * @return QWidget* pointer to this modules info. 69 * @return QWidget* pointer to this modules info.
70 */ 70 */
71QWidget *WLANModule::information(Interface *i){ 71QWidget *WLANModule::information(Interface *i){
72 WExtensions we(i->getInterfaceName()); 72 WExtensions we(i->getInterfaceName());
73 if(!we.doesHaveWirelessExtensions()) 73 if(!we.doesHaveWirelessExtensions())
74 return NULL; 74 return NULL;
75 75
76 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 76 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
77 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); 77 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
78 info->tabWidget->insertTab(information, "TCP/IP"); 78 info->tabWidget->insertTab(information, "TCP/IP");
79 return info; 79 return info;
80} 80}
81 81
82/** 82/**
83 * Get all active (up or down) interfaces 83 * Get all active (up or down) interfaces
84 * @return QList<Interface> A list of interfaces that exsist that havn't 84 * @return QList<Interface> A list of interfaces that exsist that havn't
85 * been called by isOwner() 85 * been called by isOwner()
86 */ 86 */
87QList<Interface> WLANModule::getInterfaces(){ 87QList<Interface> WLANModule::getInterfaces(){
88 return list; 88 return list;
89} 89}
90 90
91/** 91/**
92 * Attempt to add a new interface as defined by name 92 * Attempt to add a new interface as defined by name
93 * @param name the name of the type of interface that should be created given 93 * @param name the name of the type of interface that should be created given
94 * by possibleNewInterfaces(); 94 * by possibleNewInterfaces();
95 * @return Interface* NULL if it was unable to be created. 95 * @return Interface* NULL if it was unable to be created.
96 */ 96 */
97Interface *WLANModule::addNewInterface(const QString &){ 97Interface *WLANModule::addNewInterface(const QString &){
98 // We can't add a 802.11 interface, either the hardware will be there 98 // We can't add a 802.11 interface, either the hardware will be there
99 // or it wont. 99 // or it wont.
100 return NULL; 100 return NULL;
101} 101}
102 102
103/** 103/**
104 * Attempts to remove the interface, doesn't delete i 104 * Attempts to remove the interface, doesn't delete i
105 * @return bool true if successfull, false otherwise. 105 * @return bool true if successfull, false otherwise.
106 */ 106 */
107bool WLANModule::remove(Interface*){ 107bool WLANModule::remove(Interface*){
108 // Can't remove a hardware device, you can stop it though. 108 // Can't remove a hardware device, you can stop it though.
109 return false; 109 return false;
110} 110}
111 111
112// wlanmodule.cpp 112void WLANModule::receive(const QCString &param, const QByteArray &arg)
113{
114 qDebug("WLANModule::receive "+param);
115 QStringList params = QStringList::split(",",param);
116 int count = params.count();
117 qDebug("got %i params", count );
118 if (count < 2){
119 qDebug("Erorr less than 2 parameter");
120 qDebug("RETURNING");
121 return;
122 }
123
124 QDataStream stream(arg,IO_ReadOnly);
125 QString interface;
126 QString action;
127
128 stream >> interface;
129 stream >> action;
130 qDebug("got interface %s and acion %s", interface.latin1(), action.latin1());
131
132 if (count == 2){
133 // those should call the interface
134 if ( action.contains("start" ) ){
135 qDebug("starting %s not yet implemented",interface.latin1());
136 } else if ( action.contains("restart" ) ){
137 qDebug("restarting %s not yet implemented",interface.latin1());
138 } else if ( action.contains("stop" ) ){
139 qDebug("stopping %s not yet implemented",interface.latin1());
140 }
141 }else if (count == 3){
142 QString value;
143 stream >> value;
144 qDebug("setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() );
145 }
146 // if (param.contains("QString,QString,QString")) {
147// QDataStream stream(arg,IO_ReadOnly);
148// QString arg1, arg2, arg3;
149// stream >> arg1 >> arg2 >> arg3 ;
150// qDebug("interface >%s< setting >%s< value >%s<",arg1.latin1(),arg2.latin1(),arg3.latin1());
151// }
152}
113 153
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h
index 3a54de6..a617a90 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.h
+++ b/noncore/settings/networksettings/wlan/wlanmodule.h
@@ -1,41 +1,44 @@
1#ifndef WLAN_MODULE_H 1#ifndef WLAN_MODULE_H
2#define WLAN_MODULE_H 2#define WLAN_MODULE_H
3 3
4#include "module.h" 4#include "module.h"
5 5
6class WLANModule : Module{ 6class WLANModule : Module{
7 7
8signals: 8signals:
9 void updateInterface(Interface *i); 9 void updateInterface(Interface *i);
10 10
11public: 11public:
12 WLANModule(); 12 WLANModule();
13 ~WLANModule(); 13 ~WLANModule();
14 14
15
16 virtual const QString type() {return "wlan";};
15 void setProfile(const QString &newProfile); 17 void setProfile(const QString &newProfile);
16 bool isOwner(Interface *); 18 bool isOwner(Interface *);
17 QWidget *configure(Interface *i); 19 QWidget *configure(Interface *i);
18 QWidget *information(Interface *i); 20 QWidget *information(Interface *i);
19 QList<Interface> getInterfaces(); 21 QList<Interface> getInterfaces();
20 void possibleNewInterfaces(QMap<QString, QString> &){}; 22 void possibleNewInterfaces(QMap<QString, QString> &){};
21 Interface *addNewInterface(const QString &name); 23 Interface *addNewInterface(const QString &name);
22 bool remove(Interface* i); 24 bool remove(Interface* i);
23 QString getPixmapName(Interface* i); 25 QString getPixmapName(Interface* i);
26 virtual void receive(const QCString&, const QByteArray&);
24 27
25private: 28private:
26 QList<Interface> list; 29 QList<Interface> list;
27 QString profile; 30 QString profile;
28 31
29}; 32};
30 33
31extern "C" 34extern "C"
32{ 35{
33 void* create_plugin() { 36 void* create_plugin() {
34 return new WLANModule(); 37 return new WLANModule();
35 } 38 }
36}; 39};
37 40
38#endif 41#endif
39 42
40// wlanmodule.h 43// wlanmodule.h
41 44