Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 2d714ca..f74cf87 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -1,128 +1,137 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 2 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | #include "interfacesetupimp.h" | 4 | #include "interfacesetupimp.h" |
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | #include "module.h" | 6 | #include "module.h" |
7 | 7 | ||
8 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
9 | #include <qlistbox.h> | 9 | #include <qlistbox.h> |
10 | #include <qlineedit.h> | 10 | #include <qlineedit.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <qheader.h> | 12 | #include <qheader.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qpe/qcopenvelope_qws.h> | 14 | #include <qpe/qcopenvelope_qws.h> |
15 | #include <qtabwidget.h> // in order to disable the profiles tab | 15 | #include <qtabwidget.h> // in order to disable the profiles tab |
16 | #include <qpe/qpeapplication.h> | ||
16 | 17 | ||
17 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
18 | 19 | ||
19 | #ifdef QWS | 20 | #ifdef QWS |
20 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
21 | #include <qpe/qlibrary.h> | 22 | #include <qpe/qlibrary.h> |
22 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | #else | 25 | #else |
25 | #include <klibloader.h> | 26 | #include <klibloader.h> |
26 | #define QLibrary KLibrary | 27 | #define QLibrary KLibrary |
27 | #include <kconfig.h> | 28 | #include <kconfig.h> |
28 | #define Config KConfig | 29 | #define Config KConfig |
29 | #include <kapplication.h> | 30 | #include <kapplication.h> |
30 | #include <kstandarddirs.h> | 31 | #include <kstandarddirs.h> |
31 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
32 | #define showMaximized show | 33 | #define showMaximized show |
33 | #endif | 34 | #endif |
34 | 35 | ||
35 | #if QT_VERSION < 300 | 36 | #if QT_VERSION < 300 |
36 | #include <qlist.h> | 37 | #include <qlist.h> |
37 | #else | 38 | #else |
38 | #include <qptrlist.h> | 39 | #include <qptrlist.h> |
39 | #endif | 40 | #endif |
40 | #include <qdir.h> | 41 | #include <qdir.h> |
41 | #include <qfile.h> | 42 | #include <qfile.h> |
42 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
43 | #include <qregexp.h> | 44 | #include <qregexp.h> |
44 | 45 | ||
45 | #include <net/if.h> | 46 | #include <net/if.h> |
46 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
47 | #include <sys/socket.h> | 48 | #include <sys/socket.h> |
48 | 49 | ||
49 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 50 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
50 | #define _PROCNETDEV "/proc/net/dev" | 51 | #define _PROCNETDEV "/proc/net/dev" |
51 | 52 | ||
52 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ | 53 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){ |
53 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 54 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
54 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 55 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
55 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 56 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
56 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 57 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
57 | 58 | ||
58 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 59 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
59 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 60 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
60 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 61 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
61 | 62 | ||
62 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 63 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
63 | 64 | ||
64 | //FIXME: disable profiles for the moment: | 65 | //FIXME: disable profiles for the moment: |
65 | // tabWidget->setTabEnabled( tab, false ); | 66 | tabWidget->setTabEnabled( tab, false ); |
66 | 67 | ||
67 | // Load connections. | 68 | // Load connections. |
68 | // /usr/local/kde/lib/libinterfaces.la | 69 | // /usr/local/kde/lib/libinterfaces.la |
69 | #ifdef QWS | 70 | #ifdef QWS |
70 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 71 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
71 | #else | 72 | #else |
72 | loader = KLibLoader::self(); | 73 | loader = KLibLoader::self(); |
73 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 74 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
74 | #endif | 75 | #endif |
75 | getAllInterfaces(); | 76 | getAllInterfaces(); |
76 | 77 | ||
77 | Interfaces i; | 78 | Interfaces i; |
78 | QStringList list = i.getInterfaceList(); | 79 | QStringList list = i.getInterfaceList(); |
79 | QMap<QString, Interface*>::Iterator it; | 80 | QMap<QString, Interface*>::Iterator it; |
80 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 81 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
82 | /* | ||
83 | * we skipped it in getAllInterfaces now | ||
84 | * we need to ignore it as well | ||
85 | */ | ||
86 | if (m_handledIfaces.contains( *ni) ) { | ||
87 | qDebug("Not up iface handled by module"); | ||
88 | continue; | ||
89 | } | ||
81 | bool found = false; | 90 | bool found = false; |
82 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 91 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
83 | if(it.key() == (*ni)) | 92 | if(it.key() == (*ni)) |
84 | found = true; | 93 | found = true; |
85 | } | 94 | } |
86 | if(!found){ | 95 | if(!found){ |
87 | if(!(*ni).contains("_")){ | 96 | if(!(*ni).contains("_")){ |
88 | Interface *i = new Interface(this, *ni, false); | 97 | Interface *i = new Interface(this, *ni, false); |
89 | i->setAttached(false); | 98 | i->setAttached(false); |
90 | i->setHardwareName(tr("Disconnected")); | 99 | i->setHardwareName(tr("Disconnected")); |
91 | interfaceNames.insert(i->getInterfaceName(), i); | 100 | interfaceNames.insert(i->getInterfaceName(), i); |
92 | updateInterface(i); | 101 | updateInterface(i); |
93 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 102 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
94 | } | 103 | } |
95 | } | 104 | } |
96 | } | 105 | } |
97 | 106 | ||
98 | //getInterfaceList(); | 107 | //getInterfaceList(); |
99 | connectionList->header()->hide(); | 108 | connectionList->header()->hide(); |
100 | 109 | ||
101 | Config cfg("NetworkSetup"); | 110 | Config cfg("NetworkSetup"); |
102 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 111 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
103 | for ( QStringList::Iterator it = profiles.begin(); | 112 | for ( QStringList::Iterator it = profiles.begin(); |
104 | it != profiles.end(); ++it) | 113 | it != profiles.end(); ++it) |
105 | profilesList->insertItem((*it)); | 114 | profilesList->insertItem((*it)); |
106 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 115 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
107 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 116 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
108 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 117 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
109 | 118 | ||
110 | QFile file(scheme); | 119 | QFile file(scheme); |
111 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 120 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
112 | QTextStream stream( &file ); // use a text stream | 121 | QTextStream stream( &file ); // use a text stream |
113 | while ( !stream.eof() ) { // until end of file... | 122 | while ( !stream.eof() ) { // until end of file... |
114 | QString line = stream.readLine(); // line of text excluding '\n' | 123 | QString line = stream.readLine(); // line of text excluding '\n' |
115 | if(line.contains("SCHEME")){ | 124 | if(line.contains("SCHEME")){ |
116 | line = line.mid(7, line.length()); | 125 | line = line.mid(7, line.length()); |
117 | currentProfileLabel->setText(line); | 126 | currentProfileLabel->setText(line); |
118 | break; | 127 | break; |
119 | } | 128 | } |
120 | } | 129 | } |
121 | file.close(); | 130 | file.close(); |
122 | } | 131 | } |
123 | makeChannel(); | 132 | makeChannel(); |
124 | } | 133 | } |
125 | 134 | ||
126 | /** | 135 | /** |
127 | * Deconstructor. Save profiles. Delete loaded libraries. | 136 | * Deconstructor. Save profiles. Delete loaded libraries. |
128 | */ | 137 | */ |
@@ -151,96 +160,100 @@ MainWindowImp::~MainWindowImp(){ | |||
151 | #else | 160 | #else |
152 | // klibloader automaticly deletes the libraries for us... | 161 | // klibloader automaticly deletes the libraries for us... |
153 | #endif | 162 | #endif |
154 | } | 163 | } |
155 | 164 | ||
156 | /** | 165 | /** |
157 | * Query the kernel for all of the interfaces. | 166 | * Query the kernel for all of the interfaces. |
158 | */ | 167 | */ |
159 | void MainWindowImp::getAllInterfaces(){ | 168 | void MainWindowImp::getAllInterfaces(){ |
160 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 169 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
161 | if(sockfd == -1) | 170 | if(sockfd == -1) |
162 | return; | 171 | return; |
163 | 172 | ||
164 | struct ifreq ifr; | 173 | struct ifreq ifr; |
165 | QStringList ifaces; | 174 | QStringList ifaces; |
166 | QFile procFile(QString(_PROCNETDEV)); | 175 | QFile procFile(QString(_PROCNETDEV)); |
167 | int result; | 176 | int result; |
168 | Interface *i; | 177 | Interface *i; |
169 | 178 | ||
170 | if (! procFile.exists()) { | 179 | if (! procFile.exists()) { |
171 | struct ifreq ifrs[100]; | 180 | struct ifreq ifrs[100]; |
172 | struct ifconf ifc; | 181 | struct ifconf ifc; |
173 | ifc.ifc_len = sizeof(ifrs); | 182 | ifc.ifc_len = sizeof(ifrs); |
174 | ifc.ifc_req = ifrs; | 183 | ifc.ifc_req = ifrs; |
175 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 184 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
176 | 185 | ||
177 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { | 186 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { |
178 | struct ifreq *pifr = &ifrs[i]; | 187 | struct ifreq *pifr = &ifrs[i]; |
179 | 188 | ||
180 | ifaces += pifr->ifr_name; | 189 | ifaces += pifr->ifr_name; |
181 | } | 190 | } |
182 | } else { | 191 | } else { |
183 | procFile.open(IO_ReadOnly); | 192 | procFile.open(IO_ReadOnly); |
184 | QString line; | 193 | QString line; |
185 | QTextStream procTs(&procFile); | 194 | QTextStream procTs(&procFile); |
186 | int loc = -1; | 195 | int loc = -1; |
187 | 196 | ||
188 | procTs.readLine(); // eat a line | 197 | procTs.readLine(); // eat a line |
189 | procTs.readLine(); // eat a line | 198 | procTs.readLine(); // eat a line |
190 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | 199 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { |
191 | if((loc = line.find(":")) != -1) { | 200 | if((loc = line.find(":")) != -1) { |
192 | ifaces += line.left(loc); | 201 | ifaces += line.left(loc); |
193 | } | 202 | } |
194 | } | 203 | } |
195 | } | 204 | } |
196 | 205 | ||
197 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { | 206 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { |
198 | int flags = 0; | 207 | int flags = 0; |
208 | if ( m_handledIfaces.contains( (*it) ) ) { | ||
209 | qDebug(" %s is handled by a module", (*it).latin1() ); | ||
210 | continue; | ||
211 | } | ||
199 | // int family; | 212 | // int family; |
200 | i = NULL; | 213 | i = NULL; |
201 | 214 | ||
202 | strcpy(ifr.ifr_name, (*it).latin1()); | 215 | strcpy(ifr.ifr_name, (*it).latin1()); |
203 | 216 | ||
204 | struct ifreq ifcopy; | 217 | struct ifreq ifcopy; |
205 | ifcopy = ifr; | 218 | ifcopy = ifr; |
206 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 219 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
207 | flags = ifcopy.ifr_flags; | 220 | flags = ifcopy.ifr_flags; |
208 | i = new Interface(this, ifr.ifr_name, false); | 221 | i = new Interface(this, ifr.ifr_name, false); |
209 | i->setAttached(true); | 222 | i->setAttached(true); |
210 | if ((flags & IFF_UP) == IFF_UP) | 223 | if ((flags & IFF_UP) == IFF_UP) |
211 | i->setStatus(true); | 224 | i->setStatus(true); |
212 | else | 225 | else |
213 | i->setStatus(false); | 226 | i->setStatus(false); |
214 | 227 | ||
215 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 228 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
216 | i->setHardwareName("Ethernet"); | 229 | i->setHardwareName("Ethernet"); |
217 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 230 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
218 | i->setHardwareName("Point to Point"); | 231 | i->setHardwareName("Point to Point"); |
219 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 232 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
220 | i->setHardwareName("Multicast"); | 233 | i->setHardwareName("Multicast"); |
221 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 234 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
222 | i->setHardwareName("Loopback"); | 235 | i->setHardwareName("Loopback"); |
223 | else | 236 | else |
224 | i->setHardwareName("Unknown"); | 237 | i->setHardwareName("Unknown"); |
225 | 238 | ||
226 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); | 239 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); |
227 | interfaceNames.insert(i->getInterfaceName(), i); | 240 | interfaceNames.insert(i->getInterfaceName(), i); |
228 | updateInterface(i); | 241 | updateInterface(i); |
229 | connect(i, SIGNAL(updateInterface(Interface *)), | 242 | connect(i, SIGNAL(updateInterface(Interface *)), |
230 | this, SLOT(updateInterface(Interface *))); | 243 | this, SLOT(updateInterface(Interface *))); |
231 | } | 244 | } |
232 | // now lets ask the plugins too ;) | 245 | // now lets ask the plugins too ;) |
233 | QMap<Module*, QLibrary*>::Iterator it; | 246 | QMap<Module*, QLibrary*>::Iterator it; |
234 | QList<Interface> ilist; | 247 | QList<Interface> ilist; |
235 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 248 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
236 | if(it.key()){ | 249 | if(it.key()){ |
237 | ilist = it.key()->getInterfaces(); | 250 | ilist = it.key()->getInterfaces(); |
238 | for( i = ilist.first(); i != 0; i = ilist.next() ){ | 251 | for( i = ilist.first(); i != 0; i = ilist.next() ){ |
239 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | 252 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); |
240 | interfaceNames.insert(i->getInterfaceName(), i); | 253 | interfaceNames.insert(i->getInterfaceName(), i); |
241 | updateInterface(i); | 254 | updateInterface(i); |
242 | connect(i, SIGNAL(updateInterface(Interface *)), | 255 | connect(i, SIGNAL(updateInterface(Interface *)), |
243 | this, SLOT(updateInterface(Interface *))); | 256 | this, SLOT(updateInterface(Interface *))); |
244 | } | 257 | } |
245 | } | 258 | } |
246 | } | 259 | } |
@@ -262,96 +275,97 @@ void MainWindowImp::loadModules(const QString &path){ | |||
262 | // Don't want sym links | 275 | // Don't want sym links |
263 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 276 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
264 | const QFileInfoList *list = d.entryInfoList(); | 277 | const QFileInfoList *list = d.entryInfoList(); |
265 | QFileInfoListIterator it( *list ); | 278 | QFileInfoListIterator it( *list ); |
266 | QFileInfo *fi; | 279 | QFileInfo *fi; |
267 | while ( (fi=it.current()) ) { | 280 | while ( (fi=it.current()) ) { |
268 | #ifdef QWS | 281 | #ifdef QWS |
269 | if(fi->fileName().contains(".so")){ | 282 | if(fi->fileName().contains(".so")){ |
270 | #else | 283 | #else |
271 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ | 284 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ |
272 | #endif | 285 | #endif |
273 | loadPlugin(path + "/" + fi->fileName()); | 286 | loadPlugin(path + "/" + fi->fileName()); |
274 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); | 287 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); |
275 | } | 288 | } |
276 | ++it; | 289 | ++it; |
277 | } | 290 | } |
278 | } | 291 | } |
279 | 292 | ||
280 | /** | 293 | /** |
281 | * Attempt to load a function and resolve a function. | 294 | * Attempt to load a function and resolve a function. |
282 | * @param pluginFileName - the name of the file in which to attempt to load | 295 | * @param pluginFileName - the name of the file in which to attempt to load |
283 | * @param resolveString - function pointer to resolve | 296 | * @param resolveString - function pointer to resolve |
284 | * @return pointer to the function with name resolveString or NULL | 297 | * @return pointer to the function with name resolveString or NULL |
285 | */ | 298 | */ |
286 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ | 299 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ |
287 | #ifdef DEBUG | 300 | #ifdef DEBUG |
288 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); | 301 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); |
289 | #endif | 302 | #endif |
290 | #ifdef QWS | 303 | #ifdef QWS |
291 | QLibrary *lib = new QLibrary(pluginFileName); | 304 | QLibrary *lib = new QLibrary(pluginFileName); |
292 | void *functionPointer = lib->resolve(resolveString); | 305 | void *functionPointer = lib->resolve(resolveString); |
293 | if( !functionPointer ){ | 306 | if( !functionPointer ){ |
294 | #ifdef DEBUG | 307 | #ifdef DEBUG |
295 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); | 308 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); |
296 | #endif | 309 | #endif |
297 | delete lib; | 310 | delete lib; |
298 | return NULL; | 311 | return NULL; |
299 | } | 312 | } |
300 | // Try to get an object. | 313 | // Try to get an object. |
301 | Module *object = ((Module* (*)()) functionPointer)(); | 314 | Module *object = ((Module* (*)()) functionPointer)(); |
302 | if(object == NULL){ | 315 | if(object == NULL){ |
303 | #ifdef DEBUG | 316 | #ifdef DEBUG |
304 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 317 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
305 | #endif | 318 | #endif |
306 | delete lib; | 319 | delete lib; |
307 | return NULL; | 320 | return NULL; |
308 | } | 321 | } |
309 | 322 | ||
323 | m_handledIfaces += object->handledInterfaceNames(); | ||
310 | // Store for deletion later | 324 | // Store for deletion later |
311 | libraries.insert(object, lib); | 325 | libraries.insert(object, lib); |
312 | return object; | 326 | return object; |
313 | 327 | ||
314 | #else | 328 | #else |
315 | QLibrary *lib = loader->library(pluginFileName); | 329 | QLibrary *lib = loader->library(pluginFileName); |
316 | if( !lib || !lib->hasSymbol(resolveString) ){ | 330 | if( !lib || !lib->hasSymbol(resolveString) ){ |
317 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 331 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
318 | return NULL; | 332 | return NULL; |
319 | } | 333 | } |
320 | // Try to get an object. | 334 | // Try to get an object. |
321 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); | 335 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); |
322 | if(object == NULL){ | 336 | if(object == NULL){ |
323 | #ifdef DEBUG | 337 | #ifdef DEBUG |
324 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 338 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
325 | #endif | 339 | #endif |
326 | return NULL; | 340 | return NULL; |
327 | } | 341 | } |
328 | #ifdef DEBUG | 342 | #ifdef DEBUG |
329 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); | 343 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); |
330 | #endif | 344 | #endif |
331 | // Store for deletion later | 345 | // Store for deletion later |
332 | libraries.insert(object, lib); | 346 | libraries.insert(object, lib); |
333 | return object; | 347 | return object; |
334 | #endif | 348 | #endif |
335 | } | 349 | } |
336 | 350 | ||
337 | /** | 351 | /** |
338 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 352 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
339 | * load the plugin and append it to the list | 353 | * load the plugin and append it to the list |
340 | */ | 354 | */ |
341 | void MainWindowImp::addClicked(){ | 355 | void MainWindowImp::addClicked(){ |
342 | QMap<Module*, QLibrary*>::Iterator it; | 356 | QMap<Module*, QLibrary*>::Iterator it; |
343 | QMap<QString, QString> list; | 357 | QMap<QString, QString> list; |
344 | QMap<QString, Module*> newInterfaceOwners; | 358 | QMap<QString, Module*> newInterfaceOwners; |
345 | 359 | ||
346 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 360 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
347 | if(it.key()){ | 361 | if(it.key()){ |
348 | (it.key())->possibleNewInterfaces(list); | 362 | (it.key())->possibleNewInterfaces(list); |
349 | } | 363 | } |
350 | } | 364 | } |
351 | // See if the list has anything that we can add. | 365 | // See if the list has anything that we can add. |
352 | if(list.count() == 0){ | 366 | if(list.count() == 0){ |
353 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 367 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
354 | return; | 368 | return; |
355 | } | 369 | } |
356 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 370 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
357 | addNewConnection.addConnections(list); | 371 | addNewConnection.addConnections(list); |
@@ -381,130 +395,130 @@ void MainWindowImp::addClicked(){ | |||
381 | void MainWindowImp::removeClicked(){ | 395 | void MainWindowImp::removeClicked(){ |
382 | QListViewItem *item = connectionList->currentItem(); | 396 | QListViewItem *item = connectionList->currentItem(); |
383 | if(!item) { | 397 | if(!item) { |
384 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 398 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
385 | return; | 399 | return; |
386 | } | 400 | } |
387 | 401 | ||
388 | Interface *i = interfaceItems[item]; | 402 | Interface *i = interfaceItems[item]; |
389 | if(i->getModuleOwner() == NULL){ | 403 | if(i->getModuleOwner() == NULL){ |
390 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 404 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
391 | } | 405 | } |
392 | else{ | 406 | else{ |
393 | if(!i->getModuleOwner()->remove(i)) | 407 | if(!i->getModuleOwner()->remove(i)) |
394 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 408 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
395 | else{ | 409 | else{ |
396 | delete item; | 410 | delete item; |
397 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 411 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
398 | } | 412 | } |
399 | } | 413 | } |
400 | } | 414 | } |
401 | 415 | ||
402 | /** | 416 | /** |
403 | * Pull up the configure about the currently selected interface. | 417 | * Pull up the configure about the currently selected interface. |
404 | * Report an error if no interface is selected. | 418 | * Report an error if no interface is selected. |
405 | * If the interface has a module owner then request its configure. | 419 | * If the interface has a module owner then request its configure. |
406 | */ | 420 | */ |
407 | void MainWindowImp::configureClicked(){ | 421 | void MainWindowImp::configureClicked(){ |
408 | QListViewItem *item = connectionList->currentItem(); | 422 | QListViewItem *item = connectionList->currentItem(); |
409 | if(!item){ | 423 | if(!item){ |
410 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 424 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
411 | return; | 425 | return; |
412 | } | 426 | } |
413 | 427 | ||
414 | QString currentProfileText = currentProfileLabel->text(); | 428 | QString currentProfileText = currentProfileLabel->text(); |
415 | if(currentProfileText.upper() == "ALL"); | 429 | if(currentProfileText.upper() == "ALL"); |
416 | currentProfileText = ""; | 430 | currentProfileText = ""; |
417 | 431 | ||
418 | Interface *i = interfaceItems[item]; | 432 | Interface *i = interfaceItems[item]; |
419 | 433 | ||
420 | if(i->getModuleOwner()){ | 434 | if(i->getModuleOwner()){ |
421 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 435 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
422 | if(moduleConfigure != NULL){ | 436 | if(moduleConfigure != NULL){ |
423 | i->getModuleOwner()->setProfile(currentProfileText); | 437 | i->getModuleOwner()->setProfile(currentProfileText); |
424 | moduleConfigure->showMaximized(); | 438 | moduleConfigure->showMaximized(); |
425 | return; | 439 | return; |
426 | } | 440 | } |
427 | } | 441 | } |
428 | 442 | ||
429 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); | 443 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
430 | configure->setProfile(currentProfileText); | 444 | configure->setProfile(currentProfileText); |
431 | configure->showMaximized(); | 445 | configure->showMaximized(); |
432 | } | 446 | } |
433 | 447 | ||
434 | /** | 448 | /** |
435 | * Pull up the information about the currently selected interface. | 449 | * Pull up the information about the currently selected interface. |
436 | * Report an error if no interface is selected. | 450 | * Report an error if no interface is selected. |
437 | * If the interface has a module owner then request its configure. | 451 | * If the interface has a module owner then request its configure. |
438 | */ | 452 | */ |
439 | void MainWindowImp::informationClicked(){ | 453 | void MainWindowImp::informationClicked(){ |
440 | QListViewItem *item = connectionList->currentItem(); | 454 | QListViewItem *item = connectionList->currentItem(); |
441 | if(!item){ | 455 | if(!item){ |
442 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 456 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
443 | return; | 457 | return; |
444 | } | 458 | } |
445 | 459 | ||
446 | Interface *i = interfaceItems[item]; | 460 | Interface *i = interfaceItems[item]; |
447 | // if(!i->isAttached()){ | 461 | // if(!i->isAttached()){ |
448 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 462 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
449 | // return; | 463 | // return; |
450 | // } | 464 | // } |
451 | 465 | ||
452 | if(i->getModuleOwner()){ | 466 | if(i->getModuleOwner()){ |
453 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 467 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
454 | if(moduleInformation != NULL){ | 468 | if(moduleInformation != NULL){ |
455 | moduleInformation->showMaximized(); | 469 | moduleInformation->showMaximized(); |
456 | #ifdef DEBUG | 470 | #ifdef DEBUG |
457 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 471 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
458 | #endif | 472 | #endif |
459 | return; | 473 | return; |
460 | } | 474 | } |
461 | } | 475 | } |
462 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); | 476 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); |
463 | information->showMaximized(); | 477 | information->showMaximized(); |
464 | } | 478 | } |
465 | 479 | ||
466 | /** | 480 | /** |
467 | * Update this interface. If no QListViewItem exists create one. | 481 | * Update this interface. If no QListViewItem exists create one. |
468 | * @param Interface* pointer to the interface that needs to be updated. | 482 | * @param Interface* pointer to the interface that needs to be updated. |
469 | */ | 483 | */ |
470 | void MainWindowImp::updateInterface(Interface *i){ | 484 | void MainWindowImp::updateInterface(Interface *i){ |
471 | if(!advancedUserMode){ | 485 | if(!advancedUserMode){ |
472 | if(i->getInterfaceName() == "lo") | 486 | if(i->getInterfaceName() == "lo") |
473 | return; | 487 | return; |
474 | } | 488 | } |
475 | 489 | ||
476 | QListViewItem *item = NULL; | 490 | QListViewItem *item = NULL; |
477 | 491 | ||
478 | // Find the interface, making it if needed. | 492 | // Find the interface, making it if needed. |
479 | if(items.find(i) == items.end()){ | 493 | if(items.find(i) == items.end()){ |
480 | item = new QListViewItem(connectionList, "", "", ""); | 494 | item = new QListViewItem(connectionList, "", "", ""); |
481 | // See if you can't find a module owner for this interface | 495 | // See if you can't find a module owner for this interface |
482 | QMap<Module*, QLibrary*>::Iterator it; | 496 | QMap<Module*, QLibrary*>::Iterator it; |
483 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 497 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
484 | if(it.key()->isOwner(i)) | 498 | if(it.key()->isOwner(i)) |
485 | i->setModuleOwner(it.key()); | 499 | i->setModuleOwner(it.key()); |
486 | } | 500 | } |
487 | items.insert(i, item); | 501 | items.insert(i, item); |
488 | interfaceItems.insert(item, i); | 502 | interfaceItems.insert(item, i); |
489 | } | 503 | } |
490 | else | 504 | else |
491 | item = items[i]; | 505 | item = items[i]; |
492 | 506 | ||
493 | // Update the icons and information | 507 | // Update the icons and information |
494 | #ifdef QWS | 508 | #ifdef QWS |
495 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 509 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
496 | #else | 510 | #else |
497 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 511 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
498 | #endif | 512 | #endif |
499 | 513 | ||
500 | QString typeName = "lan"; | 514 | QString typeName = "lan"; |
501 | if(i->getInterfaceName() == "lo") | 515 | if(i->getInterfaceName() == "lo") |
502 | typeName = "lo"; | 516 | typeName = "lo"; |
503 | if(i->getInterfaceName().contains("irda")) | 517 | if(i->getInterfaceName().contains("irda")) |
504 | typeName = "irda"; | 518 | typeName = "irda"; |
505 | if(i->getInterfaceName().contains("wlan")) | 519 | if(i->getInterfaceName().contains("wlan")) |
506 | typeName = "wlan"; | 520 | typeName = "wlan"; |
507 | if(i->getInterfaceName().contains("usb")) | 521 | if(i->getInterfaceName().contains("usb")) |
508 | typeName = "usb"; | 522 | typeName = "usb"; |
509 | 523 | ||
510 | if(!i->isAttached()) | 524 | if(!i->isAttached()) |
@@ -594,72 +608,71 @@ void MainWindowImp::removeProfile(){ | |||
594 | } | 608 | } |
595 | } | 609 | } |
596 | } | 610 | } |
597 | 611 | ||
598 | /** | 612 | /** |
599 | * A new profile has been selected, change. | 613 | * A new profile has been selected, change. |
600 | * @param newProfile the new profile. | 614 | * @param newProfile the new profile. |
601 | */ | 615 | */ |
602 | void MainWindowImp::changeProfile(){ | 616 | void MainWindowImp::changeProfile(){ |
603 | if(profilesList->currentItem() == -1){ | 617 | if(profilesList->currentItem() == -1){ |
604 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 618 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
605 | return; | 619 | return; |
606 | } | 620 | } |
607 | QString newProfile = profilesList->text(profilesList->currentItem()); | 621 | QString newProfile = profilesList->text(profilesList->currentItem()); |
608 | if(newProfile != currentProfileLabel->text()){ | 622 | if(newProfile != currentProfileLabel->text()){ |
609 | currentProfileLabel->setText(newProfile); | 623 | currentProfileLabel->setText(newProfile); |
610 | QFile::remove(scheme); | 624 | QFile::remove(scheme); |
611 | QFile file(scheme); | 625 | QFile file(scheme); |
612 | if ( file.open(IO_ReadWrite) ) { | 626 | if ( file.open(IO_ReadWrite) ) { |
613 | QTextStream stream( &file ); | 627 | QTextStream stream( &file ); |
614 | stream << QString("SCHEME=%1").arg(newProfile); | 628 | stream << QString("SCHEME=%1").arg(newProfile); |
615 | file.close(); | 629 | file.close(); |
616 | } | 630 | } |
617 | // restart all up devices? | 631 | // restart all up devices? |
618 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 632 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
619 | // Go through them one by one | 633 | // Go through them one by one |
620 | QMap<Interface*, QListViewItem*>::Iterator it; | 634 | QMap<Interface*, QListViewItem*>::Iterator it; |
621 | for( it = items.begin(); it != items.end(); ++it ){ | 635 | for( it = items.begin(); it != items.end(); ++it ){ |
622 | if(it.key()->getStatus() == true) | 636 | if(it.key()->getStatus() == true) |
623 | it.key()->restart(); | 637 | it.key()->restart(); |
624 | } | 638 | } |
625 | } | 639 | } |
626 | } | 640 | } |
627 | // TODO change the profile in the modules | 641 | // TODO change the profile in the modules |
628 | } | 642 | } |
629 | 643 | ||
630 | 644 | ||
631 | void MainWindowImp::makeChannel() | 645 | void MainWindowImp::makeChannel() |
632 | { | 646 | { |
633 | channel = new QCopChannel( "QPE/Application/networksettings", this ); | 647 | channel = new QCopChannel( "QPE/Application/networksettings", this ); |
634 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 648 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
635 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 649 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
636 | } | 650 | } |
637 | 651 | ||
638 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | 652 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) |
639 | { | 653 | { |
640 | bool found = false; | 654 | bool found = false; |
641 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); | 655 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); |
642 | |||
643 | if (msg == "raise") { | 656 | if (msg == "raise") { |
644 | raise(); | 657 | raise(); |
645 | return; | 658 | return; |
646 | } | 659 | } |
647 | 660 | ||
648 | QString dest = msg.left(msg.find("(")); | 661 | QString dest = msg.left(msg.find("(")); |
649 | QCString param = msg.right(msg.length() - msg.find("(") - 1); | 662 | QCString param = msg.right(msg.length() - msg.find("(") - 1); |
650 | param = param.left( param.length() - 1 ); | 663 | param = param.left( param.length() - 1 ); |
651 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); | 664 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); |
652 | 665 | ||
653 | QMap<Module*, QLibrary*>::Iterator it; | 666 | QMap<Module*, QLibrary*>::Iterator it; |
654 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 667 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
655 | qDebug("plugin >%s<", it.key()->type().latin1() ); | 668 | qDebug("plugin >%s<", it.key()->type().latin1() ); |
656 | if(it.key()->type() == dest){ | 669 | if(it.key()->type() == dest){ |
657 | it.key()->receive( param, arg ); | 670 | it.key()->receive( param, arg ); |
658 | found = true; | 671 | found = true; |
659 | } | 672 | } |
660 | } | 673 | } |
661 | 674 | ||
662 | 675 | ||
663 | if (found) QPEApplication::setKeepRunning(); | 676 | if (found) QPEApplication::setKeepRunning(); |
664 | else qDebug("Huh what do ya want"); | 677 | else qDebug("Huh what do ya want"); |
665 | } | 678 | } |