author | ar <ar> | 2004-02-21 18:32:37 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-21 18:32:37 (UTC) |
commit | 536f271b1e6a1d1886e96a28524a3503c4c38c4e (patch) (unidiff) | |
tree | 63b3c0ce472a89a0f9731195fececc701bf4ca67 /noncore/settings/networksettings/mainwindowimp.cpp | |
parent | db2afda83e495bff9fc19fa14a30072f1cd4c67a (diff) | |
download | opie-536f271b1e6a1d1886e96a28524a3503c4c38c4e.zip opie-536f271b1e6a1d1886e96a28524a3503c4c38c4e.tar.gz opie-536f271b1e6a1d1886e96a28524a3503c4c38c4e.tar.bz2 |
improve support for BigScreen
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 272 |
1 files changed, 171 insertions, 101 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index d9752ce..b0a1dd9 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -1,3 +1,4 @@ | |||
1 | |||
1 | #include "mainwindowimp.h" | 2 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 3 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
@@ -5,33 +6,23 @@ | |||
5 | #include "interfaces.h" | 6 | #include "interfaces.h" |
6 | #include "module.h" | 7 | #include "module.h" |
7 | 8 | ||
9 | /* OPIE */ | ||
10 | #include <qpe/qcopenvelope_qws.h> | ||
11 | #include <qpe/qpeapplication.h> | ||
12 | #include <qpe/config.h> | ||
13 | #include <qpe/qlibrary.h> | ||
14 | #include <qpe/resource.h> | ||
15 | |||
16 | /* QT */ | ||
8 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
9 | #include <qlistbox.h> | 18 | #include <qlistbox.h> |
10 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
11 | #include <qlistview.h> | 20 | #include <qlistview.h> |
12 | #include <qheader.h> | 21 | #include <qheader.h> |
13 | #include <qlabel.h> | 22 | #include <qlabel.h> |
14 | #include <qpe/qcopenvelope_qws.h> | ||
15 | #include <qtabwidget.h> // in order to disable the profiles tab | 23 | #include <qtabwidget.h> // in order to disable the profiles tab |
16 | #include <qpe/qpeapplication.h> | ||
17 | |||
18 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
19 | 25 | ||
20 | #ifdef QWS | ||
21 | #include <qpe/config.h> | ||
22 | #include <qpe/qlibrary.h> | ||
23 | #include <qpe/resource.h> | ||
24 | #include <qpe/qpeapplication.h> | ||
25 | #else | ||
26 | #include <klibloader.h> | ||
27 | #define QLibrary KLibrary | ||
28 | #include <kconfig.h> | ||
29 | #define Config KConfig | ||
30 | #include <kapplication.h> | ||
31 | #include <kstandarddirs.h> | ||
32 | #include <kiconloader.h> | ||
33 | #define showMaximized show | ||
34 | #endif | ||
35 | 26 | ||
36 | #if QT_VERSION < 300 | 27 | #if QT_VERSION < 300 |
37 | #include <qlist.h> | 28 | #include <qlist.h> |
@@ -43,6 +34,7 @@ | |||
43 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
44 | #include <qregexp.h> | 35 | #include <qregexp.h> |
45 | 36 | ||
37 | /* STD */ | ||
46 | #include <net/if.h> | 38 | #include <net/if.h> |
47 | #include <sys/ioctl.h> | 39 | #include <sys/ioctl.h> |
48 | #include <sys/socket.h> | 40 | #include <sys/socket.h> |
@@ -50,7 +42,8 @@ | |||
50 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 42 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
51 | #define _PROCNETDEV "/proc/net/dev" | 43 | #define _PROCNETDEV "/proc/net/dev" |
52 | 44 | ||
53 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){ | 45 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) |
46 | { | ||
54 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 47 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
55 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 48 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
56 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 49 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
@@ -78,22 +71,27 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
78 | Interfaces i; | 71 | Interfaces i; |
79 | QStringList list = i.getInterfaceList(); | 72 | QStringList list = i.getInterfaceList(); |
80 | QMap<QString, Interface*>::Iterator it; | 73 | QMap<QString, Interface*>::Iterator it; |
81 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 74 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) |
75 | { | ||
82 | /* | 76 | /* |
83 | * we skipped it in getAllInterfaces now | 77 | * we skipped it in getAllInterfaces now |
84 | * we need to ignore it as well | 78 | * we need to ignore it as well |
85 | */ | 79 | */ |
86 | if (m_handledIfaces.contains( *ni) ) { | 80 | if (m_handledIfaces.contains( *ni) ) |
81 | { | ||
87 | qDebug("Not up iface handled by module"); | 82 | qDebug("Not up iface handled by module"); |
88 | continue; | 83 | continue; |
89 | } | 84 | } |
90 | bool found = false; | 85 | bool found = false; |
91 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 86 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) |
87 | { | ||
92 | if(it.key() == (*ni)) | 88 | if(it.key() == (*ni)) |
93 | found = true; | 89 | found = true; |
94 | } | 90 | } |
95 | if(!found){ | 91 | if(!found) |
96 | if(!(*ni).contains("_")){ | 92 | { |
93 | if(!(*ni).contains("_")) | ||
94 | { | ||
97 | Interface *i = new Interface(this, *ni, false); | 95 | Interface *i = new Interface(this, *ni, false); |
98 | i->setAttached(false); | 96 | i->setAttached(false); |
99 | i->setHardwareName(tr("Disconnected")); | 97 | i->setHardwareName(tr("Disconnected")); |
@@ -117,11 +115,14 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
117 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 115 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
118 | 116 | ||
119 | QFile file(scheme); | 117 | QFile file(scheme); |
120 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 118 | if ( file.open(IO_ReadOnly) ) |
119 | { // file opened successfully | ||
121 | QTextStream stream( &file ); // use a text stream | 120 | QTextStream stream( &file ); // use a text stream |
122 | while ( !stream.eof() ) { // until end of file... | 121 | while ( !stream.eof() ) |
122 | { // 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 | { | ||
125 | line = line.mid(7, line.length()); | 126 | line = line.mid(7, line.length()); |
126 | currentProfileLabel->setText(line); | 127 | currentProfileLabel->setText(line); |
127 | break; | 128 | break; |
@@ -135,7 +136,8 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
135 | /** | 136 | /** |
136 | * Deconstructor. Save profiles. Delete loaded libraries. | 137 | * Deconstructor. Save profiles. Delete loaded libraries. |
137 | */ | 138 | */ |
138 | MainWindowImp::~MainWindowImp(){ | 139 | MainWindowImp::~MainWindowImp() |
140 | { | ||
139 | // Save profiles. | 141 | // Save profiles. |
140 | Config cfg("NetworkSetup"); | 142 | Config cfg("NetworkSetup"); |
141 | cfg.setGroup("General"); | 143 | cfg.setGroup("General"); |
@@ -143,7 +145,8 @@ MainWindowImp::~MainWindowImp(){ | |||
143 | 145 | ||
144 | // Delete all interfaces that don't have owners. | 146 | // Delete all interfaces that don't have owners. |
145 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 147 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
146 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 148 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
149 | { | ||
147 | if(iIt.key()->getModuleOwner() == NULL) | 150 | if(iIt.key()->getModuleOwner() == NULL) |
148 | delete iIt.key(); | 151 | delete iIt.key(); |
149 | } | 152 | } |
@@ -151,7 +154,8 @@ MainWindowImp::~MainWindowImp(){ | |||
151 | #ifdef QWS | 154 | #ifdef QWS |
152 | // Delete Modules and Libraries | 155 | // Delete Modules and Libraries |
153 | QMap<Module*, QLibrary*>::Iterator it; | 156 | QMap<Module*, QLibrary*>::Iterator it; |
154 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 157 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
158 | { | ||
155 | delete it.key(); | 159 | delete it.key(); |
156 | // I wonder why I can't delete the libraries | 160 | // I wonder why I can't delete the libraries |
157 | // What fucking shit this is. | 161 | // What fucking shit this is. |
@@ -165,7 +169,8 @@ MainWindowImp::~MainWindowImp(){ | |||
165 | /** | 169 | /** |
166 | * Query the kernel for all of the interfaces. | 170 | * Query the kernel for all of the interfaces. |
167 | */ | 171 | */ |
168 | void MainWindowImp::getAllInterfaces(){ | 172 | void MainWindowImp::getAllInterfaces() |
173 | { | ||
169 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 174 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
170 | if(sockfd == -1) | 175 | if(sockfd == -1) |
171 | return; | 176 | return; |
@@ -176,19 +181,23 @@ void MainWindowImp::getAllInterfaces(){ | |||
176 | int result; | 181 | int result; |
177 | Interface *i; | 182 | Interface *i; |
178 | 183 | ||
179 | if (! procFile.exists()) { | 184 | if (! procFile.exists()) |
185 | { | ||
180 | struct ifreq ifrs[100]; | 186 | struct ifreq ifrs[100]; |
181 | struct ifconf ifc; | 187 | struct ifconf ifc; |
182 | ifc.ifc_len = sizeof(ifrs); | 188 | ifc.ifc_len = sizeof(ifrs); |
183 | ifc.ifc_req = ifrs; | 189 | ifc.ifc_req = ifrs; |
184 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 190 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
185 | 191 | ||
186 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { | 192 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) |
193 | { | ||
187 | struct ifreq *pifr = &ifrs[i]; | 194 | struct ifreq *pifr = &ifrs[i]; |
188 | 195 | ||
189 | ifaces += pifr->ifr_name; | 196 | ifaces += pifr->ifr_name; |
190 | } | 197 | } |
191 | } else { | 198 | } |
199 | else | ||
200 | { | ||
192 | procFile.open(IO_ReadOnly); | 201 | procFile.open(IO_ReadOnly); |
193 | QString line; | 202 | QString line; |
194 | QTextStream procTs(&procFile); | 203 | QTextStream procTs(&procFile); |
@@ -196,16 +205,20 @@ void MainWindowImp::getAllInterfaces(){ | |||
196 | 205 | ||
197 | procTs.readLine(); // eat a line | 206 | procTs.readLine(); // eat a line |
198 | procTs.readLine(); // eat a line | 207 | procTs.readLine(); // eat a line |
199 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | 208 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) |
200 | if((loc = line.find(":")) != -1) { | 209 | { |
210 | if((loc = line.find(":")) != -1) | ||
211 | { | ||
201 | ifaces += line.left(loc); | 212 | ifaces += line.left(loc); |
202 | } | 213 | } |
203 | } | 214 | } |
204 | } | 215 | } |
205 | 216 | ||
206 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { | 217 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
218 | { | ||
207 | int flags = 0; | 219 | int flags = 0; |
208 | if ( m_handledIfaces.contains( (*it) ) ) { | 220 | if ( m_handledIfaces.contains( (*it) ) ) |
221 | { | ||
209 | qDebug(" %s is handled by a module", (*it).latin1() ); | 222 | qDebug(" %s is handled by a module", (*it).latin1() ); |
210 | continue; | 223 | continue; |
211 | } | 224 | } |
@@ -245,10 +258,13 @@ void MainWindowImp::getAllInterfaces(){ | |||
245 | // now lets ask the plugins too ;) | 258 | // now lets ask the plugins too ;) |
246 | QMap<Module*, QLibrary*>::Iterator it; | 259 | QMap<Module*, QLibrary*>::Iterator it; |
247 | QList<Interface> ilist; | 260 | QList<Interface> ilist; |
248 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 261 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
249 | if(it.key()){ | 262 | { |
263 | if(it.key()) | ||
264 | { | ||
250 | ilist = it.key()->getInterfaces(); | 265 | ilist = it.key()->getInterfaces(); |
251 | for( i = ilist.first(); i != 0; i = ilist.next() ){ | 266 | for( i = ilist.first(); i != 0; i = ilist.next() ) |
267 | { | ||
252 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | 268 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); |
253 | interfaceNames.insert(i->getInterfaceName(), i); | 269 | interfaceNames.insert(i->getInterfaceName(), i); |
254 | updateInterface(i); | 270 | updateInterface(i); |
@@ -264,7 +280,8 @@ void MainWindowImp::getAllInterfaces(){ | |||
264 | * @param path a directory that is scaned for any plugins that can be loaded | 280 | * @param path a directory that is scaned for any plugins that can be loaded |
265 | * and attempts to load them | 281 | * and attempts to load them |
266 | */ | 282 | */ |
267 | void MainWindowImp::loadModules(const QString &path){ | 283 | void MainWindowImp::loadModules(const QString &path) |
284 | { | ||
268 | #ifdef DEBUG | 285 | #ifdef DEBUG |
269 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); | 286 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); |
270 | #endif | 287 | #endif |
@@ -277,11 +294,14 @@ void MainWindowImp::loadModules(const QString &path){ | |||
277 | const QFileInfoList *list = d.entryInfoList(); | 294 | const QFileInfoList *list = d.entryInfoList(); |
278 | QFileInfoListIterator it( *list ); | 295 | QFileInfoListIterator it( *list ); |
279 | QFileInfo *fi; | 296 | QFileInfo *fi; |
280 | while ( (fi=it.current()) ) { | 297 | while ( (fi=it.current()) ) |
298 | { | ||
281 | #ifdef QWS | 299 | #ifdef QWS |
282 | if(fi->fileName().contains(".so")){ | 300 | if(fi->fileName().contains(".so")) |
301 | { | ||
283 | #else | 302 | #else |
284 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ | 303 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")) |
304 | { | ||
285 | #endif | 305 | #endif |
286 | loadPlugin(path + "/" + fi->fileName()); | 306 | loadPlugin(path + "/" + fi->fileName()); |
287 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); | 307 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); |
@@ -296,14 +316,16 @@ void MainWindowImp::loadModules(const QString &path){ | |||
296 | * @param resolveString - function pointer to resolve | 316 | * @param resolveString - function pointer to resolve |
297 | * @return pointer to the function with name resolveString or NULL | 317 | * @return pointer to the function with name resolveString or NULL |
298 | */ | 318 | */ |
299 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ | 319 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
320 | { | ||
300 | #ifdef DEBUG | 321 | #ifdef DEBUG |
301 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); | 322 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); |
302 | #endif | 323 | #endif |
303 | #ifdef QWS | 324 | #ifdef QWS |
304 | QLibrary *lib = new QLibrary(pluginFileName); | 325 | QLibrary *lib = new QLibrary(pluginFileName); |
305 | void *functionPointer = lib->resolve(resolveString); | 326 | void *functionPointer = lib->resolve(resolveString); |
306 | if( !functionPointer ){ | 327 | if( !functionPointer ) |
328 | { | ||
307 | #ifdef DEBUG | 329 | #ifdef DEBUG |
308 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); | 330 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); |
309 | #endif | 331 | #endif |
@@ -312,7 +334,8 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString & | |||
312 | } | 334 | } |
313 | // Try to get an object. | 335 | // Try to get an object. |
314 | Module *object = ((Module* (*)()) functionPointer)(); | 336 | Module *object = ((Module* (*)()) functionPointer)(); |
315 | if(object == NULL){ | 337 | if(object == NULL) |
338 | { | ||
316 | #ifdef DEBUG | 339 | #ifdef DEBUG |
317 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 340 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
318 | #endif | 341 | #endif |
@@ -327,13 +350,15 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString & | |||
327 | 350 | ||
328 | #else | 351 | #else |
329 | QLibrary *lib = loader->library(pluginFileName); | 352 | QLibrary *lib = loader->library(pluginFileName); |
330 | if( !lib || !lib->hasSymbol(resolveString) ){ | 353 | if( !lib || !lib->hasSymbol(resolveString) ) |
354 | { | ||
331 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 355 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
332 | return NULL; | 356 | return NULL; |
333 | } | 357 | } |
334 | // Try to get an object. | 358 | // Try to get an object. |
335 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); | 359 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); |
336 | if(object == NULL){ | 360 | if(object == NULL) |
361 | { | ||
337 | #ifdef DEBUG | 362 | #ifdef DEBUG |
338 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 363 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
339 | #endif | 364 | #endif |
@@ -352,33 +377,40 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString & | |||
352 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 377 | * 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 | 378 | * load the plugin and append it to the list |
354 | */ | 379 | */ |
355 | void MainWindowImp::addClicked(){ | 380 | void MainWindowImp::addClicked() |
381 | { | ||
356 | QMap<Module*, QLibrary*>::Iterator it; | 382 | QMap<Module*, QLibrary*>::Iterator it; |
357 | QMap<QString, QString> list; | 383 | QMap<QString, QString> list; |
358 | QMap<QString, Module*> newInterfaceOwners; | 384 | QMap<QString, Module*> newInterfaceOwners; |
359 | 385 | ||
360 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 386 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
361 | if(it.key()){ | 387 | { |
388 | if(it.key()) | ||
389 | { | ||
362 | (it.key())->possibleNewInterfaces(list); | 390 | (it.key())->possibleNewInterfaces(list); |
363 | } | 391 | } |
364 | } | 392 | } |
365 | // See if the list has anything that we can add. | 393 | // See if the list has anything that we can add. |
366 | if(list.count() == 0){ | 394 | if(list.count() == 0) |
395 | { | ||
367 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 396 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
368 | return; | 397 | return; |
369 | } | 398 | } |
370 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 399 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
371 | addNewConnection.addConnections(list); | 400 | addNewConnection.addConnections(list); |
372 | addNewConnection.showMaximized(); | 401 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) |
373 | if(QDialog::Accepted == addNewConnection.exec()){ | 402 | { |
374 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 403 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
375 | if(!item) | 404 | if(!item) |
376 | return; | 405 | return; |
377 | 406 | ||
378 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 407 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
379 | if(it.key()){ | 408 | { |
409 | if(it.key()) | ||
410 | { | ||
380 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 411 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
381 | if(i){ | 412 | if(i) |
413 | { | ||
382 | qDebug("iface name %s",i->getInterfaceName().latin1()); | 414 | qDebug("iface name %s",i->getInterfaceName().latin1()); |
383 | interfaceNames.insert(i->getInterfaceName(), i); | 415 | interfaceNames.insert(i->getInterfaceName(), i); |
384 | updateInterface(i); | 416 | updateInterface(i); |
@@ -392,21 +424,26 @@ void MainWindowImp::addClicked(){ | |||
392 | * Prompt the user to see if they really want to do this. | 424 | * Prompt the user to see if they really want to do this. |
393 | * If they do then remove from the list and unload. | 425 | * If they do then remove from the list and unload. |
394 | */ | 426 | */ |
395 | void MainWindowImp::removeClicked(){ | 427 | void MainWindowImp::removeClicked() |
428 | { | ||
396 | QListViewItem *item = connectionList->currentItem(); | 429 | QListViewItem *item = connectionList->currentItem(); |
397 | if(!item) { | 430 | if(!item) |
431 | { | ||
398 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 432 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
399 | return; | 433 | return; |
400 | } | 434 | } |
401 | 435 | ||
402 | Interface *i = interfaceItems[item]; | 436 | Interface *i = interfaceItems[item]; |
403 | if(i->getModuleOwner() == NULL){ | 437 | if(i->getModuleOwner() == NULL) |
438 | { | ||
404 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 439 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
405 | } | 440 | } |
406 | else{ | 441 | else |
442 | { | ||
407 | if(!i->getModuleOwner()->remove(i)) | 443 | if(!i->getModuleOwner()->remove(i)) |
408 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 444 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
409 | else{ | 445 | else |
446 | { | ||
410 | delete item; | 447 | delete item; |
411 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 448 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
412 | } | 449 | } |
@@ -418,9 +455,11 @@ void MainWindowImp::removeClicked(){ | |||
418 | * Report an error if no interface is selected. | 455 | * Report an error if no interface is selected. |
419 | * If the interface has a module owner then request its configure. | 456 | * If the interface has a module owner then request its configure. |
420 | */ | 457 | */ |
421 | void MainWindowImp::configureClicked(){ | 458 | void MainWindowImp::configureClicked() |
459 | { | ||
422 | QListViewItem *item = connectionList->currentItem(); | 460 | QListViewItem *item = connectionList->currentItem(); |
423 | if(!item){ | 461 | if(!item) |
462 | { | ||
424 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 463 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
425 | return; | 464 | return; |
426 | } | 465 | } |
@@ -431,18 +470,20 @@ void MainWindowImp::configureClicked(){ | |||
431 | 470 | ||
432 | Interface *i = interfaceItems[item]; | 471 | Interface *i = interfaceItems[item]; |
433 | 472 | ||
434 | if(i->getModuleOwner()){ | 473 | if(i->getModuleOwner()) |
474 | { | ||
435 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 475 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
436 | if(moduleConfigure != NULL){ | 476 | if(moduleConfigure != NULL) |
477 | { | ||
437 | i->getModuleOwner()->setProfile(currentProfileText); | 478 | i->getModuleOwner()->setProfile(currentProfileText); |
438 | moduleConfigure->showMaximized(); | 479 | QPEApplication::showWidget( moduleConfigure ); |
439 | return; | 480 | return; |
440 | } | 481 | } |
441 | } | 482 | } |
442 | 483 | ||
443 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); | 484 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
444 | configure->setProfile(currentProfileText); | 485 | configure->setProfile(currentProfileText); |
445 | configure->showMaximized(); | 486 | QPEApplication::showDialog( configure ); |
446 | } | 487 | } |
447 | 488 | ||
448 | /** | 489 | /** |
@@ -450,9 +491,11 @@ void MainWindowImp::configureClicked(){ | |||
450 | * Report an error if no interface is selected. | 491 | * Report an error if no interface is selected. |
451 | * If the interface has a module owner then request its configure. | 492 | * If the interface has a module owner then request its configure. |
452 | */ | 493 | */ |
453 | void MainWindowImp::informationClicked(){ | 494 | void MainWindowImp::informationClicked() |
495 | { | ||
454 | QListViewItem *item = connectionList->currentItem(); | 496 | QListViewItem *item = connectionList->currentItem(); |
455 | if(!item){ | 497 | if(!item) |
498 | { | ||
456 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 499 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
457 | return; | 500 | return; |
458 | } | 501 | } |
@@ -463,10 +506,12 @@ void MainWindowImp::informationClicked(){ | |||
463 | // return; | 506 | // return; |
464 | // } | 507 | // } |
465 | 508 | ||
466 | if(i->getModuleOwner()){ | 509 | if(i->getModuleOwner()) |
510 | { | ||
467 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 511 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
468 | if(moduleInformation != NULL){ | 512 | if(moduleInformation != NULL) |
469 | moduleInformation->showMaximized(); | 513 | { |
514 | QPEApplication::showWidget( moduleInformation ); | ||
470 | #ifdef DEBUG | 515 | #ifdef DEBUG |
471 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 516 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
472 | #endif | 517 | #endif |
@@ -474,15 +519,17 @@ void MainWindowImp::informationClicked(){ | |||
474 | } | 519 | } |
475 | } | 520 | } |
476 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); | 521 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); |
477 | information->showMaximized(); | 522 | QPEApplication::showWidget( information ); |
478 | } | 523 | } |
479 | 524 | ||
480 | /** | 525 | /** |
481 | * Update this interface. If no QListViewItem exists create one. | 526 | * Update this interface. If no QListViewItem exists create one. |
482 | * @param Interface* pointer to the interface that needs to be updated. | 527 | * @param Interface* pointer to the interface that needs to be updated. |
483 | */ | 528 | */ |
484 | void MainWindowImp::updateInterface(Interface *i){ | 529 | void MainWindowImp::updateInterface(Interface *i) |
485 | if(!advancedUserMode){ | 530 | { |
531 | if(!advancedUserMode) | ||
532 | { | ||
486 | if(i->getInterfaceName() == "lo") | 533 | if(i->getInterfaceName() == "lo") |
487 | return; | 534 | return; |
488 | } | 535 | } |
@@ -490,11 +537,13 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
490 | QListViewItem *item = NULL; | 537 | QListViewItem *item = NULL; |
491 | 538 | ||
492 | // Find the interface, making it if needed. | 539 | // Find the interface, making it if needed. |
493 | if(items.find(i) == items.end()){ | 540 | if(items.find(i) == items.end()) |
541 | { | ||
494 | item = new QListViewItem(connectionList, "", "", ""); | 542 | item = new QListViewItem(connectionList, "", "", ""); |
495 | // See if you can't find a module owner for this interface | 543 | // See if you can't find a module owner for this interface |
496 | QMap<Module*, QLibrary*>::Iterator it; | 544 | QMap<Module*, QLibrary*>::Iterator it; |
497 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 545 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
546 | { | ||
498 | if(it.key()->isOwner(i)) | 547 | if(it.key()->isOwner(i)) |
499 | i->setModuleOwner(it.key()); | 548 | i->setModuleOwner(it.key()); |
500 | } | 549 | } |
@@ -537,7 +586,8 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
537 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 586 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
538 | } | 587 | } |
539 | 588 | ||
540 | void MainWindowImp::newProfileChanged(const QString& newText){ | 589 | void MainWindowImp::newProfileChanged(const QString& newText) |
590 | { | ||
541 | if(newText.length() > 0) | 591 | if(newText.length() > 0) |
542 | newProfileButton->setEnabled(true); | 592 | newProfileButton->setEnabled(true); |
543 | else | 593 | else |
@@ -549,9 +599,11 @@ void MainWindowImp::newProfileChanged(const QString& newText){ | |||
549 | * Don't add profiles that already exists. | 599 | * Don't add profiles that already exists. |
550 | * Appends to the list and QStringList | 600 | * Appends to the list and QStringList |
551 | */ | 601 | */ |
552 | void MainWindowImp::addProfile(){ | 602 | void MainWindowImp::addProfile() |
603 | { | ||
553 | QString newProfileName = newProfile->text(); | 604 | QString newProfileName = newProfile->text(); |
554 | if(profiles.grep(newProfileName).count() > 0){ | 605 | if(profiles.grep(newProfileName).count() > 0) |
606 | { | ||
555 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 607 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
556 | return; | 608 | return; |
557 | } | 609 | } |
@@ -563,24 +615,29 @@ void MainWindowImp::addProfile(){ | |||
563 | * Removes the currently selected profile in the combo. | 615 | * Removes the currently selected profile in the combo. |
564 | * Doesn't delete if there are less then 2 profiles. | 616 | * Doesn't delete if there are less then 2 profiles. |
565 | */ | 617 | */ |
566 | void MainWindowImp::removeProfile(){ | 618 | void MainWindowImp::removeProfile() |
567 | if(profilesList->count() <= 1){ | 619 | { |
620 | if(profilesList->count() <= 1) | ||
621 | { | ||
568 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 622 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
569 | return; | 623 | return; |
570 | } | 624 | } |
571 | QString profileToRemove = profilesList->currentText(); | 625 | QString profileToRemove = profilesList->currentText(); |
572 | if(profileToRemove == "All"){ | 626 | if(profileToRemove == "All") |
627 | { | ||
573 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 628 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
574 | return; | 629 | return; |
575 | } | 630 | } |
576 | // Can't remove the curent profile | 631 | // Can't remove the curent profile |
577 | if(profileToRemove == currentProfileLabel->text()){ | 632 | if(profileToRemove == currentProfileLabel->text()) |
633 | { | ||
578 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 634 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
579 | return; | 635 | return; |
580 | 636 | ||
581 | } | 637 | } |
582 | 638 | ||
583 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 639 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) |
640 | { | ||
584 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 641 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
585 | profilesList->clear(); | 642 | profilesList->clear(); |
586 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 643 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
@@ -590,15 +647,19 @@ void MainWindowImp::removeProfile(){ | |||
590 | Interfaces interfaces; | 647 | Interfaces interfaces; |
591 | // Go through them one by one | 648 | // Go through them one by one |
592 | QMap<Interface*, QListViewItem*>::Iterator it; | 649 | QMap<Interface*, QListViewItem*>::Iterator it; |
593 | for( it = items.begin(); it != items.end(); ++it ){ | 650 | for( it = items.begin(); it != items.end(); ++it ) |
651 | { | ||
594 | QString interfaceName = it.key()->getInterfaceName(); | 652 | QString interfaceName = it.key()->getInterfaceName(); |
595 | qDebug(interfaceName.latin1()); | 653 | qDebug(interfaceName.latin1()); |
596 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 654 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) |
655 | { | ||
597 | interfaces.removeInterface(); | 656 | interfaces.removeInterface(); |
598 | if(interfaces.setMapping(interfaceName)){ | 657 | if(interfaces.setMapping(interfaceName)) |
658 | { | ||
599 | if(profilesList->count() == 1) | 659 | if(profilesList->count() == 1) |
600 | interfaces.removeMapping(); | 660 | interfaces.removeMapping(); |
601 | else{ | 661 | else |
662 | { | ||
602 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 663 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
603 | } | 664 | } |
604 | } | 665 | } |
@@ -613,26 +674,32 @@ void MainWindowImp::removeProfile(){ | |||
613 | * A new profile has been selected, change. | 674 | * A new profile has been selected, change. |
614 | * @param newProfile the new profile. | 675 | * @param newProfile the new profile. |
615 | */ | 676 | */ |
616 | void MainWindowImp::changeProfile(){ | 677 | void MainWindowImp::changeProfile() |
617 | if(profilesList->currentItem() == -1){ | 678 | { |
679 | if(profilesList->currentItem() == -1) | ||
680 | { | ||
618 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 681 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
619 | return; | 682 | return; |
620 | } | 683 | } |
621 | QString newProfile = profilesList->text(profilesList->currentItem()); | 684 | QString newProfile = profilesList->text(profilesList->currentItem()); |
622 | if(newProfile != currentProfileLabel->text()){ | 685 | if(newProfile != currentProfileLabel->text()) |
686 | { | ||
623 | currentProfileLabel->setText(newProfile); | 687 | currentProfileLabel->setText(newProfile); |
624 | QFile::remove(scheme); | 688 | QFile::remove(scheme); |
625 | QFile file(scheme); | 689 | QFile file(scheme); |
626 | if ( file.open(IO_ReadWrite) ) { | 690 | if ( file.open(IO_ReadWrite) ) |
691 | { | ||
627 | QTextStream stream( &file ); | 692 | QTextStream stream( &file ); |
628 | stream << QString("SCHEME=%1").arg(newProfile); | 693 | stream << QString("SCHEME=%1").arg(newProfile); |
629 | file.close(); | 694 | file.close(); |
630 | } | 695 | } |
631 | // restart all up devices? | 696 | // restart all up devices? |
632 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 697 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) |
698 | { | ||
633 | // Go through them one by one | 699 | // Go through them one by one |
634 | QMap<Interface*, QListViewItem*>::Iterator it; | 700 | QMap<Interface*, QListViewItem*>::Iterator it; |
635 | for( it = items.begin(); it != items.end(); ++it ){ | 701 | for( it = items.begin(); it != items.end(); ++it ) |
702 | { | ||
636 | if(it.key()->getStatus() == true) | 703 | if(it.key()->getStatus() == true) |
637 | it.key()->restart(); | 704 | it.key()->restart(); |
638 | } | 705 | } |
@@ -653,7 +720,8 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | |||
653 | { | 720 | { |
654 | bool found = false; | 721 | bool found = false; |
655 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); | 722 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); |
656 | if (msg == "raise") { | 723 | if (msg == "raise") |
724 | { | ||
657 | raise(); | 725 | raise(); |
658 | return; | 726 | return; |
659 | } | 727 | } |
@@ -664,9 +732,11 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | |||
664 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); | 732 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); |
665 | 733 | ||
666 | QMap<Module*, QLibrary*>::Iterator it; | 734 | QMap<Module*, QLibrary*>::Iterator it; |
667 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 735 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
736 | { | ||
668 | qDebug("plugin >%s<", it.key()->type().latin1() ); | 737 | qDebug("plugin >%s<", it.key()->type().latin1() ); |
669 | if(it.key()->type() == dest){ | 738 | if(it.key()->type() == dest) |
739 | { | ||
670 | it.key()->receive( param, arg ); | 740 | it.key()->receive( param, arg ); |
671 | found = true; | 741 | found = true; |
672 | } | 742 | } |